/* Ballers IQ v5: onboarding, result, game intro, tab shell and home (WP5). Tokens only, no raw colours.
   Layouts follow design/SCREENS.md §3-§7 at 390 × 844 and 360 × 640. */

/* ---------- shared frame for onboarding screens ---------- */
.ob { padding: var(--sat) var(--margin) calc(var(--sab) + var(--s4)); }
.ob-top { flex: none; height: var(--header); display: flex; align-items: center; gap: var(--s2); }
.ob-mark { width: auto; height: 24px; opacity: .9; }
.ob-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ob-bottom { flex: none; display: flex; flex-direction: column; gap: var(--s2); padding-top: var(--s5); }
.ob-cap { text-align: center; }
.ob-in { animation: ob-in var(--d-small) var(--e-emph) backwards; animation-delay: var(--d, 0ms); }
@keyframes ob-in { from { opacity: 0; transform: translateY(var(--lift)); } }
.nr-body { justify-content: center; gap: var(--s2); text-align: center; }

/* ---------- welcome ---------- */
.wl-board {
  position: relative; flex: 1 1 auto; min-height: 200px; max-height: 400px; border-radius: var(--r);
  background: var(--pitch); overflow: hidden; pointer-events: none; animation: fade-in var(--d-small) var(--e-emph) backwards;
}
.wl-copy { flex: none; display: flex; flex-direction: column; gap: var(--s3); padding-top: var(--s5); }
.wl-title { font-size: clamp(28px, 8.6vw, 34px); line-height: 1.06; }
@media (max-height: 559px) { .wl-board { display: none; } .wl-copy { margin-top: auto; } }

/* ---------- position ---------- */
.pos-body { gap: var(--s2); padding-top: var(--s5); }
.pos-body .t-title { margin-top: 0; }
.pos-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); margin-top: var(--s4); }
.pos-tile {
  position: relative; display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start;
  min-height: 120px; padding: var(--s4); border-radius: var(--r); background: var(--card); color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: transform var(--d-tap) var(--e-decel), opacity var(--d-small), background-color var(--d-small), box-shadow var(--d-small);
}
.pos-tile .i { width: 32px; height: 32px; }
.pos-tile:active, .pos-tile.is-pressed { transform: scale(.94); }
.pos-tile.is-on { background: var(--raised); box-shadow: inset 0 0 0 2px var(--pri); }
.has-pick .pos-tile:not(.is-on) { opacity: .5; }
.pos-tick {
  position: absolute; top: var(--s3); right: var(--s3); width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center; background: var(--pri); color: var(--on-pri); transform: scale(0);
}
.pos-tick .i { width: 14px; height: 14px; stroke-width: 3; }
.pos-tile.is-on .pos-tick { transform: scale(1); transition: transform var(--d-small) var(--spring); }
.pos-skip { align-self: center; width: auto; min-width: 120px; }
@media (max-height: 700px) { .pos-tile { min-height: 104px; } .pos-tile .i { width: 28px; height: 28px; } }

