/* ==========================================================================
   VERITATEM — editorial "ink & paper" design system
   Dark/light via [data-theme]; system font stacks (no external font deps).
   ========================================================================== */

:root {
  /* Light (default) — warm paper, deep ink, restrained verify-blue accent. */
  --paper:       #fbfaf7;
  --surface:     #ffffff;
  --surface-alt: #f3f1ea;
  --ink:         #14181d;
  --muted:       #566170;
  --rule:        #e4e1d9;
  --accent:      #155e8a;   /* verify blue */
  --accent-ink:  #0d3f5f;
  --signal:      #b3261e;   /* corrections / errata */
  --tag-bg:      #e8eef3;
  --tag-ink:     #0d3f5f;
  --focus:       #155e8a;

  --serif: "Iowan Old Style", "Charter", "Bitstream Charter", Georgia, Cambria, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --wrap: 72rem;
  --narrow: 44rem;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(20, 24, 29, .06), 0 4px 16px rgba(20, 24, 29, .06);
}

[data-theme="dark"] {
  --paper:       #0f1216;
  --surface:     #161b21;
  --surface-alt: #1b2129;
  --ink:         #e8eaed;
  --muted:       #9aa4b0;
  --rule:        #2a323c;
  --accent:      #6db3df;
  --accent-ink:  #a8d3ef;
  --signal:      #f0857d;
  --tag-bg:      #1e2732;
  --tag-ink:     #a8d3ef;
  --focus:       #6db3df;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 18px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--serif); line-height: 1.2; font-weight: 700; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-ink); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--accent); color: #fff; padding: .6rem 1rem; border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; color: #fff; }

.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: 1.25rem; }
.wrap.narrow { max-width: var(--narrow); }
.wrap.wide { max-width: 84rem; }

/* ---- Header / nav -------------------------------------------------------- */
.site-header {
  border-bottom: 1px solid var(--rule);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  position: sticky; top: 0; z-index: 20; backdrop-filter: saturate(1.2) blur(6px);
}
.header-inner { display: flex; align-items: center; gap: 1rem; padding-block: .85rem; }
.brand { display: flex; flex-direction: column; text-decoration: none; color: var(--ink); margin-right: auto; }
.brand-mark { font-family: var(--serif); font-weight: 700; letter-spacing: .12em; font-size: 1.3rem; }
.brand-tagline { font-size: .72rem; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }

.primary-nav ul { display: flex; gap: 1.15rem; list-style: none; margin: 0; padding: 0; align-items: center; }
.primary-nav a { color: var(--ink); text-decoration: none; font-size: .95rem; padding: .3rem 0; border-bottom: 2px solid transparent; }
.primary-nav a:hover, .primary-nav a[aria-current="page"] { border-bottom-color: var(--accent); }
.nav-cta a {
  border: 1px solid var(--rule); border-radius: var(--radius); padding: .4rem .8rem !important;
  border-bottom: 1px solid var(--rule) !important;
}
.nav-cta a:hover { border-color: var(--accent); }

.theme-toggle, .nav-toggle {
  background: transparent; border: 1px solid var(--rule); border-radius: var(--radius);
  color: var(--ink); width: 2.4rem; height: 2.4rem; font-size: 1.1rem; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.theme-toggle:hover, .nav-toggle:hover { border-color: var(--accent); }
.nav-toggle { display: none; }
.nav-toggle-bar, .nav-toggle-bar::before, .nav-toggle-bar::after {
  display: block; width: 18px; height: 2px; background: var(--ink); position: relative; content: "";
}
.nav-toggle-bar::before { position: absolute; top: -6px; }
.nav-toggle-bar::after { position: absolute; top: 6px; }

/* ---- Hero ---------------------------------------------------------------- */
.hero { border-bottom: 1px solid var(--rule); padding-block: 3.5rem 3rem; background: var(--surface-alt); }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: .74rem; color: var(--accent); font-weight: 600; margin: 0 0 .6rem; }
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); margin: 0 0 .8rem; letter-spacing: -.01em; }
.hero-lede { font-size: 1.2rem; color: var(--muted); max-width: 42rem; margin: 0 0 1.6rem; }
.hero-actions { display: flex; gap: .8rem; flex-wrap: wrap; }

