/* ============================================================
   Dori's Dirt Bike Journey — styles
   Layout: one column, phone-first. A dark "garage" with neon lime,
   electric cyan and orange plastics, the same colors as the bike.
   Deliberately single-theme (night garage) — every color is set here.
   ============================================================ */
:root {
  --bg: #0a0d13;
  --bg-2: #10151e;
  --surface: #161c27;
  --surface-2: #1e2633;
  --line: #2a3344;
  --fg: #edf1f7;
  --muted: #95a1b6;
  --lime: #c9ff3f;
  --lime-ink: #0b1200;
  --cyan: #39e3ff;
  --orange: #ff7a1a;
  --ok: #5ee38a;
  --bad: #ff5e5e;
  --warn: #ffc83d;
  --font-display: "Russo One", "Rubik", Impact, "Arial Black", sans-serif;
  --font-body: "Rubik", "Heebo", "Segoe UI", Arial, sans-serif;
  --radius: 18px;
  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
#app { min-height: 100%; }
.inner {
  max-width: 640px;
  margin: 0 auto;
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
}
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { text-wrap: balance; }
button { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 2px;
}
.muted { color: var(--muted); }
[dir="ltr"] { direction: ltr; text-align: left; }

/* ---------- hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  background:
    repeating-linear-gradient(135deg, transparent 0 22px, rgba(201,255,63,.045) 22px 24px),
    radial-gradient(900px 400px at 85% -20%, rgba(57,227,255,.18), transparent 60%),
    radial-gradient(700px 360px at 10% 110%, rgba(255,122,26,.16), transparent 60%),
    var(--bg-2);
  border-bottom: 1px solid var(--line);
}
.hero-photo {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; opacity: .38;
}
.hero.has-photo::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(10,13,19,.25), rgba(10,13,19,.92));
}
.hero-inner {
  position: relative; z-index: 1;
  max-width: 640px; margin: 0 auto;
  padding-left: var(--gutter-l); padding-right: var(--gutter-r);
  padding-block: 34px 28px;
  display: grid; gap: 10px;
  text-align: center;
}
.eyebrow {
  font-family: var(--font-display);
  font-size: .72rem; letter-spacing: .18em; text-transform: uppercase;
  color: var(--cyan); text-align: center;
}
.title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 9vw, 3.4rem);
  line-height: 1.02;
  color: var(--lime);
  text-shadow: 3px 3px 0 var(--orange), 0 0 28px rgba(201,255,63,.35);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: .01em;
}
.title-he {
  font-weight: 900;
  font-size: clamp(1.4rem, 6.5vw, 2.1rem);
  line-height: 1.15;
  color: var(--fg);
}
.lede {
  color: var(--muted); font-size: 1rem; max-width: 36ch; margin-inline: auto;
}

/* ---------- garage / stage ---------- */
.garage { padding-block: 18px 6px; }
.stage {
  margin: 0;
  background:
    linear-gradient(rgba(201,255,63,.05) 1px, transparent 1px) 0 0 / 100% 28px,
    linear-gradient(90deg, rgba(201,255,63,.05) 1px, transparent 1px) 0 0 / 28px 100%,
    radial-gradient(60% 50% at 50% 70%, rgba(57,227,255,.08), transparent 70%),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 6px 8px;
  box-shadow: 0 14px 40px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.04);
}
#bike { display: block; width: 100%; height: auto; max-width: 100%; }
.stage-caption {
  color: var(--muted); font-size: .85rem; text-align: center; padding: 6px 8px 2px;
}

/* bike parts: locked = ghost; on = full color; next = breathing ghost */
#bike .part {
  opacity: .16;
  filter: grayscale(1);
  transition: opacity .9s ease, filter .9s ease;
}
#bike .part.next:not(.on) { animation: breathe 2.2s ease-in-out infinite; }
#bike .part.on { opacity: 1; filter: none; }
#bike .part.pop { animation: pop 1.1s cubic-bezier(.2,1.4,.4,1) 1; }
#bike .part.hl { animation: hl .9s ease-in-out 2; }
#bike .underglow { opacity: 0; transition: opacity 1.2s ease; }
#bike.complete .underglow { opacity: .3; animation: pulse 2.6s ease-in-out infinite; }
@keyframes breathe { 0%,100% { opacity: .16; } 50% { opacity: .42; } }
@keyframes pop { 0% { transform: scale(.94); transform-origin: 50% 60%; } 100% { transform: scale(1); } }
@keyframes hl { 0%,100% { filter: none; } 50% { filter: brightness(1.8) drop-shadow(0 0 10px rgba(201,255,63,.9)); } }
@keyframes pulse { 0%,100% { opacity: .22; } 50% { opacity: .42; } }

