/* Citizenship Test Prep. Calm study app: cool paper, spruce ink, one ochre accent for the pass line.
 * Type: Atkinson Hyperlegible Next for everything you read and tap (made for legibility, good for second-language
 * readers); Newsreader Display for screen titles and scores. Signature: the 20-cell strip with its pass line. */
@font-face { font-family: 'Atkinson Next'; src: url('fonts/atkinson-hyperlegible-next-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Atkinson Next'; src: url('fonts/atkinson-hyperlegible-next-latin-700-normal.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Newsreader Display'; src: url('fonts/newsreader-display-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }

:root {
  --paper: #f3f5f4; --surface: #ffffff; --ink: #16201e; --ink-2: #4b5855; --line: #d9e1de; --line-2: #c3cfcb;
  --spruce: #1d5247; --spruce-hover: #163f37; --on-spruce: #ffffff; --spruce-soft: #e2ede9;
  --ochre: #9a6212; --ochre-soft: #f5e8cf; --ok: #2a7548; --ok-soft: #e1f0e6; --bad: #ac3a2f; --bad-soft: #f8e3df;
  --focus: #2f6fd0;
  --serif: 'Newsreader Display', 'Iowan Old Style', Georgia, serif;
  --sans: 'Atkinson Next', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --radius: 12px; --tabh: 62px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f1715; --surface: #16211e; --ink: #e5ece9; --ink-2: #a6b4b0; --line: #283632; --line-2: #3a4a45;
    --spruce: #7cc3b0; --spruce-hover: #96d3c2; --on-spruce: #0c1412; --spruce-soft: #1c2f2a;
    --ochre: #e3ad55; --ochre-soft: #3a2e19; --ok: #6cc08c; --ok-soft: #173126; --bad: #f08a7e; --bad-soft: #3a1f1c;
    --focus: #8bb5ff; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0f1715; --surface: #16211e; --ink: #e5ece9; --ink-2: #a6b4b0; --line: #283632; --line-2: #3a4a45;
  --spruce: #7cc3b0; --spruce-hover: #96d3c2; --on-spruce: #0c1412; --spruce-soft: #1c2f2a;
  --ochre: #e3ad55; --ochre-soft: #3a2e19; --ok: #6cc08c; --ok-soft: #173126; --bad: #f08a7e; --bad-soft: #3a1f1c;
  --focus: #8bb5ff; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 17px/1.55 var(--sans); min-height: 100vh; min-height: 100dvh; }
a { color: var(--spruce); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
h1, h2 { font-weight: 400; margin: 0; }
h1 { font: 400 clamp(28px, 7vw, 36px)/1.15 var(--serif); letter-spacing: -0.01em; margin: 4px 0 10px; text-wrap: balance; }
h1:focus { outline: none; }
h2 { font: 700 19px/1.3 var(--sans); margin: 32px 0 10px; }
p { margin: 0 0 12px; }
.lead { color: var(--ink-2); font-size: 17px; max-width: 62ch; }
.muted { color: var(--ink-2); font-size: 15px; }
.kicker { color: var(--ink-2); font-size: 15px; margin: 0 0 2px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 10px 14px; z-index: 50; }
.skip:focus { left: 16px; }
[hidden] { display: none !important; }

/* ---------- header and notices ---------- */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) 8px calc(12px + env(safe-area-inset-left));
  background: var(--paper); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; min-height: 44px; min-width: 0; padding-right: 4px; }
.mark { width: 30px; height: 24px; flex: none; }
.mark .on { fill: var(--spruce); }
.mark .off { fill: none; stroke: var(--ochre); stroke-width: 1.2; }
.brandname { font: 700 16px/1.2 var(--sans); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brandshort { display: none; font: 700 16px/1.2 var(--sans); white-space: nowrap; }
@media (max-width: 440px) { .brandname { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); } .brandshort { display: inline; } }
.topactions { display: flex; align-items: center; gap: 4px; flex: none; }
.langbtn { font: 700 14px/1 var(--sans); color: var(--spruce); background: transparent; border: 1px solid var(--line-2); border-radius: 999px; min-height: 44px; padding: 0 14px; cursor: pointer; }
.langbtn:hover { background: var(--spruce-soft); }
.iconbtn { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 999px; color: var(--ink-2); }
.iconbtn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.iconbtn:hover { background: var(--spruce-soft); color: var(--spruce); }
.notice { margin: 0; padding: 6px calc(16px + env(safe-area-inset-right)) 6px calc(16px + env(safe-area-inset-left)); font-size: 13px; line-height: 1.4; color: var(--ink-2); background: var(--surface); border-bottom: 1px solid var(--line); }
.preview { margin: 0; padding: 6px 16px; font-size: 13px; font-weight: 700; color: var(--ochre); background: var(--ochre-soft); border-bottom: 1px solid var(--line); }

/* ---------- layout: bottom tabs on phones, a rail on wide screens ---------- */
.shell { display: block; }
main { display: block; max-width: 720px; margin: 0 auto; padding: 20px calc(16px + env(safe-area-inset-right)) calc(var(--tabh) + 40px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left)); outline: none; }
.tabs { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--line); padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: var(--tabh); padding: 6px 2px; color: var(--ink-2); text-decoration: none; font-size: 12px; line-height: 1.15; text-align: center; }
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.tabs a[aria-current="page"] { color: var(--spruce); font-weight: 700; }
.tabs a[aria-current="page"] svg { stroke-width: 2.3; }
body.in-test .tabs { display: none; }
body.in-test main { padding-bottom: calc(32px + env(safe-area-inset-bottom)); }
@media (min-width: 960px) {
  .shell { display: grid; grid-template-columns: 232px 1fr; max-width: 1120px; margin: 0 auto; }
  .tabs { position: sticky; top: 88px; align-self: start; display: flex; flex-direction: column; gap: 2px; border: 0; background: transparent; padding: 24px 12px; }
  .tabs a { flex-direction: row; justify-content: flex-start; gap: 12px; min-height: 48px; padding: 0 14px; border-radius: 10px; font-size: 16px; }
  .tabs a[aria-current="page"] { background: var(--spruce-soft); }
  .tabs a:hover { background: var(--spruce-soft); color: var(--spruce); }
  main { margin: 0; padding: 32px 32px 64px; }
  body.in-test .tabs { display: flex; visibility: hidden; }
  .top { padding-left: 24px; padding-right: 24px; }
  .notice, .preview { padding-left: 24px; }
}
.loading { color: var(--ink-2); padding: 40px 0; }
.noscript { padding: 16px 0; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 0 20px; border-radius: 10px; border: 1px solid var(--spruce);
  background: var(--spruce); color: var(--on-spruce); font: 700 16px/1.2 var(--sans); text-decoration: none; cursor: pointer; text-align: center; }
.btn:hover { background: var(--spruce-hover); border-color: var(--spruce-hover); }
.btn.ghost { background: transparent; color: var(--spruce); border-color: var(--line-2); }
.btn.ghost:hover { background: var(--spruce-soft); }
.btn.small { min-height: 44px; padding: 0 14px; font-size: 15px; }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); }
.btn:disabled { opacity: .45; cursor: default; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0; }
.actions.split { justify-content: space-between; }
.actions.split .btn { flex: 1 1 140px; }
.filebtn { position: relative; overflow: hidden; }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }

