:root {
  color-scheme: light;
  --paper: #f8f6f0;
  --ink: #172938;
  --secondary: #51606a;
  --gold: #946d40;
  --rule: #ded8cc;
  --surface: #ede8de;
  --serif: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
  --sans: 'Inter', 'Helvetica Neue', Arial, sans-serif;
  --gutter: clamp(1.25rem, 4.45vw, 4.25rem);
  --page-width: 87rem;
}

html:lang(zh) {
  --serif: 'Noto Serif CJK SC', 'Songti SC', 'STSong', Georgia, serif;
  --sans: 'Noto Sans CJK SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}

body.viewing { overflow: hidden; overscroll-behavior: none; }
a { color: inherit; }
button, select { font: inherit; }
button { color: inherit; }
button:not(:disabled) { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
img { display: block; max-width: 100%; }

svg:not(.icon-definitions) {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 5px;
}

.site-header, .hero, .collection, .site-footer {
  width: min(calc(100% - var(--gutter) * 2), var(--page-width));
  margin-inline: auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: 5.25rem;
  padding-block: 1rem;
  border-bottom: 1px solid var(--rule);
}

.gallery-site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: .42rem clamp(.6rem, 1.7vw, 1.3rem);
}

.language-select {
  max-width: 100%;
  min-height: 2.75rem;
  padding: .35rem .5rem;
  border: 1px solid #c7bdae;
  border-radius: .24rem;
  background: #fffcf6;
  color: var(--ink);
  font-size: .875rem;
  cursor: pointer;
}

.wordmark {
  color: var(--ink);
  font: 600 .9rem/1.25 var(--sans);
  letter-spacing: .25em;
  text-decoration: none;
  text-transform: uppercase;
}

.header-link, .back-link, .primary-link {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  text-decoration: none;
}

.header-link {
  font-size: .83rem;
  font-weight: 600;
  text-align: end;
  transition: color 180ms ease;
}

.header-link:hover { color: var(--gold); }

.header-link svg, .primary-link svg, .card-arrow svg {
  width: 1.05em;
  height: 1.05em;
  flex: none;
}

.hero {
  display: grid;
  grid-template-columns: minmax(16.5rem, .78fr) minmax(0, 1.45fr);
  padding-block: clamp(1.4rem, 2.85vw, 2.65rem) clamp(2.7rem, 5.4vw, 5rem);
}

.hero-copy {
  display: grid;
  align-content: space-between;
  justify-items: start;
  gap: clamp(1.5rem, 3.5vw, 3.15rem);
  min-height: clamp(30rem, 43vw, 38rem);
  padding: clamp(1.8rem, 4.35vw, 4rem);
  background: var(--surface);
  color: #302a22;
}

.hero-logo {
  width: clamp(4.6rem, 7.55vw, 7.15rem);
  height: auto;
  filter: brightness(.8);
}

.hero-copy .eyebrow {
  margin: 0;
  color: #76532b;
}

.eyebrow, .project-code, .viewer-code, .collection-count {
  color: var(--gold);
  font: 650 .7rem/1.35 var(--sans);
  letter-spacing: .18em;
  text-transform: uppercase;
}

.hero h1, .section-heading h2, .card-info h3, .viewer-title h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
}

.hero h1 {
  margin-top: clamp(.65rem, 1.05vw, 1rem);
  font-size: clamp(3rem, 5.34vw, 5.7rem);
  line-height: .94;
  letter-spacing: -.052em;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.hero-intro p:not(.eyebrow) {
  max-width: 25ch;
  margin: clamp(.8rem, 1.65vw, 1.45rem) 0 0;
  color: #51473a;
  font-size: clamp(.9rem, 1.12vw, 1.03rem);
  line-height: 1.6;
}

.primary-link {
  justify-content: center;
  min-height: 2.9rem;
  padding: .76rem 1.05rem;
  border: 1px solid #906d47;
  color: #5b4228;
  font-size: .8rem;
  font-weight: 600;
  line-height: 1.35;
  transition: background-color 180ms ease, color 180ms ease;
}

.primary-link:hover { background: #e3d7c4; color: #302a22; }

.hero-photo {
  position: relative;
  min-width: 0;
  margin-inline-start: .4rem;
  overflow: hidden;
  background: var(--surface);
}

.hero-photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 53% center;
}

.collection {
  border-top: 1px solid var(--rule);
  padding-block: clamp(1.6rem, 3.1vw, 2.85rem) clamp(3.4rem, 7vw, 6.6rem);
  scroll-margin-top: 1.25rem;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: clamp(1.25rem, 2.4vw, 1.95rem);
}

.section-heading h2 {
  font-size: clamp(2.5rem, 4.25vw, 4.25rem);
  line-height: 1;
  letter-spacing: -.045em;
}

.collection-count { white-space: nowrap; }

.directory-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: .65rem 1.25rem;
  margin-bottom: clamp(1.15rem, 2.3vw, 1.95rem);
}