/* progress */
.progress { display: grid; gap: 8px; padding-block: 16px 8px; }
.progress-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.progress-label { font-weight: 700; font-size: 1.05rem; }
.progress-pct {
  font-family: var(--font-display); font-size: 2.2rem; line-height: 1;
  color: var(--lime); font-variant-numeric: tabular-nums;
}
.bar {
  position: relative; height: 22px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); overflow: hidden;
}
.bar-fill {
  position: absolute; inset: 0 auto 0 0; width: 0%;
  background: linear-gradient(90deg, var(--lime), var(--cyan));
  box-shadow: 0 0 18px rgba(201,255,63,.55);
  transition: width 1.1s cubic-bezier(.2,.9,.2,1);
}
.bar-ticks { position: absolute; inset: 0; display: flex; }
.bar-ticks i { flex: 1; border-right: 1px solid rgba(10,13,19,.6); }
.bar-ticks i:last-child { border-right: 0; }
.progress-foot { display: flex; justify-content: space-between; gap: 10px; font-size: .92rem; flex-wrap: wrap; }

/* ---------- next-step card (the one loud element) ---------- */
.next-wrap { padding-block: 10px 6px; }
.next {
  border-radius: var(--radius);
  padding: 20px 18px;
  background: linear-gradient(160deg, rgba(201,255,63,.13), rgba(57,227,255,.08) 60%, transparent), var(--surface);
  border: 1.5px solid var(--lime);
  box-shadow: 0 0 0 4px rgba(201,255,63,.08), 0 18px 44px rgba(0,0,0,.5);
  display: grid; gap: 12px;
}
.next.waiting { border-color: var(--line); box-shadow: 0 14px 36px rgba(0,0,0,.45); background: var(--surface); }
.next.done { border-color: var(--cyan); }
.next-kicker { font-size: .8rem; letter-spacing: .08em; color: var(--cyan); font-weight: 700; }
.next-title { font-size: 1.45rem; font-weight: 900; line-height: 1.2; }
.next-title .en { font-family: var(--font-display); color: var(--lime); font-size: .95em; }
.next-meta { color: var(--muted); font-size: .95rem; }
.countdown {
  font-family: var(--font-display); font-size: 1.6rem; color: var(--fg); line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.countdown small { font-family: var(--font-body); font-size: .9rem; color: var(--muted); font-weight: 500; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 54px; padding: 12px 22px;
  border-radius: 999px; border: 0; cursor: pointer;
  font-weight: 900; font-size: 1.1rem;
  transition: transform .08s ease, filter .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { background: var(--lime); color: var(--lime-ink); box-shadow: 0 8px 24px rgba(201,255,63,.35); }
.btn-primary:disabled { filter: saturate(.3) brightness(.7); cursor: not-allowed; box-shadow: none; }
.btn-ghost { background: var(--surface-2); color: var(--fg); border: 1px solid var(--line); }
.btn-danger { background: transparent; color: var(--bad); border: 1px solid rgba(255,94,94,.5); }
.btn-wide { width: 100%; }
.btn-sm { min-height: 40px; padding: 6px 14px; font-size: .92rem; }
.link-btn { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 8px 0; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface-2); cursor: pointer; font-size: 1.1rem; display: grid; place-items: center;
}

/* ---------- parts ladder ---------- */
.parts { padding-block: 22px 8px; }
.section-title { font-size: 1.35rem; font-weight: 900; margin-bottom: 12px; }
.parts-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; border-top: 1px solid var(--line); }
.part-row {
  display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 12px;
  padding: 12px 4px; border-bottom: 1px solid var(--line);
  background: none; border-inline: 0; border-top: 0; width: 100%; text-align: inherit; cursor: pointer;
}
.part-row:hover { background: rgba(255,255,255,.025); }
.part-num {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  font-family: var(--font-display); font-size: 1.05rem;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
}
.part-row.done .part-num { background: var(--lime); color: var(--lime-ink); border-color: var(--lime); }
.part-row.ready .part-num { background: var(--cyan); color: var(--lime-ink); border-color: var(--cyan); }
.part-row.waiting .part-num { color: var(--warn); border-color: rgba(255,200,61,.5); }
.part-name { display: grid; gap: 2px; min-width: 0; }
.part-name b { font-size: 1.05rem; }
.part-name small { color: var(--muted); font-size: .85rem; }
.part-row.locked .part-name { opacity: .55; }
.chip {
  font-size: .8rem; font-weight: 700; padding: 5px 10px; border-radius: 999px; white-space: nowrap;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
}
.chip.done { background: rgba(94,227,138,.14); color: var(--ok); border-color: rgba(94,227,138,.35); }
.chip.ready { background: rgba(57,227,255,.14); color: var(--cyan); border-color: rgba(57,227,255,.35); }
.chip.waiting { background: rgba(255,200,61,.12); color: var(--warn); border-color: rgba(255,200,61,.3); }