/* ---------- the strip: 20 cells and the pass line ---------- */
.strip { display: flex; align-items: center; gap: 3px; margin: 8px 0; flex-wrap: nowrap; }
.strip .cell { flex: 1 1 0; min-width: 0; max-width: 18px; height: 10px; border-radius: 3px; background: transparent; border: 1.5px solid var(--line-2); padding: 0; }
.strip.big .cell { max-width: 30px; height: 30px; border-radius: 6px; }
.strip .cell.done { background: var(--spruce-soft); border-color: var(--spruce); }
.strip .cell.ok { background: var(--ok); border-color: var(--ok); }
.strip .cell.bad { background: var(--bad-soft); border-color: var(--bad); }
.strip .cell.empty { border-color: var(--line-2); }
.strip .cell.cur { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink); }
.strip .passmark { flex: none; width: 3px; align-self: stretch; margin: -3px 2px; border-radius: 2px; background: var(--ochre); }
/* question map in the mock test: 2 rows of 10 on phones (44px tall targets), one row of 20 on wide screens */
.qgrid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; margin: 8px 0; }
.qgrid .cell { position: relative; min-height: 44px; border-radius: 8px; border: 1.5px solid var(--line-2); background: var(--surface); color: var(--ink-2); font: 700 13px/1 var(--sans); cursor: pointer; padding: 0; }
.qgrid .cell.done { background: var(--spruce-soft); border-color: var(--spruce); color: var(--spruce); }
.qgrid .cell.cur { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink); color: var(--ink); }
.qgrid .cell.afterpass::before { content: ''; position: absolute; left: -4.5px; top: -2px; bottom: -2px; width: 3px; border-radius: 2px; background: var(--ochre); }
@media (min-width: 700px) { .qgrid { grid-template-columns: repeat(20, 1fr); } }
.testshape { margin: 20px 0 6px; }
.passlbl { color: var(--ochre); font-size: 14px; font-weight: 700; margin: 2px 0 14px; }

