/* ============================================================
   story.css — Stage A hero: full-viewport 3D candlestick scene
   ============================================================ */

/* --- hero section ------------------------------------------------------- */
#story {
  position: relative;
  width: 100%;
  height: 100svh;
  overflow: hidden;
}

/* --- canvas fills the section ------------------------------------------ */
#scene {
  display: block;
  width: 100%;
  height: 100%;
}

/* --- vignette overlay: warm darkening at edges ------------------------- */
#story .vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  mix-blend-mode: multiply;
  opacity: 0.55;
  background: radial-gradient(
    ellipse 75% 75% at 50% 42%,
    transparent 0%,
    transparent 48%,
    rgba(120, 96, 56, 0.12) 78%,
    rgba(92, 70, 36, 0.30) 100%
  );
}

/* --- header styles now live in chrome.css (shared by index + market) -- */

/* --- caption bottom-left ---------------------------------------------- */
.scene-caption {
  position: absolute;
  left: var(--space-5);
  bottom: var(--space-4);
  z-index: 15;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--ink-2);
  letter-spacing: 0.02em;
  pointer-events: none;
}

/* ============================================================
   Stage B1 — scroll-story overlay UI
   The #story section is pinned by ScrollTrigger for ~600% of the
   viewport; these overlays sit above the canvas (below the header)
   and crossfade as the active chapter changes.
   ============================================================ */

/* give the pinned section room to scroll-drive (pin adds its own
   spacer; this just guarantees the canvas stays full-bleed) */
#story {
  height: 100svh;
}

.story-ui {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none; /* children opt back in where interactive */
}

/* --- soft scrim behind headline text (readability on light scene) --- */
.headline-scrim {
  position: absolute;
  left: 0;
  top: 0;
  width: 46%;
  height: 100%;
  background: linear-gradient(
    100deg,
    rgba(241, 235, 221, 0.62) 0%,
    rgba(241, 235, 221, 0.42) 46%,
    rgba(241, 235, 221, 0) 100%
  );
  pointer-events: none;
}

/* --- headlines layer --------------------------------------------------- */
.headlines {
  position: absolute;
  left: 0;
  top: 0;
  width: 46%;
  height: 100%;
  display: flex;
  align-items: center;
  padding: clamp(2rem, 6vh, 6rem) var(--space-7);
  box-sizing: border-box;
}

.chapter {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-3);
  padding: inherit;
  padding-left: clamp(2rem, 6vw, 6rem);
  padding-right: clamp(1.5rem, 4vw, 4rem);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s ease;
}
.chapter.is-active {
  opacity: 1;
}

.chapter .ch-no {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: 0.18em;
  color: var(--gold);
  margin-bottom: var(--space-1);
}

.chapter .ch-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.4rem, 6vw, 4.6rem);
  line-height: 0.98;
  letter-spacing: -0.025em;
  color: var(--ink);
  text-wrap: balance;
}

/* word-mask reveal: each line sits inside an overflow-hidden mask so
   GSAP can slide it up from behind the edge */
.chapter .mask {
  display: block;
  overflow: hidden;
  padding-bottom: 0.04em; /* prevent glyph clipping on descenders */
}
.chapter .mask > .line-inner {
  display: block;
  will-change: transform;
}

.chapter .ch-copy {
  font-family: var(--font-body);
  font-size: var(--step-1);
  line-height: 1.5;
  color: var(--ink-2);
  max-width: 34ch;
  margin-top: var(--space-2);
  text-wrap: pretty;
}

/* --- progress bar (fixed to viewport bottom, gold fill) -------------- */
.progress-track {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 3px;
  background: rgba(224, 216, 199, 0.45);
  pointer-events: none;
}
.progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--gold-bright));
  transform-origin: left center;
  will-change: width;
}

/* --- chapter stepper (vertical, right edge) -------------------------- */
.stepper {
  position: absolute;
  right: clamp(1rem, 2.5vw, 2.5rem);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: auto;
}
.stepper .step {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  background: none;
  border: none;
  padding: var(--space-1) 0;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--muted);
  letter-spacing: 0.06em;
  opacity: 0.7;
  transition: color 0.25s ease, opacity 0.25s ease, transform 0.25s ease;
  text-align: right;
}
.stepper .step .step-no { font-weight: 500; }
.stepper .step .step-label {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  opacity: 0.8;
}
.stepper .step:hover { color: var(--ink); opacity: 1; }
.stepper .step.is-active {
  color: var(--gold);
  opacity: 1;
  transform: translateX(-4px);
}
.stepper .step.is-active .step-no { color: var(--gold-bright); }

/* --- scroll cue (chapter 1 only) -------------------------------------- */
.scroll-cue {
  position: absolute;
  left: 50%;
  bottom: var(--space-6);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 1;
  transition: opacity 0.5s ease;
}
.scroll-cue .cue-arrow {
  font-size: var(--step-1);
  line-height: 0.5;
  color: var(--gold);
  animation: cue-bob 1.8s ease-in-out infinite;
}
.scroll-cue.is-hidden { opacity: 0; }
@keyframes cue-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(5px); }
}

/* ============================================================
   Placeholder section (Stage C target) — lets the pin release
   ============================================================ */
.placeholder {
  min-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-6);
  text-align: center;
}
.placeholder-inner { max-width: 40rem; }
.placeholder-kicker {
  color: var(--gold);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: var(--space-3);
}
.placeholder-copy {
  color: var(--ink-2);
  margin-top: var(--space-3);
}

/* ============================================================
   STATIC / reduced-motion / small-screen FALLBACK
   When <html> gets the .story-static class, the scroll overlay is
   hidden and chapters stack as normal flowing sections instead.
   ============================================================ */
.story-static .story-ui { display: none; }
.story-static #story { display: none; }

.story-stack {
  display: none; /* shown only in static mode */
}
.story-static .story-stack {
  display: block;
  padding: var(--space-8) var(--space-6) var(--space-7);
}
.story-static #story {
  height: 78svh; /* hero still shows, a little shorter */
}

.stack-chapter {
  max-width: 44rem;
  margin: 0 auto var(--space-7);
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.stack-chapter.in {
  opacity: 1;
  transform: translateY(0);
}
.stack-chapter .ch-no {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: 0.18em;
  color: var(--gold);
}
.stack-chapter .ch-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--step-4);
  letter-spacing: -0.02em;
  margin: var(--space-2) 0 var(--space-3);
}
.stack-chapter .ch-copy {
  color: var(--ink-2);
  font-size: var(--step-1);
}

/* ---------------------------------------------------------------
   Responsive: on narrow screens the headlines layer widens so the
   copy never collides with the stepper / right edge.
   --------------------------------------------------------------- */
@media (max-width: 768px) {
  .headlines,
  .chapter { width: 76%; }
  .headline-scrim { width: 76%; }
  .stepper { right: var(--space-2); gap: var(--space-2); }
  .stepper .step-label { display: none; }
}
