/* M3 stage layer. The WebGL canvas is fixed behind everything; sections are transparent
   windows onto it. The hero paints its own opaque still on top, so it hides the live canvas. */

.scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100vw;
  height: 100lvh;         /* large viewport: the phone URL bar never resizes the buffer */
  pointer-events: none;
}
.is-still .scene, .no-webgl .scene { display: none; }

main, .footer { position: relative; z-index: 1; }
.nav { z-index: 20; }

/* Hero still. Slate fallback stays underneath until the render lands. */
.hero__bench {
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 600ms var(--ease-out);
}
.hero__bench.is-drawn { opacity: 1; }
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(120% 80% at 70% 40%, transparent 40%, rgba(16, 9, 4, 0.55) 100%),
    var(--color-slate-apron);
}
/* A soft vignette over the still keeps the cream type readable on any part of the apron. */
.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(16, 9, 4, 0.5) 0%, transparent 30%, transparent 62%, rgba(16, 9, 4, 0.7) 100%);
}
.hero { background: var(--color-walnut-shadow); }
/* Live: the hero is a window onto the same WebGL scene as every section. The slate fallback
   covers the canvas only until the first frame lands. */
.is-live .hero__bench { display: none; }
.has-frame .hero { background: transparent; }
.hero::before { transition: opacity 500ms var(--ease-out); }
.has-frame .hero::before { opacity: 0; }
/* Hero seam fix (gate F3, art review): in live mode nothing dark may scroll across the canvas.
   The hero's bottom vignette ended in a hard edge that crossed the mill, and the walnut
   section's dashed top border drew a line across the wood. The bench fades only in WebGL. */
.is-live .hero, .is-live .hero__bench { background: transparent; }
.is-live .hero::after {
  background: linear-gradient(180deg, rgba(16, 9, 4, 0.45) 0%, transparent 28%);   /* soft, no edge */
}
#walnut { border-top: 0; }

/* Live mode: pinned stages are CSS sticky (gate F4). The wrapper is one screen plus the scrub
   distance; the content sticks at the top. Sticky movement is scroll, not a layout shift, and it
   runs on the compositor, so phones get no pin swap and no CLS. */
.is-live .pinned { position: relative; }
.is-live .pinned--3 { height: calc(100svh * 4); }   /* 300% of scrub */
.is-live .pinned--4 { height: calc(100svh * 5); }   /* 400% of scrub */
.is-live .pinned > .void--pinned { position: sticky; top: 0; height: 100svh; min-height: 0; overflow: clip; }

/* Beats: the current one is full strength, the others wait. */
.is-live .beats li { opacity: 0.32; transition: opacity var(--dur-ui) var(--ease-out); }
.is-live .beats li.is-on { opacity: 1; }

/* The tags name the parts in live mode; the list is the static fallback. */
.is-live .parts { display: none; }

/* Takedown tags */
.tags {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
}
.tag {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  gap: var(--spacing-6);
  font-size: var(--text-chip);
  line-height: 1;
  white-space: nowrap;
  will-change: transform, opacity;
  opacity: 0;
}
.tag__line {
  display: block;
  width: var(--lead, 44px);
  border-top: 1px dashed var(--color-driftwood);
}
/* Anchor sits at the start of the leader; left tags flip around it. */
.tag { margin-top: -6px; }
.tag--left { flex-direction: row-reverse; translate: -100% 0; }

/* Reduced motion: one still per stage. */
.stage { position: relative; }
.stage__still {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* M4: the twist */
.stage--twist {
  touch-action: pan-y;            /* vertical drags scroll; horizontal ones can become a twist */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.is-twist .stage--twist { cursor: grab; }
.stage--twist.is-twisting { cursor: grabbing; }

/* Keyboard handle: follows the head on screen, invisible until focused. */
.twist-handle {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius-cards);
  background: transparent;
  pointer-events: none;           /* pointers go to the stage; this is for focus and arrows */
  opacity: 0;
}
.is-twist .twist-handle { opacity: 1; }
.twist-handle:focus-visible { outline: 1px dashed var(--color-warm-cream); outline-offset: 6px; }
.is-still .twist-handle { display: none; }

.hint {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: var(--spacing-6);
  margin: -6px 0 0;
  font-size: var(--text-chip);
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 400ms var(--ease-out);
}
.hint__line { display: block; width: 28px; border-top: 1px dashed var(--color-warm-cream); }
.is-twist .hint { opacity: 1; }
.hint.is-done, .is-still .hint { opacity: 0; }

.steps { display: flex; flex-wrap: wrap; gap: var(--spacing-8); }
.step { padding: 0 var(--spacing-14); border-color: var(--color-cork-border); font-variant-numeric: tabular-nums; }
.step[aria-pressed='true'] { border-color: var(--color-warm-cream); }

/* M5: credit roll (JS turns #credits into a modal; without JS it is the list above) */
.roll {
  position: fixed;
  inset: 0;
  z-index: 40;
  align-content: end;
  gap: var(--spacing-18);
  padding: 92px var(--gutter) max(var(--spacing-41), env(safe-area-inset-bottom));
  background: rgba(16, 9, 4, 0.92);   /* art review: 0.92 */
}
.roll[hidden] { display: none; }
.roll .credits__title { font-size: var(--text-subheading); line-height: var(--leading-subheading); }
.roll .credits__list { gap: var(--spacing-12); font-size: var(--text-subheading); line-height: 1.1; max-width: 46ch; }
.roll li { will-change: transform, opacity; text-wrap: pretty; }   /* no orphan words */
.roll .credit__label { white-space: nowrap; }
@media (max-width: 767px) {
  .roll .credits__list { font-size: 18px; }
}
/* The pile words would read through the roll; hide them while it is open. */
.is-roll .footer__pile, .is-roll .footer__mark { visibility: hidden; }
@media (min-width: 1100px) {
  .roll { padding-left: calc(var(--gutter) + 8vw); }
  .roll .credits__list { font-size: var(--text-heading-sm); }
}
.is-roll body { overflow: hidden; }
/* Gate M5: phone keeps 24 px between the control row and the legal line under it. */
@media (max-width: 767px) {
  .roll { padding-bottom: calc(var(--spacing-41) + 24px + env(safe-area-inset-bottom)); }
}
/* Gate M3: without WebGL the grind controls have nothing to drive. */
.no-webgl .steps, .no-webgl [data-grind], .no-webgl .twist-handle, .no-webgl .hint { display: none; }
/* The disclaimer stays visible, even above the credit roll. */
.is-roll .footer__legal { position: relative; z-index: 41; }
