/* ============================================================================
   Eyas — 04 · How it works  (the mechanism + the Falconer's voice)
   Near-monochrome + steel signature. ONE tiny amber dose: step 04, the
   "you're getting calmer" line, and the warning-state HUD bloom. Part B is the
   REAL product overlay (a clean capture of the live HUD), framed and animated.
   All custom classes prefixed `how-`.
   ========================================================================== */

.how { overflow: hidden; }

/* soft steel bloom seated behind the product overlay */
.how-bloom {
  position: absolute; z-index: 0; pointer-events: none;
  top: 34%; right: 4%; width: min(46vw, 620px); aspect-ratio: 1;
  background: radial-gradient(circle, rgba(175,200,228,0.14) 0%, transparent 68%);
  filter: blur(20px);
}

.how-wrap { position: relative; z-index: 1; }

/* ── Header ─────────────────────────────────────────────────────────────── */
.how-head { max-width: 46ch; margin-bottom: clamp(2.75rem, 6vh, 5rem); }
.how-title { margin-top: var(--sp-4); }

/* ── Composition: steps (left) + product overlay (right) ────────────────── */
.how-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: clamp(2.5rem, 5vw, 5.5rem);
  align-items: start;
}

/* ── PART A · vertical timeline of steps ────────────────────────────────── */
.how-steps { list-style: none; display: flex; flex-direction: column; }

.how-step {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: clamp(1.1rem, 2vw, 1.9rem);
  padding-bottom: clamp(1.75rem, 3.5vh, 2.75rem);
}
.how-step:last-child { padding-bottom: 0; }

/* the connecting rail runs down through the number column */
.how-step__rail {
  position: absolute; left: calc(var(--sp-3) - 0.5px); top: 2.6rem; bottom: -0.2rem;
  width: 1px;
  background: linear-gradient(180deg, rgba(186,212,240,0.30), rgba(186,212,240,0.04));
}
.how-step:last-child .how-step__rail { display: none; }

.how-step__num {
  position: relative; z-index: 1;
  display: inline-flex; align-items: flex-start; justify-content: center;
  min-width: 1.5rem;
  font-size: var(--fs-lead); font-weight: 600;
  color: var(--accent);
  line-height: 1.4;
}
.how-step--warm .how-step__num { color: var(--warm); }

.how-step__body { padding-top: 0.1rem; }
.how-step__title { color: var(--text-hi); }
.how-step__sub {
  margin-top: var(--sp-3);
  color: var(--text-mid);
  font-size: var(--fs-body);
  line-height: 1.6;
  max-width: 42ch;
}

/* ── PART B · the real HUD overlay ──────────────────────────────────────── */
.how-demo { position: relative; }

.how-hud {
  position: relative;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(0.9rem, 2vh, 1.4rem);
}

/* ambient bloom behind the panel — tinted to the active state so the warmth
   tracks the climb (jade -> gold -> garnet). Default gold (the iconic frame). */
.how-hud__bloom {
  position: absolute;
  z-index: 0;
  left: 50%; top: 42%;
  width: 116%; aspect-ratio: 1.4;
  transform: translate(-50%, -50%);
  pointer-events: none;
  background: radial-gradient(closest-side,
    rgba(227,165,84,0.20) 0%, rgba(227,165,84,0.06) 46%, transparent 72%);
  filter: blur(26px);
  transition: background .9s var(--ease);
}
[data-how-escalate][data-active="clear"] .how-hud__bloom {
  background: radial-gradient(closest-side,
    rgba(143,205,180,0.18) 0%, rgba(143,205,180,0.05) 46%, transparent 72%);
}
[data-how-escalate][data-active="stop"] .how-hud__bloom {
  background: radial-gradient(closest-side,
    rgba(201,72,95,0.20) 0%, rgba(201,72,95,0.06) 46%, transparent 72%);
}
/* a quiet two-breath warmth when the panel scrolls in, then rest (DESIGN.md §9) */
.how-demo.is-in .how-hud__bloom { animation: how-bloom-breathe 3s var(--ease) 2; }
@keyframes how-bloom-breathe {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.62; }
}

/* the overlay STACK: three real captures sharing one grid cell, crossfaded.
   Grid-stacking lets the container size to the tallest state automatically, so
   shorter states (the calm one) just center against it — the height change as it
   escalates reads as the HUD itself breathing open. The stack rises once on
   scroll-in (mirrors the old single-panel entrance). */
.how-hud__stack {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(100%, 460px);
  transform: scale(0.955) translateY(8px);
  opacity: 0.001;
  transition: opacity .7s var(--ease), transform .9s var(--ease);
}
.how-demo.is-in .how-hud__stack { opacity: 1; transform: none; }

