/* Matches the app's design language (docs/DESIGN.md): system type, one accent, cards. */
:root {
  --accent: #2B50E6;
  --accent-tint: rgb(43 80 230 / 0.10);
  --bg: #F2F2F7;
  --surface: #FFFFFF;
  --text: #1C1C1E;
  --muted: #6C6C70;
  --hairline: rgb(60 60 67 / 0.18);
  --fill: rgb(120 120 128 / 0.14);
  --green: #248A3D;
  --red: #D70015;
  --orange: #C93400;
  --radius: 22px;
  --radius-sm: 16px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent: #6E8BFF;
    --accent-tint: rgb(110 139 255 / 0.16);
    --bg: #000000;
    --surface: #1C1C1E;
    --text: #F2F2F7;
    --muted: #98989F;
    --hairline: rgb(84 84 88 / 0.6);
    --fill: rgb(118 118 128 / 0.24);
    --green: #30D158;
    --red: #FF6961;
    --orange: #FF9F0A;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 17px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--accent); text-underline-offset: 2px; }
h1, h2 { line-height: 1.15; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 5vw, 2.6rem); margin: 0.6em 0 0.3em; }
h2 { font-size: 1.35rem; margin: 0 0 0.6em; }
.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px; }
.lead { font-size: 1.2rem; color: var(--muted); margin: 0 0 1.5em; }
.small { font-size: 0.85rem; color: var(--muted); }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 8px; z-index: 10; background: var(--surface); padding: 8px 12px; border-radius: 8px; }

/* Header and footer */
.site-header { background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-bottom: 0.5px solid var(--hairline); position: sticky; top: 0; z-index: 5; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); text-decoration: none; }
.mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; color: #fff; background: linear-gradient(#456BFA, #2140CC); }
.mark svg { width: 18px; height: 18px; }
.site-header nav { display: flex; gap: 16px; font-size: 0.95rem; }
.site-header nav a { color: var(--text); text-decoration: none; }
.site-header nav a:hover { color: var(--accent); }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 16px auto 0; font-size: 0.85rem; color: var(--muted); }
.crumbs li + li::before { content: "›"; margin-right: 6px; }
.crumbs a { color: var(--muted); }
.site-footer { margin-top: 64px; padding: 32px 0 48px; border-top: 0.5px solid var(--hairline); font-size: 0.85rem; color: var(--muted); }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 16px; margin: 16px 0; }