/* ---------- result ---------- */
.result { padding-top: var(--sat); }
.rs-top { display: flex; flex-direction: column; }
.rs-group { margin-block: auto; padding-top: var(--s5); display: flex; flex-direction: column; align-items: center; text-align: center; }
.rs-iq { margin-top: var(--s2); }
.rs-iq.is-pop { animation: rs-pop 240ms var(--spring); }
@keyframes rs-pop { 50% { transform: scale(1.06); } }
.rs-band { display: flex; align-items: center; gap: var(--s2); margin-top: var(--s3); }
.rs-bar { width: 200px; margin-top: var(--s2); }
.rs-dots { display: flex; gap: 10px; margin-top: var(--s5); }
.gdot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; }
.gdot .i { width: 16px; height: 16px; stroke-width: 3; }
.gdot-pro { background: var(--gold); color: var(--bg); }
.gdot-good { background: var(--ink); color: var(--bg); }
.gdot-miss { background: var(--raised); color: var(--ink2); }
.rs-card { margin-top: var(--s5); display: flex; flex-direction: column; gap: var(--s2); }
.rs-d { margin-top: var(--s4); }
.rs-bottom { padding-top: var(--s4); }
.rs-share { min-height: var(--hit); }
.rs-share .i { width: 20px; height: 20px; }
/* staging (SCREENS §5.2 micro-interactions); .is-final shows everything at once */
.result .rs-b, .result .rs-dots .gdot, .result .rs-c, .result .rs-d, .result .rs-bottom { opacity: 0; }
.result .rs-a { animation: fade-in var(--d-small) var(--e-emph) backwards; }
.result.st-b .rs-b, .result.st-c .rs-c, .result.st-d .rs-d, .result.is-final .rs-bottom { opacity: 1; animation: ob-in var(--d-small) var(--e-emph) backwards; }
.result.st-dots .gdot { opacity: 1; animation: rs-dot var(--d-small) var(--spring) backwards; animation-delay: calc(var(--i) * 60ms); }
@keyframes rs-dot { from { opacity: 0; transform: scale(.6); } }
.result.is-final .rs-b, .result.is-final .gdot, .result.is-final .rs-c, .result.is-final .rs-d { opacity: 1; }
.result.is-final .rs-bar::after { transition-duration: var(--d-reveal); }

/* ---------- tab shell ---------- */
.screen.tabs { padding-top: 0; }
.tab-host { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tab-host.is-in { animation: fade-in 150ms linear backwards; }
.tab-host > .screen { flex: 1; }
.tabbar .tab span { font-size: 11.5px; line-height: 12px; }

/* ---------- home ---------- */
.hm { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; padding-top: var(--sat); }
.hm-head { flex: none; padding: var(--s3) var(--margin); position: relative; z-index: 2; background: var(--bg); transition: box-shadow 150ms; }
.hm.is-scrolled .hm-head { box-shadow: 0 1px 0 var(--line); }
.hm-row { display: flex; align-items: flex-start; justify-content: space-between; min-height: 80px; }
.hm-iq { display: flex; flex-direction: column; gap: var(--s1); text-align: left; border-radius: var(--r-sm); transition: opacity var(--d-tap); }
.hm-iq:active { opacity: .7; }
.hm-streak { min-width: var(--hit); min-height: var(--hit); display: grid; place-items: center end; }
.hm-pill { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 var(--s3); border-radius: var(--r-pill); background: var(--card); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink); }
.hm-pill .i { width: 16px; height: 16px; color: var(--ink3); }
.hm-streak.is-lit .hm-pill .i { color: var(--gold); fill: var(--gold-soft); }
.hm-n { position: relative; display: inline-block; min-width: 1ch; height: 16px; overflow: hidden; }
.hm-n b { display: block; font: inherit; }
.is-roll .hm-old { position: absolute; inset: 0; animation: hm-up var(--d-screen) var(--e-emph) forwards; }
.is-roll .hm-new { animation: hm-in var(--d-screen) var(--e-emph) backwards; }
.is-roll .hm-pill .i { animation: hm-flame var(--d-screen) var(--spring); }
@keyframes hm-up { to { transform: translateY(-100%); opacity: 0; } }
@keyframes hm-in { from { transform: translateY(100%); opacity: 0; } }
@keyframes hm-flame { 50% { transform: scale(1.2); } }
.hm-note { display: flex; align-items: center; gap: var(--s2); margin-top: var(--s2); min-height: 16px; text-align: left; }
.hm-note.is-notice { color: var(--ink); }
.hm-note .i { width: 16px; height: 16px; }
button.hm-note { min-height: var(--hit); margin: 0; width: 100%; }
.hm-bar { margin-top: var(--s2); }

