/* ============================================================================
   The Network Story — pinned scrollytelling (readme.com-style)
   CSS-sticky pin + GSAP-scrubbed master timeline (see js/story.js)
   ============================================================================ */

.story { padding: 0; }

.story__track { position: relative; height: 560vh; }

.story__pin {
  position: sticky; top: 0; height: 100vh; min-height: 640px;
  display: flex; align-items: stretch; overflow: hidden;
}

/* deep-space atmosphere */
.story__pin::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(900px 540px at 72% 38%, rgba(244,114,124,.07), transparent 62%),
    radial-gradient(700px 500px at 18% 80%, rgba(120,92,60,.08), transparent 60%);
}
.story__pin::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(circle, rgba(243,236,224,.05) 1px, transparent 1.4px);
  background-size: 30px 30px;
  mask-image: radial-gradient(ellipse 75% 70% at 60% 45%, black 20%, transparent 75%);
}

.story__layout {
  position: relative; z-index: 2;
  display: grid; grid-template-columns: minmax(340px, 420px) 1fr;
  gap: clamp(1.5rem, 4vw, 4rem);
  align-items: center; width: min(var(--container-wide), 100% - 2 * var(--gutter));
  margin-inline: auto;
}

/* ── Left rail: progress + chapters ───────────────────────────────────── */
.story__rail { position: relative; display: flex; gap: 1.7rem; min-height: 460px; align-items: center; }

.story__progress {
  position: relative; align-self: stretch;
  display: flex; flex-direction: column; justify-content: space-between;
  padding-block: 3.4rem;
}
.story__progress::before {
  content: ''; position: absolute; left: 50%; top: 3.4rem; bottom: 3.4rem;
  width: 1.5px; transform: translateX(-50%);
  background: var(--remi-line);
}
.story__progress .bar {
  position: absolute; left: 50%; top: 3.4rem; bottom: 3.4rem;
  width: 1.5px; transform: translateX(-50%) scaleY(0); transform-origin: top;
  background: linear-gradient(180deg, var(--remi-accent), var(--remi-accent-dark));
}
.story__dot {
  position: relative; z-index: 1;
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--remi-surface); border: 1.5px solid var(--remi-line);
  font-family: var(--font-mono); font-size: .68rem; font-weight: 600;
  color: var(--remi-muted);
  transition: border-color var(--dur-base) var(--ease-out),
              color var(--dur-base) var(--ease-out),
              background-color var(--dur-base) var(--ease-out),
              box-shadow var(--dur-base) var(--ease-out);
}
.story__dot.is-on {
  border-color: var(--remi-accent); color: #fff; background: var(--remi-accent);
  box-shadow: 0 0 0 6px rgba(var(--remi-accent-rgb), .16);
}

.story__chapters { position: relative; flex: 1; min-height: 460px; }
.story__chapter {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center;
  opacity: 0; visibility: hidden; transform: translateY(28px);
}
.story__chapter .kicker {
  font-family: var(--font-mono); font-size: var(--fs-caption); font-weight: 600;
  letter-spacing: .12em; color: var(--remi-muted);
}
.story__chapter h3 {
  margin: 1.05rem 0 0; font-size: clamp(1.7rem, 1.2rem + 1.8vw, 2.5rem);
  line-height: 1.1; font-weight: 700; letter-spacing: var(--ls-tight);
  color: var(--remi-ink);
}
.story__chapter p { margin: 1.15rem 0 0; font-size: 1.01rem; line-height: 1.7; color: var(--remi-muted); max-width: 42ch; }
.story__chapter .story__ctas { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: 1.9rem; }

.story__chapter .hl { color: var(--remi-ink); font-weight: 600; }
.story__chapter .hl--bank     { color: var(--ty-bank); }
.story__chapter .hl--exchange { color: var(--ty-exchange); }
.story__chapter .hl--mto      { color: var(--ty-mto); }
.story__chapter .hl--crypto   { color: var(--ty-crypto); }
.story__chapter .hl--accent   { color: var(--remi-accent); }