/* ---------- rules ---------- */
.rules { padding-block: 18px 8px; }
.rules-list { margin: 0; padding-inline-start: 22px; display: grid; gap: 10px; color: var(--muted); }
.rules-list b { color: var(--fg); }
.rules-list li::marker { color: var(--lime); font-weight: 900; }

.foot { padding-block: 24px 40px; }
.foot .inner { display: grid; gap: 6px; text-align: center; justify-items: center; }
.fineprint { color: var(--muted); font-size: .8rem; text-align: center; }

/* ---------- overlays (quiz / parent) ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: var(--bg);
  display: grid; grid-template-rows: auto auto 1fr auto;
  padding-top: env(safe-area-inset-top, 0px);
}
#parent.overlay { grid-template-rows: auto 1fr; }
.overlay-top {
  display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 12px;
  padding: 12px var(--gutter-r) 8px var(--gutter-l);
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
}
.overlay-title { display: grid; min-width: 0; }
.overlay-level { font-weight: 900; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.overlay-sub { color: var(--muted); font-size: .82rem; }
.overlay-count { font-family: var(--font-display); color: var(--lime); font-variant-numeric: tabular-nums; }
.dots { display: flex; gap: 5px; padding: 10px var(--gutter-r) 0 var(--gutter-l); direction: ltr; }
.dots i { flex: 1; height: 6px; border-radius: 3px; background: var(--surface-2); border: 1px solid var(--line); }
.dots i.ok { background: var(--ok); border-color: var(--ok); }
.dots i.bad { background: var(--bad); border-color: var(--bad); }
.dots i.cur { background: var(--cyan); border-color: var(--cyan); }
.quiz-body { overflow-y: auto; padding: 14px var(--gutter-r) 24px var(--gutter-l); }
.qcard {
  max-width: 640px; margin: 0 auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 16px; display: grid; gap: 12px;
}
.passage {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; white-space: pre-line; line-height: 1.55; font-size: 1rem;
}
.qtext { font-size: 1.25rem; font-weight: 700; line-height: 1.35; }
.qhint { color: var(--muted); font-size: .9rem; }
.answer { display: grid; gap: 10px; }
.opt {
  width: 100%; text-align: left; padding: 13px 14px; border-radius: 14px; cursor: pointer;
  background: var(--surface-2); border: 1.5px solid var(--line); font-size: 1.05rem; line-height: 1.3;
  transition: border-color .12s ease, background .12s ease;
}
.opt.sel { border-color: var(--cyan); background: rgba(57,227,255,.1); }
.opt.right { border-color: var(--ok); background: rgba(94,227,138,.12); }
.opt.wrong { border-color: var(--bad); background: rgba(255,94,94,.12); }
.opt:disabled { cursor: default; }
.input {
  width: 100%; padding: 14px; font-size: 1.15rem; border-radius: 14px;
  background: var(--bg-2); color: var(--fg); border: 1.5px solid var(--line); font-family: var(--font-body);
}
.input:focus { border-color: var(--cyan); }
.play-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.play-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 52px; padding: 10px 18px;
  border-radius: 999px; border: 1.5px solid var(--cyan); background: rgba(57,227,255,.1); color: var(--cyan);
  font-weight: 900; font-size: 1.05rem; cursor: pointer;
}
.play-btn.rec { border-color: var(--bad); color: var(--bad); background: rgba(255,94,94,.1); animation: recpulse 1s ease-in-out infinite; }
@keyframes recpulse { 50% { box-shadow: 0 0 0 8px rgba(255,94,94,.15); } }
.play-note { color: var(--muted); font-size: .88rem; }
.said { background: var(--bg-2); border: 1px dashed var(--line); border-radius: 12px; padding: 10px 12px; min-height: 44px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-word {
  padding: 10px 14px; border-radius: 12px; background: var(--surface-2); border: 1.5px solid var(--line);
  font-size: 1.05rem; cursor: pointer; font-weight: 500;
}
.chip-word.in { background: rgba(201,255,63,.12); border-color: var(--lime); }
.chip-word.gone { visibility: hidden; }
.sentence-line {
  min-height: 56px; padding: 10px 12px; border-radius: 12px; border: 1.5px dashed var(--cyan);
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: rgba(57,227,255,.05);
}
.sentence-line:empty::before { content: "Tap the words in order…"; color: var(--muted); }
.feedback {
  border-radius: 12px; padding: 12px 14px; font-weight: 700; display: grid; gap: 4px;
}
.feedback.ok { background: rgba(94,227,138,.14); color: var(--ok); border: 1px solid rgba(94,227,138,.4); }
.feedback.bad { background: rgba(255,94,94,.12); color: var(--bad); border: 1px solid rgba(255,94,94,.4); }
.feedback small { color: var(--fg); font-weight: 500; }
.overlay-bottom {
  padding: 10px var(--gutter-r) calc(12px + env(safe-area-inset-bottom, 0px)) var(--gutter-l);
  border-top: 1px solid var(--line); background: var(--bg-2);
}
.overlay-bottom .btn { max-width: 640px; margin: 0 auto; display: flex; }

/* result */
.result { max-width: 640px; margin: 0 auto; text-align: center; display: grid; gap: 14px; padding-block: 10px; }
.result-score { font-family: var(--font-display); font-size: 4rem; line-height: 1; color: var(--lime); }
.result-score.fail { color: var(--warn); }
.result h3 { font-size: 1.5rem; font-weight: 900; }
.result p { color: var(--muted); }
.stars { font-size: 1.6rem; letter-spacing: .1em; }

