/* Driver English Trainer — mobile first, 360x740 is the design target.
   Everything here assumes: bright cab, dirty screen, thumb only, cheap phone. */

:root {
  --ink: #12161c;
  --ink-soft: #4b5563;
  --line: #d6dbe3;
  --bg: #eef1f6;
  --card: #ffffff;
  --navy: #12304f;
  --accent: #1145a8;
  --accent-press: #0d3480;
  --pass: #0f7a3d;
  --partial: #9a6000;
  --fail: #b02020;
  --unheard: #4b5563;
  --shadow: 0 2px 10px rgba(16, 24, 40, .10);
  --dock: 132px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Every control below sets its own `display`, which would otherwise win over
   the UA stylesheet's rule for [hidden].  Toggling `el.hidden` must always
   actually hide the element. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 18px;
  line-height: 1.5;
  overscroll-behavior-y: contain;
}

body { padding-bottom: env(safe-area-inset-bottom); }

.screen { min-height: 100dvh; display: flex; flex-direction: column; }
.screen[hidden] { display: none; }
.pad { padding: 20px 18px; }
.center-col { display: flex; flex-direction: column; justify-content: center;
              flex: 1; max-width: 480px; margin: 0 auto; width: 100%; }

/* ── typography ─────────────────────────────────────────────────────────── */
.logo { font-size: 28px; line-height: 1.15; margin: 0 0 14px; color: var(--navy); }
.logo span { display: block; font-size: 20px; font-weight: 500; color: var(--ink-soft); }
.h2 { font-size: 21px; margin: 0 0 16px; }
.lead { font-size: 18px; color: var(--ink-soft); margin: 0 0 18px; }
.fine { font-size: 15px; color: var(--ink-soft); margin-top: 18px; }
.legal { font-size: 14px; line-height: 1.45; color: var(--ink-soft); }

/* ── top bar ────────────────────────────────────────────────────────────── */
.bar {
  background: var(--navy); color: #fff; display: flex; align-items: center;
  gap: 12px; padding: 12px 14px; padding-top: calc(12px + env(safe-area-inset-top));
  position: sticky; top: 0; z-index: 5;
}
.bar-title { font-size: 17px; font-weight: 600; flex: 1; text-align: center; }
.bar-btn {
  background: rgba(255,255,255,.14); color: #fff; border: 0; border-radius: 8px;
  padding: 9px 14px; font-size: 15px; font-weight: 600; cursor: pointer;
  min-height: 40px;
}
.bar-btn:active { background: rgba(255,255,255,.28); }
.bar-count { font-size: 16px; font-variant-numeric: tabular-nums; min-width: 52px;
             text-align: right; opacity: .9; }
.bar .bar-btn + .bar-title { text-align: center; }