.directory-tools .collection-count { margin: 0; }

.directory-search {
  position: relative;
  flex: 1 1 15rem;
  max-width: 28rem;
}

.directory-search svg {
  position: absolute;
  inset: .74rem auto auto .85rem;
  width: 1.35rem;
  height: 1.35rem;
  color: var(--gold);
  pointer-events: none;
}

.directory-search input {
  display: block;
  width: 100%;
  min-height: 2.9rem;
  padding: .5rem .9rem .5rem 2.7rem;
  border: 1px solid var(--rule);
  border-radius: .3rem;
  background: #fffdf8;
  color: var(--ink);
  font: inherit;
}

.directory-search input::placeholder { color: var(--secondary); }
.empty-directory { color: var(--secondary); margin: 1.35rem 0 0; }

.project-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(1.3rem, 3.1vw, 2.9rem) clamp(.9rem, 1.7vw, 1.55rem);
}

.project-card {
  position: relative;
  min-width: 0;
  margin: 0;
  border-bottom: 1px solid var(--rule);
}

.project-card a, a.project-card {
  display: block;
  height: 100%;
  text-decoration: none;
}

.card-image {
  display: block;
  overflow: hidden;
  margin: 0;
  background: var(--surface);
  aspect-ratio: 4 / 3;
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform 420ms cubic-bezier(.18, .62, .3, 1);
}

.project-card:hover .card-image img, .project-card:focus-within .card-image img {
  transform: scale(1.035);
}

.card-info {
  display: block;
  position: relative;
  padding: 1rem 3.05rem 1.15rem 0;
}

.card-info .project-code { display: block; margin: 0 0 .35rem; }

.card-info h3 {
  font-size: clamp(1.7rem, 2.45vw, 2.65rem);
  line-height: 1.06;
  letter-spacing: -.035em;
}

.card-info p:not(.project-code) {
  margin: .45rem 0 0;
  color: var(--secondary);
  font-size: .84rem;
  line-height: 1.45;
}

.card-arrow {
  position: absolute;
  inset: 50% 0 auto auto;
  display: grid;
  place-items: center;
  width: 2.35rem;
  height: 2.35rem;
  padding: .58rem;
  border: 1px solid var(--rule);
  border-radius: 50%;
  color: var(--ink);
  transform: translateY(-50%);
  transition: color 180ms ease, background-color 180ms ease, border-color 180ms ease;
}

.project-card:hover .card-arrow, .project-card:focus-within .card-arrow {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.site-footer {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: .45rem 1.75rem;
  border-top: 1px solid var(--rule);
  padding-block: 1.2rem 1.75rem;
  color: var(--secondary);
  font-size: .8rem;
}

.site-footer a { text-underline-offset: .23em; }
.site-footer a:hover { color: var(--gold); }
.site-footer p { margin: 0; }

.viewer {
  --theater: #111213;
  --bar: #191a1b;
  --edge: #3e3d39;
  --bright: #f3efe8;
  --muted: #b7b1a6;
  --accent: #d4ac77;
  color-scheme: dark;
  position: fixed;
  z-index: 100;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  /* Keep the scrollable photo strip from widening the viewer. */
  grid-template-columns: minmax(0, 1fr);
  background: var(--theater);
  color: var(--bright);
  overflow: hidden;
  overscroll-behavior: none;
}

.viewer :focus-visible { outline-color: var(--accent); outline-offset: 3px; }

.viewer.expanded > .stage { grid-row: 1 / -1; }

.viewer.expanded > .viewer-header {
  position: absolute;
  inset: 0 0 auto;
  border: 0;
  background: linear-gradient(180deg, rgb(17 18 19 / .94), rgb(17 18 19 / .5) 70%, transparent);
}

.viewer.expanded > .viewer-footer {
  position: absolute;
  inset: auto 0 0;
  background: linear-gradient(0deg, rgb(17 18 19 / .94), rgb(17 18 19 / .58));
}

.viewer.expanded .photo-browser { display: none; }

.viewer-header {
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr);
  align-items: center;
  gap: .65rem;
  min-height: 4.9rem;
  padding: max(.65rem, env(safe-area-inset-top)) max(1.45rem, env(safe-area-inset-right)) .65rem max(1.45rem, env(safe-area-inset-left));
  border-bottom: 1px solid var(--edge);
  background: var(--bar);
}

.back-link {
  justify-self: start;
  min-height: 2.6rem;
  padding: 0 .5rem;
  background: none;
  border: 0;
  color: var(--bright);
  font-size: .84rem;
  font-weight: 550;
  line-height: 1.3;
}

