/* ------------------------------------------------------------------
   Civic letterpress.

   The audience is an adult with a naturalization interview scheduled and
   something real at stake. The design borrows from federal print rather than
   from quiz apps: warm paper, navy ink, one oxblood accent, hairline rules,
   letterspaced small caps. Nothing is gamified and nothing is cute.
   ------------------------------------------------------------------ */

:root {
  --paper:      #f2ede1;
  --paper-2:    #e8e1d1;
  --card:       #fbf8f1;
  --ink:        #16232f;
  --ink-soft:   #4a5a68;
  --ink-faint:  #5f6c77;   /* 4.61 on paper, 5.08 on card — AA */
  --rule:       #cdc2ab;
  --accent:     #8c2f1e;
  --accent-2:   #a8543f;
  --brass:      #7d6130;   /* 4.96 on paper, 5.46 on card — AA */
  --pass:       #2c5a44;
  --fail:       #8c2f1e;

  --display: "Newsreader", "Iowan Old Style", Palatino, "Times New Roman", serif;
  --body: "Public Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;

  --measure: 34rem;
  --step: clamp(0.9rem, 0.85rem + 0.3vw, 1.05rem);
  --radius: 3px;
  --shadow: 0 1px 0 rgba(22, 35, 47, .06), 0 12px 28px -18px rgba(22, 35, 47, .38);
}

/* Dark is the viewer's system preference; every token is redefined, never
   left to inherit a light value. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:   #10171e;
    --paper-2: #0b1116;
    --card:    #16202a;
    --ink:     #ece4d4;
    --ink-soft:#a9b6c0;
    --ink-faint:#909da6;  /* 6.50 on paper, 5.93 on card — AA */
    --rule:    #2c3a46;
    --accent:  #d4785f;
    --accent-2:#e09277;
    --brass:   #c2a163;
    --pass:    #6fae8f;
    --fail:    #d4785f;
    --shadow: 0 1px 0 rgba(0,0,0,.3), 0 14px 30px -18px rgba(0,0,0,.8);
  }
}

*, *::before, *::after { box-sizing: border-box; }

/* The hidden attribute must win over any display our own rules set, or a
   `display: block` component quietly reappears as an empty box. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background-color: var(--paper);
  /* Paper tooth: a faint dual gradient wash rather than a flat fill. */
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(154,123,63,.10), transparent 70%),
    radial-gradient(ellipse 60% 40% at 90% 100%, rgba(140,47,30,.06), transparent 70%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--body);
  font-size: var(--step);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap { width: min(100% - 2.5rem, 60rem); margin-inline: auto; }

.skip {
  position: absolute; left: -999px;
  background: var(--ink); color: var(--paper); padding: .75rem 1rem; z-index: 10;
}
.skip:focus { left: 1rem; top: 1rem; }

/* ── Masthead ─────────────────────────────────────────────── */
.masthead { border-bottom: 1px solid var(--rule); background: color-mix(in srgb, var(--paper) 80%, transparent); backdrop-filter: blur(6px); position: sticky; top: 0; z-index: 5; }
.masthead__inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-block: .9rem; }

.wordmark { display: inline-flex; align-items: center; min-height: 44px; gap: .6rem; text-decoration: none; color: inherit; }
.wordmark__mark {
  width: 1.1rem; height: 1.1rem; border: 2px solid var(--accent); border-radius: 50%;
  position: relative; flex: none;
}
.wordmark__mark::after {
  content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--accent);
}
.wordmark__text { font-family: var(--display); font-size: 1.12rem; letter-spacing: .01em; }

