/* Base palette: light by default, dark when the reader prefers it. */
:root {
  --bg: #fdfdfb;
  --fg: #1c1c1a;
  --muted: #5d5d57;
  --rule: #e2e0d8;
  --accent: #1d5fa8;
  --accent-bg: #eef3fa;
  --maxw: 44rem;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181a;
    --fg: #e8e7e3;
    --muted: #a6a5a0;
    --rule: #33353a;
    --accent: #8ab4f8;
    --accent-bg: #1f2530;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 1.0625rem/1.65 Charter, "Iowan Old Style", Georgia, "Times New Roman", serif;
}

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Header / footer */
.site-header {
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}
.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: baseline;
  justify-content: space-between;
  padding-top: 0.7rem;
  padding-bottom: 0.7rem;
}
.site-title {
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  color: var(--fg);
}
.site-nav {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.85rem;
}

.site-footer {
  margin-top: 4rem;
  border-top: 1px solid var(--rule);
  padding: 1.5rem 0 3rem;
  color: var(--muted);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.85rem;
}
.site-footer p { margin: 0.4rem 0; }

main { padding-bottom: 1rem; }

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: system-ui, -apple-system, "Segoe UI", Helvetica, sans-serif;
  line-height: 1.25;
  margin: 2.2rem 0 0.6rem;
  scroll-margin-top: 4.5rem;
}
h1 { font-size: 1.9rem; margin-top: 2rem; margin-bottom: 2rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }
h4, h5, h6 { font-size: 1rem; }
h1:first-child { margin-top: 1.6rem; }

p, ul, ol { margin: 0 0 1rem; }
ul, ol { padding-left: 1.5rem; }
li { margin-bottom: 0.35rem; }

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

img { max-width: 100%; height: auto; }

blockquote {
  margin: 1rem 0;
  padding-left: 1rem;
  border-left: 3px solid var(--rule);
  color: var(--muted);
}

hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5rem 0; }

/* Breadcrumb ("back to contents") */
.breadcrumb {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.85rem;
  margin: 1.25rem 0 0;
}

/* Tables of contents */
.toc {
  margin: 1.5rem 0 2rem;
  padding: 1rem 1.25rem;
  background: var(--accent-bg);
  border: 1px solid var(--rule);
  border-radius: 6px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.95rem;
}
.toc > .toc-title {
  margin: 0 0 0.5rem;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.toc ul { list-style: none; margin: 0; padding-left: 0; }
.toc ul ul { padding-left: 1.1rem; font-size: 0.92em; }
.toc li { margin: 0.25rem 0; }
.toc-pages > li > a { font-weight: 600; }

/* Footnotes */
sup {
  line-height: 0;   /* a marker shouldn't stretch its line */
  font-size: 0.7em;
}
sup a {
  text-decoration: none;
  padding: 0 0.15em;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 600;
  cursor: help;     /* the note text is in the title tooltip */
}
sup a:hover, sup a:focus { text-decoration: underline; }

.footnotes {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-size: 0.92rem;
  color: var(--muted);
}
.footnotes-title {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.75rem;
}
.footnotes ol { padding-left: 1.75rem; }
.footnotes li { margin-bottom: 0.6rem; }
/* A footnote jumped to from the text gets a moment of highlight. */
.footnotes li:target {
  background: var(--accent-bg);
  outline: 0.4rem solid var(--accent-bg);
  border-radius: 2px;
}
.footnote-back { text-decoration: none; margin-left: 0.25rem; }

/* Page-level nav between sections */
.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.9rem;
}

@media print {
  .site-header, .site-footer, .pager, .breadcrumb { display: none; }
  body { font-size: 11pt; }
}
