/* Page layer over the approved frame styles (assets/frames.css). Every colour and size comes from assets/tokens.css or from the block below.
   The block below holds the motion tokens of DESIGN.md section 10.2 that the frame tokens file does not carry. Values are copied from that table. */
:root {
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-count: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-press: 80ms; --dur-fast: 180ms; --dur-slide: 280ms; --dur-enter: 520ms;
  --stagger-min: 100ms; --stagger-max: 150ms; --dur-count: 1000ms; --delay-line: 400ms; --dur-card: 1300ms;
}

html, body { min-height: 100%; overflow-x: hidden; }
body { display: flex; justify-content: center; min-height: 100vh; min-height: 100dvh; background: var(--color-deep); }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }

/* The story column. 390 wide at most, the whole width on a phone. Container units keep the hero numerals and card crop tied to the column and not to the window. */
#app {
  --vw-full: 100cqw; --vh-full: 100cqh; --hero-vw: 28cqw;
  --text-hero: clamp(var(--text-hero-min), var(--hero-vw), var(--text-hero-max));
  --text-hero-2: clamp(calc(var(--text-hero-min) * 0.64), calc(var(--hero-vw) * 0.64), calc(var(--text-hero-max) * 0.64));
  --s9-crop-w: clamp(var(--s9-crop-min), min(var(--vw-full), calc((var(--vh-full) - var(--s9-chrome-h)) * var(--s9-crop-ar-k))), var(--vw-full));
  --s0f-crop-w: min(var(--s0f-crop-max), calc((var(--vh-full) - var(--s0f-chrome-h)) * var(--s9-crop-ar-k)));
  position: relative; width: min(var(--frame-w), 100%); height: 100vh; height: 100dvh; max-height: var(--frame-h);
  align-self: center; overflow: hidden; container-type: size; background: var(--color-night);
}
@media (min-height: 845px) { #app { max-height: var(--frame-h); } }

/* The looping background: one video behind every screen (Gabe, 2026-11-17). Each screen paints its own background (DESIGN 10.1) as a veil over it.
   The veil tokens are in assets/tokens.css. Without the video the veils sit on the night page and every screen reads as before, a shade darker. */
#app .bgvid { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: var(--bg-video-opacity); pointer-events: none; }
#app .screen.bg-hero { background: var(--veil-grad-hero); }
#app .screen.bg-night { background: var(--veil-night-c); }
#app .screen.bg-gradnight { background: var(--veil-grad-night); }
#app .screen.bg-surface { background: var(--veil-surface-c); }
#app .screen.bg-spam { background: var(--veil-grad-spam); }
#app .screen.bg-coral { background: var(--veil-grad-coral); }
#app .screen.bg-mint { background: var(--veil-grad-mint); }
#app .screen.bg-deep { background: var(--veil-deep-c); }
#app .screen.bg-night.s9 { background: var(--veil-card-c); }
#app .screen.bg-glow-primary { background: radial-gradient(ellipse at 50% 42%, var(--glow-primary), transparent 65%), var(--veil-night-c); }
/* text-faint holds 4.5 to 1 on plain night or surface only (DESIGN 3.3). Over the video the address line takes text-muted, as footers do on a tint. */
#app .addr { color: var(--color-text-muted); }

#app .screen { position: absolute; inset: 0; width: 100%; min-height: 0; height: 100%; overflow-x: hidden; overflow-y: auto; padding-bottom: var(--space-4); }
#app .screen.s9 { padding-top: var(--space-4); }

/* reveal steps: hidden until their step plays. The layout space is reserved from the first paint. */
.step { opacity: 0; visibility: hidden; transform: translateY(var(--space-2)); transition: opacity var(--dur-enter) var(--ease-out), transform var(--dur-enter) var(--ease-out), visibility 0s linear var(--dur-enter); }
.step.on { opacity: 1; visibility: visible; transform: none; transition: opacity var(--dur-enter) var(--ease-out), transform var(--dur-enter) var(--ease-out), visibility 0s; }
.screen.settled .step { opacity: 1; visibility: visible; transform: none; transition: none; }
/* reduced motion: each step fades over --dur-fast with no movement (DESIGN 10.2). The rule names .step.on too, or the 520ms reveal above would win. */
@media (prefers-reduced-motion: reduce) {
  .step, .step.on { transform: none; transition: opacity var(--dur-fast) linear; }
}

/* S0 */
/* A frame narrower than the 390px design frame (--frame-w) wraps the title into three lines and puts the mute button over the
   plate's corner. There the title takes the h1 size, the penguin its cropped height, and the screen starts below the mute button. */
@container (width < 390px) {
  #app .screen.s0 { padding-top: calc(var(--bar-top) + var(--bar-h) + var(--space-2) + var(--ctrl-size) + var(--space-2)); }
  .s0 .title { font-size: var(--text-h1); }
  .s0 .narrator-hero { height: var(--penguin-crop); }
}
.title { font: var(--weight-head) var(--text-title)/var(--leading-head) var(--font-display); letter-spacing: var(--tracking-hero); text-wrap: balance; }
.bg-hero .title { background: var(--plate-night); border-radius: var(--radius-lg); padding: var(--space-2) var(--space-4); }
.s0 .narrator-hero { margin-bottom: 0; }
/* the greeting's night plate (frames.css) draws into the stack gap, so S0 grows no taller and LFG stays where it was on a small phone */
.s0 .h2 { margin-block: calc(var(--space-2) * -1); }
.input.value { color: var(--color-text); justify-content: space-between; }
.input .example { margin-left: var(--space-3); }

/* controls built as buttons */
.pill { cursor: pointer; text-align: center; -webkit-appearance: none; appearance: none; }
.pill:focus-visible, .ctrl:focus-visible { outline: var(--focus-w) solid var(--color-sky); outline-offset: var(--focus-offset); }
.bg-hero .pill:focus-visible { outline-color: var(--focus-on-hero); }
/* press: the scale goes in and eases back out over --dur-press (DESIGN 10.2, --ease-out is for button release too) */
.pill, .ctrl, .mute { transition: transform var(--dur-press) var(--ease-out); }
.pill:active:not(.is-disabled), .ctrl:active:not(.off), .mute:active { transform: scale(var(--scale-press)); }
/* a pressed previous, next or sound control also takes the wash at --state-press-wash on a round plate, because the scale
   alone moves a 24px icon by less than one pixel and a phone shows no hover (DESIGN 10.9 rule 2) */
.live .ctrl:active:not(.off), .live .mute:active { --wash: color-mix(in srgb, currentColor calc(var(--state-press-wash) * 100%), transparent); background-image: linear-gradient(var(--wash), var(--wash)); border-radius: var(--radius-pill); }
.ctrl { cursor: pointer; }
.ctrl.off { cursor: default; }
.ctrl-gap { visibility: hidden; }
a.pill { text-decoration: none; }

/* narrator face */
.narrator .penguin { transition: opacity var(--dur-fast) linear; }
.narrator .penguin.swap { opacity: 0; }

/* blockie and address */
.group .blockie { flex: none; }

/* reels */
.reel { position: relative; overflow: hidden; -webkit-mask-image: linear-gradient(to right, transparent, black 18%, black 82%, transparent); mask-image: linear-gradient(to right, transparent, black 18%, black 82%, transparent); }
.reel .strip { display: flex; will-change: transform; }
.reel-v { width: 100%; height: calc(var(--text-hero-2) * var(--leading-head)); -webkit-mask-image: linear-gradient(to bottom, transparent, black 20%, black 80%, transparent); mask-image: linear-gradient(to bottom, transparent, black 20%, black 80%, transparent); }
.reel-v .strip { flex-direction: column; }
.reel-v .tile { height: calc(var(--text-hero-2) * var(--leading-head)); display: flex; align-items: center; justify-content: center; font: var(--weight-display) var(--text-hero-2)/var(--leading-head) var(--font-display); letter-spacing: var(--tracking-hero); white-space: nowrap; }
.reel-h { width: calc(var(--logo-tile) * 5); max-width: 100%; height: var(--logo-tile); }
.reel-h .tile { flex: none; width: var(--logo-tile); height: var(--logo-tile); display: flex; align-items: center; justify-content: center; }
.reel-h .tile img { width: calc(var(--logo-tile) * 0.75); height: calc(var(--logo-tile) * 0.75); border-radius: var(--radius-pill); display: block; }
.letter { width: calc(var(--logo-tile) * 0.75); height: calc(var(--logo-tile) * 0.75); display: flex; align-items: center; justify-content: center; border-radius: var(--radius-md); background: var(--color-surface-2); color: var(--color-text); font: var(--weight-display) calc(var(--logo-tile) * var(--logo-letter-k))/1 var(--font-display); }
.letter.sm { width: var(--logo-tile-sm); height: var(--logo-tile-sm); font-size: calc(var(--logo-tile-sm) * var(--logo-letter-k)); border-radius: var(--radius-sm); }
.reel-h .marker { position: absolute; inset: 0; margin: auto; width: calc(var(--logo-tile) * 0.9); height: calc(var(--logo-tile) * 0.9); border-radius: var(--radius-lg); box-shadow: 0 0 0 var(--border-w) var(--overlay-mid); pointer-events: none; }

.logo-row { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2); }
.logo-row img { width: var(--logo-tile-sm); height: var(--logo-tile-sm); border-radius: var(--radius-pill); display: block; }
.logo-row img.tick, .logo-row .letter.tick { opacity: 0.35; }

