/* Where's Rocko? — Math Dash (beat-the-clock arithmetic race).
   Loaded by /dash/ on TOP of the shared /styles.css design tokens, then
   /landing.css reskins it for the festive stage — same pattern as
   /reveal/reveal.css and /spot/spot.css. Category is MATH, so accents use the
   math hue. All art is hand-built SVG/DOM; Rocko comes from the canonical
   /img/rocko/*.webp pose set (no game draws its own Rocko). */
:root {
  /* math-category hue, mirrored from home.css so /dash/ works standalone */
  --c-math: #DD8E06;
  --go:   #35C275;   /* correct / go-green */
  --stop: #E24A3B;   /* wrong / low-time red */
}
@media (prefers-color-scheme: dark) {
  :root { --c-math: #F0B23C; }
}

body.dash main { max-width: 1000px; margin: 0 auto; padding: 0 20px 64px; }

/* ============ mode select ============ */
.dash-hero {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 30px; flex-wrap: wrap;
  margin: 26px 0 30px; padding: 34px 36px; border-radius: 26px;
  background: radial-gradient(120% 150% at 100% 0%,
    color-mix(in srgb, var(--c-math) 18%, var(--surface)) 0%, var(--surface) 60%);
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.dash-hero-art {
  flex: 0 0 auto; width: 116px; height: 116px;
  filter: drop-shadow(0 10px 20px rgba(30,22,14,.18));
}
.dash-hero-copy { flex: 1 1 300px; min-width: 0; }
.dash-eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: #fff; background: var(--c-math); padding: 4px 11px; border-radius: 999px; margin: 0 0 12px;
}
.dash-hero h1 { font-size: clamp(1.9rem, 4.8vw, 3rem); margin: 0 0 .26em; }
.dash-hero h1 .accent { color: var(--brand); }
.dash-hero .lede { font-size: 1.06rem; font-weight: 700; color: var(--ink-soft); margin: 0; max-width: 52ch; }
.dash-hero .lede strong { color: var(--ink); }

.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.level-card {
  display: flex; flex-direction: column; text-align: left; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); color: inherit;
  transition: transform .12s ease, box-shadow .12s ease;
}
.level-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.level-thumb {
  position: relative; display: grid; place-items: center;
  height: 132px; padding: 10px; background: var(--surface-2);
}
.level-thumb .thumb-svg { width: 100%; height: 100%; display: block; }
.level-meta { padding: 13px 16px 4px; display: flex; flex-direction: column; gap: 2px; }
.level-name { font-family: var(--font-display); font-weight: 700; font-size: 1.12rem; }
.level-tag { color: var(--ink-soft); font-size: .88rem; font-weight: 700; }

/* difficulty chips (mirrors /reveal/ + /spot/) */
.diff-row { display: flex; gap: 8px; padding: 8px 16px 16px; margin-top: auto; }
.diff-btn {
  flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 1px;
  font: inherit; cursor: pointer; padding: 8px 4px; border-radius: 12px;
  background: var(--surface-2); border: 1.5px solid var(--line); color: var(--ink);
  transition: border-color .12s ease, color .12s ease, transform .08s ease;
}
.diff-btn:hover { border-color: var(--c-math); color: var(--c-math); transform: translateY(-1px); }
.diff-btn .dn { font-family: var(--font-display); font-weight: 600; font-size: .92rem; }
.diff-btn .db { font-size: .66rem; font-weight: 800; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.diff-btn .db.has { color: var(--brand-ink); }

.dash-fine { margin-top: 24px; }

/* ============ HUD ============ */
.hud { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 20px 0 12px; }
.hud-back {
  font: inherit; font-weight: 800; cursor: pointer; color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 999px; padding: 8px 15px;
}
.hud-back:hover { border-color: var(--brand); color: var(--brand-ink); }
.hud-scene { font-family: var(--font-display); font-weight: 700; font-size: 1.16rem; }
.hud-spacer { flex: 1 1 auto; }
.hud-stat { display: flex; flex-direction: column; align-items: center; line-height: 1.1; min-width: 56px; }
.hud-label { font-size: .66rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); font-weight: 800; }
.hud-value { font-weight: 800; font-variant-numeric: tabular-nums; font-size: 1.02rem; }
.hud-time-stat .hud-value { font-size: 1.35rem; color: var(--c-math); }
.hud-time-stat.low .hud-value { color: var(--stop); animation: timePulse .6s ease-in-out infinite; }
@keyframes timePulse { 50% { transform: scale(1.14); } }

