/* ==========================================================================
   BASE - reset, document defaults, bare element styling.
   No classes here. Unstyled semantic HTML should already look correct.
   ========================================================================== */

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

* { margin: 0; }

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

body {
  min-height: 100svh;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: var(--leading-body);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

/* Locked while the mobile menu or the lightbox is open. */
body[data-scroll-locked] {
  overflow: hidden;
  touch-action: none;
}

/* --------------------------------------------------------------- headings */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-tight);
  text-wrap: balance;
  font-variation-settings: "SOFT" 30, "WONK" 1;
}

h1 { font-size: var(--step-6); line-height: var(--leading-tight); }
h2 { font-size: var(--step-4); }
h3 { font-size: var(--step-2); }
h4 { font-size: var(--step-1); }
h5 { font-size: var(--step-0); }
h6 { font-size: var(--step--1); }

p, li, dd, dt, figcaption, blockquote { text-wrap: pretty; }

p { max-width: 68ch; }

/* Vertical rhythm inside prose blocks only - layout components opt out. */
:is(p, ul, ol, dl, figure, blockquote, table, pre) + :is(p, ul, ol, dl, figure, blockquote, table, pre) {
  margin-block-start: var(--space-s);
}

:is(h2, h3, h4) + * { margin-block-start: var(--space-xs); }

/* ------------------------------------------------------------------ links */
a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  transition: color var(--dur-fast) var(--ease-out);
}

a:hover { color: var(--link-hover); }

/* ------------------------------------------------------------------ lists */
ul, ol { padding-inline-start: 1.25em; }

/* ------------------------------------------------------------ media & svg */
img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

img, video {
  height: auto;
  background-color: var(--bg-alt);
}

/* Icons inherit the surrounding text colour. A CSS rule outranks the
   fill="none" presentation attribute, so outline icons need it back. */
svg { fill: currentColor; }
svg[fill="none"] { fill: none; }

figure { margin: 0; }

/* ------------------------------------------------------------------ forms */
input, button, textarea, select {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}

button { background: none; border: 0; cursor: pointer; }

textarea { resize: vertical; }

::placeholder { color: var(--text-subtle); opacity: 1; }

/* ----------------------------------------------------------------- tables */
table { width: 100%; border-collapse: collapse; }

th { text-align: start; font-weight: 700; }

th, td {
  padding: var(--space-xs) var(--space-s);
  border-block-end: var(--border-width) solid var(--border);
}

/* ------------------------------------------------------------------- text */
strong, b { font-weight: 700; }

small { font-size: var(--step--1); }

blockquote {
  font-family: var(--font-display);
  font-size: var(--step-2);
  font-style: italic;
  line-height: var(--leading-snug);
}

hr {
  border: 0;
  border-block-start: var(--border-width) solid var(--border);
  margin-block: var(--space-l);
}

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

::selection {
  background-color: var(--brand);
  color: var(--on-brand);
}

/* ------------------------------------------------------------------ focus
   Visible for keyboard users, invisible for mouse users, never removed. */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
  border-radius: var(--radius-xs);
}

:target { scroll-margin-block-start: calc(var(--header-h) + var(--space-m)); }

/* ------------------------------------------------------- reduced motion
   Honour the OS setting everywhere, including JS-driven reveals. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
