/* =========================================================
   Photos gallery — one-page, mobile-first stylesheet

   Design system (ui-ux-pro-max skill, "Minimalist Portfolio" pairing):
     - Pattern : cinematic selection stage + portfolio carousels — visuals
                 first, lightbox at the original aspect ratio, category
                 filtering without hidden navigation.
     - Style   : Swiss minimalism on a light "gallery wall": hairline borders,
                 generous whitespace, monochrome ink accents. The photos carry
                 all the color; the chrome stays quiet so nothing competes
                 with the work. The Selection is a cinematic full-bleed dark
                 stage — a blurred color wash of the frame behind the complete
                 photo floating in front — the one loud moment of the page.
     - Type    : Space Grotesk (display) + Archivo (body/UI), loaded in the
                 template head.

   Rules applied:
     - Mobile-first: base styles target phones; min-width queries enhance
       tablet/desktop; (hover:hover) gates pointer-only affordances.
     - Touch targets >= 44px tall, >= 8px gaps between tappable chips/pills.
     - Zoom is disabled at three levels: the viewport meta tag (template),
       touch-action: manipulation on html, and touch-action: pan-x pan-y on
       the rails (no pinch-zoom anywhere, while vertical page scrolling still
       works while swiping a rail).
     - Hybrid scrolling: the page scrolls vertically; only .rail rows and the
       chip row scroll horizontally, with subtle snap (x proximity) so the
       next frame always peeks in.
     - Motion: a filter pill click fades the row out/in in two phases (the
       hidden-state swap happens while the frames are invisible); the
       lightbox steps on a left/right finger swipe (touch-action: none on
       the image wrap hands the gesture to gallery.js).
     - Uniform-height rows: every rail row has one fixed height (--row-h);
       each card's width is that height × the photo's natural ratio (frames
       are never stretched or squashed) and the row scrolls horizontally
       whenever it overflows. (The Selection is the cinematic stage, not a
       row — see below.)
     - dvh units for the lightbox so mobile browser chrome is accounted for.
     - scroll-margin-top keeps anchored sections clear of the sticky header.
     - .js-gated effects: without JavaScript the page is fully visible and
       browsable (cards are plain links to the full-size images).
     - prefers-reduced-motion disables all non-essential movement.
========================================================= */

:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --ink: #17181a;
  --muted: #6f7076;
  --line: rgba(23, 24, 26, 0.12);
  --line-strong: rgba(23, 24, 26, 0.32);
  --stage: #121215; /* dark band behind the Selection */
  --stage-wash-blur: 80px; /* Selection background: blur so strong that only
                               the frame's colors remain — a soft wash, no detail */

  --font-display: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Archivo", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;

  --wrap-w: 76rem;
  --pad: clamp(1rem, 4vw, 2.5rem);
  --gap: clamp(0.75rem, 2vw, 1.25rem);
  --header-h: 6.9rem; /* two-row mobile header (brand + chip rail) */
}

/* =========================================================
   Base
========================================================= */

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%; /* keep iOS from auto-zooming text on load */
  touch-action: manipulation;     /* no pinch / double-tap zoom at the document level */
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;                /* >= 16px body text on mobile */
  line-height: 1.55;
  overflow-x: hidden;             /* no horizontal page scroll at any viewport */
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

::selection {
  background: var(--ink);
  color: var(--bg);
}

a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  border-radius: 4px;
}

#main:focus {
  outline: none;
}

/* =========================================================
   Utilities
========================================================= */

.wrap {
  max-width: var(--wrap-w);
  margin-inline: auto;
  padding-inline: var(--pad);
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  z-index: 100;
  background: var(--ink);
  color: var(--bg);
  padding: 0.75rem 1.25rem;
  border-radius: 0 0 0.5rem 0;
  text-decoration: none;
  font-size: 0.85rem;
}

.skip-link:focus {
  left: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* =========================================================
   Header — sticky, translucent, two rows on mobile
========================================================= */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(250, 250, 250, 0.86);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  transition: transform 0.35s cubic-bezier(0.25, 0.8, 0.35, 1);
}