.hm-road { --k: 1; position: relative; padding: 0 var(--margin) calc(142px + var(--s3) + var(--s5)); }
.hm.is-first .hm-road { animation: fade-in var(--d-screen) var(--e-emph) backwards; }
@media (max-width: 379px) { .hm-road { --k: .85; } }
.rd-step { display: flex; align-items: center; gap: var(--s2); margin: var(--s5) 0 var(--s4); }
.rd-step i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }
.rd-season { display: flex; align-items: center; gap: var(--s3); margin-top: var(--s6); }
.rd-season::before, .rd-season::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.rd-season-cap { text-align: center; margin-top: var(--s2); }
.rd-end { margin-top: var(--s6); padding: var(--s5); text-align: center; display: flex; flex-direction: column; gap: var(--s2); }

.nd-wrap { position: relative; display: flex; flex-direction: column; align-items: center; gap: var(--s2); padding-bottom: 28px; transform: translateX(calc(var(--x) * 1px * var(--k))); }
.nd {
  position: relative; width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center;
  background: var(--card); color: var(--ink-lock); box-shadow: 0 4px 0 var(--lo), inset 0 0 0 1px var(--line);
  transition: transform var(--d-tap) var(--e-decel);
}
.nd .i { width: 28px; height: 28px; }
.nd:active, .nd.is-pressed { transform: scale(.94); }
.nd-done { background: var(--c); color: var(--bg); box-shadow: 0 4px 0 var(--lo); }
.nd-current, .nd-open { background: var(--raised); color: var(--ink); }
.nd-current::after { content: ''; position: absolute; inset: -9px; border-radius: 50%; border: 3px solid var(--pri); pointer-events: none; }
.nd-current.is-pulse::before { content: ''; position: absolute; inset: -9px; border-radius: 50%; border: 3px solid var(--pri); pointer-events: none; animation: nd-pulse 800ms var(--e-decel) 300ms 2 backwards; opacity: 0; }
@keyframes nd-pulse { from { opacity: 1; transform: scale(1); } to { opacity: 0; transform: scale(1.18); } }
.nd-lock { position: absolute; right: -2px; bottom: -2px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--raised); color: var(--ink-lock); }
.nd-lock .i { width: 12px; height: 12px; }
.nd-lock.is-shake { animation: nd-shake 300ms linear; }
@keyframes nd-shake { 17% { transform: translateX(-6px); } 33% { transform: translateX(6px); } 50% { transform: translateX(-6px); } 67% { transform: translateX(6px); } 83% { transform: translateX(-3px); } }
.nd-md { width: 72px; height: 72px; box-shadow: 0 4px 0 var(--lo), inset 0 0 0 3px var(--ink-lock); }
.nd-md .i { width: 32px; height: 32px; }
.nd-md.nd-done { background: var(--card); color: var(--ink); box-shadow: 0 4px 0 var(--lo), inset 0 0 0 3px var(--c); }
.nd-md.nd-current, .nd-md.nd-open { box-shadow: 0 4px 0 var(--lo), inset 0 0 0 3px var(--c); }
.nd-md.is-gold { background: var(--gold); color: var(--bg); box-shadow: 0 4px 0 var(--lo); }
.nd-label { max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink2); text-align: center; transition: color 150ms; }
.nd-wrap:has(.nd-current) .nd-label, .nd-wrap:has(.nd-open) .nd-label, .nd-label.is-hint { color: var(--ink); }
.nd-wrap:has(.nd-locked) .nd-label:not(.is-hint) { color: var(--ink-lock); }
.nd-label.is-hint { max-width: 220px; animation: fade-in 150ms linear; }
.nd-chip { height: 20px; padding: 0 var(--s2); border-radius: var(--r-pill); background: var(--raised); color: var(--ink2); display: inline-flex; align-items: center; }
.nd-pos { height: 20px; padding: 0 var(--s2); border-radius: var(--r-pill); background: var(--card); color: var(--pri-ink); display: inline-flex; align-items: center; margin-bottom: var(--s1); }