.stop { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); }
.stop .stopname { font: var(--weight-display) var(--text-h2)/var(--leading-head) var(--font-display); letter-spacing: var(--tracking-hero); }
.stop img.big { width: var(--logo-tile); height: var(--logo-tile); border-radius: var(--radius-pill); display: block; }

/* bars with counts */
.bars .bar { grid-template-columns: var(--bars-label-w) 1fr var(--bars-label-w); }
.bars .bar .fill { transform-origin: left center; }
.bars .bar .count { font: var(--weight-label) var(--text-small)/var(--leading-body) var(--font-body); color: var(--color-text); text-align: right; font-variant-numeric: tabular-nums; }
.caption { font: var(--weight-body) var(--text-small)/var(--leading-body) var(--font-body); color: var(--color-text-muted); }

/* market rows */
.mrows { width: 100%; display: flex; flex-direction: column; gap: var(--space-4); }
.mrow { display: grid; grid-template-columns: 1fr 1fr; align-items: center; column-gap: var(--space-4); }
.mrow .mlabel { font: var(--weight-display) var(--text-lead)/var(--leading-head) var(--font-display); text-align: left; font-variant-numeric: tabular-nums; }
.mrow .mline { width: 100%; height: var(--space-7); }
.mrow .mline path { fill: none; stroke-width: var(--stroke-chart); stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; stroke-dasharray: var(--path-len); stroke-dashoffset: 0; }
.mrow.down .mline path { stroke: var(--color-coral); } .mrow.up .mline path { stroke: var(--color-mint); } .mrow.flat .mline path { stroke: var(--color-sky); }
.mrow.down .mlabel { color: var(--color-coral); } .mrow.up .mlabel { color: var(--color-mint); }