.progress-track { height: 5px; background: #cfd6e0; }
.progress-fill { height: 100%; background: var(--accent); width: 0; transition: width .25s; }

/* ── buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 14px 20px; border: 0; border-radius: 12px;
  font-size: 18px; font-weight: 700; font-family: inherit; cursor: pointer;
}
.btn-block { display: flex; width: 100%; margin-top: 12px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:active { background: var(--accent-press); }
.btn-primary[disabled] { background: #93a3bd; }
.btn-quiet { background: #fff; color: var(--ink); border: 2px solid var(--line); }
.btn-quiet:active { background: #e9edf3; }
.btn-play {
  background: #fff; color: var(--accent); border: 2px solid var(--accent);
  min-height: 52px; width: 100%; margin-top: 12px;
}
.btn-play:active { background: #e8eefb; }
.link-btn {
  background: none; border: 0; color: var(--accent); font-size: 17px; font-weight: 600;
  font-family: inherit; text-decoration: underline; padding: 14px 4px; cursor: pointer;
  display: block; margin: 8px auto 0;
}

/* ── login ──────────────────────────────────────────────────────────────── */
.field-label { display: block; font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.code-input {
  width: 100%; padding: 16px; font-size: 26px; font-weight: 700; letter-spacing: .1em;
  text-align: center; text-transform: uppercase; border: 2px solid var(--line);
  border-radius: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #fff; color: var(--ink);
}
.code-input:focus { outline: 3px solid var(--accent); outline-offset: 1px; }
.error {
  background: #fdeaea; border: 1px solid #f0bcbc; color: #8f2020; border-radius: 10px;
  padding: 12px 14px; margin: 12px 0 0; font-size: 16px;
}

/* ── menu tiles ─────────────────────────────────────────────────────────── */
.tile {
  display: block; width: 100%; text-align: left; background: var(--card);
  border: 2px solid var(--line); border-radius: 14px; padding: 18px;
  margin-bottom: 12px; font-family: inherit; cursor: pointer; box-shadow: var(--shadow);
}
.tile:active { background: #e9edf3; }
.tile-primary { border-color: var(--accent); border-width: 3px; }
.tile-quiet { background: transparent; box-shadow: none; }
.tile-kicker { display: block; font-size: 13px; font-weight: 700; letter-spacing: .06em;
               text-transform: uppercase; color: var(--accent); margin-bottom: 4px; }
.tile-title { display: block; font-size: 21px; font-weight: 700; color: var(--ink); }
.tile-sub { display: block; font-size: 16px; color: var(--ink-soft); margin-top: 3px; }

/* ── mic screens ────────────────────────────────────────────────────────── */
.big-icon { font-size: 56px; text-align: center; margin-bottom: 8px; }
.steps { font-size: 17px; color: var(--ink-soft); padding-left: 22px; margin: 0 0 20px; }
.steps li { margin-bottom: 10px; }

/* ── practice ───────────────────────────────────────────────────────────── */
.practice-body { flex: 1; padding-bottom: calc(var(--dock) + 24px); }

.officer-cue { font-size: 19px; color: var(--ink-soft); text-align: center; margin: 6px 0 18px; }

.sign-frame {
  background: #fff; border: 2px solid var(--line); border-radius: 14px;
  padding: 18px; margin-bottom: 16px; display: flex; align-items: center;
  justify-content: center; min-height: 190px;
}
.sign-frame img { max-width: 100%; max-height: 240px; display: block; }
.dms {
  background: #111; color: #ffb300; font-family: ui-monospace, Menlo, monospace;
  font-weight: 700; font-size: 22px; line-height: 1.35; letter-spacing: .06em;
  text-align: center; padding: 22px 16px; border-radius: 6px; width: 100%;
}

.reveal {
  background: #fff; border: 2px solid var(--line); border-radius: 12px;
  padding: 16px; margin-top: 12px;
}
.reveal-en { font-size: 22px; font-weight: 700; margin: 0 0 6px; }
.reveal-es { font-size: 17px; color: var(--ink-soft); margin: 0; }

.guidance {
  background: #fff8e6; border: 2px solid #f0dca8; border-radius: 12px;
  padding: 16px; margin-top: 14px; font-size: 17px;
}
.guidance p { margin: 0; }

/* result */
.verdict {
  display: flex; align-items: center; justify-content: space-between;
  border-radius: 14px; padding: 16px 18px; color: #fff; margin-bottom: 16px;
}
.verdict.pass { background: var(--pass); }
.verdict.partial { background: var(--partial); }
.verdict.fail { background: var(--fail); }
.verdict.unheard { background: var(--unheard); }
.verdict-label { font-size: 22px; font-weight: 800; }
.verdict-score { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }

.block { background: #fff; border: 2px solid var(--line); border-radius: 12px;
         padding: 16px; margin-bottom: 12px; }
.block-h { font-size: 14px; font-weight: 700; text-transform: uppercase;
           letter-spacing: .06em; color: var(--ink-soft); margin: 0 0 8px; }
.transcript { font-size: 19px; margin: 0; font-style: italic; }
.transcript.empty { color: var(--ink-soft); font-style: normal; }
.feedback { font-size: 18px; margin: 0; }
.model-answer { font-size: 21px; font-weight: 700; margin: 0; }

/* ── talk dock ──────────────────────────────────────────────────────────── */
.talk-dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  background: linear-gradient(to top, var(--bg) 72%, rgba(238,241,246,0));
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom));
  text-align: center;
}
.talk-hint { font-size: 15px; color: var(--ink-soft); margin: 0 0 8px; }
.talk-btn {
  width: 100%; min-height: 78px; border-radius: 16px; border: 0;
  background: var(--accent); color: #fff; font-family: inherit; font-size: 22px;
  font-weight: 800; cursor: pointer; touch-action: none; user-select: none;
  box-shadow: var(--shadow);
}
.talk-btn.recording { background: var(--fail); animation: pulse 1.1s ease-in-out infinite; }
.talk-btn[disabled] { background: #93a3bd; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(.985); } }
.dock-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dock-actions .btn { width: 100%; margin: 0; }

/* ── summary ────────────────────────────────────────────────────────────── */
.summary-head { text-align: center; margin-bottom: 22px; }
.summary-ring {
  width: 132px; height: 132px; border-radius: 50%; margin: 0 auto 14px;
  display: grid; place-items: center; background: #fff; border: 10px solid var(--line);
  font-size: 30px; font-weight: 800;
}
.summary-ring.listo { border-color: var(--pass); color: var(--pass); }
.summary-ring.casi { border-color: var(--partial); color: var(--partial); }
.summary-ring.practicar { border-color: var(--fail); color: var(--fail); }
.summary-read { font-size: 19px; margin: 0; }
.summary-list { list-style: none; padding: 0; margin: 0 0 20px; }
.summary-list li {
  background: #fff; border: 2px solid var(--line); border-left-width: 8px;
  border-radius: 10px; padding: 12px 14px; margin-bottom: 8px; font-size: 17px;
}
.summary-list li.pass { border-left-color: var(--pass); }
.summary-list li.partial { border-left-color: var(--partial); }
.summary-list li.fail { border-left-color: var(--fail); }
.summary-list li.unheard { border-left-color: var(--unheard); }
.summary-list .li-en { font-weight: 700; display: block; }
.summary-list .li-verdict { font-size: 15px; color: var(--ink-soft); }

/* ── progress ───────────────────────────────────────────────────────────── */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
            margin-bottom: 18px; }
