/* ============================================================================
   "How it works" walkthrough, homepage only (2026-11-16).
   Markup: src/content/home-body.html #how-it-works. Player: assets/how.js.

   Every element's plain style is its FINISHED state, so the page reads
   correctly with no JS, in print and under reduced motion. The motion only
   runs once how.js adds `.how-live` and marks a screen `.is-active`; each
   keyframe starts from the "before" look and lands on that plain style.
   ========================================================================== */

/* ---- Hero link: quiet, after the CTAs and the trust row ---- */
.how-link {
  display: inline-flex; align-items: center; gap: 9px; margin-top: 22px;
  font-size: 14.5px; font-weight: 600; color: var(--text-secondary);
  padding: 6px 2px; border-radius: 8px; transition: color .25s;
}
.how-link .how-ic { color: var(--signal); flex: none; transition: transform .35s var(--ease-spring); }
.how-link:hover { color: var(--text-primary); }
.how-link:hover .how-ic { transform: scale(1.12); }
.how-link-meta { font-weight: 500; font-size: 13px; color: var(--text-muted); }
.how-link-meta::before { content: "·"; margin-right: 9px; }

/* Old #how links land on the section too. */
.how-alias { position: absolute; top: 0; }

/* ---- Layout ---- */
/* Tighter top: the anchor lands on the heading and the walkthrough should
   still fit on a laptop screen under it. */
.how { --how-dur: 7s; padding-top: clamp(40px, 5vw, 72px); }
.how .sec-head { margin-bottom: clamp(28px, 4vw, 44px); }
.how-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); gap: clamp(32px, 6vw, 80px); align-items: center; max-width: 1000px; margin: 0 auto; }

