/* ---------- tokens ---------- */
:root {
  color-scheme: light;
  --paper: #f3ecdf;
  --surface: #fbf7ef;
  --ink: #1c1814;
  --ink-soft: #3a332b;
  --ink-muted: #5a5045;
  --rule: #d6cab4;
  --accent: #7a1f16;
  --accent-soft: #a8261c;
  --on-accent: #fff8ef;
  --gold: #634306;
  --shadow: 0 1px 2px #1c181414, 0 8px 24px #1c181412;
  --display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --gutter: clamp(1rem, 4vw, 2.5rem);
  --bar: 2.75rem;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #171310;
    --surface: #211b16;
    --ink: #f0e7d8;
    --ink-soft: #d8ccb8;
    --ink-muted: #b3a48d;
    --rule: #4a4036;
    --accent: #e08073;
    --accent-soft: #e08073;
    --on-accent: #171310;
    --gold: #d9a94e;
    --shadow: 0 1px 2px #00000066, 0 8px 24px #00000055;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #171310;
  --surface: #211b16;
  --ink: #f0e7d8;
  --ink-soft: #d8ccb8;
  --ink-muted: #b3a48d;
  --rule: #4a4036;
  --accent: #e08073;
  --accent-soft: #e08073;
  --on-accent: #171310;
  --gold: #d9a94e;
  --shadow: 0 1px 2px #00000066, 0 8px 24px #00000055;
}
/* ---------- base ---------- */
* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--bar) + 1rem); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.65;
}
main, footer { max-width: 60rem; margin: 0 auto; padding: 0 var(--gutter); }
section { margin: 3.5rem 0; }
h1, h2, h3 { font-family: var(--display); line-height: 1.15; text-wrap: balance; }
h1 { font-size: clamp(2rem, 5.4vw, 3.4rem); margin: 0.6rem 0 1rem; }
h2 { font-size: clamp(1.5rem, 3.4vw, 2.2rem); margin: 0 0 0.6rem; }
h3 { font-size: 1.25rem; margin: 1.6rem 0 0.4rem; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 2px; }
.skip {
  position: absolute; left: -999px; top: 0; z-index: 50;
  background: var(--ink); color: var(--paper); padding: 0.5rem 1rem;
}
.skip:focus { left: 0.5rem; top: 0.5rem; }
/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 0.75rem;
  min-height: var(--bar); max-height: var(--bar);
  padding: 0 var(--gutter); overflow: hidden;
  background: var(--surface); border-bottom: 1px solid var(--rule);
  font-family: var(--sans); font-size: 0.85rem; white-space: nowrap;
}
.topbar .home { font-weight: 700; text-decoration: none; color: var(--ink); }
.topnav { display: flex; gap: 0.7rem; overflow-x: auto; scrollbar-width: none; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a { text-decoration: none; color: var(--ink-soft); }
.topnav a:hover { color: var(--accent); }
.langmenu { margin-left: auto; display: flex; gap: 0.6rem; }
.langmenu a { color: var(--ink-soft); }
#theme {
  border: 1px solid var(--rule); border-radius: 999px;
  background: none; color: var(--ink); cursor: pointer;
  width: 2rem; height: 2rem; padding: 0.3rem; flex: none;
}
#theme svg { width: 100%; height: 100%; display: none; }
:root:not([data-theme="dark"]) #theme .i-moon { display: block; }
:root[data-theme="dark"] #theme .i-sun { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) #theme .i-moon { display: none; }
  :root:not([data-theme="light"]):not([data-theme="dark"]) #theme .i-sun { display: block; }
}
/* ---------- hero ---------- */
.hero { margin-top: 2rem; }
.kicker {
  font-family: var(--sans); font-size: 0.85rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold);
  margin: 0;
}
.deck { font-size: 1.3rem; color: var(--ink-soft); max-width: 44rem; }
.byline { font-family: var(--sans); font-size: 0.9rem; color: var(--ink-muted); }
.lede { font-size: 1.2rem; color: var(--ink-soft); }
/* ---------- figures ---------- */
.fig { margin: 1.6rem 0; }
.fig img { width: 100%; height: auto; display: block; border-radius: 4px; box-shadow: var(--shadow); }
.fig figcaption { font-size: 0.95rem; color: var(--ink-muted); margin-top: 0.5rem; }
.fig .credit { font-size: 0.85rem; }
/* ---------- chapters ---------- */
.chnum {
  font-family: var(--sans); font-size: 0.85rem; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent);
  margin-bottom: 0.2rem;
}
.scene {
  margin: 1.6rem 0; padding: 1rem 1.2rem;
  border-left: 4px solid var(--accent-soft);
  background: var(--surface); border-radius: 0 4px 4px 0;
}
.scene .sq { font-size: 1.2rem; margin: 0 0 0.4rem; }
.scene .sg { margin: 0 0 0.4rem; color: var(--ink-soft); }
.scene cite { font-style: normal; font-size: 0.9rem; color: var(--ink-muted); }
.meanwhile {
  margin: 1.2rem 0; padding: 0.2rem 1rem;
  border: 1px dashed var(--rule); border-radius: 4px;
  font-size: 1.02rem;
}
/* ---------- reader ---------- */
.tnote { font-size: 0.95rem; color: var(--ink-muted); }
.doc { margin: 2rem 0; padding: 1.2rem 1.4rem; background: var(--surface); border: 1px solid var(--rule); border-radius: 6px; }
.docdate { font-family: var(--sans); font-size: 0.9rem; color: var(--gold); font-weight: 700; }
.clause { margin: 0.9rem 0; border-top: 1px solid var(--rule); padding-top: 0.7rem; }
.clause summary { cursor: pointer; font-weight: 700; font-family: var(--display); font-size: 1.1rem; }
.clause .latin { font-style: italic; }
.reader-actions { display: none; gap: 0.6rem; margin: 0.6rem 0; }
html.js .reader-actions { display: flex; }
/* ---------- numbers ---------- */
.numbers { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; }
.numbers li { background: var(--surface); border: 1px solid var(--rule); border-radius: 6px; padding: 1rem 1.2rem; }
.nval { display: block; font-family: var(--display); font-size: 2.2rem; font-weight: 700; color: var(--accent); }
/* ---------- game ---------- */
.cards { display: grid; gap: 1.2rem; }
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: 6px; padding: 1.2rem 1.4rem; }
.card .q { font-weight: 700; margin-top: 0; }
.card-buttons { display: none; gap: 0.8rem; flex-wrap: wrap; margin: 0.8rem 0; }
html.js .card-buttons { display: flex; }
.card-buttons button, .score-actions button, .reader-actions button {
  font-family: var(--sans); font-size: 1rem; min-height: 44px; padding: 0.6rem 1.1rem;
  border: 1px solid var(--accent); border-radius: 6px;
  background: var(--surface); color: var(--ink); cursor: pointer;
}
.card-buttons button:hover, .score-actions button:hover, .reader-actions button:hover {
  background: var(--accent); color: var(--on-accent);
}
.card.answered button[data-choice] { opacity: 0.55; }
.card.answered button.picked { opacity: 1; outline: 3px solid var(--accent-soft); }
.card.right { border-color: #2e7d32; }
.card.wrong { border-color: var(--accent-soft); }
.card-answer { margin-top: 0.6rem; }
.card-answer summary { cursor: pointer; font-weight: 700; }
.score { font-family: var(--display); font-size: 1.4rem; font-weight: 700; }
.score-actions { display: none; gap: 0.8rem; align-items: center; }
html.js .score-actions { display: flex; }
.copied { font-family: var(--sans); font-size: 0.9rem; color: var(--ink-muted); }
/* ---------- myths / sources ---------- */
.myth { border-top: 1px solid var(--rule); padding: 0.4rem 0 1rem; }
.myth .claim { color: var(--ink-soft); }
.srclist { padding-left: 1.2rem; }
.srclist li { margin: 0.5rem 0; overflow-wrap: anywhere; }
.srclist a { font-size: 0.9rem; font-family: var(--sans); }
footer { border-top: 1px solid var(--rule); margin: 3rem auto 2rem; padding-top: 1rem; font-size: 0.95rem; color: var(--ink-muted); }
/* ---------- motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