.masthead__nav { display: flex; gap: .25rem; }
.tab {
  display: inline-flex; align-items: center;
  font: inherit; font-size: .78rem; font-weight: 500; letter-spacing: .1em; text-transform: uppercase;
  background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--ink-soft); padding: .55rem .7rem; cursor: pointer; min-height: 44px;
}
.tab:hover { color: var(--ink); }
.tab[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Type ─────────────────────────────────────────────────── */
.view { padding-block: clamp(2rem, 5vw, 4rem) 5rem; animation: rise .5s cubic-bezier(.2,.7,.3,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.eyebrow {
  font-size: .72rem; font-weight: 700; letter-spacing: .18em; text-transform: uppercase;
  color: var(--brass); margin: 0 0 .9rem;
}
.eyebrow::after { content: ""; display: block; width: 2.2rem; height: 1px; background: var(--brass); margin-top: .55rem; opacity: .6; }

.display {
  font-family: var(--display); font-weight: 300;
  font-size: clamp(2.1rem, 1.3rem + 3.4vw, 3.6rem);
  line-height: 1.08; letter-spacing: -0.015em; margin: 0 0 1.1rem;
  text-wrap: balance;
}
.display em { font-style: italic; color: var(--accent); }

.standfirst { font-size: 1.06rem; color: var(--ink-soft); max-width: var(--measure); margin: 0 0 1.6rem; }
.lede { margin-bottom: 2.4rem; }
.hint { font-size: .84rem; color: var(--ink-faint); margin: .45rem 0 0; max-width: var(--measure); }
.prompt { font-family: var(--display); font-style: italic; font-size: 1.05rem; color: var(--ink-soft); margin: 0 0 1rem; }

/* ── Card ─────────────────────────────────────────────────── */
.card {
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: clamp(1.25rem, 3vw, 2rem); box-shadow: var(--shadow); max-width: 42rem;
  position: relative;
}
/* Engraved top rule, the way a printed form is ruled off. */
.card::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 3px;
  background: linear-gradient(90deg, var(--accent) 0 22%, var(--brass) 22% 34%, transparent 34%);
  border-radius: var(--radius) var(--radius) 0 0;
}
.card__title { font-family: var(--display); font-weight: 400; font-size: 1.3rem; margin: .35rem 0 1.4rem; }

/* ── Form ─────────────────────────────────────────────────── */
.field { margin-bottom: 1.15rem; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 1.15rem; }
label {
  display: block; font-size: .76rem; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--ink-soft); margin-bottom: .45rem;
}
input[type="date"], input[type="number"], select {
  font: inherit; width: 100%; min-height: 48px; padding: .6rem .75rem;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--rule); border-radius: var(--radius);
}
input:focus-visible, select:focus-visible, button:focus-visible, .linkish:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.error { color: var(--fail); font-weight: 500; margin: 0 0 1rem; }

.verdict {
  display: block; border-left: 3px solid var(--brass); background: var(--paper-2);
  padding: .9rem 1rem; margin: 0 0 1.35rem; font-size: .95rem;
}
.verdict strong { font-family: var(--display); font-size: 1.15rem; font-weight: 500; display: block; margin-bottom: .15rem; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  font: inherit; font-weight: 500; letter-spacing: .02em;
  min-height: 48px; padding: .7rem 1.4rem; border-radius: var(--radius);
  border: 1px solid transparent; cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background-color .12s ease;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); color: #fdf9f2; box-shadow: 0 2px 0 color-mix(in srgb, var(--accent) 70%, black); }
.btn--primary:hover { background: var(--accent-2); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn--ghost:hover { background: var(--paper-2); }
.btn--yes { background: var(--pass); color: #f4faf7; box-shadow: 0 2px 0 color-mix(in srgb, var(--pass) 70%, black); }
.btn--no  { background: transparent; color: var(--ink); border-color: var(--ink-faint); }
.btn--no:hover { background: var(--paper-2); }

.linkish {
  font: inherit; font-size: .85rem; background: none; border: 0; color: var(--ink-faint);
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
  padding: .75rem 0; min-height: 44px; margin-top: 1.5rem;
}
.linkish:hover { color: var(--accent); }
.actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 2rem; }

/* ── The officer's tally ──────────────────────────────────── */
.exam__head { margin-bottom: 2rem; }
.tally { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .7rem; }
.tally__mark {
  width: 1.5rem; height: 2rem; border: 1px solid var(--rule); border-radius: 2px;
  background: var(--card); position: relative;
}
.tally__mark--right { background: var(--pass); border-color: var(--pass); }
.tally__mark--wrong { background: transparent; border-color: var(--fail); }
/* A struck diagonal for a wrong answer: a mark on a form, not an emoji. */
.tally__mark--wrong::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top right, transparent calc(50% - 1px), var(--fail) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px));
}
.tally__mark--current { border-color: var(--accent); border-width: 2px; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { border-color: color-mix(in srgb, var(--accent) 35%, transparent); } }
.tally__legend { font-size: .82rem; color: var(--ink-soft); margin: 0; }

/* ── Question ─────────────────────────────────────────────── */
.question { max-width: 42rem; }
.question__number { font-size: .74rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--brass); margin: .3rem 0 .8rem; }
.question__text { font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.1rem); margin-bottom: 1.8rem; }
.question__act { animation: rise .35s ease both; }