.btn {
  display: inline-block; padding: .7rem 1.3rem; border-radius: var(--radius);
  text-decoration: none; font-weight: 600; font-size: .98rem; border: 1px solid transparent;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); color: #fff; }
.btn-ghost { border-color: var(--rule); color: var(--ink); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ---- Sections ------------------------------------------------------------ */
.section { padding-block: 3rem; }
.section-alt { background: var(--surface-alt); border-block: 1px solid var(--rule); }
.section-title { font-size: 1.6rem; margin: 0 0 1.4rem; }
.empty-note, .map-noscript { color: var(--muted); font-style: italic; }

.card-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.4rem; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1.3rem; box-shadow: var(--shadow); }
.card-meta { display: flex; gap: .6rem; align-items: center; font-size: .8rem; color: var(--muted); margin: 0 0 .5rem; }
.card-title { font-size: 1.25rem; margin: 0 0 .5rem; }
.card-title a { text-decoration: none; color: var(--ink); }
.card-title a:hover { color: var(--accent); }
.card-summary { color: var(--muted); margin: 0; font-size: .95rem; }

.tag { background: var(--tag-bg); color: var(--tag-ink); border-radius: 999px; padding: .1rem .6rem; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

.feature-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.4rem; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }
.feature-grid h3 { margin: 0 0 .4rem; font-size: 1.25rem; }
.feature-grid p { margin: 0; color: var(--muted); }
.trust-band { max-width: var(--narrow); }
.trust-band p { font-size: 1.1rem; }

/* ---- Article / prose ----------------------------------------------------- */
.page { padding-block: 2.5rem 3rem; }
.page-header, .article-header { margin-bottom: 1.5rem; }
.page-header h1, .article-header h1 { font-size: clamp(1.9rem, 4vw, 2.7rem); margin: 0 0 .6rem; }
.page-lede { font-size: 1.2rem; color: var(--muted); margin: 0 0 1rem; }
.byline { color: var(--muted); font-size: .9rem; display: flex; gap: 1rem; flex-wrap: wrap; }
.byline .author { color: var(--ink); font-weight: 600; }

.prose { font-size: 1.12rem; line-height: 1.75; }
.prose > * + * { margin-top: 1.1rem; }
.prose h2 { font-size: 1.6rem; margin-top: 2.4rem; }
.prose h3 { font-size: 1.28rem; margin-top: 1.8rem; }
.prose img { max-width: 100%; height: auto; border-radius: var(--radius); }
.prose blockquote { margin: 1.4rem 0; padding: .4rem 0 .4rem 1.2rem; border-left: 3px solid var(--accent); color: var(--muted); font-style: italic; }
.prose table { border-collapse: collapse; width: 100%; font-size: .95rem; }
.prose th, .prose td { border: 1px solid var(--rule); padding: .5rem .7rem; text-align: left; }
.prose th { background: var(--surface-alt); }
.prose code { background: var(--surface-alt); padding: .1rem .35rem; border-radius: 4px; font-size: .9em; }

/* Inline source callout (sourcebox shortcode) */
.sourcebox { border: 1px solid var(--rule); border-left: 3px solid var(--accent); background: var(--surface); border-radius: var(--radius); padding: .9rem 1.1rem; font-size: .95rem; }
.sourcebox .sourcebox-label { text-transform: uppercase; letter-spacing: .08em; font-size: .7rem; color: var(--accent); font-weight: 700; }

/* Sources list at article foot */
.sources { margin-top: 2.5rem; border-top: 1px solid var(--rule); padding-top: 1.2rem; }
.sources h2 { font-size: 1.1rem; text-transform: uppercase; letter-spacing: .06em; }
.sources ol { color: var(--muted); font-size: .92rem; padding-left: 1.2rem; }

.article-footer { margin-top: 2rem; border-top: 1px solid var(--rule); padding-top: 1.2rem; }
.correction-note { color: var(--muted); font-size: .92rem; }