/* gallery.js slides the header out while scrolling down and back in on scroll up */
.site-header.is-scrolled {
  transform: translateY(-100%);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 1rem;
  padding-block: 0.6rem 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 2.75rem;            /* >= 44px touch target */
  text-decoration: none;
  color: var(--ink);
  cursor: pointer;
}

.logo-mark {
  display: grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  border: 1px solid var(--line-strong);
  border-radius: 0.55rem;
}

.logo-mark svg {
  width: 1.05rem;
  height: 1.05rem;
}

.wordmark {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* Chip rail — one horizontally scrollable row of section shortcuts */
.chip-rail {
  order: 3;
  flex-basis: 100%;
  display: flex;
  gap: 0.5rem;                    /* >= 8px between tappable targets */
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-block: 0.65rem 0;
}

.chip-rail::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.75rem;            /* >= 44px touch target */
  padding: 0 0.95rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.chip-count {
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  opacity: 0.5;
  font-variant-numeric: tabular-nums;
}

.chip:hover {
  border-color: var(--line-strong);
  background: rgba(23, 24, 26, 0.03);
}

.chip.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

.chip.is-active .chip-count {
  opacity: 0.65;
}

/* Desktop: single row — brand left, chips right */
@media (min-width: 720px) {
  :root {
    --header-h: 4rem;
  }

  .header-inner {
    flex-wrap: nowrap;
    justify-content: space-between;
    padding-block: 0.5rem;
  }

  .chip-rail {
    order: 0;
    flex-basis: auto;
    padding-block: 0;
  }
}

/* =========================================================
   Sections + editorial typography
========================================================= */

.section {
  padding-block: clamp(2.75rem, 7vw, 5.5rem);
  border-bottom: 1px solid var(--line);
  scroll-margin-top: calc(var(--header-h) + 0.75rem); /* clear the sticky header */
}

/* The Selection stands on a full-bleed dark "stage": the one loud moment of
   the page, clearly separating the featured frames from the quiet collections. */
.section--hero {
  padding-top: clamp(2.25rem, 6vw, 4.5rem);
  padding-bottom: 0; /* the hero-foot owns the closing space */
  background: var(--stage);
  border-bottom: none; /* the color change is the divider */
}

.section--hero .eyebrow {
  color: rgba(255, 255, 255, 0.55);
}

.section--hero .eyebrow i {
  background: #ffffff;
}

.section--hero .sec-title {
  color: #ffffff;
}

.section--hero .count-pill {
  border-color: rgba(255, 255, 255, 0.25);
  color: rgba(255, 255, 255, 0.65);
}

.section--hero .section-desc {
  color: rgba(255, 255, 255, 0.62);
}

.section--hero .photo-card {
  background: #1e1e23;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.4),
    0 18px 44px -20px rgba(0, 0, 0, 0.65);
}

.section--hero .frame {
  background: #1e1e23;
}

.section--hero .cap {
  color: rgba(255, 255, 255, 0.85);
}

.section--hero .cap i,
.section--hero .cap small {
  color: rgba(255, 255, 255, 0.45);
}

.sec-head {
  max-width: 62ch;
  margin-bottom: clamp(0.9rem, 2.5vw, 1.4rem); /* compact header — the photos are the point */
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.eyebrow i {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: var(--ink);
}

.sec-title {
  margin: 0.6rem 0 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.8rem, 5.5vw, 2.75rem);
  line-height: 1.04;
  letter-spacing: -0.02em;
}

/* The hero statement — the largest type on the page */
.hero-title {
  font-size: clamp(2.6rem, 11vw, 4.5rem);
}

.head-meta-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.65rem;
}

.count-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.32rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.section-desc {
  margin: 0.55rem 0 0;
  max-width: 56ch;
  color: var(--muted);
  font-size: 1rem;                /* >= 16px body text on mobile */
  line-height: 1.65;
}