/* ---------- home ---------- */
.streak { display: flex; align-items: center; gap: 12px; margin: 18px 0 8px; }
.streak p { margin: 0; font-size: 15px; color: var(--ink-2); }
.streak strong { color: var(--ink); }
.week { display: grid; grid-template-columns: repeat(7, 10px); gap: 3px; flex: none; }
.week span { height: 22px; border-radius: 3px; border: 1.5px solid var(--line-2); }
.week span.on { background: var(--ochre); border-color: var(--ochre); }
.week span.today { box-shadow: 0 2px 0 0 var(--ink); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px 18px 4px; margin: 18px 0; }
.panel h2 { margin: 0 0 6px; }
.panel.primary { border-color: var(--spruce); box-shadow: inset 4px 0 0 var(--spruce); }
.panel.quiet { background: transparent; }
.panel .actions, .panel > .btn { margin: 14px 0 16px; }
.warn { background: var(--ochre-soft); color: var(--ink); border-radius: 10px; padding: 12px 14px; font-size: 15px; }

/* ---------- lists ---------- */
.rows, .chapters, .bych, .history, .links, .review, .localq { list-style: none; margin: 16px 0; padding: 0; }
.rows li + li, .chapters li + li, .history li + li { border-top: 1px solid var(--line); }
.rows, .chapters { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.row, .chapter { display: flex; align-items: center; gap: 14px; padding: 14px 4px; min-height: 64px; color: var(--ink); text-decoration: none; }
.row:hover, .chapter:hover { background: var(--spruce-soft); }
.rowtext { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.rowtitle { font-weight: 700; }
.rowsub { color: var(--ink-2); font-size: 15px; }
.row .strip { width: 110px; flex: none; margin: 0; }
.row .strip .cell { height: 8px; }
.row .strip .passmark { margin: -2px 1px; width: 2px; }
.count { flex: none; min-width: 28px; height: 28px; padding: 0 8px; border-radius: 999px; background: var(--ochre-soft); color: var(--ochre); font-weight: 700; font-size: 14px; display: grid; place-items: center; }
.chev { flex: none; width: 9px; height: 9px; border-right: 2px solid var(--ink-2); border-top: 2px solid var(--ink-2); transform: rotate(45deg); margin-right: 4px; }
.chn { flex: none; width: 34px; height: 34px; border-radius: 999px; border: 1.5px solid var(--line-2); display: grid; place-items: center; font: 400 18px/1 var(--serif); color: var(--ink-2); }
.meta { color: var(--ink-2); font-size: 14px; margin-top: 2px; }
.bar { display: block; height: 4px; border-radius: 4px; background: var(--line); margin-top: 6px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--spruce); border-radius: 4px; }
.bych li a { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: baseline; padding: 10px 2px; color: var(--ink); text-decoration: none; min-height: 48px; }
.bych li a:hover { background: var(--spruce-soft); }
.bych .bar { grid-column: 1 / -1; }
.bcs { color: var(--ink-2); font-size: 15px; font-variant-numeric: tabular-nums; }
.history li > a, .history li > div { display: grid; grid-template-columns: 1fr auto auto; gap: 4px 12px; align-items: center; padding: 12px 2px; color: var(--ink); text-decoration: none; }
.history .strip { grid-column: 1 / -1; margin: 2px 0 0; }
.hd { color: var(--ink-2); font-size: 15px; }
.hs { font-weight: 700; font-variant-numeric: tabular-nums; }
.tag { display: inline-block; font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 999px; margin: 0; }
.tag.ok { color: var(--ok); background: var(--ok-soft); }
.tag.bad { color: var(--bad); background: var(--bad-soft); }
.tag.big { font-size: 16px; padding: 6px 14px; }
.links li { padding: 6px 0; }
.links a { display: inline-flex; min-height: 44px; align-items: center; }
.ext { font-size: .85em; }
.rules { padding-left: 20px; margin: 12px 0; }
.rules li { margin: 6px 0; }
.source { color: var(--ink-2); font-size: 14px; margin-top: 18px; }
.crumb { margin: 0 0 10px; font-size: 15px; }
.crumb a { display: inline-flex; align-items: center; min-height: 44px; text-decoration: none; }
.foot { margin-top: 32px; }

/* ---------- study notes ---------- */
.toc { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 14px 0 18px; }
.toc summary { display: flex; align-items: center; min-height: 48px; cursor: pointer; font-weight: 700; font-size: 15px; color: var(--spruce); list-style: none; }
.toc summary::-webkit-details-marker { display: none; }
.toc summary::after { content: ''; width: 8px; height: 8px; margin-left: 10px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-3px); }
.toc[open] summary::after { transform: rotate(-135deg) translateY(-2px); }
.toc ul { list-style: none; margin: 0 0 10px; padding: 0; }
.toc a { display: flex; align-items: center; min-height: 44px; padding: 4px 0; font-size: 15px; text-decoration: none; color: var(--ink); line-height: 1.3; }
.toc a:hover { color: var(--spruce); text-decoration: underline; }
.notes section { padding: 6px 0 4px; scroll-margin-top: 80px; }
.notes h2 { font: 400 23px/1.25 var(--serif); margin: 22px 0 8px; }
.notes p { max-width: 66ch; }
.nextch { margin: 8px 0 0; }
.nextch a { display: inline-flex; min-height: 44px; align-items: center; font-weight: 700; text-decoration: none; }