/* ── Scene ─────────────────────────────────────────────────────────────── */
.story__scene { position: relative; display: grid; place-items: center; }
.story__scene svg {
  width: min(100%, 86vh); height: auto; max-height: 88vh;
  overflow: visible;
}

/* node + label styling */
#netscene .ring { fill: none; stroke: var(--remi-line); stroke-width: 1.2; stroke-dasharray: 3 7; opacity: .8; }
#netscene .spoke { fill: none; stroke-width: 1.6; stroke: var(--remi-line); }
#netscene .spoke--p { stroke: color-mix(in srgb, var(--remi-accent) 34%, var(--remi-line)); }

#netscene .nlabel {
  font-family: var(--font-sans); font-weight: 600; font-size: 21px;
  letter-spacing: -0.01em; fill: var(--remi-ink); text-anchor: middle;
}
#netscene .nsub {
  font-family: var(--font-mono); font-weight: 500; font-size: 14.5px;
  letter-spacing: .06em; fill: var(--remi-muted); text-anchor: middle;
}
#netscene .node__bg { fill: var(--remi-surface); stroke-width: 2; }
#netscene .node__icon { fill: none; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

#netscene .op--bank     .node__bg { stroke: var(--ty-bank); }
#netscene .op--exchange .node__bg { stroke: var(--ty-exchange); }
#netscene .op--crypto   .node__bg { stroke: var(--ty-crypto); }
#netscene .op--bank     .node__icon { stroke: var(--ty-bank); }
#netscene .op--exchange .node__icon { stroke: var(--ty-exchange); }
#netscene .op--crypto   .node__icon { stroke: var(--ty-crypto); }
#netscene .op .nsub { fill: var(--remi-muted); }

#netscene .pp .node__bg { stroke: color-mix(in srgb, var(--remi-accent) 55%, var(--remi-line)); }
#netscene .pp .node__icon { stroke: var(--remi-accent); }

#netscene .core__halo { opacity: .95; }
#netscene .core__ring { fill: none; stroke: rgba(244,114,124,.45); stroke-width: 1.6; stroke-dasharray: 4 8; }
#netscene .core__bg { fill: #241f1b; stroke: var(--remi-accent); stroke-width: 2.4; }
#netscene .core__icon { /* the Remi knot mark at the hub centre */ }

/* gate pills */
#netscene .gate__bg { fill: #241f1b; stroke: var(--remi-line); stroke-width: 1.5; rx: 19; }
#netscene .gate__txt {
  font-family: var(--font-mono); font-weight: 600; font-size: 14px;
  letter-spacing: .08em; fill: var(--remi-ink-soft); text-anchor: start;
}
#netscene .gate__tick { fill: none; stroke: var(--remi-success); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
#netscene .gate--on .gate__bg { stroke: var(--remi-success); }

/* payout chip */
#netscene .chip__bg { fill: var(--remi-success-soft); stroke: var(--remi-success); stroke-width: 1.6; }
#netscene .chip__txt { font-family: var(--font-mono); font-weight: 600; font-size: 14.5px; letter-spacing: .05em; fill: var(--remi-success); text-anchor: start; }

/* the travelling pulse */
#netscene .pulse { fill: var(--remi-accent); }

/* ambient pulses (ch4) */
#netscene .amb { fill: var(--remi-accent); opacity: .9; }

/* ── Readout (mono event log under scene) ─────────────────────────────── */
.story__readout {
  position: absolute; left: 50%; bottom: -2.4rem; transform: translateX(-50%);
  display: flex; gap: .55rem 1.6rem; flex-wrap: wrap; justify-content: center;
  width: max-content; max-width: 100%;
  font-family: var(--font-mono); font-size: .76rem; letter-spacing: .03em;
  color: var(--remi-muted-2); white-space: nowrap;
}
.story__readout span { opacity: .28; transition: opacity var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out); }
.story__readout span.is-on { opacity: 1; color: var(--remi-ink-soft); }
.story__readout span.is-on b { color: var(--remi-success); font-weight: 600; }
.story__readout b { font-weight: 600; }