/* =========================================================
   Subcategory filter pills (inside category sections)
========================================================= */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;                    /* >= 8px between tappable targets */
  margin-top: 0.9rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;            /* >= 44px touch target */
  padding: 0 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.pill i {
  font-style: normal;
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  padding: 0.14rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
}

.pill:hover {
  border-color: var(--line-strong);
}

.pill.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

.pill.is-active i {
  color: var(--bg);
  border-color: rgba(255, 255, 255, 0.35);
}

/* Filter change choreography (gallery.js, initFilters). A pill click runs
   two phases so the row never reflows under the animation:
   .is-filter-out — the departing frames fade out in place while they still
                    occupy their space (and stop opening the lightbox);
   .is-filter-in  — the invisible start state the incoming frames unhide
                    with; the class is dropped two frames later and the
                    card's base opacity transition carries them in. */
.js .photo-card.is-filter-out {
  opacity: 0;
  transform: translateY(12px) scale(0.985);
  transition: opacity 0.18s ease, transform 0.22s ease;
  pointer-events: none;
}

.js .photo-card.is-filter-in {
  opacity: 0;
  transform: translateY(12px) scale(0.985);
}

/* =========================================================
   Rails — horizontal snap carousels (the hybrid scroll layer)
========================================================= */

.rail-shell {
  position: relative;
  margin-top: clamp(1.25rem, 3vw, 2rem);
}

.rail {
  --row-h: clamp(260px, 42vw, 520px); /* fixed height of every collection row */
  display: flex;
  gap: var(--gap);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;  /* subtle snap — the next frame keeps peeking in */
  /* Align the first card with the .wrap edge, full-bleed on wide screens. */
  padding-inline: max(var(--pad), calc((100% - var(--wrap-w)) / 2));
  padding-bottom: 0.35rem;        /* room for the card shadow */
  scrollbar-width: none;
  /* Horizontal swipes scroll the rail, vertical swipes keep scrolling the page —
     and pinch-zoom is excluded everywhere. This is what makes the hybrid
     vertical + horizontal mobile experience work. */
  touch-action: pan-x pan-y;
}

.rail::-webkit-scrollbar {
  display: none;
}

/* While the user is dragging or wheeling, pause snapping so the row follows
   input 1:1 instead of fighting proximity snap (gallery.js toggles these
   classes). */
.rail.is-dragging,
.rail.is-wheeling {
  scroll-snap-type: none;
}

/* Sync-group rows (the two Selection rows) never snap at all: they loop as
   a continuous strip and are mirrored scroll-to-scroll, so proximity snap
   would fight both the wrapping and the mirroring. */
.rail.no-snap {
  scroll-snap-type: none;
}

.rail.is-dragging {
  cursor: grabbing;
}

/* =========================================================
   Photo cards — justified rows with uniform height
========================================================= */

.photo-card {
  /* Card width = row height × the photo's natural ratio (gallery.js sets
     --ar once each image loads; 1.5 is the no-JS fallback), so every frame
     is shown whole at exactly row height — never stretched, never squashed.
     The row scrolls horizontally whenever its content overflows. */
  flex: 0 0 calc(var(--row-h) * var(--ar, 1.5));
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  border-radius: 0.9rem;
  overflow: hidden;
  background: #eceae6;
  text-decoration: none;
  color: var(--ink);
  box-shadow:
    0 1px 2px rgba(23, 24, 26, 0.05),
    0 14px 34px -20px rgba(23, 24, 26, 0.3);
  /* opacity participates so the filter fade (.is-filter-in / .is-filter-out)
     animates at the card level with no extra transition rule */
  transition: transform 0.3s ease, box-shadow 0.3s ease, opacity 0.45s ease;
  cursor: pointer;
  scroll-snap-align: start; /* completes the rail's x proximity snap */
}

/* The Selection no longer uses a hero rail — it is the cinematic stage
   (see the "Cinematic stage" section below). .rail is collections- and
   fallback-only. */