/* ---- Maps ---------------------------------------------------------------- */
.map-figure { margin: 1.8rem 0; }
.leaflet-map { width: 100%; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface-alt); }
.map-figure figcaption { font-size: .88rem; color: var(--muted); margin-top: .6rem; }
.map-caption { display: block; font-weight: 600; color: var(--ink); }
.map-provenance { display: block; margin-top: .2rem; }
.map-error { color: var(--signal); padding: 1rem; }

/* ---- Footer -------------------------------------------------------------- */
.site-footer { border-top: 1px solid var(--rule); background: var(--surface-alt); margin-top: 3rem; padding-block: 2.5rem 1.5rem; }
.footer-grid { display: grid; gap: 2rem; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); }
.footer-heading { font-family: var(--serif); font-weight: 700; margin: 0 0 .7rem; font-size: 1rem; }
.footer-col ul { list-style: none; margin: 0; padding: 0; }
.footer-col li { margin-bottom: .4rem; }
.footer-col a { color: var(--ink); text-decoration: none; font-size: .93rem; }
.footer-col a:hover { color: var(--accent); text-decoration: underline; }
.footer-note { color: var(--muted); font-size: .9rem; margin: 0; }
.footer-legal { border-top: 1px solid var(--rule); margin-top: 2rem; padding-top: 1.2rem; color: var(--muted); font-size: .82rem; }

/* ---- Corrections list marker -------------------------------------------- */
.correction-entry { border-left: 3px solid var(--signal); padding-left: 1rem; }

/* ---- Responsive ---------------------------------------------------------- */
@media (max-width: 48rem) {
  .nav-toggle { display: inline-flex; order: 3; }
  .theme-toggle { order: 2; }
  .primary-nav { display: none; order: 4; width: 100%; }
  .primary-nav.is-open { display: block; }
  .primary-nav ul { flex-direction: column; align-items: flex-start; gap: .3rem; padding-top: .6rem; }
  .header-inner { flex-wrap: wrap; }
}

/* ---- Print --------------------------------------------------------------- */
/* Article hero image (single) + card thumbnail (list) */
.article-hero { margin: 0 0 2rem; }
.article-hero img { display: block; width: 100%; height: auto; border-radius: var(--radius); border: 1px solid var(--rule); }
.article-hero figcaption { margin-top: .5rem; font-size: .8rem; color: var(--muted); font-style: italic; }
.card-hero { display: block; margin: -1.3rem -1.3rem 1rem; border-radius: var(--radius) var(--radius) 0 0; overflow: hidden; }
.card-hero img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }

/* Public article feedback — a clear button that expands a compact form */
.feedback { margin-top: 2.2rem; font-size: .88rem; }
.feedback > summary {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .5rem 1rem; border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); font-weight: 600; cursor: pointer;
  list-style: none; -webkit-tap-highlight-color: transparent;
}
.feedback > summary::-webkit-details-marker { display: none; }
.feedback > summary::before { content: "\2691"; }              /* flag */
.feedback > summary::after { content: "\25BE"; color: var(--muted); font-size: .8em; transition: transform .15s ease; }  /* caret */
.feedback > summary:hover { border-color: var(--accent); color: var(--accent); }
.feedback > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.feedback[open] > summary { margin-bottom: .9rem; border-color: var(--accent); color: var(--accent); }
.feedback[open] > summary::after { transform: rotate(180deg); }
.feedback form { display: flex; flex-direction: column; gap: .55rem; max-width: 34rem; }
.fb-row { display: flex; gap: .5rem; }
.feedback select { flex: 1 1 auto; }
.feedback select, .feedback textarea { font: inherit; padding: .45rem .55rem; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); color: var(--ink); }
.feedback .btn { flex: none; padding: .45rem 1.1rem; }
.fb-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.fb-status { margin: 0; font-size: .85rem; min-height: 1em; color: var(--muted); }
.fb-status.ok { color: var(--tag-ink); }
.fb-status.err { color: var(--signal); }

@media print {
  .site-header, .site-footer, .hero-actions, .theme-toggle, .nav-toggle, .correction-note, .feedback { display: none; }
  body { background: #fff; color: #000; }
  a { color: #000; text-decoration: underline; }
}
