/* Round 2: the catalogue's plates and drawers behave like the objects they show.
   Every animation sits behind prefers-reduced-motion: no-preference. The base
   state of every element is its finished state, so motion off = complete page. */

:root {
  --spring: linear(0, 0.21 6.5%, 0.56 14%, 0.86 22%, 1.03 31%, 1.06 38%, 1.02 48%, 0.995 60%, 1);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --amber: #f0b454;
}

/* Cross-document page transitions: the header holds, the page crossfades. */
@view-transition { navigation: auto; }
body > header { view-transition-name: site-header; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 260ms; }
::view-transition-old(site-header), ::view-transition-new(site-header) { animation: none; }
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
}

/* Chapters */
.chapter { padding: 72px 0; }
.chapter-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 36ch); gap: 48px; align-items: end; margin-bottom: 32px; }
.chapter-head p { margin: 0; }
.chapter-head h2 { margin-bottom: 0; }

/* Folio: a running head in the margin, desktop only. Replaces a fixed bar. */
.folio { display: none; }
@media (min-width: 1300px) {
  .folio { display: block; position: fixed; left: 28px; top: 50%; transform: translateY(-50%); z-index: 5; }
  .folio ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--rule); }
  .folio a { display: block; padding: 6px 0 6px 14px; margin-left: -1px; border-left: 1px solid transparent; font-size: 0.8125rem; letter-spacing: 0.02em; color: var(--ink-2); text-decoration: none; transition: color 150ms var(--ease-out), border-color 150ms var(--ease-out); }
  .folio a[aria-current] { color: var(--red); border-left-color: var(--red); }
  .folio a:hover { color: var(--ink); }
}

/* Hero depth: planes move on a fine pointer, a few pixels, nothing more. */
.hero-stage { position: relative; }
.hero .plane-a { transform: translate(calc(var(--mx, 0) * 6px), calc(var(--my, 0) * 4px)); }
.hero .plane-b { transform: translate(calc(var(--mx, 0) * -10px), calc(var(--my, 0) * -6px)); }
.hero .plane-c { transform: translate(calc(var(--mx, 0) * 3px), calc(var(--my, 0) * 2px)); }
.hero h1 { text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55); }

