:root {
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --greek: "Gentium Plus", "SBL Greek", "Noto Serif", "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Colour modes. The reader picks one from the gear menu (web/site.js), which
   sets data-theme on <html>; with no choice, the page follows the device's
   light or dark setting. Every mode defines the same tokens. */
:root, :root[data-theme="light"] {
  color-scheme: light;
  --bg: #fbfaf7;
  --surface: #ffffff;
  --text: #1f1d1a;
  --muted: #6b665e;
  --line: #e4e0d8;
  --accent: #7a4b14;
  --accent-soft: #f3e9dc;
  --mark: #fff1c2;
  --warn: #8a5a00;
  --warn-bg: #fff6e0;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #171614;
    --surface: #201e1b;
    --text: #ece8e1;
    --muted: #a39d93;
    --line: #34312c;
    --accent: #e0a96a;
    --accent-soft: #3a2e20;
    --mark: #4a3d16;
    --warn: #f0c060;
    --warn-bg: #2f2716;
  }
}
/* Sepia: warm parchment, softer than white for long reading. */
:root[data-theme="sepia"] {
  color-scheme: light;
  --bg: #f4ecd8;
  --surface: #fbf5e6;
  --text: #40331f;
  --muted: #6f5e46;
  --line: #ddcfb1;
  --accent: #74450f;
  --accent-soft: #ecdcc0;
  --mark: #f3dfa2;
  --warn: #6f4e10;
  --warn-bg: #efe0c2;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171614;
  --surface: #201e1b;
  --text: #ece8e1;
  --muted: #a39d93;
  --line: #34312c;
  --accent: #e0a96a;
  --accent-soft: #3a2e20;
  --mark: #4a3d16;
  --warn: #f0c060;
  --warn-bg: #2f2716;
}
/* Night: near-black with dimmed text, for reading in the dark. */
:root[data-theme="night"] {
  color-scheme: dark;
  --bg: #000000;
  --surface: #0e0d0c;
  --text: #d4cec4;
  --muted: #918a7f;
  --line: #27241f;
  --accent: #c9965a;
  --accent-soft: #241a10;
  --mark: #3a2f12;
  --warn: #d9ad55;
  --warn-bg: #1f1a0e;
}
/* High contrast: black on white, strong edges, links always underlined. */
:root[data-theme="contrast"] {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --text: #000000;
  --muted: #2b2b2b;
  --line: #000000;
  --accent: #5a2d00;
  --accent-soft: #f2e3cf;
  --mark: #ffe25c;
  --warn: #000000;
  --warn-bg: #ffe25c;
}
:root[data-theme="contrast"] a { text-decoration: underline; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.6 var(--sans);
}
a { color: var(--accent); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

header.site {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
header.site .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 0 24px; min-height: 56px; }
header.site .brand { font-family: var(--serif); font-size: 20px; color: var(--text); text-decoration: none; white-space: nowrap; }
header.site nav { display: flex; gap: 16px; margin-left: auto; font-size: 15px; }

/* The colour-mode menu: a gear at the right of the header. */
.prefs { position: relative; }
.prefs-btn {
  display: grid; place-items: center; width: 36px; height: 36px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--muted); cursor: pointer;
}
.prefs-btn:hover, .prefs-btn[aria-expanded="true"] { color: var(--text); border-color: var(--muted); }
.prefs-btn:focus-visible, .prefs-menu button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.prefs-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; width: 240px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.18); padding: 10px;
}
.prefs-label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 2px 6px 6px; }
.prefs-menu [role="radiogroup"] { display: grid; gap: 2px; }
.prefs-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px;
  border: 0; border-radius: 6px; background: none; color: var(--text); font: inherit; font-size: 15px; text-align: left; cursor: pointer;
}
.prefs-menu button:hover { background: var(--accent-soft); }
.prefs-menu button[aria-checked="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; box-shadow: inset 0 0 0 1.5px var(--accent); }
.swatch {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, var(--sw-bg) 50%, var(--sw-accent) 50%);
  box-shadow: inset 0 0 0 1px rgb(127 127 127 / 0.5);
}
.prefs-menu .check { margin-left: auto; visibility: hidden; }
.prefs-menu button[aria-checked="true"] .check { visibility: visible; }
header.site nav a { color: var(--muted); text-decoration: none; }
header.site nav a:hover, header.site nav a[aria-current] { color: var(--text); }

