/* ПДД Альберта — оформление. Мобильный приоритет, светлая и тёмная темы. */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --ink: #10233a;
  --ink-soft: #566a83;
  --line: #d9e1ea;
  --brand: #0b3f7a;
  --brand-ink: #ffffff;
  --ok: #0f7a45;
  --ok-bg: #e6f6ed;
  --bad: #c0261c;
  --bad-bg: #fdecea;
  --accent: #f0a202;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 35, 58, .06), 0 8px 24px rgba(16, 35, 58, .07);
  --maxw: 720px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1620;
    --surface: #16222f;
    --surface-2: #1e2c3b;
    --ink: #e8eef5;
    --ink-soft: #9db0c4;
    --line: #2a3a4c;
    --brand: #3d8bd8;
    --brand-ink: #06131f;
    --ok: #4cc98a;
    --ok-bg: #12321f;
    --bad: #ff8172;
    --bad-bg: #34191a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 28px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { line-height: 1.2; letter-spacing: -.015em; margin: 0 0 .5em; }
p { margin: 0 0 1em; }

/* ── Шапка ─────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px max(14px, env(safe-area-inset-left)) 10px max(14px, env(safe-area-inset-right));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand-mark svg { width: 26px; height: 26px; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text b { font-size: 15px; }
.brand-text small { color: var(--ink-soft); font-size: 11px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.chip {
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 4px 9px; border-radius: 999px; background: var(--surface-2); color: var(--ink-soft);
}
.lang { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.lang button {
  appearance: none; border: 0; background: transparent; color: var(--ink-soft);
  font: 600 12px/1 inherit; padding: 7px 11px; cursor: pointer;
}
.lang button.on { background: var(--brand); color: var(--brand-ink); }

/* ── Раскладка ─────────────────────────────────────────── */
main { max-width: var(--maxw); margin: 0 auto; padding: 22px 16px 60px; }
.view { animation: rise .22s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .view { animation: none; } }

.hero { text-align: center; padding: 18px 0 6px; }
.eyebrow {
  display: inline-block; font-size: 12px; font-weight: 600; color: var(--ink-soft);
  background: var(--surface-2); padding: 5px 12px; border-radius: 999px; margin-bottom: 14px;
}
.hero h1 { font-size: clamp(25px, 6.4vw, 36px); }
.lede { color: var(--ink-soft); font-size: 16px; max-width: 34em; margin: 0 auto 22px; }
.hero-note { margin-top: 14px; font-size: 13px; color: var(--ink-soft); }

.facts {
  list-style: none; margin: 26px 0; padding: 0;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
}
.facts li {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 6px; text-align: center;
}
.facts b { display: block; font-size: 22px; color: var(--brand); }
.facts span { font-size: 11px; color: var(--ink-soft); line-height: 1.25; display: block; }

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin: 16px 0; box-shadow: var(--shadow);
}
.panel h2, .panel h3 { font-size: 17px; }

.topics { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.topics li { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.topics li:last-child { border-bottom: 0; }
.topics span { color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.steps { margin: 0; padding-left: 1.15em; color: var(--ink-soft); font-size: 14px; }
.steps li { margin-bottom: 7px; }

/* ── Кнопки ────────────────────────────────────────────── */
.btn {
  appearance: none; border: 1px solid transparent; border-radius: 11px;
  font: 600 15px/1 inherit; padding: 13px 20px; cursor: pointer;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
}
.btn:active { transform: scale(.985); }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; }
.btn-lg { font-size: 17px; padding: 16px 34px; border-radius: 13px; }
.btn-quiet { background: transparent; color: var(--ink-soft); border-color: var(--line); }
.btn-ghost { background: var(--surface-2); color: var(--ink); border-color: var(--line); font-size: 14px; padding: 10px 16px; }

/* ── Экзамен ───────────────────────────────────────────── */
.exam-bar { margin-bottom: 14px; }
.exam-meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-soft); margin-bottom: 8px; }
.exam-meta b { color: var(--ink); font-variant-numeric: tabular-nums; }
.mistakes.hot b { color: var(--bad); }
.mistake-hint {
  margin: 8px 0 0; font-size: 12.5px; font-weight: 600; color: var(--bad);
  text-align: right;
}
.progress { height: 5px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--brand); border-radius: 999px; transition: width .25s ease; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.topic-tag { font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-soft); margin: 0 0 8px; }
.question { font-size: clamp(18px, 4.6vw, 22px); margin-bottom: 16px; }

