/* Builder P: act 4, the peak (the reversal that stops dead), drawn as the
   full payment journey on both sides. Everything is scoped to .st-peak.
   Linework colours come from the side tokens through currentColor and
   var(--sc-*), never raw hex. Default rules describe the END state, so no-JS
   and reduced motion read the outcome. .st-live (added by story.js) switches
   on the scroll-driven states. */

/* ------------------------------------------------------------ shared ---- */
.st-ln { fill: none; stroke: currentColor; stroke-width: 1.3; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; }
.st-ln--soft { stroke: var(--sc-hairline-strong); }
.st-ln--thin { stroke-width: 0.8; }
.st-ln--acc { stroke: var(--sc-accent); stroke-width: 2; }
.st-node { fill: var(--sc-canvas); stroke: currentColor; stroke-width: 1.3; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.st-node--acc { stroke: var(--sc-accent); }

/* Era weights. The past is cut: heavier ink, square caps, hatched shading.
   The future is drawn: hairlines, round caps, accent. Both read on their own
   ground through the side tokens, so variant B re-inks the past by itself. */
.st-era-past { --st-ink-w: 1.75px; }
.st-era-past .st-ln, .st-era-past .st-node { stroke-width: var(--st-ink-w); stroke-linecap: square; stroke-linejoin: miter; }
.st-era-past .st-ln--thin { stroke-width: 0.9px; }
.st-era-past .st-ln--soft { stroke: var(--sc-ink-soft); }
.st-hatch { fill: url(#st-engrave); stroke: none; opacity: 0.6; }
.st-rule { fill: none; stroke: var(--sc-hairline-strong); stroke-width: 0.8; vector-effect: non-scaling-stroke; }
.st-cord { stroke-width: 1.4px; stroke-linecap: round; }
.st-plug { fill: var(--sc-ink); stroke: none; }
.st-wax__blob { fill: url(#st-engrave); stroke: currentColor; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.st-coin { fill: var(--sc-surface); stroke: currentColor; stroke-width: 1.5px; vector-effect: non-scaling-stroke; }
.st-claw { fill: var(--sc-canvas); stroke: currentColor; stroke-width: 1.5px; stroke-linecap: square; stroke-linejoin: miter; vector-effect: non-scaling-stroke; }
.st-till__drawer { stroke-width: 1.5px; }

.st-era-future .st-ln, .st-era-future .st-node { stroke-width: 1; stroke-linecap: round; }
.st-era-future .st-ln--thin { stroke-width: 0.6; }
.st-era-future .st-ln--acc { stroke-width: 1.8; }
.st-sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
.st-col { position: relative; min-width: 0; }

/* ----------------------------------------------------------- timing ---- */
/* Ramps read the engine's --sc-p. The fallback of 1 is the end state, so a
   page without the engine still shows the outcome. --k-d is the depth drift
   of the planes: constant through the authored silence (p < 0.12). */
.st-peak {
  --k-d:      calc(clamp(0, (var(--sc-p, 1) - 0.12) / 0.84, 1) - 0.5);
  --k-seal:   clamp(0, (var(--sc-p, 1) - 0.655) / 0.05, 1);
  --k-stamp:  clamp(0, (var(--sc-p, 1) - 0.595) / 0.045, 1);
  --k-ledger: clamp(0, (var(--sc-p, 1) - 0.62) / 0.04, 1);
  --k-capl:   clamp(0, (var(--sc-p, 1) - 0.63) / 0.06, 1);
  --k-capr:   clamp(0, (var(--sc-p, 1) - 0.71) / 0.06, 1);
  --k-sub:    clamp(0, (var(--sc-p, 1) - 0.75) / 0.06, 1);
}

/* ----------------------------------------------------------- layout ---- */
.st-peak [data-sc-stage] > .split { height: 100%; }
.st-peak .side { min-width: 0; }
@media (min-width: 760px) {
  /* both drawings sit on the same line, so the two returns read as one mapping */
  [data-sc-stage] > .split > .side.st-pside { justify-content: flex-start; padding-top: clamp(5rem, 18vh, 11rem); }
}
.st-peak .st-col--peak {
  width: 100%;
  /* the divider winds up to 2.5vw either way and the card side leans to 47%:
     keep at least 6vw of air on the inner edge after both */
  padding-right: 5.5vw;
}
.st-peak .side--vp .st-col--peak { padding-right: 0; padding-left: 3vw; }

/* ------------------------------------------------------------ figure --- */
.st-fig { position: relative; max-width: 38rem; color: var(--sc-ink); container-type: inline-size; }
.st-fig__svg { position: relative; display: block; width: 100%; height: auto; overflow: visible; }

/* plane 1: the drafting grid, furthest back, drifts the most */
.st-grid {
  position: absolute; inset: -14% -5% -10% -5%; width: 110%; height: 124%;
  color: var(--sc-hairline);
  -webkit-mask-image: radial-gradient(closest-side, black 55%, transparent);
  mask-image: radial-gradient(closest-side, black 55%, transparent);
  translate: calc(var(--k-d) * 12px) calc(var(--k-d) * 34px);
}
/* plane 2 (route) is the reference. Stations sit a hair nearer, the tokens
   ride the route, the callouts are nearest and drift against the grid. */
.st-pl--stn { translate: 0 calc(var(--k-d) * -7px); }
.st-fig__tag, .st-stamp, .st-seal { translate: 0 calc(var(--k-d) * -18px); }

/* route lines */
.st-base { fill: none; stroke: var(--sc-hairline-strong); stroke-width: 1.2; stroke-dasharray: 2 5; vector-effect: non-scaling-stroke; }
.st-trail {
  fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 1 2; stroke-dashoffset: calc(1 - var(--st-f, 1));
}
.st-fig--vp .st-trail { stroke: var(--sc-ink); stroke-width: 1.2; }
.st-era-past .st-trail { stroke-width: 2; stroke-linecap: square; }
.st-trail--fee { stroke: var(--sc-accent); stroke-width: 1; stroke-dashoffset: calc(1 - var(--st-s, 1)); }
.st-trail--fee-under { stroke: color-mix(in oklab, var(--sc-accent) 20%, transparent); stroke-width: 5; stroke-dashoffset: calc(1 - var(--st-s, 1)); }
.st-run { fill: none; stroke: none; }

/* stations */
.st-hex { fill: color-mix(in oklab, var(--sc-accent) 14%, transparent); stroke: var(--sc-accent); stroke-width: 1; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.st-hex--inner { fill: none; stroke-width: 0.6; }
.st-split { fill: var(--sc-accent); }
.st-split--ring { fill: none; stroke: var(--sc-accent); stroke-width: 0.7; vector-effect: non-scaling-stroke; }
.st-fee__body { fill: color-mix(in oklab, var(--sc-accent) 14%, var(--sc-canvas)); stroke: var(--sc-accent); }
/* the converter's orbit ring: it turns with the depth drift, behind the node */
.st-orbit { transform-box: fill-box; transform-origin: center; rotate: calc(-22deg + var(--k-d) * 36deg); }
.st-orbit__ring { fill: none; stroke: var(--sc-accent); stroke-width: 0.8; vector-effect: non-scaling-stroke; }
.st-orbit__sat { fill: var(--sc-accent); }
/* the exchange: a projection frame (thin double line), no glow */
.st-holo__frame { stroke: var(--sc-accent); fill: var(--sc-canvas); }
.st-holo__inner { fill: none; stroke: var(--sc-accent); stroke-width: 0.5; vector-effect: non-scaling-stroke; }
.st-holo__beam { fill: none; stroke: color-mix(in oklab, var(--sc-accent) 45%, transparent); stroke-width: 0.6; vector-effect: non-scaling-stroke; }
.st-holo__base { fill: none; stroke: var(--sc-accent); stroke-width: 2; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.st-peak.st-live:not([data-st-fee]) .st-fee__body { fill: var(--sc-canvas); stroke: currentColor; }

/* the payment: a note on both sides; on VanPay it leaves the exchange as a coin */
.st-tok__note { fill: var(--sc-surface); stroke: currentColor; stroke-width: 1.4; vector-effect: non-scaling-stroke; }
.st-era-past .st-tok__note { stroke-width: 1.6px; }
.st-tok__coin-face, .st-tok--slice path { fill: var(--sc-accent); stroke: var(--sc-accent); stroke-width: 1; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.st-tok__coin-edge { fill: none; stroke: var(--sc-accent-ink); stroke-width: 0.6; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.st-tok__fiat, .st-tok__coin { transform-box: fill-box; transform-origin: center; }
/* the card payment: a note on the way in, a clerk's hand with the coins on the way back.
   Default (no engine, reduced motion) is the end state: the hand has them. */
.st-peak.st-live:not([data-st-draw]) .st-tok__hand { opacity: 0; }
.st-tok__note-g { opacity: 0; }
.st-peak.st-live:not([data-st-draw]) .st-tok__note-g { opacity: 1; }
/* end state: the coin has become "received" in the wallet glyph */
.st-tok--vp { opacity: 0; }
.st-peak.st-live:not([data-st-r="held"]) .st-tok--vp { opacity: 1; }
.st-peak.st-live:not([data-st-slice]) .st-tok--slice { opacity: 0; }

/* labels: short, mono, centred on their station */
.st-fig__tag {
  position: absolute; top: 2%; white-space: nowrap;
  font: 500 0.75rem/1.2 var(--sc-font-mono); letter-spacing: 0.04em; color: var(--sc-ink-soft);
  transform: translateX(-50%);
}
.st-fig__tag--a   { left: 8.75%; }
.st-fig__tag--vp  { left: 29.06%; }
.st-fig__tag--mid { left: 49.38%; }
.st-fig__tag--proc { left: 45.3%; }
.st-fig__tag--end { left: 90%; }
.st-fig__tag--fee { left: auto; right: 33.2%; top: 40.9%; transform: translateY(-50%); color: var(--sc-accent); }
.st-fig__tag--mark { top: 88.5%; left: 61.2%; }
.st-fig__tag--gate { color: var(--sc-accent); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }

/* ------------------------------------------------ the return (signature) */
.st-track { fill: none; stroke: var(--sc-hairline-strong); stroke-width: 1.2; stroke-dasharray: 3 6; vector-effect: non-scaling-stroke; }
.st-ret {
  fill: none; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 1 2;
}
.st-ret--card { stroke: var(--sc-ink); stroke-width: 2.4; stroke-dashoffset: calc(1 - var(--st-l, 1)); }
.st-ret--vp   { stroke: var(--sc-accent); stroke-width: 3.6; stroke-dashoffset: calc(1 - var(--st-r, 0.4)); }
.st-tip path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.st-tip--card path { stroke: var(--sc-ink); stroke-width: 2.6; }
.st-tip--vp path   { stroke: var(--sc-accent); stroke-width: 3.8; }
.st-peak.st-live:not([data-st-draw]) .st-tip { opacity: 0; }

/* the light gate: a faint band, one bright beam, two posts */
.st-gate__band { stroke: color-mix(in oklab, var(--sc-accent) 16%, transparent); stroke-width: 9; stroke-linecap: butt; }
.st-gate__beam { stroke: var(--sc-accent); stroke-width: 1.6; stroke-linecap: butt; }
.st-gate__post { fill: var(--sc-accent); stroke: none; }

/* wallet glyph (hardware from tomorrow): one update, after the stamp */
.st-wallet-glyph__body { fill: var(--sc-canvas); stroke: var(--sc-accent); }
.st-wallet-glyph__screen { fill: color-mix(in oklab, var(--sc-accent) 14%, var(--sc-canvas)); stroke: var(--sc-accent); stroke-width: 0.6; vector-effect: non-scaling-stroke; }
.st-wallet-glyph__check { fill: none; stroke: var(--sc-accent); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.st-peak.st-live:not([data-st-r="held"]) .st-wallet-glyph__screen { fill: var(--sc-surface); }
.st-peak.st-live:not([data-st-r="held"]) .st-wallet-glyph__check { opacity: 0; }

/* the chargeback stamp: an inked rubber stamp, lands with scale and a small
   rotate. The bleed is a hair of offset ink, not a halo. */
.st-stamp {
  position: absolute; left: 36%; top: 57%;
  padding: 0.42em 0.8em 0.38em;
  border: 2.5px solid var(--sc-ink);
  border-radius: 2px;
  background: color-mix(in oklab, var(--sc-canvas) 82%, transparent);
  color: var(--sc-ink);
  font: 800 clamp(1rem, 0.5rem + 1.25vw, 1.75rem)/1 var(--sc-font-display);
  font-stretch: 112%; letter-spacing: 0.12em; text-transform: uppercase; white-space: nowrap;
  box-shadow:
    inset 0 0 0 2px color-mix(in oklab, var(--sc-canvas) 82%, transparent),
    inset 0 0 0 3px var(--sc-ink),
    0.6px 0.8px 0.9px color-mix(in oklab, var(--sc-ink) 45%, transparent);
  text-shadow:
    0.5px 0.6px 0.8px color-mix(in oklab, var(--sc-ink) 55%, transparent),
    -0.4px 0.2px 0.7px color-mix(in oklab, var(--sc-ink) 35%, transparent);
  opacity: var(--k-stamp);
  transform: translate(-50%, -50%) rotate(calc(-7deg - (1 - var(--k-stamp)) * 9deg)) scale(calc(1 + (1 - var(--k-stamp)) * 0.6));
}
.st-ledger {
  margin: clamp(0.9rem, 1.6vw, 1.4rem) 0 0;
  font: 500 0.82rem/1.3 var(--sc-font-mono); letter-spacing: 0.02em; color: var(--sc-ink-soft);
  opacity: var(--k-ledger);
}
.st-ledger b { color: var(--sc-ink); font-weight: 700; text-decoration: line-through; text-decoration-thickness: 1px; }

/* the seal: the heaviest object on the page, set on the path the reversal never reached */
.st-seal {
  position: absolute; left: 38%; top: 70%;
  width: 25%; aspect-ratio: 1;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--sc-accent);
  background: color-mix(in oklab, var(--sc-surface) 90%, transparent);
  box-shadow: var(--sc-e2);
  opacity: var(--k-seal);
  transform: translate(-50%, -50%) rotate(calc(-10deg + (1 - var(--k-seal)) * 14deg)) scale(calc(1 + (1 - var(--k-seal)) * 0.45));
}
.st-seal__ring { position: absolute; inset: 0; width: 100%; height: 100%; }
.st-seal__text {
  position: relative; text-align: center;
  font: 800 2.65cqi/1.1 var(--sc-font-display);
  font-stretch: 106%; letter-spacing: 0.05em; text-transform: uppercase;
}
.st-seal__text > span { display: block; white-space: nowrap; }

.st-wallet {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.75rem;
  margin: clamp(0.9rem, 1.6vw, 1.4rem) 0 0;
  font: 600 0.9rem/1.3 var(--sc-font-text); color: var(--sc-ink);
}
.st-wallet__pre { display: none; color: var(--sc-ink-soft); font-weight: 500; }
.st-peak.st-live:not([data-st-r="held"]) .st-wallet__pre { display: inline; }
.st-peak.st-live:not([data-st-r="held"]) .st-wallet__post { display: none; }
.st-wallet__post::before {
  content: ""; display: inline-block; width: 0.5rem; height: 0.5rem; margin-right: 0.45rem;
  border-radius: 50%; background: var(--sc-accent); vertical-align: 0.06em;
}

/* captions: the card side states it, the VanPay side lands it */
.st-cap { margin: clamp(1.25rem, 2.4vw, 2.25rem) 0 0; text-wrap: balance; }
.st-cap--card {
  font-size: clamp(1.35rem, 0.9rem + 1.5vw, 2.4rem); line-height: 1.06; max-width: 18ch;
  opacity: var(--k-capl);
  transform: translate3d(0, calc((1 - var(--k-capl)) * 0.75rem), 0);
}
.st-cap--vp {
  font-size: clamp(2.1rem, 1rem + 4vw, 5.25rem); line-height: 0.96; letter-spacing: -0.03em;
  font-stretch: 108%;
  opacity: var(--k-capr);
  transform: translate3d(0, calc((1 - var(--k-capr)) * 1.25rem), 0);
}
.st-cap-sub {
  margin: clamp(0.6rem, 1.2vw, 1rem) 0 0; max-width: 30rem; color: var(--sc-ink-soft);
  opacity: var(--k-sub);
}

/* --------------------------------------------------------- mobile ---- */
@media (max-width: 759.98px) {
  .st-peak .side { align-items: stretch; }
  .st-peak .st-col--peak,
  .st-peak .side--vp .st-col--peak { padding: 0; }
  .st-fig { max-width: 26rem; }
  /* simpler stations: outlines only */
  .st-dt { display: none; }
  .st-fig__tag { font-size: 0.6875rem; letter-spacing: 0.01em; }
  .st-fig__tag--a { left: 0; transform: none; }
  .st-fig__tag--end { left: auto; right: 0; transform: none; }
  .st-fig__tag--fee { transform: translateY(-50%); }
  .st-ledger, .st-wallet { margin-top: 0.4rem; font-size: 0.74rem; }
  .st-cap { margin-top: 0.5rem; }
  .st-cap--card { font-size: 1.2rem; }
  .st-cap--vp { font-size: 2rem; }
  .st-cap-sub { margin-top: 0.3rem; font-size: 0.78rem; line-height: 1.35; }
  .st-stamp { font-size: 0.9rem; border-width: 2px; }
  .st-seal__text { letter-spacing: 0.03em; }
  .st-grid { translate: 0 calc(var(--k-d) * 18px); }
  .st-fig__tag, .st-stamp, .st-seal { translate: 0 calc(var(--k-d) * -8px); }
}
@media (max-width: 759.98px) and (max-height: 700px) {
  /* 360x640: a slightly smaller drawing, same stations and labels */
  .st-fig { max-width: 19.5rem; }
  .st-cap-sub { font-size: 0.72rem; }
  .st-cap--vp { font-size: 1.7rem; }
  .st-cap--card { font-size: 1.05rem; }
}

/* --------------------------------------------------- reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  .st-peak { --k-d: 0; --k-seal: 1; --k-stamp: 1; --k-ledger: 1; --k-capl: 1; --k-capr: 1; --k-sub: 1; }
  .st-trail { stroke-dashoffset: 0; }
  .st-ret--card { stroke-dashoffset: 0; }
  .st-ret--vp { stroke-dashoffset: 0.6; }
  .st-peak .st-tip { opacity: 1 !important; }
  .st-peak .st-tok--vp { opacity: 0 !important; }
  .st-peak .st-tok--slice { opacity: 1 !important; }
  .st-peak .st-wallet__pre { display: none !important; }
  .st-peak .st-wallet__post { display: inline !important; }
  .st-peak .st-wallet-glyph__screen { fill: color-mix(in oklab, var(--sc-accent) 14%, var(--sc-canvas)) !important; }
  .st-peak .st-wallet-glyph__check { opacity: 1 !important; }
  .st-peak .st-tok__hand { opacity: 1 !important; }
  .st-peak .st-tok__note-g { opacity: 0 !important; }
  .st-orbit { rotate: -22deg; }
}