.frame {
  display: block;
  width: 100%;
  height: var(--row-h); /* every frame in a row has exactly the row's fixed height */
  overflow: hidden;
  background: #e4e2de;
}

/* The fixed row height reserves the exact frame space before the image
   arrives, so nothing jumps while lazy images load. */
.frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Frames are pre-downloaded before any animation runs (template head preload +
     gallery.js warm-up), so this short settle only covers rare stragglers — it reads
     as a crisp appearance, never a slow mid-swipe materialization. */
  transition: transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.3s ease;
}

/* JS-gated fade-in: without JavaScript images are simply visible. */
.js .frame img {
  opacity: 0;
}

.js .frame img.is-loaded {
  opacity: 1;
}

/* Minimal caption strip under the frame — number, title, optional subcategory */
.cap {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  margin: 0;
  padding: 0.65rem 0.85rem 0.75rem;
  font-size: 0.82rem;
  line-height: 1.3;
}

.cap i {
  flex: none;
  font-style: normal;
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.cap em {
  font-style: normal;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cap small {
  color: var(--muted);
  font-weight: 400;
}

/* Two-line caption: title row + optional location line (data.py `location`). */
.cap-text {
  display: flex;
  flex-direction: column;
  min-width: 0; /* let the title/location lines ellipsize instead of overflowing */
  min-height: 2.15rem; /* reserve title + location lines so every card — and thus every row — has the same height */
}

.cap-loc {
  margin-top: 0.18rem;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Uniform-height rows (mobile-first) ---
   Row heights live on the rails so they scale with the viewport:
     .rail        collections — clamp(260px, 42vw, 520px)
   Each card's width is --row-h × its photo's natural ratio (--ar, set by
   gallery.js from the loaded image), so a frame is always shown whole at
   exactly row height; the row scrolls horizontally when it overflows.
   (The Selection is no longer a rail — it is the cinematic stage.) */

/* Hover feedback is a pointer-device nicety only */
@media (hover: hover) and (pointer: fine) {
  .photo-card:hover {
    transform: translateY(-4px);
    box-shadow:
      0 2px 3px rgba(23, 24, 26, 0.06),
      0 24px 48px -22px rgba(23, 24, 26, 0.38);
  }

  .photo-card:hover .frame img {
    transform: scale(1.045);
  }

  /* The Selection keeps its own (darker) hover shadow on the stage */
  .section--hero .photo-card:hover {
    box-shadow:
      0 2px 4px rgba(0, 0, 0, 0.5),
      0 28px 60px -24px rgba(0, 0, 0, 0.8);
  }
}

/* =========================================================
   Cinematic stage — the Selection as a rotating exhibit
=========================================================

   One stage, one frame at a time. Each .stage-slide stacks five layers:
     .slide-bg       the frame blurred to a pure color wash — only its palette
                     remains (crossfade + a slow Ken Burns drift while active);
                     the same file as the floating photo, so it always resolves
                     from cache;
     .slide-veil     scrims: deep at the bottom for the caption & dock, soft
                     at the top, a radial vignette to focus the centre;
     .slide-index    an oversized ghost number — depth, not decoration;
     .slide-exhibit  the COMPLETE photo, floating, never cropped;
     .slide-copy     counter + title + location, bottom-left.

   Without JavaScript only the first slide shows (it carries .is-active in
   the markup) and the .stage-fallback rail below the stage keeps every
   frame reachable as a plain link. With JavaScript (gallery.js,
   initHeroStage) the stage rotates: auto-advance every ROTATE_MS with a
   progress fill on the active thumbnail, prev/next buttons, a thumb
   filmstrip, swipe, arrow keys and a polite live region. Rotation pauses
   while the pointer or focus is on the stage, during a swipe, while the
   lightbox is open, while the stage is off-screen, and never under
   prefers-reduced-motion (manual stepping still works then).

   Sizing note: the old banner chained percentage heights (slide -> card ->
   frame -> img), and a percentage against a stretched flex item can
   resolve to auto — the stage then collapsed onto the photos' natural
   heights and everything below the fold was cropped black. Every size
   here is absolute positioning + viewport units instead, so the stage can
   never collapse onto its content.
========================================================= */

.stage {
  position: relative;
  height: clamp(460px, 76vh, 860px);
  overflow: hidden;
  background: #0b0b0d;
}

/* Inset focus ring: an outline would be clipped by the stage's overflow. */
.stage:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.9);
}

.stage-slides {
  position: absolute;
  inset: 0;
}

.stage-slide {
  position: absolute;
  inset: 0;
  margin: 0;
  z-index: 1;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.9s ease, visibility 0s linear 0.9s;
}

.stage-slide.is-active {
  z-index: 2;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.9s ease, visibility 0s;
}

/* Color wash: the frame cover-cropped, then blurred so hard that no detail
   survives — only the photo's own colors remain, as a soft field behind the
   floating photo (the .slide-veil scrims on top keep the caption legible).
   The box extends 3.5× the blur radius beyond the stage on every side and
   .stage's overflow clips it, so the blur's edge falloff (which samples
   outside the image and fades toward the stage's dark background) is never
   visible. The active slide's wash drifts (Ken Burns) for the whole cycle. */
.slide-bg {
  position: absolute;
  inset: calc(var(--stage-wash-blur) * -3.5);
  width: calc(100% + var(--stage-wash-blur) * 7);
  height: calc(100% + var(--stage-wash-blur) * 7);
  object-fit: cover;
  object-position: center;
  transform: scale(1.05);
  filter: blur(var(--stage-wash-blur)) saturate(1.35) brightness(0.82);
}

.stage-slide.is-active .slide-bg {
  animation: stage-kb 9s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}

@keyframes stage-kb {
  from {
    transform: scale(1.04);
  }
  to {
    transform: scale(1.13);
  }
}

/* Scrims for legibility — the photos do the talking, these only make the
   type sit on top. */
.slide-veil {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to top, rgba(8, 8, 10, 0.85) 0%, rgba(8, 8, 10, 0.34) 22%, rgba(8, 8, 10, 0) 44%),
    linear-gradient(to bottom, rgba(8, 8, 10, 0.55) 0%, rgba(8, 8, 10, 0) 18%),
    radial-gradient(120% 95% at 50% 42%, rgba(0, 0, 0, 0) 45%, rgba(8, 8, 10, 0.55) 100%);
}

