/* Element defaults. No classes here — only what bare HTML should look like. */

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

html {
  -webkit-text-size-adjust: 100%;
  /* Anchor links and the skip link land below the sticky header rather than
     underneath it. */
  scroll-padding-block-start: var(--space-xl);
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  /* Kerning and ligatures: this is an editorial page, not a dashboard. */
  font-kerning: normal;
  text-rendering: optimizeLegibility;
}

/* --- Headings ------------------------------------------------------------- */

h1,
h2,
h3,
h4 {
  margin-block: 0 var(--space-s);
  color: var(--ink-strong);
  font-family: var(--font-display);
  font-weight: 600;
  line-height: var(--leading-tight);
  /* Prevents a lone word on the last line of a display heading. */
  text-wrap: balance;
}

h1 { font-size: var(--text-2xl); letter-spacing: -0.01em; }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-md); }

/* --- Flow ----------------------------------------------------------------- */

p,
ul,
ol,
dl,
blockquote,
figure,
table {
  margin-block: 0 var(--space-s);
}

p {
  /* Avoids a single trailing word on a paragraph's last line. */
  text-wrap: pretty;
}

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

/* Space above a heading that follows body copy, without collapsing margins. */
* + :is(h2, h3) {
  margin-block-start: var(--space-l);
}

/* --- Links ---------------------------------------------------------------- */

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  transition: color var(--transition);
}

a:hover {
  color: var(--accent-hover);
  text-decoration-thickness: 2px;
}

/* --- Media ---------------------------------------------------------------- */

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

/* --- Quotes and rules ----------------------------------------------------- */

blockquote {
  margin-inline: 0;
  padding-inline-start: var(--space-m);
  border-inline-start: 2px solid var(--accent-surface);
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-style: italic;
  color: var(--ink);
}

hr {
  height: 1px;
  margin-block: var(--space-l);
  border: 0;
  background: var(--rule);
}

/* --- Forms ---------------------------------------------------------------- */

input,
textarea,
select,
button {
  font: inherit;
  color: inherit;
}

/* --- Focus ----------------------------------------------------------------
 * A visible focus ring is a requirement. If this ever needs changing, replace
 * it with something at least as visible — never remove it.
 */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 1px;
}

/* --- Motion ---------------------------------------------------------------
 * Respect the OS setting. Near-zero rather than `none` so transitionend and
 * animationend still fire and no JS waits forever on an event.
 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