/* ---- Tabs ---- */
.how-tabs { display: flex; flex-direction: column; gap: 8px; }
.how-tab {
  position: relative; display: grid; grid-template-columns: 44px 1fr; gap: 16px; align-items: start;
  width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer;
  padding: 18px 20px 20px; border-radius: var(--r-card-sm);
  background: transparent; border: 1px solid transparent;
  transition: background .35s var(--ease-out), border-color .35s, box-shadow .35s;
}
.how-tab:hover { background: rgba(255,255,255,0.025); }
.how-tab:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
.how-tab.is-active {
  background: linear-gradient(180deg, var(--surface-raised), var(--surface));
  border-color: var(--hairline-strong); box-shadow: var(--card-shadow), inset 0 1px 0 rgba(255,255,255,0.05);
}
.ht-num {
  font-family: var(--font-display); font-weight: 700; font-size: 14px;
  width: 44px; height: 44px; border-radius: 13px; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); background: rgba(255,255,255,0.03); border: 1px solid var(--hairline);
  transition: color .35s, background .35s, border-color .35s;
}
.how-tab.is-active .ht-num { color: var(--signal); background: var(--signal-faint); border-color: var(--signal-muted); }
.ht-body { display: flex; flex-direction: column; gap: 6px; padding-top: 2px; }
.ht-title { font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: -0.01em; line-height: 1.25; color: var(--text-secondary); transition: color .35s; }
.how-tab.is-active .ht-title { color: var(--text-primary); }
.ht-short { display: none; }
.ht-text { font-size: 14.5px; line-height: 1.55; color: var(--text-muted); }
.how-tab.is-active .ht-text { color: var(--text-secondary); }
.ht-bar { position: absolute; left: 20px; right: 20px; bottom: 9px; height: 2px; border-radius: 2px; background: transparent; overflow: hidden; }
.how-tab.is-active .ht-bar { background: rgba(255,255,255,0.06); }
.ht-bar i { display: block; height: 100%; background: var(--signal); transform: scaleX(0); transform-origin: left; }
.how-tab.is-active .ht-bar i { transform: scaleX(1); }
.how.is-auto .how-tab.is-active .ht-bar i { animation: how-bar var(--how-dur) linear both; }
@keyframes how-bar { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ---- Stage + phone ---- */
.how-stage { position: relative; display: flex; flex-direction: column; align-items: center; }
.how-glow { position: absolute; inset: 10% 0; background: radial-gradient(closest-side, rgba(61,255,168,0.18), transparent); filter: blur(30px); z-index: -1; }
.how-phone {
  position: relative; width: 100%; max-width: 320px; padding: 10px;
  border-radius: 48px; background: linear-gradient(160deg, #222c35, #0d1217 60%);
  border: 1px solid var(--hairline-strong);
  box-shadow: 0 40px 80px -30px rgba(0,0,0,0.85), inset 0 1px 0 rgba(255,255,255,0.08);
}
.hp-status {
  display: flex; align-items: center; justify-content: space-between; height: 34px; padding: 0 22px;
  font-size: 12px; font-weight: 600; color: var(--text-primary);
  background: #080b0e; border-radius: 38px 38px 0 0;
}
.hp-island { width: 78px; height: 22px; border-radius: 12px; background: #000; }
.hp-sig { display: inline-flex; align-items: flex-end; gap: 2px; height: 10px; }
.hp-sig i { width: 3px; border-radius: 1px; background: var(--text-primary); }
.hp-sig i:nth-child(1) { height: 4px; } .hp-sig i:nth-child(2) { height: 7px; } .hp-sig i:nth-child(3) { height: 10px; }
.hp-screens { position: relative; height: 462px; background: #080b0e; overflow: hidden; }
.hp-home { height: 26px; background: #080b0e; border-radius: 0 0 38px 38px; position: relative; }
.hp-home::after { content: ""; position: absolute; left: 50%; top: 10px; width: 96px; height: 4px; border-radius: 4px; background: rgba(255,255,255,0.35); transform: translateX(-50%); }

.hp-screen {
  position: absolute; inset: 0; padding: 14px 16px 12px; display: flex; flex-direction: column; gap: 10px;
  opacity: 0; transform: translateY(10px) scale(.985); pointer-events: none;
  /* The outgoing screen leaves fast; the incoming one waits for it. */
  transition: opacity .2s var(--ease-out), transform .3s var(--ease-out);
  font-size: 12.5px; line-height: 1.4;
}
.hp-screen.is-active { opacity: 1; transform: none; pointer-events: auto; transition: opacity .45s var(--ease-out) .15s, transform .6s var(--ease-spring) .15s; }
.how-note { margin-top: 14px; font-size: 12px; color: var(--text-muted); text-align: center; }
.how-cap { display: none; }

/* ---- Shared screen bits ---- */
.hs-kicker { font-size: 10px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); }
.hs-title { font-family: var(--font-display); font-weight: 700; font-size: 19px; letter-spacing: -0.015em; line-height: 1.2; margin-top: -4px; }
.hs-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }
.hs-label { font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); margin-top: 2px; }
.hs-foot { font-size: 11px; color: var(--text-muted); text-align: center; margin-top: auto; }
.ob-txt { display: flex; flex-direction: column; min-width: 0; }
.ob-txt b { font-weight: 600; font-size: 13px; color: var(--text-primary); }
.ob-txt small { font-size: 11px; color: var(--text-muted); }
.up { color: var(--up); } .dn { color: var(--down); }

/* 01 · onboarding */
.ob-opts { display: flex; flex-direction: column; gap: 7px; }
.ob-opt, .ob-chip { position: relative; }
.ob-opt { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 14px; background: rgba(255,255,255,0.025); border: 1px solid var(--hairline); }
.ob-radio { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--hairline-strong); flex: none; position: relative; }
.ob-opt.is-pick { background: var(--signal-faint); border-color: var(--signal-muted); }
.ob-opt.is-pick .ob-radio { border-color: var(--signal); }
.ob-opt.is-pick .ob-radio::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--signal); }
.ob-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ob-chip { font-size: 12px; font-weight: 600; padding: 6px 12px; border-radius: var(--r-chip); color: var(--text-secondary); background: rgba(255,255,255,0.03); border: 1px solid var(--hairline); }
.ob-chip.is-pick { color: var(--up); background: var(--signal-muted); border-color: var(--signal-muted); }
.ob-ready { display: flex; align-items: center; gap: 11px; padding: 12px; border-radius: 16px; background: linear-gradient(180deg, var(--surface-raised), var(--surface)); border: 1px solid var(--hairline-strong); margin-top: 4px; }
.ob-check { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--signal); color: var(--on-signal); flex: none; }

