/* Palette and card system ported from the original FSC Practice Exam artifact. */
:root {
  --bg: #edf0e9;
  --panel: #ffffff;
  --panel-2: #f5f6f1;
  --ink: #1b231d;
  --ink-muted: #5b665e;
  --line: #d7dcd0;
  --brass: #96702a;
  --brass-ink: #2a1d09;
  --brass-soft: #e8dcc4;
  --moss: #3f6b46;
  --moss-soft: #dfeade;
  --rust: #a83e26;
  --rust-soft: #f3ddd4;
  --focus: #7a5420;
  --shadow: 0 1px 2px rgba(27, 35, 29, 0.06), 0 8px 24px rgba(27, 35, 29, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161a;
    --panel: #1a2024;
    --panel-2: #20272b;
    --ink: #edf1ec;
    --ink-muted: #9aa79f;
    --line: #2d363b;
    --brass: #d3a959;
    --brass-ink: #1a1206;
    --brass-soft: #3a2f18;
    --moss: #74b283;
    --moss-soft: #1e2f22;
    --rust: #e2846a;
    --rust-soft: #33201a;
    --focus: #d3a959;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Charter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

body {
  /* dvh, not vh — mobile Safari's collapsing toolbar makes vh overshoot. */
  min-height: 100dvh;
  padding: 40px 16px 64px;
}

.font-display {
  font-family: "Iowan Old Style", Palatino, "Palatino Linotype", "URW Palladio L", Georgia, serif;
}
.font-mono {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-variant-numeric: tabular-nums;
}

.stage { max-width: 640px; margin: 0 auto; }

/* ---- Masthead ---- */
.masthead { text-align: center; margin-bottom: 28px; }
.masthead .eyebrow {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brass);
  font-weight: 600;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 14px;
  background: var(--panel);
}
.masthead h1 {
  font-size: clamp(28px, 6vw, 38px);
  margin: 14px 0 6px;
  letter-spacing: 0.01em;
  text-wrap: balance;
}
.masthead .sub {
  color: var(--ink-muted);
  font-size: 15px;
  max-width: 46ch;
  margin: 0 auto;
}

/* ---- Cards ---- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 28px 28px 26px;
}
@media (max-width: 480px) {
  .card { padding: 22px 18px 20px; }
  body { padding: 24px 12px 48px; }
}

.rule { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.center { text-align: center; }

/* ---- Cover ---- */
.stat-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 20px 0 24px;
  flex-wrap: wrap;
}
.stat-chip {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 16px;
  text-align: center;
  background: var(--panel-2);
  min-width: 108px;
  flex: 1 1 108px;
}
/* Three chips must stay on one row at 360px, where the card leaves ~300px
   of inner width — 108px minimums would wrap the third onto its own line. */
@media (max-width: 480px) {
  .stat-row { gap: 8px; flex-wrap: nowrap; }
  /* flex-basis must drop to 0 as well — a 108px basis is what forces the wrap. */
  .stat-chip { flex: 1 1 0; min-width: 0; padding: 10px 6px; }
  .stat-chip .lbl { font-size: 10px; letter-spacing: 0.04em; }
}

.stat-chip .num { font-size: 20px; font-weight: 600; }
.stat-chip .lbl {
  font-size: 11px;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
}

.intro-list {
  text-align: left;
  color: var(--ink-muted);
  font-size: 14px;
  line-height: 1.65;
  margin: 0 0 22px;
  padding-left: 1.2em;
}
.intro-list li { margin-bottom: 6px; }
.intro-list b { color: var(--ink); }

/* ---- Buttons ---- */
.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  border-radius: 9px;
  padding: 13px 22px;
  font-size: 15px;
  letter-spacing: 0.01em;
  min-height: 48px; /* tap target */
  background: var(--brass);
  color: var(--brass-ink);
  transition: transform 0.12s ease, filter 0.12s ease, opacity 0.12s ease;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-sm { padding: 9px 14px; font-size: 13.5px; min-height: 40px; }
/* Anchors wearing .btn: they're inline by default, and page-level link colors
   (.content-page a) tie on specificity with .btn, so the label ends up brass on
   brass. Pin both here, with .content-page in the selector so it wins. */
a.btn,
.content-page a.btn {
  display: inline-block;
  text-align: center;
  text-decoration: none;
  color: var(--brass-ink);
}

.link-btn {
  background: none;
  border: none;
  font: inherit;
  color: var(--brass);
  text-decoration: underline;
  cursor: pointer;
  /* Vertical padding brings these inline links up to a usable touch target
     without pushing them out of the surrounding sentence. */
  display: inline-block;
  padding: 12px 4px;
  margin: -12px -4px;
}
.link-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

/* ---- Quiz chrome ---- */
.topline {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
  gap: 12px;
}
.qcount, .running-score { font-size: 13px; color: var(--ink-muted); }