.how-hud__layer {
  grid-area: 1 / 1;
  align-self: center;          /* a shorter state floats centered on the tallest */
  opacity: 0;
  transition: opacity .9s var(--ease);
}
.how-hud__layer.is-active { opacity: 1; }

/* JS seeds the calm first frame without a backward fade (see main.js §2b) */
.how-no-anim .how-hud__layer,
.how-no-anim .how-voice__state,
.how-no-anim .how-hud__capstate,
.how-no-anim .how-hud__bloom,
.how-no-anim .how-ladder__dot { transition: none !important; }

/* the real overlay capture: alpha-rounded PNG, soft drop-shadow that follows the
   rounded alpha (box-shadow would show a rectangle). */
.how-hud__panel {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 28px 60px rgba(0,0,0,0.55)) drop-shadow(0 2px 10px rgba(0,0,0,0.40));
}

/* ── PART B hero: the spoken warning, large ─────────────────────────────── */
.how-voice {
  margin: 0 0 clamp(1.6rem, 3.5vh, 2.6rem);
  text-align: center;
}
/* a speaking equalizer above the quote: the cue that this is spoken, live */
.how-voice__wave {
  display: inline-flex; align-items: center; gap: 3px;
  height: 22px; margin-bottom: var(--sp-4);
}
.how-voice__wave span {
  width: 3px; border-radius: var(--r-pill);
  background: var(--accent);
  transform-origin: center; transform: scaleY(0.4);
  opacity: 0.85;
}
.how-voice__wave span:nth-child(2n) { transform: scaleY(0.72); }
.how-voice__wave span:nth-child(3n) { transform: scaleY(1); opacity: 1; }
.how-demo.is-in .how-voice__wave span { animation: how-bar 1.4s var(--ease) 3; }
.how-demo.is-in .how-voice__wave span:nth-child(2) { animation-delay: -0.3s; }
.how-demo.is-in .how-voice__wave span:nth-child(3) { animation-delay: -0.6s; }
.how-demo.is-in .how-voice__wave span:nth-child(4) { animation-delay: -0.9s; }
.how-demo.is-in .how-voice__wave span:nth-child(5) { animation-delay: -0.45s; }
.how-demo.is-in .how-voice__wave span:nth-child(6) { animation-delay: -0.75s; }
.how-demo.is-in .how-voice__wave span:nth-child(7) { animation-delay: -1.05s; }
@keyframes how-bar {
  0%, 100% { transform: scaleY(0.3); }
  50%      { transform: scaleY(1); }
}

.how-voice__quote {
  margin: 0;
  font-size: clamp(1.5rem, 2.3vw, 2.2rem);
  font-weight: 500;
  line-height: 1.32;
  letter-spacing: var(--tracking-snug);
  color: var(--text-hi);
  text-wrap: balance;
}
.how-voice__quote p { margin: 0; }
.how-voice__by {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
  max-width: 54ch;
  font-size: var(--fs-sm);
  line-height: 1.5;
  color: var(--text-lo);
}
.how-voice__dot {
  width: 6px; height: 6px; flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--glow-steel);
}

/* the three spoken states share one grid cell and crossfade in sync with the
   HUD; the cell sizes to the tallest line so nothing below jumps. */
.how-voice__stack { display: grid; }
.how-voice__state {
  grid-area: 1 / 1;
  opacity: 0;
  transition: opacity .8s var(--ease);
}
.how-voice__state.is-active { opacity: 1; }

/* HUD proof caption: three narrations sharing one grid cell, crossfaded with
   the state. Grid-stack so the tallest line reserves the height (no jump). */
.how-hud__cap {
  position: relative;
  z-index: 1;
  display: grid;
  max-width: 46ch;
}
.how-hud__capstate {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-1);
  text-align: center;
  opacity: 0;
  transition: opacity .7s var(--ease);
}
.how-hud__capstate.is-active { opacity: 1; }
.how-hud__tag {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--accent);
}
.how-hud__cap-txt {
  color: var(--text-mid);
  font-size: var(--fs-sm);
  line-height: 1.5;
}

