/* Reliable Error — hand-written stylesheet, no framework. */

:root {
  --paper:      #f6f4f1;
  --surface:    #fffefc;
  --ink:        #1f1d26;
  --ink-muted:  #67627a;
  --rule:       #e2ded9;
  --rule-soft:  #ece9e4;
  --accent:     #4a3f8f;
  --accent-dim: #6b5fb0;
  --mark:       #ece9f3;
  --measure:    38rem;
  --display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:      #17161b;
    --surface:    #1d1b23;
    --ink:        #e5e2ea;
    --ink-muted:  #9a94ac;
    --rule:       #2f2c38;
    --rule-soft:  #26232d;
    --accent:     #a99cf0;
    --accent-dim: #8b7fd4;
    --mark:       #262232;
  }
}

*, *::before, *::after { 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: 17px;
  line-height: 1.68;
  text-rendering: optimizeLegibility;
}

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

/* ---- masthead ---------------------------------------------------------- */

header.masthead {
  border-bottom: 1px solid var(--rule);
  padding: 2rem 0 1rem;
  margin-bottom: 2.8rem;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: .55rem;
  text-decoration: none;
  color: inherit;
}

.brand .mark {
  flex: none;
  align-self: center;
}

.brand b {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.14rem;
  letter-spacing: -.01em;
}

.brand span {
  font-size: .76rem;
  color: var(--ink-muted);
  letter-spacing: .03em;
}

nav {
  margin-top: 1rem;
  font-size: .8rem;
  letter-spacing: .015em;
}

nav a {
  color: var(--ink-muted);
  text-decoration: none;
  margin-right: 1.05rem;
  padding-bottom: 3px;
  border-bottom: 1px solid transparent;
  white-space: nowrap;
}

nav a:hover { color: var(--ink); border-bottom-color: var(--accent); }
nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

/* ---- prose ------------------------------------------------------------- */

h1 {
  font-family: var(--display);
  font-size: 2rem;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -.016em;
  margin: 0 0 .4rem;
}

.standfirst {
  color: var(--ink-muted);
  font-size: 1.02rem;
  margin: 0 0 2.4rem;
  max-width: 32rem;
}

h2 {
  font-family: var(--display);
  font-size: 1.28rem;
  font-weight: 600;
  letter-spacing: -.008em;
  margin: 2.8rem 0 .7rem;
}

h3 {
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 2.1rem 0 .5rem;
}

p { margin: 0 0 1.2rem; }

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

ul, ol { margin: 0 0 1.2rem; padding-left: 1.35rem; }
li { margin-bottom: .5rem; }

strong { font-weight: 650; }

blockquote {
  margin: 1.7rem 0;
  padding: .1rem 0 .1rem 1.15rem;
  border-left: 2px solid var(--accent);
  color: var(--ink-muted);
}

blockquote p:last-child { margin-bottom: 0; }

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

code, .mono {
  font-family: var(--mono);
  font-size: .85em;
  background: var(--mark);
  padding: .1em .36em;
  border-radius: 3px;
}

/* ---- pull-out note ----------------------------------------------------- */

.note {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1.1rem 1.25rem;
  margin: 1.9rem 0;
  font-size: .96rem;
}

.note p:last-child { margin-bottom: 0; }

.note strong { color: var(--ink); }

/* ---- figures ----------------------------------------------------------- */

figure { margin: 2.2rem 0; }

figure svg { display: block; width: 100%; height: auto; }

figcaption {
  font-size: .77rem;
  color: var(--ink-muted);
  margin-top: .65rem;
  line-height: 1.55;
}

/* ---- tables ------------------------------------------------------------ */

.table-scroll { overflow-x: auto; margin: 1.7rem 0; }

table {
  border-collapse: collapse;
  width: 100%;
  font-size: .9rem;
}

th, td {
  text-align: left;
  padding: .55rem .8rem .55rem 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}

th {
  font-size: .72rem;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

td.term { font-weight: 650; }

/* ---- numbered article index ------------------------------------------- */

.index { margin: 2.6rem 0 0; counter-reset: item; list-style: none; padding: 0; }

.index li {
  counter-increment: item;
  display: flex;
  gap: 1rem;
  padding: 1.2rem 0;
  border-top: 1px solid var(--rule);
  margin: 0;
}

.index li:last-child { border-bottom: 1px solid var(--rule); }

.index li::before {
  content: counter(item, decimal-leading-zero);
  font-family: var(--mono);
  font-size: .78rem;
  color: var(--accent);
  padding-top: .3rem;
  flex: none;
}

.index a {
  font-family: var(--display);
  font-size: 1.12rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--ink);
  display: block;
}

.index a:hover { color: var(--accent); }

.index p {
  margin: .25rem 0 0;
  color: var(--ink-muted);
  font-size: .93rem;
  line-height: 1.6;
}

/* ---- sources list ------------------------------------------------------ */

.sources { font-size: .89rem; color: var(--ink-muted); }
.sources li { margin-bottom: .7rem; }

/* ---- footer ------------------------------------------------------------ */

footer {
  margin-top: 4.5rem;
  padding: 1.5rem 0 3.5rem;
  border-top: 1px solid var(--rule);
  font-size: .77rem;
  color: var(--ink-muted);
}

footer a { color: var(--ink-muted); }
footer a:hover { color: var(--accent); }

/* ---- small screens ----------------------------------------------------- */

@media (max-width: 30rem) {
  body { font-size: 16px; }
  h1 { font-size: 1.6rem; }
  nav a { margin-right: .8rem; }
  .index li { gap: .7rem; }
}
