/* ─────────────────────────────────────────────────────────────────────────
   One stylesheet, no framework, no build step.

   Colours are defined once as tokens on :root and redefined only inside the
   two dark-mode blocks. Nothing below the token blocks names a literal
   colour, which is what keeps the two themes from drifting apart as pages
   get added.
   ───────────────────────────────────────────────────────────────────────── */

:root {
  --paper:      #F6F7F5;
  --surface:    #FFFFFF;
  --surface-2:  #ECEEEA;
  --ink:        #1A1F23;
  --ink-2:      #4E585F;
  --ink-3:      #7C868C;
  --rule:       #DCDFDA;
  --rule-firm:  #BEC4BE;
  --accent:     #1F5E52;
  --accent-2:   #E3EFEB;
  --measure:    34rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:      #10151A;
    --surface:    #171E24;
    --surface-2:  #1F282F;
    --ink:        #E8EDEA;
    --ink-2:      #A7B3B4;
    --ink-3:      #77858A;
    --rule:       #26313A;
    --rule-firm:  #38464F;
    --accent:     #5FC0AC;
    --accent-2:   #12312C;
  }
}

:root[data-theme="dark"] {
  --paper:      #10151A;
  --surface:    #171E24;
  --surface-2:  #1F282F;
  --ink:        #E8EDEA;
  --ink-2:      #A7B3B4;
  --ink-3:      #77858A;
  --rule:       #26313A;
  --rule-firm:  #38464F;
  --accent:     #5FC0AC;
  --accent-2:   #12312C;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Source Serif 4", Georgia, "Times New Roman", serif;
  font-size: 19px;
  line-height: 1.68;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: oldstyle-nums;
}

.wrap {
  max-width: 46rem;
  margin: 0 auto;
  padding: 0 1.5rem 7rem;
}

/* ── Masthead ─────────────────────────────────────────────────────────── */

.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding: 2.5rem 0 1.1rem;
  border-bottom: 2px solid var(--ink);
  margin-bottom: 3rem;
}

.masthead a.wordmark {
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
}

.masthead nav {
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.masthead nav a {
  color: var(--ink-2);
  text-decoration: none;
  margin-left: 1.1rem;
}

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

/* ── Typography ───────────────────────────────────────────────────────── */

h1, h2, h3 {
  text-wrap: balance;
  line-height: 1.18;
  letter-spacing: -0.015em;
  margin: 0;
}

h1 { font-size: clamp(2rem, 5.2vw, 2.9rem); font-weight: 600; }
h2 {
  font-size: 1.42rem;
  font-weight: 600;
  margin: 3.1rem 0 0.2rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--rule);
}
h3 { font-size: 1.12rem; font-weight: 600; margin: 2.1rem 0 0; }

p, ul, ol { margin: 1.05rem 0 0; max-width: var(--measure); }
li { margin-top: 0.35rem; }
li > p { margin-top: 0.4rem; }

a { color: var(--accent); text-underline-offset: 0.16em; }

strong { font-weight: 600; }

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

blockquote {
  margin: 1.4rem 0 0;
  padding-left: 1.1rem;
  border-left: 3px solid var(--rule-firm);
  color: var(--ink-2);
  max-width: var(--measure);
}

/* ── Code, and the numbers ────────────────────────────────────────────── */

code, pre, table {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

code {
  font-size: 0.83em;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 0.08em 0.32em;
}

pre {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--rule-firm);
  border-radius: 2px;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.55;
  margin: 1.4rem 0 0;
}

pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
}

/* Tables carry the evidence in these essays, so they get real attention.
   The wrapper scrolls rather than the page — a table wider than the viewport
   must never make the body scroll sideways. */

.table-scroll {
  overflow-x: auto;
  margin: 1.5rem 0 0;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--surface);
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.79rem;
  font-variant-numeric: tabular-nums;
}

th, td {
  padding: 0.5rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}

th {
  font-weight: 500;
  color: var(--ink-2);
  background: var(--surface-2);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

td:not(:first-child), th:not(:first-child) { text-align: right; }

tr:last-child td { border-bottom: 0; }

td strong { color: var(--accent); font-weight: 600; }

/* ── Essay furniture ──────────────────────────────────────────────────── */

.essay-head { margin-bottom: 2.2rem; }

.essay-meta {
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 0.76rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 0.9rem;
}

.standfirst {
  font-size: 1.12rem;
  line-height: 1.55;
  color: var(--ink-2);
  margin-top: 1.1rem;
  max-width: var(--measure);
}

/* ── Index listing ────────────────────────────────────────────────────── */

.lede { font-size: 1.15rem; line-height: 1.6; color: var(--ink-2); }
.lede strong { color: var(--ink); }

.entry {
  display: block;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
  color: inherit;
}

.entry:first-of-type { border-top: 1px solid var(--rule); }

.entry h3 { margin: 0; color: var(--ink); }
.entry:hover h3 { color: var(--accent); }

.entry p {
  margin-top: 0.4rem;
  font-size: 0.95rem;
  color: var(--ink-2);
  max-width: var(--measure);
}

/* The last entry's bottom border and a following h2's top border would
   otherwise stack into two rules with a gap between them. */
.entry + h2 { border-top: 0; padding-top: 0; margin-top: 2.7rem; }

.entry .kicker {
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: block;
  margin-bottom: 0.4rem;
}

/* ── Footer ───────────────────────────────────────────────────────────── */

footer {
  margin-top: 4.5rem;
  padding-top: 1.3rem;
  border-top: 1px solid var(--rule);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 0.8rem;
  color: var(--ink-3);
}

footer a { color: var(--ink-2); }

/* ── Focus and motion ─────────────────────────────────────────────────── */

a:focus-visible, .entry:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

@media (max-width: 34rem) {
  body { font-size: 17.5px; }
  .wrap { padding: 0 1.15rem 4rem; }
  th, td { padding: 0.42rem 0.6rem; }
}