/* Ghost index — oversized and barely there: a depth cue, never a label. */
.slide-index {
  position: absolute;
  top: clamp(0.75rem, 3.5vh, 2rem);
  right: clamp(1rem, 4vw, 2.75rem);
  z-index: 2;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(3.5rem, 12vw, 8.5rem);
  line-height: 1;
  letter-spacing: -0.04em;
  color: rgba(255, 255, 255, 0.07);
  user-select: none;
}

/* The complete frame, floating in front of its own wash. The exhibit box
   reserves chrome space at the bottom (caption + dock) so the photo can
   never collide with them. */
.slide-exhibit {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: clamp(2rem, 6vh, 3.5rem) clamp(1.25rem, 7vw, 7rem) clamp(5.75rem, 16vh, 8.5rem);
}

/* Overrides the generic card look: full-dark mat, one soft edge light, a
   deep float shadow. Enters with a rise + settle each time it activates. */
.stage .slide-card {
  position: relative;
  display: block;
  line-height: 0;
  border-radius: 0.3rem;
  background: #0a0a0c;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.09),
    0 40px 100px -30px rgba(0, 0, 0, 0.9),
    0 14px 38px -18px rgba(0, 0, 0, 0.75);
  opacity: 0;
  transform: translateY(18px) scale(0.982);
  transition:
    opacity 0.8s ease 0.1s,
    transform 0.95s cubic-bezier(0.2, 0.8, 0.2, 1) 0.1s,
    box-shadow 0.3s ease;
}