/* ---------- questions ---------- */
.quizhead { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.stop { font-size: 15px; display: inline-flex; align-items: center; min-height: 44px; }
.qof { color: var(--ink-2); font-size: 14px; margin: 6px 0 4px; }
h1.question { font: 400 clamp(22px, 5.6vw, 28px)/1.3 var(--serif); margin: 4px 0 18px; }
.options { display: grid; gap: 10px; }
.options.tf { grid-template-columns: 1fr 1fr; }
.opt { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 12px 14px; text-align: left; font: 400 17px/1.35 var(--sans); color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--line-2); border-radius: var(--radius); cursor: pointer; }
.options.tf .opt { justify-content: center; font-weight: 700; }
.options.tf .letter { display: none; }
.opt:hover:not(:disabled) { border-color: var(--spruce); }
.letter { flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font: 700 14px/1 var(--sans); color: var(--ink-2); background: var(--paper); }
.opt.picked { border-color: var(--spruce); background: var(--spruce-soft); box-shadow: inset 0 0 0 1px var(--spruce); }
.opt.picked .letter { background: var(--spruce); color: var(--on-spruce); }
.opt.right { border-color: var(--ok); background: var(--ok-soft); opacity: 1; }
.opt.right .letter { background: var(--ok); color: var(--surface); }
.opt.wrongpick { border-color: var(--bad); background: var(--bad-soft); opacity: 1; }
.opt.wrongpick .letter { background: var(--bad); color: var(--surface); }
.opt.dim { opacity: .6; }
.opt:disabled { cursor: default; color: var(--ink); }
.verdict { margin: 18px 0 0; padding: 14px 16px 6px; border-radius: var(--radius); border-left: 4px solid; background: var(--surface); }
.verdict.ok { border-color: var(--ok); }
.verdict.bad { border-color: var(--bad); }
.vtitle { font-weight: 700; margin-bottom: 4px; }
.verdict.ok .vtitle { color: var(--ok); }
.verdict.bad .vtitle { color: var(--bad); }
.vans { font-weight: 700; }
.ref { color: var(--ink-2); font-size: 14px; margin: 8px 0 2px; }
.reflinks { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 15px; margin: 0 0 8px; }
.reflinks a { display: inline-flex; align-items: center; min-height: 44px; }
.score { font: 400 clamp(36px, 10vw, 48px)/1.1 var(--serif); }
.score .of { color: var(--ink-2); font-size: .55em; margin-left: 4px; }
.result { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 4px 0 6px; }
.review li { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--line-2); border-radius: var(--radius); padding: 14px 16px 4px; margin: 12px 0; }
.review li.ok { border-left-color: var(--ok); }
.review li.bad { border-left-color: var(--bad); }
.rq { font-weight: 700; }
.ra { color: var(--ink-2); font-size: 15px; margin-bottom: 4px; }
.review li.bad .ra { color: var(--bad); }
.rc { color: var(--ok); font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.rx { font-size: 15px; }
.localq li { border-top: 1px solid var(--line); padding: 12px 0 2px; }

/* ---------- mock test bar ---------- */
.testbar { position: sticky; top: calc(61px + env(safe-area-inset-top)); z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--paper); padding: 8px 0; margin: -8px 0 4px; }
.clock { display: flex; flex-direction: column; gap: 2px; font-variant-numeric: tabular-nums; }
.clocklbl { color: var(--ink-2); font-size: 13px; line-height: 1.2; }
.testbar .btn { white-space: nowrap; }
#clock { font: 700 22px/1 var(--sans); }
.clock.low #clock { color: var(--bad); }
.confirm { background: var(--surface); border: 1.5px solid var(--ochre); border-radius: var(--radius); padding: 14px 16px 2px; margin: 16px 0; }