/* S7 PSA words */
.psa .word { display: inline-block; opacity: 0; transform: scale(1.18); transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out); }
.psa .word.on, .screen.settled .psa .word { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .psa .word { transform: none; } }

/* S8 two-part row */
.row2 .part { display: inline; }

/* S9 bubbles */
.chat { width: 100%; display: flex; flex-direction: column; gap: var(--space-4); }
.bubble { max-width: var(--bubble-max-w); padding: var(--space-3) var(--space-4); border-radius: var(--radius-lg); font: var(--weight-body) var(--text-body)/var(--leading-body) var(--font-body); text-align: left; }
.bubble.me { align-self: flex-end; background: var(--color-primary); color: var(--color-white); border-bottom-right-radius: var(--radius-sm); }
.bubble.pg { align-self: flex-start; background: var(--color-surface-2); color: var(--color-text); border-bottom-left-radius: var(--radius-sm); }
.bubble .chip { display: block; font: var(--weight-label) var(--text-micro)/var(--leading-body) var(--font-body); color: var(--color-text-muted); margin-bottom: var(--space-1); }
.bubble.me .chip { color: var(--color-text); }

/* S10 pnl */
.tint { position: absolute; inset: 0; opacity: 0; pointer-events: none; transition: opacity var(--dur-card) var(--ease-out); }
.tint.on, .screen.settled .tint { opacity: 1; }
.tint.coral { background: var(--veil-tint-coral); } .tint.mint { background: var(--veil-tint-mint); }
.screen > * { position: relative; }
.screen > .tint { position: absolute; }
.screen > .progress { position: absolute; }
.numwrap { position: relative; display: flex; flex-direction: column; align-items: center; gap: var(--space-2); width: 100%; }
.dots { position: absolute; inset: 0; margin: auto; display: flex; align-items: center; justify-content: center; gap: var(--space-4); pointer-events: none; }
.dots i { width: var(--space-4); height: var(--space-4); border-radius: var(--radius-pill); background: var(--color-text); opacity: 0.25; display: block; }
.dots.gone { opacity: 0; transition: opacity var(--dur-fast) linear; }