.answers { border-top: 1px solid var(--rule); padding-top: 1.2rem; margin-bottom: 1.6rem; }
.answers__label { font-size: .74rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-faint); margin: 0 0 .7rem; }
.answers__list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.answers__list li {
  font-family: var(--display); font-size: 1.12rem; line-height: 1.4;
  padding-left: 1.1rem; position: relative;
}
.answers__list li::before { content: ""; position: absolute; left: 0; top: .62em; width: .5rem; height: 1px; background: var(--brass); }
.answers__note {
  margin: 1rem 0 0; padding: .7rem .9rem; background: var(--paper-2);
  border-left: 3px solid var(--brass); font-size: .88rem; color: var(--ink-soft);
}
.judge { display: flex; flex-wrap: wrap; gap: .75rem; }

/* ── Result ───────────────────────────────────────────────── */
.stamp {
  display: inline-block; border: 3px double currentColor; border-radius: 4px;
  padding: .5rem 1.4rem; margin-bottom: 1.5rem; transform: rotate(-2.5deg);
  font-family: var(--display); font-weight: 500; font-size: 1.5rem;
  letter-spacing: .16em; text-transform: uppercase;
  animation: stamp .45s cubic-bezier(.2,1.4,.4,1) both;
}
.stamp--pass { color: var(--pass); }
.stamp--fail { color: var(--fail); }
@keyframes stamp { from { opacity: 0; transform: rotate(-2.5deg) scale(1.7); } }
.result__early {
  max-width: var(--measure); border-left: 3px solid var(--brass);
  padding: .8rem 1rem; background: var(--paper-2); font-size: .92rem; margin: 0 0 2rem;
}

.concept-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }
.concept-list button {
  font: inherit; text-align: left; width: 100%; background: var(--paper); cursor: pointer;
  border: 1px solid var(--rule); border-radius: var(--radius); padding: .8rem 1rem; min-height: 48px;
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; color: inherit;
}
.concept-list button:hover { border-color: var(--accent); background: var(--paper-2); }
.concept-list .count { font-size: .76rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint); flex: none; }

/* ── Study ────────────────────────────────────────────────── */
.filterbar { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; padding-bottom: 1.4rem; border-bottom: 1px solid var(--rule); margin-bottom: 2rem; }
.filterbar__label { margin: 0; }
.filterbar select { width: auto; min-width: 20rem; max-width: 100%; }
.switch { display: inline-flex; align-items: center; gap: .5rem; text-transform: none; letter-spacing: 0; font-size: .9rem; font-weight: 400; color: var(--ink); margin: 0; }
.switch input { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }

.domain { margin-bottom: 2.6rem; }
.domain__title { font-family: var(--display); font-weight: 400; font-size: 1.7rem; margin: 0 0 .25rem; }
.domain__rule { height: 1px; background: linear-gradient(90deg, var(--brass), transparent); margin-bottom: 1.2rem; }

.concept { border: 1px solid var(--rule); border-radius: var(--radius); background: var(--card); margin-bottom: .6rem; overflow: hidden; }
.concept > summary {
  cursor: pointer; padding: .9rem 1.1rem; min-height: 48px; display: flex;
  justify-content: space-between; align-items: center; gap: 1rem; list-style: none;
  font-weight: 500;
}
.concept > summary::-webkit-details-marker { display: none; }
/* Let the topic name take the slack so its count and the toggle stay paired
   at the right edge, rather than the count floating mid-row. */
.concept > summary > span:first-child { flex: 1; }
.concept > summary .count { margin-right: .25rem; }
.concept > summary::after { content: "+"; font-family: var(--display); font-size: 1.4rem; color: var(--brass); flex: none; line-height: 1; }
.concept[open] > summary::after { content: "–"; }
.concept[open] > summary { border-bottom: 1px solid var(--rule); }
.concept__body { padding: .4rem 1.1rem 1.1rem; }

.qa { padding: 1rem 0; border-bottom: 1px dotted var(--rule); }
.qa:last-child { border-bottom: 0; }
.qa__q { font-family: var(--display); font-size: 1.12rem; margin: 0 0 .1rem; }
.qa__meta { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); margin: 0 0 .55rem; }
.qa__badge { color: var(--accent); font-weight: 700; }
.qa__a { margin: 0; padding: 0; list-style: none; display: grid; gap: .25rem; }
.qa__a li { padding-left: 1.1rem; position: relative; color: var(--ink-soft); }
.qa__a li::before { content: ""; position: absolute; left: 0; top: .68em; width: .5rem; height: 1px; background: var(--brass); }
.qa__note { font-size: .84rem; color: var(--ink-faint); font-style: italic; margin: .4rem 0 0; }
.empty { color: var(--ink-faint); font-style: italic; }

/* ── Footer ───────────────────────────────────────────────── */
.footer { border-top: 1px solid var(--rule); padding-block: 2rem 3rem; font-size: .82rem; color: var(--ink-faint); }
.footer p { max-width: 46rem; margin: 0 0 .5rem; }
.footer__meta { font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
