/* Reset, layout primitives, navigation, controls. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  /* Deliberately not smooth. The whole site is one document roughly 29,000px
   * tall, and animating a jump from the masthead to the glossary takes several
   * seconds of the reader staring at a blur. */
  scroll-behavior: auto;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

body {
  margin: 0;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4,
p,
figure,
blockquote {
  margin: 0;
}

img,
svg {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

/* Focus: always visible, never removed. Two-tone so it reads on any surface. */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

:where(a, button, input, select, [tabindex]):focus:not(:focus-visible) {
  outline: none;
}

.skip-link {
  position: absolute;
  inset-inline-start: 0;
  inset-block-start: 0;
  transform: translateY(-120%);
  background: var(--accent);
  color: #fff;
  padding: 0.6rem 1rem;
  z-index: 100;
  text-decoration: none;
}

.skip-link:focus {
  transform: translateY(0);
}

/* Layout ----------------------------------------------------------------- */

.shell {
  width: 100%;
  max-width: 74rem;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* A reading column, left-aligned with every other section rather than
 * re-centred on the viewport -- otherwise a route's intro and its content sit
 * on two different left edges, which reads as a mistake. */
.shell--reading > * {
  max-width: 46rem;
}

.band {
  background: var(--surface);
  color: var(--text);
  padding-block: clamp(2.5rem, 6vw, 4.5rem);
}

.band--dark {
  background: var(--surface);
}

.band + .band {
  border-block-start: 1px solid var(--rule);
}

.band--dark + .band,
.band + .band--dark {
  border-block-start: 0;
}

.stack > * + * {
  margin-block-start: var(--stack-gap, 1rem);
}

/* Section heading pattern: a rule, a short label, then the heading. No
 * tracked-out caps eyebrow -- the rule does the separating work instead. */
.section-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
  padding-block-end: 0.5rem;
  border-block-end: 1px solid var(--rule);
  margin-block-end: 1.5rem;
}

/* Links ------------------------------------------------------------------ */

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  text-decoration-thickness: 2px;
}

.prose a {
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

.prose a:hover {
  text-decoration-color: var(--accent);
}

/* Navigation ------------------------------------------------------------- */

.nav {
  position: sticky;
  inset-block-start: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px);
  border-block-end: 1px solid var(--rule);
}

.nav__inner {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  min-height: 3.5rem;
  flex-wrap: wrap;
}

.nav__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
  margin-inline-end: auto;
}

.nav__brand img {
  width: 26px;
  height: 26px;
}

.nav__links {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  list-style: none;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}

.nav__links a {
  display: inline-block;
  padding: 0.35rem 0.6rem;
  font-size: var(--text-sm);
  color: var(--slate-violet);
  text-decoration: none;
  border-radius: var(--radius);
}

.nav__links a:hover {
  color: var(--ink);
  background: var(--surface-sunken);
}

/* Current section is marked by weight and an underline, not by colour alone.
 * aria-current="true" rather than "page": these are sections of one document,
 * not separate pages. */
.nav__links a[aria-current] {
  color: var(--ink);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--grape);
}

@media (max-width: 32rem) {
  .nav__inner {
    padding-block: 0.5rem;
  }

  /* The <nav> is the flex item, not the list inside it, so this is where
   * min-width:auto has to be defeated. Without it the document itself scrolls
   * horizontally by the width of the overflowing links. */
  .nav__inner > nav {
    width: 100%;
    min-width: 0;
  }

  .nav__links {
    width: 100%;
    /* A flex item defaults to min-width:auto, which refuses to shrink below
     * its content and pushed the whole document 47px wide at 375. The scroll
     * container only contains anything once this is zeroed. */
    min-width: 0;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
  }

  .nav__links::-webkit-scrollbar {
    display: none;
  }

  .nav__links a {
    white-space: nowrap;
  }
}

/* Controls --------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.75rem;
  padding: 0.5rem 1.1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}

.btn:hover {
  background: var(--accent-strong);
}

.btn--quiet {
  background: transparent;
  color: var(--accent);
  border-color: var(--rule-strong);
}

.btn--quiet:hover {
  background: var(--surface-sunken);
  color: var(--accent-strong);
}

[data-surface="dark"] .btn {
  color: var(--void);
}

[data-surface="dark"] .btn--quiet {
  color: var(--accent);
  background: transparent;
}

[data-surface="dark"] .btn--quiet:hover {
  background: var(--accent-quiet);
}

/* Screen-reader-only, with the standard focusable escape hatch. */
.visually-hidden:not(:focus):not(:active) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Tables ----------------------------------------------------------------- */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.table th,
.table td {
  text-align: start;
  padding: 0.5rem 0.65rem;
  border-block-end: 1px solid var(--rule);
  vertical-align: baseline;
}

.table th {
  font-weight: 600;
  color: var(--text-muted);
}

.table td.num,
.table th.num {
  text-align: end;
  font-variant-numeric: tabular-nums lining-nums;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Illustrative figures --------------------------------------------------- */

/* Any benchmark number that is a plausible range rather than a sourced fact is
 * marked here and logged in docs/SOURCES.md. It must look different from a
 * figure the model actually computed. */
.illustrative {
  border-block-end: 1px dotted var(--accent);
  cursor: help;
}

.illustrative::after {
  content: " illustrative";
  font-size: 0.72em;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent);
  vertical-align: 0.15em;
  margin-inline-start: 0.25em;
}

/* Masthead --------------------------------------------------------------- */

/* A publication nameplate, not a hero. Left-aligned, no bloom, no glow, no
 * light streaks, no centred logo -- the thesis sentence is the largest object
 * on the screen and the bag sits at nameplate scale beside the kicker. This is
 * the only place on the site that uses the dark field for its own sake. */
.masthead {
  padding-block: clamp(3rem, 9vw, 6.5rem) clamp(2.5rem, 7vw, 5rem);
}

/* The masthead carried a second bag and wordmark directly beneath the sticky
 * nav's. One of them had to go, and it was this one: the nav already names the
 * publication on every route, so repeating it here only delayed the thesis. */
.masthead__kicker {
  display: inline-block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
  padding-block-end: 0.5rem;
  border-block-end: 1px solid var(--rule);
  margin-block-end: clamp(1.5rem, 4vw, 2.5rem);
}

.masthead__thesis {
  font-size: var(--text-3xl);
  max-width: 19ch;
  color: var(--text);
  text-wrap: balance;
}

.masthead__standfirst {
  margin-block-start: clamp(1.25rem, 3vw, 1.75rem);
  max-width: 56ch;
  font-size: var(--text-md);
  line-height: 1.55;
  color: var(--text-muted);
}

.masthead__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-block-start: clamp(1.75rem, 4vw, 2.5rem);
}

@media (max-width: 30rem) {
  .masthead__thesis {
    max-width: none;
  }

  .masthead__actions .btn {
    flex: 1 1 100%;
  }
}

.footer {
  padding-block: 2.5rem 3.5rem;
  border-block-start: 1px solid var(--rule);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.footer p {
  max-width: var(--measure);
}

.footer p + p {
  margin-block-start: 0.75rem;
}