.progress-track {
  height: 5px;
  background: var(--panel-2);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
  margin-bottom: 22px;
}
.progress-fill { height: 100%; background: var(--brass); width: 0%; transition: width 0.25s ease; }

.chapter-label {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brass);
  font-weight: 700;
  margin-bottom: 10px;
}
.question-text { font-size: 19px; line-height: 1.45; margin: 0 0 20px; }

/* ---- Choices ---- */
.choices { display: flex; flex-direction: column; gap: 10px; margin-bottom: 4px; }
.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  min-height: 48px;
  cursor: pointer;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  transition: background 0.15s ease, border-color 0.15s ease;
}
.choice:hover:not(:disabled) { border-color: var(--brass); }
.choice:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.choice .badge {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-weight: 700;
  font-size: 13px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink-muted);
}
.choice .txt { flex: 1; min-width: 0; overflow-wrap: break-word; }
.choice:disabled { cursor: default; }
.choice.is-correct { background: var(--moss-soft); border-color: var(--moss); }
.choice.is-correct .badge { background: var(--moss); color: #fff; border-color: var(--moss); }
.choice.is-wrong { background: var(--rust-soft); border-color: var(--rust); }
.choice.is-wrong .badge { background: var(--rust); color: #fff; border-color: var(--rust); }
.choice.is-dim { opacity: 0.55; }

/* ---- Explanation ---- */
.explain {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
  display: none;
}
.explain.show { display: block; }
.explain .cite {
  display: block;
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink-muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}
.explain .verdict { font-weight: 700; }
.explain .verdict.right { color: var(--moss); }
.explain .verdict.wrong { color: var(--rust); }

.quiz-footer { display: flex; justify-content: flex-end; margin-top: 22px; }

/* On a phone the Next button sticks to the bottom, clear of the home indicator. */
@media (max-width: 700px) {
  .quiz-footer {
    position: sticky;
    bottom: 0;
    margin: 22px -18px -20px;
    padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
    background: var(--panel);
    border-top: 1px solid var(--line);
    border-radius: 0 0 14px 14px;
  }
  .quiz-footer .btn { width: 100%; }
}

/* ---- Paywall ---- */
.paywall { text-align: center; }
.paywall .price {
  font-size: 42px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 6px 0 2px;
}
.paywall .price-sub { color: var(--ink-muted); font-size: 13.5px; margin-bottom: 20px; }
.paywall .sell-list {
  text-align: left;
  list-style: none;
  padding: 0;
  margin: 0 0 22px;
  font-size: 14.5px;
  line-height: 1.6;
}
.paywall .sell-list li {
  padding-left: 26px;
  position: relative;
  margin-bottom: 8px;
}
.paywall .sell-list li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--moss);
  font-weight: 700;
}
.wallet-note {
  font-size: 12.5px;
  color: var(--ink-muted);
  margin-top: 14px;
  line-height: 1.5;
}

/* ---- Forms ---- */
.field { text-align: left; margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-muted);
  font-weight: 600;
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  /* 16px minimum, or iOS Safari zooms the viewport on focus. */
  font-size: 16px;
  font-family: inherit;
  padding: 12px 14px;
  min-height: 48px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
}
.field input:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.field input.code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 22px;
  letter-spacing: 0.35em;
  text-align: center;
}

.form-msg { font-size: 13.5px; margin: 10px 0 0; line-height: 1.5; }
.form-msg.error { color: var(--rust); }
.form-msg.ok { color: var(--moss); }

/* ---- Results ---- */
.seal {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  margin: 0 auto 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--moss);
  position: relative;
}
.seal::before {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  border: 1px dashed var(--moss);
  opacity: 0.5;
}
.seal .mark { font-size: 40px; color: var(--moss); font-weight: 700; line-height: 1; }
.seal.fail { border-color: var(--rust); }
.seal.fail::before { border-color: var(--rust); }
.seal.fail .mark { color: var(--rust); }

.score-big { text-align: center; font-size: 44px; font-weight: 700; letter-spacing: -0.01em; }
.score-pct { text-align: center; color: var(--ink-muted); font-size: 14px; margin: 2px 0 4px; }
.verdict-line { text-align: center; font-size: 15px; margin-bottom: 22px; }
.verdict-line.pass { color: var(--moss); }
.verdict-line.fail { color: var(--rust); }