/* ── Escalation ladder: green -> amber -> red, the climb made legible ─────── */
.how-ladder {
  position: relative;
  z-index: 1;
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-top: var(--sp-2);
}
.how-ladder__rung { display: flex; align-items: center; }
.how-ladder__dot {
  display: block;
  width: 7px; height: 7px;
  border-radius: var(--r-pill);
  background: var(--text-faint);
  opacity: 0.38;
  transition: width .6s var(--ease), background .6s var(--ease),
              opacity .6s var(--ease), box-shadow .6s var(--ease);
}
/* passed or current rungs carry their own state colour */
.how-ladder__rung.is-on .how-ladder__dot { opacity: 1; }
.how-ladder__rung[data-state="clear"].is-on .how-ladder__dot {
  background: var(--status-clear); box-shadow: 0 0 8px rgba(143,205,180,0.55);
}
.how-ladder__rung[data-state="amber"].is-on .how-ladder__dot {
  background: var(--status-warn); box-shadow: 0 0 8px var(--warm-glow);
}
.how-ladder__rung[data-state="stop"].is-on .how-ladder__dot {
  background: var(--status-stop); box-shadow: 0 0 9px rgba(201,72,95,0.55);
}
/* the current rung stretches into a pill */
.how-ladder__rung.is-active .how-ladder__dot { width: 22px; opacity: 1; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 960px) {
  .how-grid {
    grid-template-columns: 1fr;
    gap: clamp(2.5rem, 7vh, 4rem);
  }
  .how-bloom { top: 60%; right: -8%; }
  /* on a single column the overlay leads, caption + ladder sit beneath it */
  .how-hud { align-items: center; }
}

@media (max-width: 480px) {
  .how-hud__stack { width: min(100%, 380px); }
  .how-hud__cap { font-size: var(--fs-xs); }
}

/* ════════════════════════════════════════════════════════════════════════
   DESKTOP (>=1024px) — balance the two columns. The steps list is tall; the
   overlay is compact. We give the overlay its own column track that sticks to
   the viewport so it rides vertically centered against the list, and tighten
   the numeral + step rhythm so the left reads as a deliberate editorial
   timeline rather than a stack of paragraphs.
   ════════════════════════════════════════════════════════════════════════ */
@media (min-width: 1024px) {

  .how-head { max-width: 52ch; }

  .how-grid {
    grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
    gap: clamp(3.5rem, 6vw, 7rem);
    /* stretch so the sticky overlay can measure itself against the full list */
    align-items: stretch;
  }

  /* steps: a touch more air between beats, consistent rhythm */
  .how-step { padding-bottom: clamp(2.25rem, 4vh, 3.5rem); }

  /* numeral treatment: larger, lighter weight, tabular, with a hairline tick
     so each step reads as a marked station on the rail */
  .how-step__num {
    font-size: clamp(1.4rem, 1.8vw, 1.85rem);
    font-weight: 500;
    line-height: 1.1;
    min-width: 2.4rem;
    font-variant-numeric: tabular-nums;
    letter-spacing: var(--tracking-snug);
    padding-top: 0.12em;
  }
  /* node dot where the rail meets each number, premium timeline cue */
  .how-step__num::before {
    content: "";
    position: absolute;
    left: calc(var(--sp-3) - 3px);
    top: 0.72rem;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 4px rgba(175,200,228,0.10), 0 0 12px var(--glow-steel);
  }
  .how-step--warm .how-step__num::before {
    background: var(--warm);
    box-shadow: 0 0 0 4px rgba(227,165,84,0.10), 0 0 12px var(--warm-glow);
  }
  /* rail starts just below the node dot and runs to the next station */
  .how-step__rail { top: 1.5rem; }

  .how-step__title { font-size: clamp(1.35rem, 1.7vw, 1.7rem); }
  .how-step__sub { max-width: 46ch; }

  /* overlay column rides as its own sticky band so it sits optically centered
     against the tall steps list instead of pinning to the top */
  .how-demo {
    position: sticky;
    top: clamp(5rem, 16vh, 9rem);
    align-self: center;
  }

  .how-hud__stack { width: min(100%, 440px); }
}

/* Ultra-wide: let the composition breathe, cap the overlay so it stays a
   premium product moment rather than stretching into a banner. */
@media (min-width: 1440px) {
  .how-grid { gap: clamp(5rem, 6vw, 8rem); }
  .how-demo { justify-self: end; width: 100%; max-width: 560px; }
}

/* ── Reduced motion: static, legible, nothing implied is lost ─────────────
   The waveform rest row and the panel's final position are the defaults, so we
   only suppress the scroll-in burst, the bloom breath, and the panel slide. */
@media (prefers-reduced-motion: reduce) {
  .how-demo.is-in .how-hud__bloom,
  .how-hud__bloom { animation: none; }
  .how-demo.is-in .how-voice__wave span,
  .how-voice__wave span { animation: none; }
  .how-hud__stack { opacity: 1; transform: none; transition: none; }
  /* no crossfade — JS snaps straight to the rest state */
  .how-hud__layer,
  .how-voice__state,
  .how-hud__capstate,
  .how-ladder__dot { transition: none; }
}