footer.site { border-top: 1px solid var(--line); margin-top: 64px; padding: 24px 0 40px; color: var(--muted); font-size: 14px; }

/* Home and prose pages */
.hero { padding: 56px 0 24px; max-width: 720px; }
.hero h1 { font-family: var(--serif); font-weight: normal; font-size: clamp(34px, 6vw, 52px); line-height: 1.15; margin: 0 0 16px; }
.hero p { font-size: 19px; color: var(--muted); margin: 0 0 24px; }
.button { display: inline-block; background: var(--accent); color: var(--bg); padding: 10px 18px; border-radius: 6px; text-decoration: none; font-weight: 600; }
.points { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 32px 0; }
.points div { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 16px 18px; }
.points h2 { font-size: 16px; margin: 0 0 6px; }
.points p { margin: 0; color: var(--muted); font-size: 15px; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.button.ghost { background: none; color: var(--accent); border: 1px solid var(--accent); }
.label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 0 4px; }
.label:first-child { margin-top: 0; }

.example, .progress, .involve { margin: 40px 0; }
.example h2, .progress h2, .involve h2 { font-family: var(--serif); font-weight: normal; font-size: 28px; margin: 0 0 16px; }
.example-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 24px; align-items: start;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 20px 22px; }
.example .greek { margin: 0; }
.example mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 2px; }
.lvl { display: grid; grid-template-columns: 84px 1fr; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.lvl:first-of-type { border-top: 0; }
.lvl .tag { font-size: 13px; font-weight: 600; color: var(--accent); padding-top: 3px; }
.lvl p { margin: 0; font-family: var(--serif); font-size: 19px; line-height: 1.5; }
.card.decision { cursor: default; margin: 0; padding: 16px 18px; background: var(--accent-soft); border-color: transparent; }
.card.decision .choice { font-family: var(--serif); font-size: 20px; font-weight: normal; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0 0 16px; }
.stats div { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; }
.stats b { display: block; font-family: var(--serif); font-size: 34px; font-weight: normal; line-height: 1.1; }
.stats span { color: var(--muted); font-size: 14px; }
.progress p, .involve li { max-width: 72ch; }
.passages { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0; }
.passages a { display: inline-block; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 14px; text-decoration: none; }
.involve ul { padding-left: 20px; }
.involve li { margin: 6px 0; }

.prose { max-width: 720px; padding: 32px 0; }

/* Articles */
.article-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; max-width: 760px; }
.article-list a { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px 18px; text-decoration: none; }
.article-list a:hover { border-color: var(--accent); }
.a-title { display: block; font-family: var(--serif); font-size: 20px; color: var(--text); }
.a-summary { display: block; color: var(--muted); font-size: 15px; margin-top: 2px; }
.article { font-size: 18px; }
.article p, .article li { line-height: 1.7; }
.article .crumb { font-size: 14px; margin: 0; }
.prose.article h1 { margin: 6px 0 8px; line-height: 1.2; }
.article .byline { color: var(--muted); font-size: 14px; margin: 0 0 28px; }
.article .status { background: var(--warn-bg); color: var(--warn); border-radius: 4px; padding: 1px 6px; }
.prose.article h2 { font-family: var(--serif); font-weight: normal; font-size: 24px; margin: 36px 0 8px; }
.article blockquote { margin: 20px 0; padding: 4px 0 4px 18px; border-left: 3px solid var(--accent); font-family: var(--serif); font-size: 20px; }
.article blockquote p { margin: 0; }
.article .greek { font-size: 1.1em; }
.more { margin: 8px 0 0; }
.more h2, .latest h2 { font-family: var(--serif); font-weight: normal; font-size: 24px; margin: 0 0 12px; }
.latest { margin: 40px 0; }
.prose h1 { font-family: var(--serif); font-weight: normal; font-size: 34px; }
.prose h2 { font-size: 18px; margin-top: 32px; }