.sign { margin: 0 0 18px; display: flex; justify-content: center; }
.sign svg { width: 132px; height: 132px; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .18)); }

.options { display: grid; gap: 9px; }
.opt {
  display: flex; gap: 11px; align-items: flex-start; text-align: left; width: 100%;
  background: var(--surface-2); border: 1.5px solid transparent; border-radius: 12px;
  padding: 13px 15px; font: 500 15px/1.4 inherit; color: var(--ink); cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.opt:hover:not(:disabled) { border-color: var(--brand); }
.opt:disabled { cursor: default; }
.opt .key {
  flex: 0 0 22px; height: 22px; border-radius: 6px; background: var(--surface);
  border: 1px solid var(--line); font-size: 12px; font-weight: 700; color: var(--ink-soft);
  display: grid; place-items: center;
}
.opt.correct { background: var(--ok-bg); border-color: var(--ok); }
.opt.correct .key { background: var(--ok); color: #fff; border-color: var(--ok); }
.opt.wrong { background: var(--bad-bg); border-color: var(--bad); }
.opt.wrong .key { background: var(--bad); color: #fff; border-color: var(--bad); }
.opt.dim { opacity: .55; }

.verdict { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.verdict-line { font-weight: 700; margin-bottom: 10px; }
.verdict.is-ok .verdict-line { color: var(--ok); }
.verdict.is-bad .verdict-line { color: var(--bad); }
.explain {
  margin-top: 12px; background: var(--surface-2); border-left: 3px solid var(--brand);
  border-radius: 0 10px 10px 0; padding: 13px 15px; font-size: 14.5px; color: var(--ink);
}
.explain p:last-child { margin-bottom: 0; }

.exam-actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 16px; }

/* Блок «экзамен провален» — появляется прямо под вопросом на шестой ошибке */
.fail-notice {
  margin-top: 18px; padding: 20px 18px; text-align: center;
  background: var(--bad-bg); border: 1.5px solid var(--bad); border-radius: 12px;
  animation: rise .2s ease both;
}
.fail-mark svg { width: 62px; height: 62px; display: block; margin: 0 auto 12px; }
.fail-notice h3 { font-size: 18px; color: var(--bad); margin-bottom: 6px; }
.fail-notice p { font-size: 14px; color: var(--ink-soft); margin: 0 auto 16px; max-width: 30em; }
.fail-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ── Результат ─────────────────────────────────────────── */
.result-head { text-align: center; padding: 26px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.result-mark svg { width: 78px; height: 78px; display: block; margin: 0 auto 16px; }
.result-badge { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 6px 14px; border-radius: 999px; margin-bottom: 12px; }
.result-head.pass .result-badge { background: var(--ok-bg); color: var(--ok); }
.result-head.fail .result-badge { background: var(--bad-bg); color: var(--bad); }
.result-score { font-size: 40px; font-weight: 700; margin: 4px 0; font-variant-numeric: tabular-nums; }
.result-head.pass .result-score { color: var(--ok); }
.result-head.fail .result-score { color: var(--bad); }
.result-sub { color: var(--ink-soft); font-size: 14px; margin: 0; }
.result-actions { display: flex; gap: 10px; justify-content: center; margin: 18px 0; flex-wrap: wrap; }

.review { display: grid; gap: 14px; }
.review-item { border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.review-item h4 { font-size: 15px; margin: 0 0 10px; }
.review-line { font-size: 14px; margin: 0 0 5px; }
.review-line .lbl { color: var(--ink-soft); }
.review-line.bad { color: var(--bad); }
.review-line.good { color: var(--ok); }
.review-item .explain { margin-top: 11px; }
.review-sign svg { width: 84px; height: 84px; float: right; margin: 0 0 8px 12px; }

/* ── Подвал ────────────────────────────────────────────── */
.footer { max-width: var(--maxw); margin: 0 auto; padding: 22px 16px 40px; font-size: 12.5px; color: var(--ink-soft); text-align: center; border-top: 1px solid var(--line); }
.footer .muted { opacity: .75; }

@media (max-width: 420px) {
  .facts { grid-template-columns: repeat(2, 1fr); }
  .btn-lg { width: 100%; }
  .fail-actions .btn, .result-actions .btn { flex: 1 1 100%; }
}