/* Cards and buttons */
.card { background: var(--surface); border-radius: var(--radius); padding: 24px; margin: 20px 0; }
.card > :last-child { margin-bottom: 0; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 52px; padding: 0 24px; border-radius: var(--radius-sm); font: inherit; font-weight: 600; border: 0; cursor: pointer; text-decoration: none; }
.button.primary { background: var(--accent); color: #fff; }
.button.primary:hover { filter: brightness(1.08); }
.button.secondary { background: var(--accent-tint); color: var(--accent); }
.button.disabled { background: var(--fill); color: var(--muted); cursor: default; margin: 0; }
.ticks { list-style: none; padding: 0; margin: 0 0 1.2em; }
.ticks li { position: relative; padding-left: 28px; margin: 0.45em 0; }
.ticks li::before { content: "✓"; position: absolute; left: 4px; color: var(--accent); font-weight: 700; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 0 0 1em; }
.facts div { background: var(--bg); border-radius: var(--radius-sm); padding: 12px 16px; }
.facts dt { font-size: 0.85rem; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-weight: 600; }
.topics { width: 100%; border-collapse: collapse; }
.topics th, .topics td { text-align: left; padding: 10px 0; border-bottom: 0.5px solid var(--hairline); }
.topics td:last-child, .topics th:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.topics tr:last-child td { border-bottom: 0; }
.prose h2 { font-size: 1.1rem; margin-top: 1.4em; }
.prose h2:first-child { margin-top: 0; }
.pager { display: flex; flex-wrap: wrap; gap: 8px; margin: 24px 0; }
.pager a, .pager span { padding: 6px 12px; border-radius: 999px; background: var(--surface); font-size: 0.9rem; text-decoration: none; }
.pager span { background: var(--accent); color: #fff; }
.note { color: var(--muted); }

/* Quiz */
.quiz { margin: 8px 0 24px; }
.quiz-bar { position: sticky; top: 57px; z-index: 4; display: flex; align-items: center; gap: 12px; padding: 10px 16px; margin: 0 -16px 8px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); font-size: 0.95rem; }
.quiz-title { font-weight: 600; margin-right: auto; }
.quiz-count { color: var(--muted); font-variant-numeric: tabular-nums; }
.timer { font-weight: 700; font-variant-numeric: tabular-nums; padding: 4px 12px; border-radius: 999px; background: var(--fill); }
.timer.warning { color: var(--orange); background: color-mix(in srgb, var(--orange) 15%, transparent); }
.timer.critical { color: var(--red); background: color-mix(in srgb, var(--red) 15%, transparent); }
.q { border: 0; margin: 0 0 16px; padding: 24px; background: var(--surface); border-radius: var(--radius); min-width: 0; }
.q legend { float: left; width: 100%; padding: 0; margin-bottom: 16px; }
.q legend + * { clear: both; }
.qn { font-size: 0.85rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.stem { display: block; font-size: 1.2rem; font-weight: 600; line-height: 1.35; }
.opt { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 12px 16px; margin: 0 0 10px; border: 1px solid var(--hairline); border-radius: var(--radius-sm); cursor: pointer; transition: border-color .15s, background .15s, transform .1s; }
.opt:hover { border-color: var(--accent); }
.opt:active { transform: scale(0.99); }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.letter { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--hairline); font-weight: 700; font-size: 0.9rem; color: var(--muted); }
.opt:has(input:checked) { border: 2px solid var(--accent); background: var(--accent-tint); padding: 11px 15px; }
.opt:has(input:checked) .letter { background: var(--accent); border-color: var(--accent); color: #fff; }
.opt:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
/* Marked state. Scoped under .quiz.done so it outranks the :has(input:checked) "selected" rules. */
.quiz.done .opt.correct { border: 2px solid var(--green); background: color-mix(in srgb, var(--green) 12%, transparent); padding: 11px 15px; }
.quiz.done .opt.correct .letter { background: var(--green); border-color: var(--green); color: #fff; }
.quiz.done .opt.incorrect { border: 2px solid var(--red); background: color-mix(in srgb, var(--red) 12%, transparent); padding: 11px 15px; }
.quiz.done .opt.incorrect .letter { background: var(--red); border-color: var(--red); color: #fff; }
.quiz.done .opt.correct::after, .quiz.done .opt.incorrect::after { margin-left: auto; font-weight: 800; font-size: 1.1rem; }
.quiz.done .opt.correct::after { content: "✓"; color: var(--green); }
.quiz.done .opt.incorrect::after { content: "✗"; color: var(--red); }
.qn { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.verdict { flex: none; padding: 3px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 800; }
.verdict.right { color: var(--green); background: color-mix(in srgb, var(--green) 14%, transparent); }
.verdict.wrong { color: var(--red); background: color-mix(in srgb, var(--red) 14%, transparent); }
.verdict.none { color: var(--muted); background: var(--fill); }
.q.is-correct { box-shadow: inset 4px 0 0 var(--green); }
.q.is-wrong { box-shadow: inset 4px 0 0 var(--red); }
.q.is-unanswered { box-shadow: inset 4px 0 0 var(--hairline); }
.quiz.done .opt { cursor: default; }
.quiz.done .opt:not(.correct):not(.incorrect) { opacity: 0.6; }
.explain { margin-top: 14px; padding-top: 14px; border-top: 0.5px solid var(--hairline); }
.explain p { margin: 0 0 8px; }
.explain .source { font-size: 0.85rem; color: var(--muted); }
.quiz-actions { margin: 20px 0; }
.quiz-actions .button { width: 100%; }
.quiz-result { text-align: center; padding: 28px 24px; background: var(--surface); border-radius: var(--radius); margin: 0 0 16px; outline: none; }
.quiz-result .score { font-size: 3.5rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.quiz-result .of { color: var(--muted); }
.badge { display: inline-block; margin: 12px 0 6px; padding: 4px 12px; border-radius: 999px; font-size: 0.85rem; font-weight: 800; letter-spacing: 0.05em; }
.badge.pass { color: var(--green); background: color-mix(in srgb, var(--green) 14%, transparent); }
.badge.notyet { color: var(--orange); background: color-mix(in srgb, var(--orange) 14%, transparent); }
.pitch h2 { margin-bottom: 0.4em; }
.errata li { margin: 0.4em 0; }

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

@media (max-width: 560px) {
  .site-header .wrap { padding-top: 8px; padding-bottom: 8px; }
  .site-header nav { width: 100%; gap: 14px; font-size: 0.9rem; overflow-x: auto; }
  .quiz-bar { top: 92px; flex-wrap: wrap; }
  .q { padding: 20px 16px; }
  .card { padding: 20px; }
}