/* Reader */
.notice {
  background: var(--warn-bg); color: var(--warn);
  border-radius: 6px; padding: 8px 12px; font-size: 14px; margin: 16px 0 0;
}
.controls { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--line); }
.control { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--surface); }
.seg button {
  border: 0; background: none; color: var(--text); font: inherit; font-size: 14px;
  padding: 6px 12px; cursor: pointer; border-left: 1px solid var(--line);
}
.seg button:first-child { border-left: 0; }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.seg button:focus-visible, .verse:focus-visible, .word:focus-visible, .card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hint { font-size: 13px; color: var(--muted); margin: 4px 0 0; max-width: 60ch; }

.reader { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 32px; align-items: start; }
.passage h1 { font-family: var(--serif); font-weight: normal; font-size: 30px; margin: 24px 0 4px; }
.passage .sub { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
.text { font-family: var(--serif); font-size: 21px; line-height: 1.75; }
.verse { cursor: pointer; border-radius: 3px; padding: 1px 0; }
.verse:hover { background: var(--accent-soft); }
.verse[aria-current="true"] { background: var(--mark); }
.verse sup { font-family: var(--sans); font-size: 12px; color: var(--accent); font-weight: 700; margin-right: 3px; }
.verse .fn { font-family: var(--sans); font-size: 12px; color: var(--muted); margin-left: 2px; }

.panel {
  position: sticky; top: 16px; margin-top: 24px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 18px 20px; max-height: calc(100vh - 32px); overflow: auto;
}
.panel h2 { font-size: 18px; margin: 0 0 4px; }
.panel .empty { color: var(--muted); font-size: 15px; }
.panel h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 20px 0 8px; }
.status { display: inline-block; font-size: 12px; background: var(--warn-bg); color: var(--warn); border-radius: 4px; padding: 1px 6px; }
.greek { font-family: var(--greek); font-size: 21px; line-height: 1.9; }
.word { cursor: pointer; border-radius: 3px; }
.word:hover, .word.on { background: var(--mark); }
.wordinfo { font-size: 14px; color: var(--muted); min-height: 1.4em; margin: 2px 0 0; }
.gloss { font-style: italic; color: var(--muted); font-size: 15px; margin: 0; }
.card { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 0 0 8px; cursor: pointer; }
.card.on { border-color: var(--accent); }
.card .cat { font-size: 12px; color: var(--muted); }
.card .choice { font-weight: 600; margin: 2px 0; }
.card .alts { font-size: 14px; color: var(--muted); margin: 2px 0; }
.card .why { font-size: 15px; margin: 4px 0 0; }
.badge { display: inline-block; font-size: 11px; border-radius: 4px; padding: 0 5px; margin-left: 4px; background: var(--accent-soft); color: var(--accent); }
.badge.unc { background: var(--warn-bg); color: var(--warn); }

/* Phones: the nav links move to their own row under the brand and gear. */
@media (max-width: 560px) {
  header.site .wrap { padding-top: 10px; }
  header.site .prefs { margin-left: auto; }
  header.site nav { order: 3; width: 100%; margin-left: 0; gap: 20px; padding: 8px 0 10px; }
}

@media (max-width: 860px) {
  .reader { grid-template-columns: 1fr; }
  .example-grid { grid-template-columns: 1fr; padding: 16px; }
  .lvl { grid-template-columns: 1fr; gap: 2px; }
  .stats { gap: 8px; }
  .stats div { padding: 10px 12px; }
  .stats b { font-size: 26px; }
  .stats span { font-size: 13px; }
  .panel { position: static; max-height: none; }
}