.chapter-breakdown { display: flex; flex-direction: column; gap: 10px; margin: 20px 0 8px; }
.cb-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; }
.cb-name { font-size: 13.5px; }
.cb-frac { font-size: 13px; color: var(--ink-muted); text-align: right; }
.cb-bar {
  grid-column: 1 / -1;
  height: 6px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.cb-bar-fill { height: 100%; background: var(--moss); }
.cb-bar-fill.weak { background: var(--rust); }

.review-toggle { margin-top: 22px; }
.review-list { margin-top: 16px; display: none; flex-direction: column; gap: 14px; }
.review-list.show { display: flex; }
.review-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  background: var(--panel-2);
}
.review-item .rq { font-size: 14px; margin-bottom: 8px; font-weight: 600; }
.review-item .ra { font-size: 13px; margin: 3px 0; }
.review-item .ra.wrong { color: var(--rust); }
.review-item .ra.right { color: var(--moss); }
.review-item .rexp { font-size: 13px; color: var(--ink-muted); margin-top: 8px; line-height: 1.5; }

.results-actions { display: flex; gap: 10px; margin-top: 26px; justify-content: center; flex-wrap: wrap; }
@media (max-width: 480px) {
  .results-actions { flex-direction: column; }
  .results-actions .btn { width: 100%; }
}

/* ---- Study mode chapter picker ---- */
.chapter-grid { display: flex; flex-direction: column; gap: 10px; margin: 4px 0 20px; }
.chapter-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  min-height: 48px;
  cursor: pointer;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  transition: border-color 0.15s ease;
}
.chapter-btn:hover { border-color: var(--brass); }
.chapter-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.chapter-btn .ch-num {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brass);
  font-weight: 700;
  display: block;
  margin-bottom: 2px;
}
.chapter-btn .ch-count {
  font-size: 12.5px;
  color: var(--ink-muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  flex: 0 0 auto;
}

/* ---- Misc ---- */
.screen { display: none; }
.screen.active { display: block; }

.footnote {
  text-align: center;
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 22px;
  line-height: 1.6;
}
.footnote a { color: var(--ink-muted); }

.banner {
  border: 1px solid var(--moss);
  background: var(--moss-soft);
  color: var(--ink);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 14px;
  margin-bottom: 20px;
  text-align: center;
}
.banner.error { border-color: var(--rust); background: var(--rust-soft); }

.topbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  max-width: 640px;
  margin: 0 auto 12px;
  font-size: 13px;
  color: var(--ink-muted);
  min-height: 24px;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }

.spinner-note { text-align: center; color: var(--ink-muted); font-size: 14px; padding: 20px 0; }

/* ---- Site nav & footer (shared across home + content pages) ---- */
.site-nav {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  max-width: 640px;
  margin: 0 auto 22px;
}
.site-nav a {
  flex: 1 1 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 40px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.site-nav a:hover { border-color: var(--brass); color: var(--brass); }
.site-nav a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.site-nav a.active { background: var(--brass); color: var(--brass-ink); border-color: var(--brass); }
@media (max-width: 480px) {
  .site-nav { gap: 6px; }
  .site-nav a { flex-basis: calc(50% - 3px); font-size: 12.5px; padding: 9px 8px; }
}

.site-footer-links {
  text-align: center;
  margin-top: 26px;
  font-size: 12.5px;
  line-height: 2.2;
}
.site-footer-links a { color: var(--ink-muted); margin: 0 8px; }
.site-footer-links a:hover { color: var(--brass); }

/* ---- Prose content pages (FAQ, study guide, what-is-fsc) ---- */
.content-page h2 {
  font-family: "Iowan Old Style", Palatino, "Palatino Linotype", "URW Palladio L", Georgia, serif;
  font-size: 20px;
  margin: 26px 0 10px;
}
.content-page h2:first-child { margin-top: 0; }
.content-page h3 { font-size: 16px; margin: 20px 0 6px; }
.content-page p { font-size: 14.5px; line-height: 1.7; color: var(--ink-muted); margin: 0 0 12px; }
.content-page p b, .content-page li b { color: var(--ink); }
.content-page ul, .content-page ol { font-size: 14.5px; line-height: 1.7; color: var(--ink-muted); margin: 0 0 14px; padding-left: 1.3em; }
.content-page li { margin-bottom: 6px; }
.content-page a { color: var(--brass); }

.faq-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px 16px;
  margin-bottom: 10px;
  background: var(--panel-2);
}
.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
  padding: 14px 0;
  list-style: none;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "+";
  float: right;
  color: var(--brass);
  font-weight: 700;
}
.faq-item[open] summary::after { content: "−"; }
.faq-item .faq-a {
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink-muted);
  padding: 0 0 16px;
  margin: 0;
}
.faq-item .faq-a a { color: var(--brass); }

.cta-band {
  text-align: center;
  margin-top: 30px;
}
.cta-band p { margin: 0 0 14px; }

.site-footer {
  max-width: 640px;
  margin: 32px auto 0;
  text-align: center;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--ink-muted);
}

.resume-banner {
  max-width: 640px;
  margin: 0 auto 16px;
  border: 1px solid var(--brass);
  background: var(--brass-soft);
  color: var(--ink);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.resume-banner .rb-text { flex: 1 1 auto; }

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