/* ==========================================================================
   Base: reset, typography, accessibility helpers, layout primitives
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 6rem; /* keeps jump targets clear of the sticky header */
  interpolate-size: allow-keywords;
}

/* Motion: off when the system asks for less motion, or the visitor turns it off */
@media (prefers-reduced-motion: reduce) {
  html:not([data-motion="on"]) { scroll-behavior: auto; }
  html:not([data-motion="on"]) *,
  html:not([data-motion="on"]) *::before,
  html:not([data-motion="on"]) *::after { animation: none !important; transition: none !important; }
}
html[data-motion="off"] { scroll-behavior: auto; }
html[data-motion="off"] *,
html[data-motion="off"] *::before,
html[data-motion="off"] *::after { animation: none !important; transition: none !important; }

/* Gentle cross-fade between pages, only when motion is welcome */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  transition: background-color var(--duration-base), color var(--duration-base);
}

/* Wide spacing: the WCAG 1.4.12 text-spacing values */
html[data-spacing="wide"] body { letter-spacing: 0.12em; word-spacing: 0.16em; }
html[data-spacing="wide"] :is(p, li, dd, summary, .accordion__body) { line-height: 2; }
html[data-spacing="wide"] p + p { margin-top: 2em; }

img, svg, video { display: block; max-width: 100%; height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
p, h1, h2, h3, h4, figure, blockquote, ul, ol { margin: 0; }
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }

/* ---------- Typography ---------- */
h1, h2, h3, h4, .display {
  font-family: var(--font-display);
  font-weight: var(--weight-semibold);
  font-synthesis-weight: none;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: inherit;
  text-wrap: balance;
  overflow-wrap: break-word;
  hyphens: auto;
}
.text-4xl { font-size: var(--text-4xl); }
.text-3xl { font-size: var(--text-3xl); }
.text-2xl { font-size: var(--text-2xl); }
.text-xl  { font-size: var(--text-xl); line-height: var(--leading-snug); }
.text-lg  { font-size: var(--text-lg); }
.text-sm  { font-size: var(--text-sm); }
.text-xs  { font-size: var(--text-xs); }
.text-muted { color: var(--color-text-muted); }
.text-center { text-align: center; }
p { text-wrap: pretty; max-width: 65ch; overflow-wrap: break-word; }
strong, b { font-weight: var(--weight-bold); }

a { color: var(--color-link); text-underline-offset: 0.18em; text-decoration-thickness: 0.08em; }
a:hover { color: var(--color-link-hover); text-decoration-thickness: 0.14em; }

.eyebrow {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--color-text-muted);
}

/* ---------- Accessibility ---------- */
:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 3px;
  box-shadow: 0 0 0 7px var(--color-focus-halo);
  border-radius: var(--radius-sm);
}
[data-tone="navy"] :focus-visible { outline-color: var(--yellow-300); box-shadow: none; }

/* The block being read aloud by "Listen to this page" */
.is-speaking {
  background: var(--color-highlight);
  color: var(--color-text);
  box-shadow: 0 0 0 0.25em var(--color-highlight);
  border-radius: 0.2em;
}

/* Windows High Contrast and other forced colour modes */
@media (forced-colors: active) {
  :focus-visible { outline: 3px solid Highlight; box-shadow: none; }
  .is-speaking { background: Mark; color: MarkText; forced-color-adjust: none; }
}

/* Solid header when the system asks for less transparency */
@media (prefers-reduced-transparency: reduce) {
  .site-header { backdrop-filter: none; background: var(--color-bg); }
}

/* Print: just the words */
@media print {
  .site-header, .announce, .skip-link, .reading-panel, .scroller__controls, .curve, form { display: none !important; }
  body { color: #000; background: #fff; font-size: 12pt; }
  .tone, [data-tone] { background: none !important; color: #000 !important; }
  a[href^="http"]::after { content: " (" attr(href) ")"; }
  details > * { display: block; }
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -100px;
  z-index: 100;
  padding: var(--space-3) var(--space-5);
  background: var(--color-ink);
  color: var(--color-on-ink);
  border-radius: var(--radius-pill);
  font-weight: var(--weight-bold);
}
.skip-link:focus { top: var(--space-4); color: var(--color-on-ink); }

/* ---------- Layout primitives ---------- */
.container {
  width: 100%;
  max-width: calc(var(--container) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.container--narrow { max-width: calc(var(--container-narrow) + var(--gutter) * 2); }

.section { padding-block: var(--section-y); }
.section--tight { padding-block: calc(var(--section-y) * 0.6); }

/* Tone surfaces: apply data-tone + .tone */
.tone { background: var(--tone-bg); color: var(--tone-text); }

/* Stack: vertical rhythm. Set --stack-gap to change. */
.stack { display: flex; flex-direction: column; gap: var(--stack-gap, var(--space-4)); }
.stack--sm { --stack-gap: var(--space-2); }
.stack--lg { --stack-gap: var(--space-8); }

/* Cluster: wrapping row of items */
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cluster-gap, var(--space-3)); }

/* Grid: responsive columns, min width per item via --grid-min */
.grid {
  display: grid;
  gap: var(--grid-gap, var(--space-6));
  grid-template-columns: repeat(auto-fit, minmax(min(var(--grid-min, 16rem), 100%), 1fr));
}

/* Split: two columns that stack on small screens */
.split {
  display: grid;
  gap: var(--split-gap, clamp(2rem, 5vw, 5rem));
  align-items: center;
}
.split > *, .grid > * { min-width: 0; }
@media (min-width: 56rem) {
  .split { grid-template-columns: 1fr 1fr; }
  .split--reverse > :first-child { order: 2; }
}

.section-head { max-width: 44rem; margin-bottom: clamp(2.5rem, 5vw, 4rem); }
.section-head.text-center { margin-inline: auto; }
.section-head.text-center p { margin-inline: auto; }