.back-link svg, .control-button svg, .play-button svg, .nav-button svg {
  display: block;
  flex: none;
  width: 1.125rem;
  height: 1.125rem;
}

.back-link:hover { color: var(--accent); }

.booklet-link {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.6rem;
  padding: .35rem .75rem;
  border: 1px solid #7e6a50;
  border-radius: .25rem;
  color: var(--accent);
  font-size: .9rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
}

.booklet-link:hover { border-color: var(--accent); background: #27231f; }

.viewer-title { min-width: 0; text-align: center; }
.viewer-code { margin: 0 0 .15rem; color: var(--accent); font-size: .62rem; }

.viewer-title h1 {
  overflow: hidden;
  font-size: clamp(1.55rem, 3vw, 2.45rem);
  line-height: 1;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.viewer-title h1:focus-visible { outline: none; }

.counter {
  justify-self: end;
  color: var(--muted);
  font-size: .87rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stage {
  position: relative;
  isolation: isolate;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  touch-action: pan-y pinch-zoom;
}

.photo-frame {
  position: absolute;
  inset: 0;
  isolation: isolate;
  background: var(--theater);
  pointer-events: none;
}

.photo-frame::before {
  position: absolute;
  z-index: -1;
  inset: -2.25rem;
  background: var(--stage-photo) center / cover no-repeat;
  content: '';
  filter: blur(25px);
  opacity: .27;
}

.stage.fill .photo-frame::before { opacity: 0; }

.photo-frame img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
  user-select: none;
  -webkit-user-drag: none;
}

.stage.fill .photo-frame img { object-fit: cover; }

.image-error {
  position: absolute;
  inset: 50% 4rem auto;
  margin: 0;
  transform: translateY(-50%);
  color: var(--muted);
  text-align: center;
}

.nav-button {
  position: absolute;
  z-index: 1;
  inset-block-start: 50%;
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  transform: translateY(-50%);
  border: 1px solid #ffffff48;
  border-radius: 50%;
  background: #141414bc;
  color: #fff;
  backdrop-filter: blur(8px);
  transition: border-color 180ms ease, background-color 180ms ease;
}

.nav-button.previous { inset-inline-start: max(1.25rem, env(safe-area-inset-left)); }
.nav-button.next { inset-inline-end: max(1.25rem, env(safe-area-inset-right)); }
.nav-button:hover { border-color: var(--accent); background: #242321; }

.viewer-footer {
  z-index: 2;
  min-width: 0;
  background: var(--bar);
  padding-bottom: env(safe-area-inset-bottom);
}

.progress-track { height: 2px; background: var(--edge); }

.progress-fill {
  width: 100%;
  height: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
}

.photo-browser {
  --rail-padding: max(.9rem, env(safe-area-inset-left), env(safe-area-inset-right));
  max-width: 78rem;
  margin-inline: auto;
  padding: .42rem var(--rail-padding) 0;
}

.photo-browser-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: .65rem;
}

.space-filters, .thumbnail-rail {
  display: flex;
  align-items: start;
  gap: .4rem;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
  scrollbar-color: #786750 #201f1e;
}

.space-filters {
  padding: 3px 3px .3rem;
  scrollbar-width: none;
}

.space-filters button {
  flex: none;
  min-height: 2.1rem;
  padding: .25rem .72rem;
  border: 1px solid var(--edge);
  border-radius: 1.2rem;
  background: transparent;
  color: var(--muted);
  font-size: .875rem;
  white-space: nowrap;
}

.space-filters button:hover { border-color: var(--accent); color: var(--bright); }
.space-filters button[aria-pressed='true'] {
  border-color: var(--accent);
  background: #382b20;
  color: #f6d8b0;
}

.thumbnail-rail {
  padding: .15rem 4px .37rem;
  touch-action: pan-x;
}

.photo-thumbnail {
  flex: 0 0 clamp(4.75rem, 8.5vw, 6.7rem);
  width: clamp(4.75rem, 8.5vw, 6.7rem);
  padding: .17rem;
  overflow: hidden;
  border: 1px solid var(--edge);
  border-radius: .27rem;
  background: #222324;
  color: var(--bright);
}

.photo-thumbnail img {
  width: 100%;
  height: auto;
  aspect-ratio: 240 / 152;
  border-radius: .12rem;
  object-fit: cover;
  background: #312b23;
}

.photo-thumbnail span {
  display: block;
  margin: .25rem 0 .05rem;
  overflow: hidden;
  font-size: .875rem;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-thumbnail:hover,
.photo-thumbnail[aria-current='true'] { border-color: var(--accent); }

.photo-thumbnail[aria-current='true'] { background: #382b20; color: #f6d8b0; }
.photo-thumbnail:focus-visible { outline-offset: 1px; }

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: .65rem;
  min-height: 4.2rem;
  padding: .65rem max(.65rem, env(safe-area-inset-right)) .65rem max(.65rem, env(safe-area-inset-left));
}

.play-button, .control-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: .47rem;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: .52rem .72rem;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: var(--bright);
  font-size: .82rem;
  font-weight: 560;
  line-height: 1.25;
  transition: background-color 150ms ease, border-color 150ms ease;
}

.play-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #1a1713;
  padding-inline: .85rem;
}

.control-button:hover, .control-button[aria-expanded='true'], .control-button[aria-pressed='true'] {
  border-color: var(--edge);
  background: #323130;
}

.play-button:hover { background: #e7c394; border-color: #e7c394; }
.settings-wrap { position: relative; }

.settings-panel {
  position: absolute;
  inset: auto auto calc(100% + .7rem) 50%;
  z-index: 3;
  width: min(19rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 5.8rem);
  overflow-y: auto;
  padding: .65rem .8rem;
  transform: translateX(-50%);
  border: 1px solid var(--edge);
  border-radius: 5px;
  background: #252524;
  box-shadow: 0 .8rem 2rem #0007;
  color: var(--bright);
  font-size: .82rem;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .8rem;
  min-height: 2.7rem;
  padding: .35rem 0;
}

.setting-row + .setting-row { border-top: 1px solid var(--edge); }

.settings-panel select {
  min-width: 0;
  max-width: 59%;
  min-height: 2.05rem;
  padding: .25rem .45rem;
  border: 1px solid #5a5750;
  border-radius: 3px;
  background: var(--bar);
  color: var(--bright);
}

.viewer-home-link {
  color: var(--accent);
  text-underline-offset: .18em;
}

@media (max-width: 940px) {
  .hero-copy { min-height: 27rem; padding: clamp(1.55rem, 3.35vw, 2.75rem); }
  .hero h1 { font-size: clamp(2.75rem, 5.4vw, 3.8rem); }
  .project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 650px) {
  .site-header { min-height: 4.25rem; gap: .55rem; }
  .site-footer { flex-wrap: wrap; }
  .hero { grid-template-columns: 1fr; padding-block: 1rem 2.5rem; }
  .hero-copy { gap: 1.35rem; min-height: 0; padding: clamp(1.35rem, 5.7vw, 2.6rem); }
  .hero-logo { width: 4rem; }
  .hero h1 { font-size: clamp(2.85rem, 10.75vw, 4.9rem); }
  .hero-intro p:not(.eyebrow) { max-width: 33ch; }
  .hero-photo { aspect-ratio: 16 / 9; margin: .35rem 0 0; }
  .section-heading { align-items: center; }
  .collection-count { font-size: .59rem; }
  .viewer-header {
    min-height: 3.75rem;
    padding-inline: max(.6rem, env(safe-area-inset-left)) max(.6rem, env(safe-area-inset-right));
  }
  .viewer-title h1 { font-size: clamp(1.15rem, 4.8vw, 1.9rem); }
  .viewer-code { font-size: .55rem; letter-spacing: .1em; }
  .back-link { gap: .35rem; padding-inline: .35rem; font-size: .72rem; }
  .booklet-link { padding-inline: .37rem; font-size: .8rem; }
  .photo-browser { --rail-padding: max(.55rem, env(safe-area-inset-left), env(safe-area-inset-right)); }
  .counter { font-size: .71rem; padding-right: .28rem; }
  .nav-button { width: 2.7rem; height: 2.7rem; }
  .nav-button.previous { inset-inline-start: max(.55rem, env(safe-area-inset-left)); }
  .nav-button.next { inset-inline-end: max(.55rem, env(safe-area-inset-right)); }
  .controls { position: relative; gap: .25rem; min-height: 3.8rem; padding-block: .5rem; }
  .control-button, .play-button { gap: .33rem; padding-inline: .53rem; font-size: .75rem; }
  .settings-wrap { position: static; }
  .settings-panel { width: min(19rem, calc(100% - 1.25rem)); }
}

@media (max-width: 410px) {
  .project-grid { grid-template-columns: 1fr; }
  .card-image { aspect-ratio: 16 / 11; }
  .section-heading h2 { font-size: 2.32rem; }
}

@media (max-height: 560px) and (orientation: landscape) {
  .viewer-header { min-height: 3.3rem; padding-block: .3rem; }
  .viewer-title h1 { font-size: 1.45rem; }
  .photo-thumbnail { flex-basis: 4.85rem; width: 4.85rem; }
  .controls { min-height: 3.3rem; padding-block: .3rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; }
}