/* countdown bar under the HUD */
.timer-bar {
  height: 10px; border-radius: 999px; overflow: hidden; margin: 0 0 14px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.timer-fill {
  display: block; height: 100%; width: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--go), var(--c-math));
  transform-origin: left center;
}
.timer-fill.low { background: linear-gradient(90deg, var(--stop), #ff8a3c); }

/* ============ race track ============ */
.dash-track {
  position: relative; width: 100%; aspect-ratio: 320 / 120; max-height: 240px;
  margin: 0 auto 16px; overflow: hidden; border-radius: var(--radius);
  border: 1px solid var(--line); box-shadow: var(--shadow); background: #bfe3ff;
}
.track-scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.runner {
  position: absolute; bottom: 4%; left: 3%; width: 22%; max-width: 96px; height: auto;
  transform: translateX(-6%);
  transition: left .5s cubic-bezier(.34,1.4,.5,1);
  filter: drop-shadow(0 5px 6px rgba(20,30,10,.35));
  will-change: left;
}
.runner.dashing { animation: runnerBounce .5s ease; }
@keyframes runnerBounce {
  0% { transform: translateX(-6%) translateY(0) rotate(0); }
  35% { transform: translateX(-6%) translateY(-14%) rotate(-4deg); }
  100% { transform: translateX(-6%) translateY(0) rotate(0); }
}
.runner.lap { animation: runnerLeap .45s ease; }
@keyframes runnerLeap { 40% { transform: translateX(-6%) translateY(-26%) rotate(-8deg) scale(1.08); } }

.lap-flash {
  position: absolute; top: 12%; left: 50%; transform: translate(-50%, -6px) scale(.6);
  font-family: var(--font-display); font-weight: 700; font-size: clamp(1.3rem, 4vw, 2rem);
  color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.25), 0 0 18px rgba(255,201,60,.7);
  opacity: 0; pointer-events: none;
}
.lap-flash.show { animation: lapPop 1s ease both; }
@keyframes lapPop {
  0% { opacity: 0; transform: translate(-50%, 8px) scale(.5); }
  25% { opacity: 1; transform: translate(-50%, -6px) scale(1.1); }
  75% { opacity: 1; transform: translate(-50%, -10px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -22px) scale(1); }
}

/* 3-2-1-GO overlay */
.dash-go {
  position: absolute; inset: 0; z-index: 3; display: grid; place-items: center;
  background: rgba(24,10,64,.34); backdrop-filter: blur(2px);
}
.dash-go[hidden] { display: none; }
.go-num {
  font-family: var(--font-display); font-weight: 700; color: #fff;
  font-size: clamp(3rem, 12vw, 6rem); line-height: 1;
  text-shadow: 0 4px 0 rgba(0,0,0,.22), 0 0 30px rgba(255,201,60,.7);
}
.go-num.tick { animation: goTick .7s ease both; }
@keyframes goTick {
  0% { opacity: 0; transform: scale(1.7); }
  30% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(.7); }
}
.go-num.go { color: #FFE07A; }

/* ============ problem + choices ============ */
.dash-play { max-width: 620px; margin: 0 auto; }
.dash-caption { text-align: center; color: var(--ink-soft); font-weight: 800; margin: 0 0 12px; font-size: .96rem; }
.dash-caption b { color: var(--c-math); }

.problem {
  display: flex; align-items: center; justify-content: center; gap: .28em; flex-wrap: wrap;
  font-family: var(--font-display); font-weight: 700; font-variant-numeric: tabular-nums;
  font-size: clamp(2.2rem, 9vw, 3.4rem); line-height: 1; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 22px; margin: 0 0 16px; text-align: center;
}
.problem .p-op, .problem .p-eq { color: var(--c-math); }
.problem .p-q { color: var(--brand); }
.problem.shake { animation: problemShake .4s ease; }
@keyframes problemShake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-7px); } 40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(3px); }
}