.hm-next {
  position: absolute; left: var(--margin); right: var(--margin); bottom: var(--s3); z-index: 3; width: auto;
  display: flex; flex-direction: column; gap: var(--s3); box-shadow: inset 0 1px 0 var(--hi), inset 0 0 0 1px var(--line), 0 -8px 24px var(--lo);
}
.hm-next.is-nudge { animation: hm-nudge var(--d-screen) var(--e-emph); }
@keyframes hm-nudge { 50% { transform: scale(1.03); } }
.hm-next-row { display: flex; align-items: center; gap: var(--s3); min-height: 40px; }
.hm-tile { flex: none; width: 40px; height: 40px; border-radius: var(--r-sm); background: var(--raised); color: var(--c); display: grid; place-items: center; }
.hm-next-text { min-width: 0; display: flex; flex-direction: column; }
.hm-next-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hm-play { overflow: hidden; }
.hm-play.is-shine::after {
  content: ''; position: absolute; top: 0; bottom: 0; left: -40px; width: 40px; background: var(--hi-2); opacity: .7;
  transform: skewX(-20deg); animation: hm-shine 1700ms linear 2; pointer-events: none;
}
@keyframes hm-shine { 0% { left: -40px; } 41% { left: 100%; } 100% { left: 100%; } }

.hm-bubble {
  position: absolute; z-index: 4; padding: var(--s4); border-radius: var(--r); background: var(--raised);
  box-shadow: inset 0 1px 0 var(--hi), var(--shadow); display: flex; flex-direction: column; gap: var(--s1);
  animation: hm-bub var(--d-small) var(--spring); transform-origin: var(--ax) 0;
}
.hm-bubble.is-above { transform-origin: var(--ax) 100%; }
.hm-bubble::before { content: ''; position: absolute; top: -6px; left: calc(var(--ax) - 6px); width: 12px; height: 12px; background: var(--raised); transform: rotate(45deg); border-radius: 2px; }
.hm-bubble.is-above::before { top: auto; bottom: -6px; }
.hm-bubble .hm-replay { min-height: 48px; margin-top: var(--s2); }
.hm-bubble.is-out { animation: fade-out 150ms linear forwards; pointer-events: none; }
.hm-road .nd-wrap { transition: opacity 150ms linear; }
.hm-road.has-bubble .nd-wrap:not(.is-bub), .hm-road.has-bubble .rd-step, .hm-road.has-bubble .rd-season { opacity: .25; }
@keyframes hm-bub { from { opacity: 0; transform: scale(.9); } }
.hm-layer { position: absolute; inset: 0; z-index: var(--z-sheet); display: flex; flex-direction: column; background: var(--bg); }

/* reduced motion: fades only */
@media (prefers-reduced-motion: reduce) {
  .nd-current.is-pulse::before, .hm-play.is-shine::after { animation: none; }
  .nd-lock.is-shake, .hm-next.is-nudge, .rs-iq.is-pop { animation: none; }
}
:root[data-motion="reduce"] .nd-current.is-pulse::before, :root[data-motion="reduce"] .hm-play.is-shine::after,
:root[data-motion="reduce"] .nd-lock.is-shake, :root[data-motion="reduce"] .hm-next.is-nudge { animation: none; }

/* Debug view (?debug=1, WP10) */
.debug .dbg { flex: 1; min-height: 0; overflow-y: auto; padding: calc(var(--sat) + var(--s4)) var(--margin) calc(var(--sab) + var(--s5)); display: flex; flex-direction: column; gap: var(--s3); }
.dbg-list { list-style: none; margin: 0; padding: 0; }
.dbg-row { display: flex; justify-content: space-between; gap: var(--s3); padding: var(--s2) 0; border-bottom: 1px solid var(--line); font: 500 14px/20px var(--f-body); }
.dbg-btns { display: flex; gap: var(--s3); margin-top: var(--s3); }