.stage-slide.is-active .slide-card {
  opacity: 1;
  transform: none;
}

/* The mat keeps the .frame class (gallery.js fade-in hooks) but drops the
   rail sizing. */
.stage .slide-mat {
  display: block;
  width: 100%;
  height: auto;
  overflow: hidden;
  border-radius: 0.3rem;
  background: transparent;
}

/* Fit inside the exhibit box at the original ratio — never cropped, never
   stretched. Both caps are viewport-based (not percentage heights) so the
   sizing can never depend on a parent chain. */
.slide-photo {
  display: block;
  width: auto;
  height: auto;
  max-width: calc(100vw - 2.5rem);
  max-height: calc(clamp(460px, 76vh, 860px) - 168px);
  object-fit: contain;
}

@media (min-width: 640px) {
  .slide-photo {
    max-width: calc(100vw - 224px);
    max-height: calc(clamp(460px, 76vh, 860px) - 192px);
  }
}

/* Caption — bottom-left over the deep scrim. */
.slide-copy {
  position: absolute;
  left: clamp(1rem, 4vw, 2.75rem);
  bottom: clamp(1rem, 3.5vh, 1.9rem);
  z-index: 4;
  max-width: min(72vw, 36rem);
  opacity: 0;
  transform: translateY(14px);
  transition:
    opacity 0.7s ease 0.28s,
    transform 0.85s cubic-bezier(0.2, 0.8, 0.2, 1) 0.28s;
}

.stage-slide.is-active .slide-copy {
  opacity: 1;
  transform: none;
}

.slide-cap-no {
  margin: 0 0 0.4rem;
  font-size: 0.7rem;
  letter-spacing: 0.24em;
  color: rgba(255, 255, 255, 0.5);
  font-variant-numeric: tabular-nums;
}

.slide-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.4rem, 3.6vw, 2.2rem);
  line-height: 1.12;
  letter-spacing: -0.01em;
  color: #ffffff;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.55);
}

.slide-title small {
  font-size: 0.6em;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.55);
}

.slide-loc {
  margin: 0.35rem 0 0;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.48);
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.5);
}

/* Dock: prev · thumb filmstrip · next. Hidden without JavaScript — the
   stage then shows the first frame and the fallback rail below lists
   every one. */
.stage-dock {
  display: none;
}

.js .stage-dock {
  position: absolute;
  right: clamp(1rem, 4vw, 2.75rem);
  bottom: clamp(0.9rem, 3.2vh, 1.7rem);
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.stage-btn {
  width: 2.75rem; /* >= 44px touch target */
  height: 2.75rem;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.07);
  color: #ffffff;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.stage-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.4);
}

.stage-btn:active {
  transform: scale(0.94);
}

.stage-thumbs {
  display: flex;
  gap: 0.4rem;
}

.thumb {
  position: relative;
  width: 2.75rem; /* >= 44px touch target */
  height: 2.75rem;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 0.55rem;
  background: #17171b;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.5;
  transition: opacity 0.25s ease;
}

.thumb:hover {
  transform: translateY(-2px);
}

.thumb:hover img {
  opacity: 0.85;
}

.thumb.is-active {
  border-color: #ffffff;
}

.thumb.is-active img {
  opacity: 1;
}

/* The active thumb's bottom edge fills as the auto-advance cycle runs;
   gallery.js freezes it while the stage is paused. */
.thumb-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: rgba(255, 255, 255, 0.18);
}

.thumb-progress span {
  display: block;
  height: 100%;
  width: 0;
  background: #ffffff;
}

/* White focus rings on the dark stage (the page default is ink-on-light). */
.section--hero .stage-btn:focus-visible,
.section--hero .thumb:focus-visible {
  outline-color: #ffffff;
}

/* The stage photo never lifts on hover (the whole stage is the exhibit) —
   it deepens its float and eases in slightly. Overrides the generic card
   hover rules (later in the file, >= specificity). */