/* S11 and S12 */
.cardstage { position: relative; align-self: center; flex: none; width: var(--s9-crop-w); height: calc(var(--s9-crop-w) * var(--s9-crop-h-k)); perspective: calc(var(--s9-crop-w) * 3); }
.cardstage .cardcrop { position: absolute; inset: 0; }
.cardstage .flipper { position: absolute; inset: 0; transform-style: preserve-3d; }
.cardstage .flipface, .cardstage .flipback { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.cardstage .flipface { transform: rotateY(180deg); }
/* the glow that lands after the flip hugs the slab and takes the tier's own colour (--glow in card.css, and a common card has none).
   It used to sit on the whole stage box in the epic colour, which drew a hard-edged band above and below every card. */
.cardstage .wc-slab .glow { position: absolute; inset: 0; opacity: 0; pointer-events: none; border-radius: inherit; box-shadow: 0 0 var(--glow-tier-blur) color-mix(in srgb, var(--glow) var(--glow-tier-share), transparent); }
.cardstage.flipped .flipper { transform: rotateY(180deg); }
.screen .cardcrop { width: var(--s9-crop-w); height: calc(var(--s9-crop-w) * var(--s9-crop-h-k)); }
.cardcrop img { max-width: none; }
.s9 .stack { padding-bottom: var(--space-4); }
/* S11 and S12: the card takes the height the kicker and the sheet leave, so the card column never scrolls (desktop Chrome on Windows drew a 15px bar
   under the sound button). The slot is a size container: inside it the crop is as wide as the column or as wide as the slot's height allows at
   --s9-crop-ar-k, whichever is less, so the card keeps its ratio and shrinks on a short screen. The sheet keeps its own height.
   The slot reaches into the gutters, so on a tall screen the crop is the whole frame width, as before. */
.cardslot { flex: 1 1 0; min-height: 0; align-self: stretch; margin-inline: calc(var(--gutter) * -1); display: flex; flex-direction: column; align-items: center; container-type: size;
  --s9-crop-w: min(100cqw, calc(100cqh * var(--s9-crop-ar-k))); }
.sheet-up .s10-head .penguin { height: var(--penguin-row); width: auto; }
.actions3.triple { grid-template-columns: repeat(3, 1fr); }
.actions3.triple .pill, .actions3 .pill { padding: 0 var(--space-3); }
.sheet-up .pill { min-height: var(--pill-h); }
/* S12 with the save image button: save and watch again share a row, and wrap another wallet takes the last row */
.actions3 #save ~ .pill-ghost { grid-column: 1 / -1; }

@media (prefers-reduced-motion: reduce) {
  .pill-primary::before { animation: none !important; }
}

#app .screen.out { pointer-events: none; }

.screen:not(.settled) .step:not(.on) { pointer-events: none; }
/* S11 and S12 fit their frame at rest (the fit page test holds that), so neither the screen nor its card column needs a scrollbar
   while it plays in: the sheet waits 8px low and the card grows as it turns, which would draw a 15px bar on desktop Chrome for 2 s.
   clip draws no bar and cuts the same edge a scroll box does. At rest both scroll again, so content that does not fit still scrolls. */
#app .screen.s9 { display: flex; flex-direction: column; }
#app .screen.s9:not([data-state="rest"]), #app .screen.s9:not([data-state="rest"]) .stack { overflow: clip; }
/* the card column reaches both edges of the frame, so the slab's glow fades out and is not cut at the gutter */
.screen.s9 .stack { min-height: 0; overflow-y: auto; overflow-x: hidden; justify-content: flex-start; margin: 0 calc(var(--gutter) * -1); padding-left: var(--gutter); padding-right: var(--gutter); }
#app .sheet-up { position: relative; left: auto; right: auto; bottom: auto; flex: none; margin: 0 calc(var(--gutter) * -1) calc(var(--space-4) * -1); }
.actions3.triple .pill-primary { grid-column: auto; }
/* S11: the cyan halo of the three primary pills reaches about 23px under them (--glow-primary-halo), and at its high point the credit line
   measured 4.2 to 1 inside it. The footer steps down out of the halo. */
.sheet-up .actions3.triple + .footer { padding-top: var(--space-2); }
.screen.s9 .stack { padding-top: var(--space-2); }
/* the card column scrolls above the sheet, so Tab stops on it: it shows the sky ring inside its edge, where overflow cannot cut it */
.screen.s9 .stack:focus-visible { outline: var(--focus-w) solid var(--color-sky); outline-offset: calc(var(--focus-w) * -1); }

/* story progress: the current segment fills from app.js, on the same clock as the animation */
.progress .seg { position: relative; overflow: hidden; }
.progress .seg.cur i { position: absolute; inset: 0; border-radius: inherit; background: var(--bar-fill); transform-origin: left center; transform: scaleX(var(--p, 0)); }

/* sound toggle, top right, on every screen */
.mute { position: absolute; z-index: 30; top: calc(var(--bar-top) + var(--bar-h) + var(--space-2)); right: var(--gutter); width: var(--ctrl-size); height: var(--ctrl-size); display: flex; align-items: center; justify-content: center; border-radius: var(--radius-pill); background: var(--plate-mute); color: var(--color-text); }
.mute .icon { width: var(--ctrl-icon); height: var(--ctrl-icon); }
/* hover: the same wash as previous and next (DESIGN 10.9), only where hover and a fine pointer exist */
@media (hover: hover) and (pointer: fine) { .live .mute:hover:not(:active) { --wash: color-mix(in srgb, currentColor calc(var(--state-hover-wash) * 100%), transparent); background-image: linear-gradient(var(--wash), var(--wash)); } }
.mute[aria-pressed="false"] { color: var(--color-text-muted); }
.mute:focus-visible { outline: var(--focus-w) solid var(--color-sky); outline-offset: var(--focus-offset); }
.load-quip { margin: 0 auto var(--space-4); min-height: calc(2 * var(--leading-body) * 1em); text-align: center; font: var(--weight-head) var(--text-lead)/var(--leading-body) var(--font-display); text-wrap: balance; max-width: var(--measure); color: var(--color-text); }
.load-line { margin: var(--space-3) 0 0; text-align: center; font: var(--weight-label) var(--text-small)/var(--leading-body) var(--font-body); color: var(--color-text-muted); font-variant-numeric: tabular-nums; }

/* S0 input */
.wform { width: 100%; display: flex; flex-direction: column; gap: var(--space-3); }
input.input { font: var(--weight-body) var(--text-body)/var(--leading-body) var(--font-body); color: var(--color-text); text-align: left; }
input.input::placeholder { color: var(--color-text-muted); }
input.input:focus-visible { outline: var(--focus-w) solid var(--color-sky); outline-offset: var(--focus-offset); }
.demo-note { margin: 0; font: var(--weight-label) var(--text-micro)/var(--leading-body) var(--font-body); color: var(--color-coral); text-align: left; }
.demo-note[hidden] { display: none; }
/* On the hero gradient every small line sits on a night plate (DESIGN 3.3). Coral on the plate is 8.50 to 1. */
.bg-hero .demo-note { align-self: flex-start; background: var(--plate-night); border-radius: var(--radius-sm); padding: var(--space-1) var(--space-3); }

/* loading state, with a bar that fills while the wallet is read */
.loadbar { width: 100%; height: var(--space-2); border-radius: var(--radius-pill); background: var(--overlay-mid); overflow: hidden; }
.loadbar i { display: block; height: 100%; width: 100%; border-radius: inherit; background: var(--bar-fill); transform-origin: left center; transform: scaleX(0); }

/* the card, drawn live */
.cardstage .wc-stage { position: absolute; inset: 0; display: flex; justify-content: center; align-items: flex-start; --cw: calc(var(--s9-crop-w) * 0.8); }
.wc-pname { white-space: normal; font-size: 7cqw; line-height: 1.05; text-wrap: balance; }
.wc-slab-back { padding-top: calc(var(--cw) * 0.045); }
.wc-slab-back .wc-card { margin-top: calc(var(--cw) * 0.12); }
.wc-sweep { z-index: 6; }
.screen.is-paused .progress .seg.cur i { opacity: 0.7; }
.wc-art { display: block; width: 100%; height: 100%; object-fit: cover; }

/* the face-down card starts with a "?" (DESIGN 10.2, Gabe's "the card starting with ? and then slowly showing up").
   It takes the tier's accent lifted toward the text colour, so it hints at the tier and stays over 3 to 1 on the lightest stripe
   at the low point of its breath, which runs on the halo's clock. */
.wc-faceback { align-items: center; justify-content: center; }
.wc-q { font: var(--weight-display) 46cqw/1 var(--font-display); color: color-mix(in srgb, var(--accent) 65%, var(--color-text)); text-shadow: 0 0 6cqw color-mix(in srgb, var(--accent) 45%, transparent); }
@keyframes q-breathe { 0%, 100% { opacity: 0.9; transform: scale(0.96); } 50% { opacity: 1; transform: scale(1.04); } }
@media (prefers-reduced-motion: no-preference) { .flipback .wc-q { animation: q-breathe var(--dur-pulse) var(--ease-pulse) infinite; } }

/* S10: the ETH inside "somETHing" takes the sky highlight (DESIGN 3.1, "highlight text") and pops once when its line lands */
.lead .pun { font-weight: var(--weight-display); color: var(--color-sky); display: inline-block; }
@keyframes pun-pop { 0% { transform: scale(1); } 40% { transform: scale(1.18) rotate(-4deg); } 100% { transform: none; } }
@media (prefers-reduced-motion: no-preference) { .screen:not(.settled) .step.on .pun { animation: pun-pop var(--dur-enter) var(--ease-out) var(--delay-line) both; } }

/* S7: the spam count is the self-own people screenshot. Both numbers grow to display numerals inside Gabe's sentence,
   and they stay muted grey, so the scammers still get no colour (storyboard S7). */
.spamline .val { font: var(--weight-display) var(--text-h1)/var(--leading-tight) var(--font-display); color: var(--color-text-muted); letter-spacing: var(--tracking-hero); font-variant-numeric: tabular-nums; }