.choices { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.choices.three { grid-template-columns: repeat(3, 1fr); }
.choice {
  font-family: var(--font-display); font-weight: 700; font-variant-numeric: tabular-nums;
  font-size: clamp(1.5rem, 6vw, 2.1rem); cursor: pointer;
  padding: 20px 10px; min-height: 74px; border-radius: 16px;
  background: var(--surface); color: var(--ink); border: 2px solid var(--line);
  box-shadow: var(--shadow); transition: transform .08s ease, border-color .12s ease, box-shadow .12s ease;
}
.choice:hover { transform: translateY(-2px); border-color: var(--c-math); box-shadow: var(--shadow-lift); }
.choice:active { transform: translateY(0); }
.choice:disabled { cursor: default; }
.choice.correct {
  border-color: var(--go); background: color-mix(in srgb, var(--go) 16%, var(--surface));
  color: color-mix(in srgb, var(--go) 55%, var(--ink)); animation: choicePop .3s ease;
}
@keyframes choicePop { 0% { transform: scale(1); } 45% { transform: scale(1.09); } 100% { transform: scale(1); } }
.choice.wrong {
  border-color: var(--stop); background: color-mix(in srgb, var(--stop) 14%, var(--surface));
  color: color-mix(in srgb, var(--stop) 55%, var(--ink)); animation: choiceShake .4s ease;
}
@keyframes choiceShake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-6px); } 75% { transform: translateX(6px); }
}
@media (max-width: 380px) { .choices, .choices.three { grid-template-columns: repeat(2, 1fr); } }

.dash-feedback { text-align: center; font-weight: 800; min-height: 1.5em; margin: 12px 0 0; font-variant-numeric: tabular-nums; }
.dash-feedback.ok { color: var(--go); }
.dash-feedback.no { color: var(--stop); }

/* ============ win / time-up modal (reused pattern) ============ */
.win { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center;
  background: rgba(10,12,20,.5); backdrop-filter: blur(3px); padding: 20px; }
.win[hidden] { display: none; }   /* class display must not beat the hidden attr */
.win-card {
  background: var(--surface); color: var(--ink); border-radius: 22px; padding: 30px 30px 26px;
  text-align: center; max-width: 400px; width: 100%; box-shadow: 0 24px 70px rgba(0,0,0,.4);
  animation: winPop .35s ease both;
}
@keyframes winPop { 0% { transform: scale(.9); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.win-rocko { width: 116px; height: 116px; animation: rockoWag 1s ease-in-out infinite alternate; }
@keyframes rockoWag { from { transform: rotate(-5deg); } to { transform: rotate(5deg); } }
.win-card h2 { font-size: 1.9rem; margin: 6px 0 4px; }
.win-time { font-size: 1.15rem; color: var(--ink-soft); font-weight: 700; margin: 0 0 2px; }
.win-time strong { color: var(--brand-ink); font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.win-sub { color: var(--ink-soft); font-weight: 700; margin: 0 0 2px; font-variant-numeric: tabular-nums; }
.win-best { font-weight: 800; color: var(--brand-ink); margin: 4px 0 18px; min-height: 1.2em; }
.win-actions { display: flex; flex-direction: column; gap: 10px; }
.win-actions .btn { justify-content: center; border-radius: 14px; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Rocko & Me: the kid's own cartoon runs the race, Rocko trots just ahead */
.kid-runner { width: auto; height: 74%; max-width: 30%; object-fit: contain; object-position: bottom; bottom: 3%; }
.runner.with-kid { width: 19%; max-width: 84px; z-index: 1; }