.stat {
  background: #fff; border: 2px solid var(--line); border-radius: 12px;
  padding: 14px 8px; text-align: center;
}
.stat-num { display: block; font-size: 26px; font-weight: 800; line-height: 1.1; }
.stat-lbl { display: block; font-size: 13px; color: var(--ink-soft); margin-top: 2px; }

.pcard {
  background: #fff; border: 2px solid var(--line); border-radius: 12px;
  padding: 16px; margin-bottom: 12px;
}
.pcard-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.pcard-name { font-size: 19px; font-weight: 700; }
.pill { padding: 5px 12px; border-radius: 999px; font-size: 15px; font-weight: 700;
        color: #fff; white-space: nowrap; }
.pill.listo { background: var(--pass); }
.pill.casi { background: var(--partial); }
.pill.practicar { background: var(--fail); }
.pill.sin_datos { background: var(--unheard); }
.pcard-sub { font-size: 15px; color: var(--ink-soft); margin: 6px 0 0; }

/* ── overlay + toast ────────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; background: rgba(18, 22, 28, .55); z-index: 20;
  display: grid; place-items: center;
}
.overlay[hidden] { display: none; }
.overlay-box { background: #fff; border-radius: 14px; padding: 26px 30px; text-align: center;
               font-size: 17px; max-width: 300px; }
.spinner {
  width: 34px; height: 34px; margin: 0 auto 14px; border-radius: 50%;
  border: 4px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--dock) + 20px); z-index: 30;
  background: #12161c; color: #fff; border-radius: 12px; padding: 14px 16px;
  font-size: 16px; text-align: center; box-shadow: var(--shadow);
}
.toast[hidden] { display: none; }

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

/* ── mode chip ──────────────────────────────────────────────────────────── */
.mode-chip {
  background: #fff; color: var(--navy); border-radius: 999px; padding: 3px 10px;
  font-size: 13px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
}
.bar .mode-chip + .bar-count { margin-left: 6px; }

/* Playback state on the replay button, so a driver can see which pass is
   playing without reading anything. */
.btn-play .pass-label { font-size: 15px; font-weight: 600; opacity: .8; }
.btn-play.playing { background: #e8eefb; }

/* ── paraphrase variants ────────────────────────────────────────────────── */
/* The enforcement guidance tells inspectors to "paraphrase (in English) as
   appropriate", so a driver who only ever hears one wording is under-trained. */
.variants { border-top: 2px solid var(--line); margin-top: 14px; padding-top: 12px; }
.variants-h {
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-soft); margin: 0 0 8px;
}
.variants-list { list-style: none; margin: 0; padding: 0; }
.variants-list li {
  font-size: 18px; color: var(--ink); padding: 6px 0 6px 14px;
  border-left: 3px solid var(--line); margin-bottom: 4px;
}
.asked-en { font-size: 20px; font-weight: 700; margin: 0; }

/* ── driving mode ───────────────────────────────────────────────────────── */
/* Nothing here should need touching at speed. The controls exist for a parked
   driver; on the road the lock screen and steering-wheel buttons drive it. */
.tile-drive { border-color: var(--navy); }
.warn {
  background: #fff8e6; border: 2px solid #f0dca8; border-radius: 12px;
  padding: 16px; margin: 6px 0 18px; font-size: 17px;
}
.warn p { margin: 0; }
.drive-body { flex: 1; display: flex; flex-direction: column; justify-content: center;
              text-align: center; max-width: 480px; margin: 0 auto; width: 100%; }
.drive-stage {
  font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-soft); margin: 0 0 12px;
}
.drive-line { font-size: 27px; font-weight: 700; line-height: 1.3; margin: 0 0 8px; }
.drive-gloss { font-size: 19px; color: var(--ink-soft); margin: 0 0 32px; }
.drive-controls { display: flex; justify-content: center; align-items: center; gap: 18px; }
.drive-btn {
  width: 76px; height: 76px; border-radius: 50%; border: 2px solid var(--line);
  background: #fff; font-size: 26px; cursor: pointer; color: var(--ink);
}
.drive-btn-main {
  width: 104px; height: 104px; background: var(--accent); color: #fff;
  border-color: var(--accent); font-size: 34px;
}
.drive-btn:active { background: #e9edf3; }
.drive-btn-main:active { background: var(--accent-press); }

/* ── offline download ───────────────────────────────────────────────────── */
.offline-card {
  background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 16px;
}
.offline-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.offline-title { font-size: 18px; font-weight: 700; }
.offline-state { font-size: 15px; color: var(--ink-soft); white-space: nowrap; }
.offline-sub { font-size: 16px; color: var(--ink-soft); margin: 6px 0 12px; }
.offline-bar { height: 8px; background: #dfe4ec; border-radius: 999px; overflow: hidden;
               margin-bottom: 12px; }
.offline-fill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
