:root {
  --ink: #16232a;
  --paper: #f2f6f6;
  --cover: #0e3a46;
  --cover-ink: #f2f6f6;
  --muted: #4d6068;
  --rule: #ccd8da;
  --link: #0f5568;
  --measure: 66ch;
  --gutter: clamp(1.25rem, 5vw, 3rem);
  --display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --body: "Source Serif 4", Georgia, "Times New Roman", serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #dde7ea;
    --paper: #0f1417;
    --cover: #125463;
    --cover-ink: #f2f6f6;
    --muted: #93a4aa;
    --rule: #253338;
    --link: #5cc2d6;
  }
}

:root[data-theme="dark"] {
  --ink: #dde7ea;
  --paper: #0f1417;
  --cover: #125463;
  --cover-ink: #f2f6f6;
  --muted: #93a4aa;
  --rule: #253338;
  --link: #5cc2d6;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1.125rem;
  line-height: 1.6;
  font-optical-sizing: auto;
}

a { color: var(--link); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--link); outline-offset: 3px; border-radius: 2px; }

.wrap {
  max-width: calc(72rem + 2 * var(--gutter));
  margin: 0 auto;
  padding-inline: var(--gutter);
}

/* The cover: one saturated field, type as the image */
.cover {
  background: var(--cover);
  color: var(--cover-ink);
  padding-block: clamp(1.25rem, 2.5vw, 1.75rem) clamp(2rem, 4vw, 2.75rem);
}

.cover a { color: inherit; }

.masthead {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 600;
  font-stretch: 100%;
  margin-bottom: clamp(1.75rem, 4vw, 2.5rem);
}

.masthead nav { display: flex; align-items: center; gap: 1.25rem; font-weight: 500; }

.theme-toggle {
  font: inherit;
  font-weight: 500;
  color: inherit;
  background: none;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 0.15em 0.75em;
  cursor: pointer;
  opacity: 0.75;
}
.theme-toggle:hover { opacity: 1; }
.masthead nav a { text-decoration: none; }
.masthead nav a:hover { text-decoration: underline; }

.cover h1 {
  font-family: var(--display);
  font-stretch: 62%;
  font-weight: 800;
  font-size: clamp(2.25rem, 5vw, 3.5rem);
  line-height: 0.88;
  letter-spacing: -0.01em;
  margin: 0 0 clamp(1.5rem, 4vw, 2.25rem);
}

.cover .lede {
  text-wrap: balance;
  font-size: clamp(1.0625rem, 1.6vw, 1.1875rem);
  line-height: 1.45;
  max-width: 34em;
  margin: 0;
}

/* Proof points as measures, separated by barlines, ending in a final barline */
.bars {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-block-end: 1px solid var(--rule);
}

.bars li {
  position: relative;
  padding: 1.75rem 1.5rem 1.75rem 1.25rem;
  border-inline-start: 1.5px solid var(--ink);
  font-size: 1rem;
  line-height: 1.5;
}

.bars li:last-child { padding-inline-end: 2.25rem; }

.bars li:last-child::after {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-end: 0;
  width: 9px;
  border-inline-start: 1.5px solid var(--ink);
  border-inline-end: 5px solid var(--ink);
}

.bars strong {
  display: block;
  font-family: var(--display);
  font-stretch: 75%;
  font-weight: 700;
  font-size: 1.5rem;
  line-height: 1.1;
  margin-bottom: 0.4rem;
}

@media (max-width: 760px) {
  .bars { grid-template-columns: 1fr; border-block-end: 0; }
  .bars li { border-inline-start: 0; border-block-start: 1.5px solid var(--ink); padding-inline: 0; }
  .bars li:last-child { padding-inline-end: 0; padding-block-end: 2.25rem; }
  .bars li:last-child::after {
    inset-block: auto 0;
    inset-inline: 0;
    width: auto;
    height: 9px;
    border-inline: 0;
    border-block-start: 1.5px solid var(--ink);
    border-block-end: 5px solid var(--ink);
  }
}

main section { padding-block: clamp(2.5rem, 7vw, 4.5rem) 0; max-width: var(--measure); }
article > * { max-width: var(--measure); }
footer { max-width: var(--measure); }

h2 {
  font-family: var(--display);
  font-stretch: 75%;
  font-weight: 700;
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  line-height: 1.1;
  margin: 0 0 1.25rem;
}

h3 {
  font-family: var(--display);
  font-stretch: 87.5%;
  font-weight: 650;
  font-size: 1.25rem;
  line-height: 1.25;
  margin: 2rem 0 0.4rem;
}

p { margin: 0 0 1.1rem; text-wrap: pretty; }

.work h3:first-of-type { margin-top: 0; }

.contact dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 0.5rem 1.5rem; }
.contact dt { font-family: var(--display); font-weight: 600; font-stretch: 87.5%; }
.contact dd { margin: 0; }

footer {
  margin-top: clamp(3rem, 8vw, 5rem);
  padding-block: 1.5rem 2.5rem;
  border-block-start: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.9rem;
}

/* Essay pages */
.cover.short { padding-block-end: clamp(2rem, 6vw, 3.5rem); }
.cover.short .masthead { margin-bottom: clamp(2rem, 7vw, 4rem); }
.cover.short h1 { font-size: clamp(2.75rem, 9vw, 5.5rem); max-width: 14ch; }

article { padding-block-start: clamp(2rem, 6vw, 3.5rem); }
article p, article li { line-height: 1.7; }
article h2 { margin-top: 2.5rem; font-size: 1.75rem; }
article blockquote {
  margin: 1.75rem 0;
  padding-inline-start: 1.25rem;
  border-inline-start: 5px solid var(--ink);
  font-size: 1.25rem;
  line-height: 1.5;
}
article ul { padding-inline-start: 1.25rem; }
article li { margin-bottom: 0.6rem; }
.byline { color: var(--muted); font-size: 1rem; }

/* Figures — see DIAGRAMS.md */
article, .diagrams { counter-reset: figure; }

/* Diagrams take the wide frame; their prose keeps the reading measure. */
.diagrams { max-width: none; }
.diagrams > h2,
.diagrams > p { max-width: var(--measure); }

figure {
  margin: 2.25rem 0;
  scroll-margin-top: 1.5rem;
  counter-increment: figure;
  max-width: none;
}

figure .plate {
  overflow-x: auto;
  padding-bottom: 0.25rem;
  border-block: 1px solid var(--rule);
  padding-block: 1.25rem;
}

figure svg {
  display: block;
  width: 100%;
  min-width: 680px;          /* keeps 12px labels ≥ 11px rendered; the plate scrolls on a phone */
  max-width: 780px;
  height: auto;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

figcaption {
  margin-top: 0.7rem;
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--muted);
  max-width: var(--measure);
}

figcaption::before {
  content: "Figure " counter(figure) ". ";
  font-family: var(--display);
  font-stretch: 87.5%;
  font-weight: 700;
  color: var(--ink);
}
