/* ==========================================================================
   Base styles: fonts, reset, typography and layout primitives.
   Every colour, size and space comes from tokens.css.
   ========================================================================== */

/* Fonts: self-hosted IBM Plex, Latin subset, SIL Open Font License 1.1.
   The licences are in the fonts folder next to the files. */
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/ibm-plex-sans-latin-400-normal.77bc02670657.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/ibm-plex-sans-latin-500-normal.f7016cd446d2.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/ibm-plex-sans-latin-600-normal.196e3cbc5fee.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/ibm-plex-mono-latin-400-normal.79936b18df9f.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Anchor links and the skip link land below the sticky header. */
  scroll-padding-top: var(--header-offset);
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--theme-bg);
  color: var(--theme-text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: 400;
  line-height: var(--leading-body);
  /* A long word, address or link breaks rather than run off a narrow screen. */
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

main {
  flex: 1 0 auto;
}

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

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

[hidden] {
  display: none !important;
}

::selection {
  background: var(--color-accent-tint);
  color: var(--color-ink);
}

/* Typography */
h1, .h1,
h2, .h2,
h3, .h3,
h4, .h4 {
  font-weight: 600;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  text-wrap: balance;
}

h1, .h1 { font-size: var(--text-4xl); }
h2, .h2 { font-size: var(--text-3xl); }
h3, .h3 { font-size: var(--text-2xl); line-height: var(--leading-snug); }
h4, .h4 { font-size: var(--text-xl); line-height: var(--leading-snug); letter-spacing: 0; }

p {
  text-wrap: pretty;
}

strong,
b {
  font-weight: 600;
}

em,
i {
  font-style: normal;
  font-weight: 500;
}

small,
.text-sm {
  font-size: var(--text-sm);
}

.text-xs {
  font-size: var(--text-xs);
}

.text-lg {
  font-size: var(--text-lg);
}

.text-xl {
  font-size: var(--text-xl);
}

.text-muted {
  color: var(--theme-text-muted);
}

.lead {
  font-size: var(--text-lg);
  line-height: var(--leading-snug);
  color: var(--theme-text-muted);
  max-width: var(--measure);
}

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: text-decoration-thickness var(--duration) var(--ease);
}

a:hover {
  text-decoration-thickness: 2px;
}

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

pre {
  overflow-x: auto;
  padding: var(--space-4);
  background: var(--theme-bg-alt);
  border: var(--border) solid var(--theme-rule);
  border-radius: var(--radius);
}

hr {
  border: 0;
  border-top: var(--border) solid var(--theme-rule);
}

blockquote {
  padding-left: var(--space-5);
  border-left: 3px solid var(--color-accent);
  font-size: var(--text-lg);
  line-height: var(--leading-snug);
}

:focus-visible {
  outline: 3px solid var(--theme-text);
  outline-offset: 3px;
}

.on-dark :focus-visible {
  outline-color: var(--color-accent);
}

/* Long-form content: article text and anything an editor writes */
.prose {
  max-width: var(--measure);
}

.prose > * + * {
  margin-top: var(--space-4);
}

.prose > h2 {
  margin-top: var(--space-8);
}

.prose > h3,
.prose > h4 {
  margin-top: var(--space-7);
}

.prose > h2 + *,
.prose > h3 + *,
.prose > h4 + * {
  margin-top: var(--space-3);
}

.prose ul,
.prose ol {
  padding-left: 1.25em;
}

.prose li + li {
  margin-top: var(--space-2);
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

th,
td {
  padding: var(--space-3) var(--space-4) var(--space-3) 0;
  text-align: left;
  vertical-align: top;
  border-bottom: var(--border) solid var(--theme-rule);
}

th {
  font-weight: 600;
}

thead th {
  border-bottom-color: var(--theme-rule-strong);
}

/* A table wider than the screen scrolls inside a ruled box, so its edge shows. */
.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: thin;
}

.table-scroll:has(> table:not(.spec-table)) {
  border-inline: var(--border) solid var(--theme-rule);
}

/* Phones: short cells stay on one line and the table scrolls, rather than
   squeezing every column into tall, narrow rows. The last column, usually
   a sentence, wraps at a readable width. */
@media (max-width: 47.9375rem) {
  .table-scroll > table:not(.spec-table) :is(th, td) {
    white-space: nowrap;
  }

  .table-scroll > table:not(.spec-table) td:last-child {
    min-width: var(--table-note-min);
    white-space: normal;
  }
}

/* Layout primitives. The side margin grows past a phone's notch or rounded corners. */
.container,
.container--narrow {
  --side: max(var(--gutter), env(safe-area-inset-left), env(safe-area-inset-right));
  width: min(100% - 2 * var(--side), var(--container));
  margin-inline: auto;
}

.container--narrow {
  width: min(100% - 2 * var(--side), var(--container-narrow));
}

.section {
  padding-block: var(--section-space);
}

.section--tight {
  padding-block: var(--section-space-tight);
}

.section--surface {
  background: var(--theme-bg-alt);
}

.section--ink {
  background: var(--color-ink);
  color: var(--color-paper);
}

.on-dark .text-muted,
.on-dark .lead {
  color: var(--color-on-dark-muted);
}

.stack {
  --stack-space: var(--space-4);
}

.stack--loose {
  --stack-space: var(--space-7);
}

.stack > * + * {
  margin-top: var(--stack-space);
}

.measure {
  max-width: var(--measure);
}

.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--cluster-space, var(--space-4));
}

.grid {
  display: grid;
  gap: var(--grid-gap, var(--space-6));
  grid-template-columns: repeat(auto-fit, minmax(min(var(--grid-min, 16rem), 100%), 1fr));
}

.list-plain {
  padding: 0;
  list-style: none;
}

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

.skip-link {
  position: absolute;
  top: -5rem;
  left: var(--space-4);
  z-index: 100;
  padding: var(--space-3) var(--space-4);
  background: var(--color-ink);
  color: var(--color-paper);
}

.skip-link:focus {
  top: var(--space-4);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