/* parent panel */
.ptitle { font-size: 1.2rem; font-weight: 900; }
.panel { max-width: 640px; margin: 0 auto; display: grid; gap: 14px; }
.panel-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 10px; }
.panel-card h4 { margin: 0; font-size: 1.05rem; }
.prows { display: grid; border-top: 1px solid var(--line); }
.prow { display: grid; grid-template-columns: 40px 1fr; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--line); align-items: start; }
.prow .part-num { width: 36px; height: 36px; font-size: .95rem; }
.prow.done .part-num { background: var(--lime); color: var(--lime-ink); border-color: var(--lime); }
.prow.ready .part-num { background: var(--cyan); color: var(--lime-ink); border-color: var(--cyan); }
.prow-body { display: grid; gap: 4px; min-width: 0; font-size: .95rem; }
.prow-body small { color: var(--muted); font-size: .85rem; }
.prow-body .row-actions { margin-top: 4px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.field { display: grid; gap: 6px; }
.field label { color: var(--muted); font-size: .88rem; }
.field .input { font-size: 1rem; padding: 10px 12px; }
textarea.input { min-height: 90px; font-size: .85rem; font-family: ui-monospace, Menlo, monospace; direction: ltr; }

/* toast + confetti */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--surface-2); color: var(--fg); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 999px; z-index: 90; max-width: calc(100% - 32px); text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 80; }

@media (min-width: 600px) {
  body { font-size: 18px; }
  .hero-inner { padding-block: 48px 38px; }
  .stage { padding: 14px 12px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