@media (hover: hover) and (pointer: fine) {
  .stage .slide-card:hover {
    transform: none;
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.12),
      0 46px 110px -30px rgba(0, 0, 0, 0.95),
      0 16px 42px -18px rgba(0, 0, 0, 0.8);
  }

  .stage-slide.is-active .slide-card:hover {
    opacity: 1;
  }

  .slide-card:hover .slide-photo {
    transform: scale(1.015);
  }
}

/* Film grain — a barely-there texture over the whole stage. */
.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* No-JS fallback row: the plain scroll row of selected frames. */
.js .stage-fallback {
  display: none;
}

/* Below the stage: hint + the "see more" CTA into the collections. */
.hero-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  flex-wrap: wrap;
  padding-top: clamp(1.25rem, 3.5vh, 2rem);
  padding-bottom: clamp(1.5rem, 4vh, 2.5rem);
}

.hero-hint {
  margin: 0;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.45);
}

.hero-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 2.75rem; /* >= 44px touch target */
  padding: 0.4rem 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  color: #ffffff;
  text-decoration: none;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.35);
  transition: border-color 0.25s ease;
}

.hero-cta svg {
  transition: transform 0.25s ease;
}

.hero-cta:hover {
  border-color: #ffffff;
}

@media (hover: hover) and (pointer: fine) {
  .hero-cta:hover svg {
    transform: translateY(3px);
  }
}

/* Mobile: the dock spans the width (swipe covers stepping, so the arrows
   step aside), the caption clears it, and the photo reserves room. */
@media (max-width: 639px) {
  .js .stage-dock {
    left: 1rem;
    right: 1rem;
    justify-content: space-between;
  }

  .stage-prev,
  .stage-next {
    display: none;
  }

  .slide-copy {
    bottom: 4.75rem;
  }

  .slide-exhibit {
    padding-bottom: 8.5rem;
  }
}

@media (min-width: 640px) {
  .thumb {
    width: 3.5rem;
    height: 2.625rem;
  }

  .stage-btn {
    width: 3rem; /* 48px on desktop */
    height: 3rem;
  }
}

/* Thin progress line under each rail; gallery.js scales it as you swipe.
   On pointer devices (PC) it also works as a scrubber — click or drag it to
   scroll the rail (see the hover/pointer block below and initRails() in
   gallery.js). */
.rail-meter {
  margin: 1rem auto 0;
  width: min(100% - 2 * var(--pad), var(--wrap-w));
  height: 2px;
  border-radius: 999px;
  background: var(--line);
}

.rail-meter span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px; /* the track no longer clips, so round the fill itself */
  background: var(--ink);
  transition: width 0.15s linear;
}

/* PC (pointer) devices only: the 2px line is too thin to aim at, so an
   invisible ::before widens the hit area vertically and the cursor advertises
   that the meter can be clicked or dragged to scroll the rail. */
@media (hover: hover) and (pointer: fine) {
  .rail-meter {
    position: relative;
    cursor: pointer;
  }

  .rail-meter::before {
    content: "";
    position: absolute;
    top: -12px;
    bottom: -12px;
    left: 0;
    right: 0;
    cursor: pointer;
  }

  .rail-meter:active,
  .rail-meter:active::before {
    cursor: grabbing;
  }
}

/* =========================================================
   Footer — quiet sign-off, no personal data
========================================================= */

.site-footer {
  padding-block: 2rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
}

.footer-brand {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none;
  color: var(--ink);
  cursor: pointer;
}

.footer-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

/* =========================================================
   Lightbox — near-black stage so the photo is the only thing you see
========================================================= */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 4vw, 2.5rem);
  background: rgba(12, 12, 14, 0.94);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.lightbox.open {
  opacity: 1;
  pointer-events: auto;
}

.lightbox :focus-visible {
  outline-color: #ffffff;
}

/* The content scales in softly while the backdrop fades — a smoother
   transition than a plain fade for both opening and closing. */
.lightbox-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: min(92vw, 70rem);
  transform: scale(0.96);
  transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.lightbox.open .lightbox-inner {
  transform: scale(1);
}