/* 02 · analysis */
.an-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.an-head .chip { font-size: 9.5px; padding: 4px 9px; white-space: nowrap; }
.an-chart, .pr-chart { position: relative; height: 124px; border-radius: 12px; background: rgba(255,255,255,0.02); border: 1px solid var(--hairline); overflow: hidden; }
.pr-chart { height: 128px; }
.an-chart svg, .pr-chart svg { width: 100%; height: 100%; display: block; }
.grid { stroke: rgba(255,255,255,0.05); stroke-width: 1; }
.cd line { stroke-width: 1.1; }
.cd.up line { stroke: var(--up); } .cd.up rect { fill: var(--up); }
.cd.dn line { stroke: var(--down); } .cd.dn rect { fill: var(--down); }
.cd { transform-box: fill-box; transform-origin: center; }
.lvl line { stroke-width: 1; stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; transform-box: fill-box; transform-origin: 0 50%; }
.lvl.key line, .lvl.mine line { stroke: var(--up); }
.lvl.inv line { stroke: var(--down); }
.an-tag { position: absolute; right: 6px; font-size: 9px; font-weight: 700; letter-spacing: 0.04em; padding: 2px 6px; border-radius: 6px; transform: translateY(-50%); }
.an-tag.key { top: 48.4%; color: var(--on-signal); background: var(--up); }
.an-tag.inv { top: 64.5%; color: #fff; background: var(--down); }
.an-tag.mine { top: 79.8%; left: 28px; right: auto; color: var(--on-signal); background: var(--up); }
.an-levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.an-lv { display: flex; flex-direction: column; gap: 1px; padding: 7px 9px; border-radius: 10px; background: rgba(255,255,255,0.025); border: 1px solid var(--hairline); }
.an-lv span { font-size: 9px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.an-lv b { font-size: 13px; font-weight: 600; }
.an-why { padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,0.025); border: 1px solid var(--hairline); }
.an-why p { margin-top: 5px; display: flex; flex-direction: column; gap: 3px; color: var(--text-secondary); font-size: 12px; }
.wl { display: block; }
.wl::before { content: "•"; color: var(--signal); margin-right: 6px; }
.an-link { display: flex; align-items: center; gap: 7px; padding: 9px 11px; border-radius: 12px; font-size: 11.5px; font-weight: 600; color: var(--signal); background: var(--signal-faint); border: 1px solid var(--signal-muted); }

/* 03 · lesson + quiz */
.ln-card, .st-card { display: flex; align-items: center; gap: 11px; padding: 12px; border-radius: 16px; background: linear-gradient(180deg, var(--surface-raised), var(--surface)); border: 1px solid var(--hairline-strong); }
.ln-ic { width: 38px; height: 38px; border-radius: 12px; display: flex; align-items: center; justify-content: center; color: var(--signal); background: var(--signal-faint); border: 1px solid var(--signal-muted); flex: none; }
.ln-card .ob-txt, .st-card .ob-txt { flex: 1; }
.ln-prog, .st-xp { display: block; height: 4px; margin-top: 7px; border-radius: 4px; background: rgba(255,255,255,0.07); overflow: hidden; }
.ln-prog i, .st-xp i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--signal), var(--up)); }
.ln-prog i { width: 100%; }
.st-xp i { width: 78%; }
.qz { display: flex; flex-direction: column; gap: 6px; }
.qz-q { font-size: 13px; font-weight: 600; color: var(--text-primary); line-height: 1.4; margin: 2px 0 2px; }
.qz-opt { position: relative; display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 12px; background: rgba(255,255,255,0.025); border: 1px solid var(--hairline); color: var(--text-secondary); font-weight: 500; }
.qz-opt.is-off { opacity: .45; }
.qz-opt.is-right { color: var(--up); background: var(--signal-faint); border-color: var(--signal); }
.qz-tick { width: 18px; height: 18px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--signal); color: var(--on-signal); }
.qz-xp { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--warn); }
.st-flame { width: 38px; height: 38px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.25); flex: none; }
.st-num { display: inline-flex; flex-direction: column; height: 1.3em; overflow: hidden; vertical-align: bottom; line-height: 1.3; }
.st-num span { transform: translateY(-100%); }

