/* 01 · Light stage — a tall scroll track with a sticky viewport */
.stage {
  position: relative;
  height: 520vh;
  background: var(--ink);
}
.stage__sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
}
.stage__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Fallback when WebGL is unavailable */
.stage__fallback {
  position: absolute;
  left: 50%;
  top: 62%;
  width: min(120vw, 1500px);
  max-width: none;
  transform: translate(-50%, -50%);
  opacity: 0;
  filter: saturate(0.7) brightness(var(--fb-bright, 0.6)) contrast(1.1);
  -webkit-mask-image: radial-gradient(ellipse 55% 45% at 50% 62%, #000 40%, transparent 100%);
  mask-image: radial-gradient(ellipse 55% 45% at 50% 62%, #000 40%, transparent 100%);
  pointer-events: none;
}
.no-gl .stage__canvas { display: none; }
.no-gl .stage__fallback { opacity: var(--fb-opacity, 1); }

/* Soft top gradient so the header and copy always sit on darkness */
.stage__sticky::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 45%;
  background: linear-gradient(180deg, rgba(10, 12, 11, 0.55), transparent);
  pointer-events: none;
}

/* ---------- Beats (copy that changes along the timeline) ---------- */
.stage__beats {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
.beat {
  position: absolute;
  left: var(--gutter);
  top: calc(var(--header-h) + clamp(1.5rem, 7vh, 5rem));
  max-width: 38rem;
  opacity: 0;
  visibility: hidden;
  will-change: opacity, transform;
}
.beat.is-active { opacity: 1; visibility: visible; }
.beat.is-live { pointer-events: auto; }
.beat .eyebrow { margin-bottom: 1.5rem; }
.beat__title {
  font-family: var(--f-display);
  font-weight: 400;
  font-size: var(--fs-beat);
  line-height: 0.98;
  letter-spacing: -0.014em;
  color: var(--bone);
}
.beat__text {
  margin-top: 1.5rem;
  max-width: 27rem;
  font-size: var(--fs-body);
  line-height: 1.6;
  color: var(--bone-dim);
}
.beat__actions {
  margin-top: 2.25rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.25rem 2rem;
}
.rm-only { display: none; }

/* ---------- Chapter index ---------- */
.stage__index {
  position: absolute;
  z-index: 2;
  left: var(--gutter);
  bottom: clamp(1.75rem, 5vh, 3rem);
  display: flex;
  gap: 2rem;
  font-family: var(--f-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--mist-2);
}
.stage__index li {
  position: relative;
  padding-top: 0.9rem;
  transition: color var(--dur) var(--ease-out);
}
.stage__index li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 1px;
  background: var(--line);
}
.stage__index li::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  height: 1px;
  width: calc(var(--fill, 0) * 100%);
  background: var(--bone);
}
.stage__index li span { color: inherit; margin-right: 0.5em; opacity: 0.7; }
.stage__index li.is-current { color: var(--bone); }

/* ---------- Scroll cue ---------- */
.stage__cue {
  position: absolute;
  z-index: 2;
  right: var(--gutter);
  bottom: clamp(1.75rem, 5vh, 3rem);
  display: flex;
  align-items: center;
  gap: 1rem;
  font-family: var(--f-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--mist);
}
.stage__cue-line {
  position: relative;
  width: 3.5rem;
  height: 1px;
  background: var(--line);
  overflow: hidden;
}
.stage__cue-line::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, var(--light), transparent);
  animation: cue 2.8s var(--ease-in-out) infinite;
}
@keyframes cue {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}

/* ---------- Tablet / mobile ---------- */
@media (max-width: 1100px) {
  .stage__index { gap: 1.25rem; }
}
@media (max-width: 860px) {
  /* The next section slides over the empty floor below the car like a curtain */
  .stage { height: 460vh; margin-bottom: -24vh; }
  .reduced .stage { margin-bottom: 0; }
  .stage__index { display: none; }
  .stage__cue {
    left: var(--gutter);
    right: auto;
  }
  .beat {
    top: calc(var(--header-h) + clamp(1rem, 4vh, 2.5rem));
    right: var(--gutter);
  }
  .beat .eyebrow { margin-bottom: 1.1rem; }
  .beat__text { margin-top: 1.1rem; font-size: 1.0625rem; }
  .beat__actions { margin-top: 1.5rem; }
}
@media (max-width: 860px) and (max-height: 700px) {
  .beat__text { display: none; }
}

/* ---------- Reduced motion: a single calm, fully lit frame ---------- */
.reduced .stage { height: auto; }
.reduced .stage__sticky { position: relative; height: 100vh; height: 100svh; }
.reduced .beat[data-beat="0"] { opacity: 1; visibility: visible; pointer-events: auto; }
.reduced .beat:not([data-beat="0"]) { display: none; }
.reduced .rm-only { display: inline-flex; margin-top: 2rem; }
.reduced .stage__index,
.reduced .stage__cue { display: none; }