/* Wrapper reserves space so the layout doesn't jump while the photo loads */
.lightbox-img-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-width: min(64vw, 26rem);
  min-height: min(38vh, 18rem);
  border-radius: 0.5rem;
  overflow: hidden;
  background: #17171a;
  /* Left/right finger swipes step through the photos (gallery.js): handing
     the whole gesture to JS keeps the 1:1 follow and the spring-back clean. */
  touch-action: none;
}

/* Subtle loading ring while the full-size frame is still coming from the
   server (large photos can take a moment; cached frames skip it entirely). */
.lightbox-img-wrap::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2rem;
  height: 2rem;
  margin: -1rem 0 0 -1rem;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: rgba(255, 255, 255, 0.7);
  opacity: 0;
  transition: opacity 0.3s ease;
  animation: lb-spin 0.9s linear infinite;
}

.lightbox-img-wrap.is-loading::after {
  opacity: 1;
}

@keyframes lb-spin {
  to {
    transform: rotate(360deg);
  }
}

/* width/height auto + max-* preserves the original aspect ratio (no cropping) */
.lightbox-img {
  display: block;
  width: auto;
  height: auto;
  max-width: min(92vw, 70rem);
  max-height: calc(100vh - 12rem);
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.45s ease;
}

@supports (height: 100dvh) {
  .lightbox-img {
    max-height: calc(100dvh - 12rem); /* dvh = accurate on mobile browsers */
  }
}

.lightbox-img.is-loaded {
  opacity: 1;
}

.lightbox-caption {
  margin-top: 1rem;
  padding-inline: 3.5rem;
  text-align: center;
}

.lb-badge {
  display: inline-block;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  color: rgba(255, 255, 255, 0.45);
}

.lightbox-title {
  margin: 0.45rem 0 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  color: #ffffff;
}

.lightbox-desc {
  margin: 0.35rem 0 0;
  max-width: 48ch;
  margin-inline: auto;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.95rem;
  line-height: 1.55;
}

/* Location line under the lightbox title (hidden by JS when empty). */
.lightbox-loc {
  margin: 0.3rem 0 0;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
}

.lb-btn,
.lb-close {
  position: absolute;
  z-index: 2;
  width: 2.75rem;                 /* >= 44px touch target */
  height: 2.75rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #ffffff;
  cursor: pointer;
  touch-action: manipulation;     /* no zoom from the lightbox controls */
  transition: background 0.2s ease, transform 0.2s ease;
}

.lb-btn:hover,
.lb-close:hover {
  background: rgba(255, 255, 255, 0.18);
}

.lb-prev {
  left: clamp(0.5rem, 3vw, 1.25rem);
  top: 50%;
  transform: translateY(-50%);
}

.lb-next {
  right: clamp(0.5rem, 3vw, 1.25rem);
  top: 50%;
  transform: translateY(-50%);
}

.lb-close {
  top: 0.75rem;
  right: 0.75rem;
}

@media (min-width: 900px) {
  .lb-btn,
  .lb-close {
    width: 3rem;                  /* 48px on desktop */
    height: 3rem;
  }
}

body.no-scroll {
  overflow: hidden;
}

/* =========================================================
   JS-gated reveal (sections fade up once, when they enter view)
========================================================= */

.js .reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.js .reveal.in-view {
  opacity: 1;
  transform: none;
}

/* =========================================================
   Small-phone tweaks
========================================================= */

@media (max-width: 640px) {
  /* Blur is expensive on phones — use a near-opaque header instead */
  .site-header {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(250, 250, 250, 0.97);
  }

  .lightbox-caption {
    padding-inline: 0.5rem;
  }
}

/* =========================================================
   Reduced motion — everything stays visible, nothing moves
========================================================= */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .js .reveal {
    opacity: 1;
    transform: none;
  }

  /* Images must stay visible even without the fade-in transition */
  .frame img,
  .lightbox-img {
    opacity: 1;
  }
}