/* 04 · simulator */
.pr-handle { position: absolute; left: 8px; top: 79.8%; width: 12px; height: 12px; margin-top: -6px; border-radius: 50%; background: var(--up); box-shadow: 0 0 0 4px rgba(61,255,168,0.2); }
.pr-count { position: absolute; left: 8px; top: 6px; font-size: 9.5px; font-weight: 600; color: var(--text-muted); padding: 2px 6px; border-radius: 6px; background: rgba(0,0,0,0.45); }
@property --n { syntax: "<integer>"; inherits: false; initial-value: 40; }
.pr-count b { --n: 40; counter-reset: n var(--n); font-weight: 700; color: var(--text-primary); }
.pr-count b::after { content: counter(n); }
.pr-ctrl { display: flex; align-items: center; justify-content: center; gap: 12px; }
.pr-btn { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--text-secondary); background: rgba(255,255,255,0.04); border: 1px solid var(--hairline); }
.pr-btn.play { width: 40px; height: 40px; color: var(--on-signal); background: var(--signal); border-color: transparent; }
.pr-speed { font-size: 11px; font-weight: 700; color: var(--text-muted); padding: 4px 8px; border-radius: 8px; border: 1px solid var(--hairline); }
.pr-review { padding: 10px 12px; border-radius: 14px; background: linear-gradient(180deg, var(--surface-raised), var(--surface)); border: 1px solid var(--hairline-strong); display: flex; flex-direction: column; gap: 6px; }
.pr-row { display: flex; justify-content: space-between; gap: 8px; color: var(--text-secondary); font-size: 12px; }
.pr-row b { font-weight: 600; color: var(--text-primary); }
.pr-row b.up { color: var(--up); }

/* ============================================================================
   Motion. Only with .how-live (how.js) on the active screen.
   ========================================================================== */
.how-live .is-active .hs-in { animation: hs-in .55s var(--ease-out) var(--d, 0s) both; }
@keyframes hs-in { from { opacity: 0; transform: translateY(10px); } }

/* 01 */
.how-live .is-active .ob-opt.is-pick,
.how-live .is-active .ob-chip.is-pick { animation: ob-pick .4s var(--ease-out) var(--d) both; }
@keyframes ob-pick {
  from { background: rgba(255,255,255,0.03); border-color: var(--hairline); color: var(--text-secondary); transform: scale(1); }
  45% { transform: scale(.95); }
}
.how-live .is-active .ob-opt.is-pick .ob-radio::after { animation: pop .35s var(--ease-spring) calc(var(--d) + .1s) both; }
@keyframes pop { from { transform: scale(0); } }
.ob-opt.is-pick::after, .ob-chip.is-pick::after { content: ""; position: absolute; inset: -1px; border-radius: inherit; border: 2px solid var(--up); opacity: 0; pointer-events: none; }
.how-live .is-active .ob-opt.is-pick::after,
.how-live .is-active .ob-chip.is-pick::after { animation: ripple .7s var(--ease-out) var(--d) both; }
@keyframes ripple { from { opacity: .7; transform: scale(.92); } to { opacity: 0; transform: scale(1.12); } }

/* 02 */
.how-live .is-active .an-chart .cd { animation: cd-in .35s var(--ease-out) calc(.25s + var(--i) * 45ms) both; }
@keyframes cd-in { from { opacity: 0; transform: scaleY(.15); } }
.how-live .is-active .lvl line { animation: lvl-in .6s var(--ease-out) 1.25s both; }
.how-live .is-active .lvl.inv line { animation-delay: 1.45s; }
@keyframes lvl-in { from { transform: scaleX(0); } }
.how-live .is-active .an-tag.key { animation: hs-tag .4s var(--ease-out) 1.6s both; }
.how-live .is-active .an-tag.inv { animation: hs-tag .4s var(--ease-out) 1.75s both; }
@keyframes hs-tag { from { opacity: 0; transform: translate(6px, -50%); } }
.how-live .is-active .wl { animation: wl-in .6s var(--ease-out) var(--d) both; }
@keyframes wl-in { from { clip-path: inset(0 100% 0 0); opacity: .4; } to { clip-path: inset(0 0 0 0); opacity: 1; } }

