/* Base: reset, typography, browser surfaces, layout primitives. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 5.5rem; }
body {
  margin: 0;
  background: var(--color-background);
  color: var(--color-text-primary);
  font-family: var(--font-body);
  font-size: var(--text-body);
  line-height: var(--leading-body);
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
img, svg, video { display: block; max-width: 100%; height: auto; }
h1, h2, h3, h4 {
  font-family: var(--font-heading);
  color: var(--color-text-primary);
  margin: 0;
  text-wrap: balance;
}
h1 { font-size: var(--text-h1); line-height: var(--leading-tight); font-weight: 800; letter-spacing: var(--tracking-display); }
h2 { font-size: var(--text-h2); line-height: var(--leading-heading); font-weight: 750; letter-spacing: var(--tracking-heading); }
h3 { font-size: var(--text-h3); line-height: 1.3; font-weight: 700; letter-spacing: -0.01em; }
h4 { font-size: var(--text-h4); line-height: 1.35; font-weight: 700; }
/* text-wrap: pretty removed (layout cost test) */
p { margin: 0; }
.flow > p, .flow > ul, .reading, .section__head > p { max-width: 62ch; }
p + p { margin-top: var(--space-4); }
ul, ol { margin: 0; padding: 0; }

a { color: var(--color-teal); text-decoration-line: underline; text-decoration-thickness: 1px; text-underline-offset: 0.2em; transition: text-decoration-thickness var(--duration-fast) var(--ease-out); }
a:hover { text-decoration-thickness: 2px; }

/* Browser surfaces carry the palette */
::selection { background: var(--color-cta-background); color: var(--color-button-text); }
:focus-visible { outline: var(--focus-ring); outline-offset: var(--focus-offset); border-radius: 4px; }
input, textarea, select { caret-color: var(--color-teal); }
html { scrollbar-color: var(--color-text-secondary) var(--color-section-alt); }
.num, table { font-variant-numeric: tabular-nums; }

/* Layout primitives */
.container { width: 100%; max-width: calc(var(--width-container) + 2 * var(--space-gutter)); margin-inline: auto; padding-inline: var(--space-gutter); }
.reading { max-width: var(--width-reading); }
.section { padding-block: var(--space-section); }
.section--alt { background: var(--color-section-alt); }
.section--cta { background: var(--color-cta-background); }
.section__head { max-width: var(--width-reading); margin-bottom: var(--space-8); }
.section__head h2 + * { margin-top: var(--space-4); }
.lead { font-size: var(--text-lead); color: var(--color-text-secondary); line-height: 1.6; }
.muted { color: var(--color-text-secondary); }
.mono { font-family: var(--font-mono); font-size: var(--text-xs); letter-spacing: 0; }

.skip-link { position: absolute; left: var(--space-4); top: -100px; z-index: 100; background: var(--color-surface); color: var(--color-text-primary); padding: var(--space-3) var(--space-4); border: 1px solid var(--color-text-secondary); border-radius: var(--radius-button); font-weight: 600; }
.skip-link:focus { top: var(--space-4); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

@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; }
}
a[href^="tel:"], a[href^="mailto:"] { white-space: nowrap; }

/* Short pages (404, legal): keep the footer at the bottom of the viewport instead of leaving page background below it. */
body { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
body > main { flex: 1 0 auto; }
