/* ==========================================================================
   Base — reset, document defaults, typography
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + var(--space-6));
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0 0 var(--space-2);
  font-family: var(--font-heading);
  font-weight: var(--font-heading-weight);
  line-height: 1.12;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

h1 { font-size: clamp(2.25rem, 1.4rem + 3.6vw, 4.25rem); }
h2 { font-size: clamp(1.6rem, 1.25rem + 1.5vw, 2.1rem); }
h3 { font-size: clamp(1.35rem, 1.15rem + 0.8vw, 1.6rem); }
h4 { font-size: 1.25rem; }
h5 { font-size: 1rem; }

h6 {
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

p {
  margin: 0 0 var(--space-3);
  text-wrap: pretty;
}

/* Justified throughout, with hyphenation on so the extra word spacing does
   not open rivers down the column. A last line and any single-line element
   are unaffected by justification, so this is safe to apply broadly. */
p,
li,
.measure,
.lede,
.card-body,
.detail-desc,
dd {
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
}

/* Micro-type in narrow panels is the one place justification does more harm
   than good: too few words per line to distribute the space invisibly. */
.atlas-note,
.atlas-credit,
.refs-list,
.colophon,
figcaption,
.conn-hint {
  text-align: left;
  hyphens: manual;
}

a {
  color: var(--color-accent);
  text-underline-offset: 3px;
  transition: color var(--dur-fast) var(--ease);
}

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

img,
video,
svg {
  display: block;
  max-width: 100%;
}

img,
video { height: auto; }

figure { margin: 0; }

figcaption {
  margin-top: var(--space-1);
  font-size: 0.7rem;
  color: color-mix(in srgb, var(--color-text) 55%, transparent);
}

ul,
ol { margin: 0 0 var(--space-3); padding-left: 1.15em; }

li { margin-bottom: var(--space-1); }

hr {
  height: 1px;
  margin: var(--space-6) 0;
  border: 0;
  background: var(--color-divider);
}

code,
kbd,
samp { font-family: var(--font-mono); font-size: 0.9em; }

button { font: inherit; color: inherit; }

:focus { outline: none; }

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

::selection {
  background: color-mix(in srgb, var(--color-accent) 30%, transparent);
}

/* --- Utilities --- */

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--space-6);
}

.wrap-narrow { max-width: var(--wrap-narrow); }

.text-muted { color: color-mix(in srgb, var(--color-text) 55%, transparent); }

.measure { max-width: 80ch; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  z-index: 200;
  padding: var(--space-2) var(--space-4);
  background: var(--color-accent);
  color: var(--color-bg);
  text-decoration: none;
}

.skip-link:focus-visible { top: var(--space-2); color: var(--color-bg); }


/* --- Multi-column prose ----------------------------------------------------
   Used on the text-heavy pages. The column count is not fixed: the browser
   fits as many columns of at least `column-width` as the container allows, so
   it is two or three on a desktop and one on a phone with no breakpoints. */

.prose-cols {
  /* Overrides .wrap-narrow: a column layout needs room for at least two
     columns, otherwise the browser silently renders one. */
  max-width: var(--wrap);
  column-width: 34rem;
  column-gap: clamp(var(--space-8), 3.5vw, var(--space-16));
  orphans: 3;
  widows: 3;
}

.prose-cols > * { break-inside: avoid-column; }
.prose-cols > h2,
.prose-cols > h3,
.prose-cols > h4,
.prose-cols > h6 { break-after: avoid-column; }
.prose-cols > :first-child { margin-top: 0; }

/* Blocks that must not be split or stranded mid-column. */
.prose-cols > .notice,
.prose-cols > table,
.prose-cols > figure { break-inside: avoid; }

/* A single column that is wider than the reading default, for blocks too
   short to justify splitting into columns. */
.prose-wide { max-width: min(92ch, 100%); }

/* A callout that lines up with the prose beside it rather than sitting in a
   narrower well. */
.callout-wide { max-width: min(120ch, 100%); }