/* The bench: the signature move. Base state is a slider; motion turns it into a pinned, scroll-scrubbed stage. */
.bench { background: var(--steel); color: var(--on-steel); }
.bench .muted { color: var(--on-steel-2); }
.bench a { color: var(--on-steel); }
.bench .plate img { border-color: var(--on-steel-2); background: var(--steel); }
.bench ::selection { background: var(--on-steel); color: var(--ink); }
.bench-stage { display: grid; grid-template-columns: 500px 1fr; gap: 48px; align-items: center; padding: 56px 0; }
.bench-stage > div:first-child { position: relative; }
.bench-img { aspect-ratio: 5 / 3; }
.bench-img img { width: 100%; height: auto; }
.bench-meta { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-top: 12px; }
.bench-meta output { font-family: var(--display); font-weight: 700; font-size: 1.25rem; letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }
.gauge { position: relative; height: 3px; background: #4b4945; margin-top: 10px; overflow: hidden; }
.gauge-fill { position: absolute; inset: 0; background: var(--on-steel); transform-origin: left; transform: scaleX(1); }
.bench-range { width: 100%; margin: 14px 0 0; accent-color: var(--red); }
.bench-steps { margin: 0; padding: 0; list-style: none; border-top: 1px solid #4b4945; }
.bench-steps li { padding: 14px 0; border-bottom: 1px solid #4b4945; max-width: 52ch; }
.bench-steps strong { font-family: var(--display); font-weight: 700; font-size: 1.3rem; display: block; line-height: 1.1; margin-bottom: 2px; }
.bench-steps span { color: var(--on-steel-2); }

html.js.motion .bench { height: 440vh; }
html.js.motion .bench-stage { position: sticky; top: 0; min-height: 100vh; box-sizing: border-box; padding: 24px 0; }
html.js.motion .bench-range { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
html.js.motion .bench-steps li { opacity: 0.28; transform: translateX(-8px); transition: opacity 320ms var(--ease-out), transform 420ms var(--spring); }
html.js.motion .bench-steps li.hit { opacity: 1; transform: none; }
html.js.motion .bench-steps li.now strong { color: var(--mint); }

/* Chapter 2: plates wiped on, left to right, the way a plate is laid on a page. */
.plates-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }

/* Chapter 4: drawers. The carcass clips, the plate travels out on its runner. */
.carcass { overflow: hidden; }
.drawer { margin: 0; }
.drawer .plate img { margin: 0; }
.drawer-front { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--mint); color: var(--on-mint); padding: 10px 12px; margin-top: -1px; font-size: 0.875rem; font-weight: 500; }
.drawer-front b { font-family: var(--display); font-weight: 700; font-size: 1.1rem; letter-spacing: 0.02em; }
.drawers { display: grid; grid-template-columns: repeat(2, minmax(0, 500px)); gap: 32px 48px; justify-content: space-between; }

/* Chapter 5: a sentence, one line at a time. */
.quote-lines p { display: block; }
.quote-lines .line { display: block; }

/* Chapter 6: lamps. Cold until reached, one flicker, then steady. */
.lamp { position: relative; }
.lamp::before { content: ""; position: absolute; left: 10%; right: 10%; top: -34px; height: 70px; background: radial-gradient(ellipse at center, rgba(240, 180, 84, 0.55), rgba(240, 180, 84, 0) 70%); pointer-events: none; opacity: 1; }
.lamp img { background: #1c1b19; border-color: var(--on-steel-2); }

/* Index + colophon spacing */
.colophon { font-size: 0.9375rem; }

/* Motion. Everything below is additive to the finished base state. */
@media (prefers-reduced-motion: no-preference) {
  /* Once, on load: the mark lays from the keystone outward; the headline presses in. */
  html.js .home .mark img { animation: lay 1100ms var(--ease-out) both; }
  html.js .hero h1 { animation: press 900ms var(--spring) 180ms backwards; }
  html.js .hero .settle { animation: settle 700ms var(--ease-out) 520ms backwards; }
  html.js .hero .plane-a, html.js .hero .plane-b, html.js .hero .plane-c { transition: transform 600ms var(--ease-out); }

  /* Lamps, time-based, triggered when reached. */
  html.js .lamp:not(.on) img { filter: grayscale(0.75) brightness(0.42); }
  html.js .lamp:not(.on)::before { opacity: 0; }
  html.js .lamp.on img { animation: warm 1100ms linear both; }
  html.js .lamp.on::before { animation: glow 1100ms linear both; }

  /* Scroll-driven, native. */
  @supports (animation-timeline: view()) {
    .wipe { animation: wipe linear both; animation-timeline: view(); animation-range: entry 12% entry 62%; }
    .drawer { animation: drawer linear both; animation-timeline: view(); animation-range: entry 8% entry 70%; }
    .quote-lines .line { animation: lineup linear both; animation-timeline: view(); animation-range: entry 25% entry 70%; }
  }
  /* Scroll-driven, IntersectionObserver fallback. */
  html.io .wipe { clip-path: inset(0 100% 0 0); transition: clip-path 700ms var(--ease-out); }
  html.io .wipe.in { clip-path: inset(0 0 0 0); }
  html.io .drawer { transform: translateX(-104%); transition: transform 900ms var(--spring); }
  html.io .drawer.in { transform: none; }
  html.io .quote-lines .line { clip-path: inset(0 0 100% 0); transform: translateY(0.3em); transition: clip-path 500ms var(--ease-out), transform 500ms var(--ease-out); }
  html.io .quote-lines .line.in { clip-path: inset(0 0 -12% 0); transform: none; }
  html.io .quote-lines .line:nth-child(2) { transition-delay: 90ms; }
  html.io .quote-lines .line:nth-child(3) { transition-delay: 180ms; }
  html.io .quote-lines .line:nth-child(4) { transition-delay: 270ms; }
}

@keyframes lay { from { clip-path: circle(0% at 50% 100%); } to { clip-path: circle(80% at 50% 100%); } }
@keyframes press { from { transform: scale(1.05); filter: blur(6px); opacity: 0; } to { transform: none; filter: blur(0); opacity: 1; } }
@keyframes settle { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes wipe { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes drawer { from { transform: translateX(-104%); } 62% { transform: translateX(1.6%); } to { transform: none; } }
@keyframes lineup { from { clip-path: inset(0 0 100% 0); transform: translateY(0.3em); } to { clip-path: inset(0 0 -12% 0); transform: none; } }
@keyframes warm {
  0% { filter: grayscale(0.75) brightness(0.42); }
  48% { filter: grayscale(0.2) brightness(0.92); }
  56% { filter: grayscale(0.55) brightness(0.5); }
  64% { filter: grayscale(0.1) brightness(1.02); }
  70% { filter: grayscale(0.3) brightness(0.78); }
  100% { filter: none; }
}
@keyframes glow { 0% { opacity: 0; } 48% { opacity: 0.9; } 56% { opacity: 0.3; } 64% { opacity: 1; } 70% { opacity: 0.6; } 100% { opacity: 1; } }

/* Mobile composition: stacked bench, one step at a time; full-width drawers. */
@media (max-width: 1024px) {
  .bench-stage { grid-template-columns: 1fr; gap: 24px; }
  .drawers { grid-template-columns: 1fr; justify-content: start; }
  .chapter-head { grid-template-columns: 1fr; gap: 12px; align-items: start; }
}
@media (max-width: 800px) {
  .chapter { padding: 48px 0; }
  .plates-3 { grid-template-columns: 1fr; gap: 20px; }
  .plates-3 .plate { max-width: 500px; }
  html.js.motion .bench { height: 380vh; }
  html.js.motion .bench-stage { padding: 16px 0; align-content: start; min-height: 100svh; }
  html.js.motion .bench-steps { border-top: 0; position: relative; min-height: 7.5em; }
  html.js.motion .bench-steps li { position: absolute; inset: 0 auto auto 0; width: 100%; border-bottom: 0; padding: 0; opacity: 0; transform: translateY(6px); }
  html.js.motion .bench-steps li.now { opacity: 1; transform: none; }
  .hero h1 { font-size: clamp(2.4rem, 11vw, 2.9rem); }
}