/* ---------- flashcards ---------- */
.flash { display: flex; flex-direction: column; justify-content: center; gap: 16px; width: 100%; min-height: 240px; margin: 12px 0 6px; padding: 24px 20px; text-align: left;
  background: var(--surface); border: 1.5px solid var(--line-2); border-radius: 18px; cursor: pointer; color: var(--ink); font: inherit; }
.flash .front { font: 400 clamp(22px, 6vw, 28px)/1.3 var(--serif); }
.flash .back { font-size: 18px; line-height: 1.5; padding-top: 16px; border-top: 1px solid var(--line); }
.flash .hint { color: var(--ink-2); font-size: 14px; }
.flash.flipped { border-color: var(--spruce); cursor: default; }
.boxinfo { color: var(--ink-2); font-size: 14px; }

/* ---------- progress ---------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 18px 0; }
.stats div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stats dt { color: var(--ink-2); font-size: 14px; }
.stats dd { margin: 2px 0 0; font: 400 30px/1.1 var(--serif); font-variant-numeric: tabular-nums; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, 1fr); } }
textarea { width: 100%; font: 14px/1.4 ui-monospace, Menlo, Consolas, monospace; color: var(--ink); background: var(--surface); border: 1.5px solid var(--line-2); border-radius: 10px; padding: 10px; resize: vertical; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: calc(var(--tabh) + 16px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 10px; font-size: 15px; max-width: calc(100% - 32px); transition: opacity .2s, transform .2s; z-index: 60; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } html { scroll-behavior: auto; } }