/* ── Story heading shown before pin engages ───────────────────────────── */
.story__intro {
  position: absolute; top: 0; left: 0; right: 0; z-index: 3;
  padding-top: clamp(4.5rem, 4rem + 4vw, 7.5rem); text-align: center; pointer-events: none;
}

/* ── Mobile / stacked layout ──────────────────────────────────────────── */
@media (max-width: 900px) {
  .story__track { height: 600vh; }
  /* Reserve the slimmer 56px mobile nav so the centered stack (scene + rail)
     clears the header — box-sizing:border-box keeps the pin at 100vh. */
  .story__pin { min-height: 0; padding-top: 56px; }
  .story__layout {
    grid-template-columns: 1fr; gap: .6rem;
    align-content: center; height: 100%;
  }
  .story__scene { order: 1; }
  .story__scene svg { width: auto; max-width: 100%; height: min(37vh, 72vw); }
  .story__rail { order: 2; min-height: 340px; gap: 1.1rem; }
  .story__chapters { min-height: 340px; }
  .story__progress { padding-block: 1rem; }
  .story__dot { width: 28px; height: 28px; font-size: .6rem; }
  .story__chapter h3 { font-size: 1.3rem; }
  .story__chapter p { font-size: .88rem; max-width: none; }
  .story__readout { display: none; }
  #netscene .nlabel { font-size: 26px; }
  #netscene .nsub { font-size: 18px; }
}

/* ── Phones / small tablets: drop the illustration, keep the chaptered story ──
   Render the static (unpinned, stacked) layout at FIRST PAINT — the same layout
   js/story.js applies via .story--static on mobile. Doing it in CSS avoids the
   massive JS-driven reflow (560vh pinned track → auto height) that otherwise
   collapses the page on load and scores CLS ~1.0. Keep these in sync with the
   .story--static rules below. */
@media (max-width: 768px) {
  .story__scene { display: none; }
  .story__track { height: auto; }
  .story__pin {
    position: static; height: auto; min-height: 0; overflow: visible;
    padding-block: var(--section-py); display: block;
  }
  .story__intro {
    position: static; padding-top: 0; pointer-events: auto;
    margin-bottom: clamp(2rem, 5vw, 3.5rem);
  }
  .story__intro .lead { display: none; }
  .story__layout { grid-template-columns: 1fr; }
  .story__rail { align-items: stretch; }
  .story__progress { display: none; }
  .story__chapters { min-height: 0; }
  .story__chapter {
    position: static; opacity: 1; visibility: visible; transform: none;
    margin-top: 2.6rem;
  }
  .story__readout { position: static; transform: none; margin-top: 1.4rem; }
}

/* ── Reduced motion / no-GSAP: unpin, stack everything in one column ─────
   The pin is normally a flex row; left as-is here the intro and chapters sit
   side-by-side as two cramped columns (worst on mobile and in in-app browsers
   where GSAP may not load). Force a block stack and bring the intro back into
   flow so it reads as a normal heading above the chapters. */
.story--static .story__track { height: auto; }
.story--static .story__pin { position: static; height: auto; min-height: 0; overflow: visible; padding-block: var(--section-py); display: block; }
.story--static .story__intro { position: static; padding-top: 0; margin-bottom: clamp(2rem, 5vw, 3.5rem); }
.story--static .story__intro .lead { display: none; } /* "keep scrolling…" — nothing animates in static mode */
.story--static .story__layout { grid-template-columns: 1fr; }
.story--static .story__rail { align-items: stretch; }
.story--static .story__progress { display: none; }
.story--static .story__chapters { min-height: 0; }
.story--static .story__chapter {
  position: static; opacity: 1; visibility: visible; transform: none;
  margin-top: 2.6rem;
}
.story--static .story__readout { position: static; transform: none; margin-top: 1.4rem; }
.story--static .story__readout span { opacity: 1; }