/* 03 */
.how-live .is-active .qz-opt.is-right { animation: hs-in .45s var(--ease-out) .25s both, qz-right .45s var(--ease-out) 1.4s both; }
@keyframes qz-right { from { color: var(--text-secondary); background: rgba(255,255,255,0.025); border-color: var(--hairline); } 50% { transform: scale(1.03); } }
.how-live .is-active .qz-opt.is-off { animation: hs-in .45s var(--ease-out) both, qz-off .4s var(--ease-out) 1.45s both; }
.how-live .is-active .qz-opt.is-off:nth-of-type(4) { animation-delay: .35s, 1.45s; }
@keyframes qz-off { from { opacity: 1; } }
.how-live .is-active .qz-tick { animation: pop .35s var(--ease-spring) 1.5s both; }
.how-live .is-active .qz-xp { animation: xp-pop .7s var(--ease-spring) 1.7s both; }
@keyframes xp-pop { from { opacity: 0; transform: translateY(8px) scale(.8); } 55% { opacity: 1; transform: translateY(-3px) scale(1.08); } }
.how-live .is-active .ln-prog i { animation: grow-from .9s var(--ease-out) 2.1s both; --from: 55%; }
.how-live .is-active .st-xp i { animation: grow-from .9s var(--ease-out) 3.2s both; --from: 62%; }
@keyframes grow-from { from { width: var(--from); } }
.how-live .is-active .st-num span { animation: st-flip .5s var(--ease-spring) 3.1s both; }
@keyframes st-flip { from { transform: translateY(0); } }

/* 04 */
.how-live .is-active .pr-chart .cd { animation: cd-in .25s var(--ease-out) calc(.3s + var(--i) * 105ms) both; }
.how-live .is-active .pr-count b { animation: count 2.75s steps(26, end) .3s both; }
@keyframes count { from { --n: 14; } to { --n: 40; } }
.how-live .is-active .pr-handle { animation: handle 1s var(--ease-spring) 1.1s both; }
@keyframes handle { from { top: 40%; opacity: 0; } 25% { opacity: 1; } }
.how-live .is-active .lvl.mine line { animation: lvl-in .5s var(--ease-out) 1.9s both; }
.how-live .is-active .an-tag.mine { animation: hs-in .4s var(--ease-out) 2.1s both; }
.how-live .is-active .pr-btn.play { animation: play-pulse 1.6s var(--ease-out) .3s 2 both; }
@keyframes play-pulse { 0% { box-shadow: 0 0 0 0 rgba(0,179,126,0.55); } 100% { box-shadow: 0 0 0 12px rgba(0,179,126,0); } }

/* Hover or focus on the walkthrough, or it scrolling out of view, holds
   everything where it is, the tab timer included. */
.how.is-paused .ht-bar i,
.how.is-paused .hp-screen *,
.how.is-paused .hp-screen *::before,
.how.is-paused .hp-screen *::after { animation-play-state: paused !important; }

/* ---- Phone widths: pills above the phone, the step text under it ---- */
@media (max-width: 940px) {
  .how-grid { grid-template-columns: 1fr; gap: 22px; max-width: 460px; }
  .how-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .how-tab { grid-template-columns: 1fr; justify-items: center; gap: 6px; padding: 10px 4px 14px; text-align: center; border-radius: 16px; }
  .ht-num { width: 32px; height: 32px; border-radius: 10px; font-size: 12px; }
  .ht-title { font-size: 13px; }
  .ht-long, .ht-text { display: none; }
  .ht-short { display: inline; }
  .ht-bar { left: 12px; right: 12px; bottom: 6px; }
  .how-cap { display: block; margin-top: 16px; text-align: center; max-width: 36ch; }
  .how-cap b { display: block; font-family: var(--font-display); font-size: 18px; color: var(--text-primary); margin-bottom: 4px; }
  .how-cap span { font-size: 14.5px; color: var(--text-secondary); }
}
@media (max-width: 380px) {
  .how-phone { max-width: 300px; padding: 8px; }
  .hp-screen { padding: 12px 13px 10px; }
}

/* Reduced motion: the site-wide rule already shortens every animation to
   nothing, which lands each one on its finished state. The tab timer is
   switched off in how.js, so nothing advances on its own. */
