/* ==========================================================================
   Base: reset, elements, typography, layout primitives, utilities.
   Depends on tokens.css. Contains no component styling.
   ========================================================================== */

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Sticky header offset so anchor links don't land under it. */
  scroll-padding-top: calc(var(--header-height) + var(--space-4));
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  background: var(--color-page);
  color: var(--text-body);
  font-family: var(--font-body);
  font-size: var(--text-md);
  line-height: var(--leading-relaxed);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* The `hidden` attribute must beat any component that sets `display`.
   The UA rule is `[hidden] { display: none }`, which a single class selector
   like `.btn { display: inline-flex }` outranks, so `el.hidden = true` silently
   did nothing to a button and the funnel showed Back, Next, and Submit at once.
   `!important` is the standard fix and is what normalize.css does. */
[hidden] {
  display: none !important;
}

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

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

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

/* The UA default is a groove border with its own padding, which draws a box
   around every radio group and every funnel step. A fieldset is here to bind a
   legend to its controls for assistive tech, not to be a visible container, so
   the grouping stays semantic and the layout comes from .field like any other.
   min-inline-size undoes the UA's min-content floor, which otherwise stops a
   fieldset from shrinking inside a grid column. */
fieldset {
  border: none;
  padding: 0;
  min-inline-size: 0;
}

legend {
  padding: 0;
}

/* ---------- Typography --------------------------------------------------- */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  color: var(--text-heading);
  font-weight: var(--weight-medium);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  text-wrap: balance;
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 {
  font-size: var(--text-sm);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  font-weight: var(--weight-semibold);
}

p {
  text-wrap: pretty;
}

a {
  color: var(--text-link);
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
  text-underline-offset: 0.18em;
  transition: var(--transition-colors);
}

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

strong, b { font-weight: var(--weight-semibold); color: var(--text-heading); }

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

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

hr {
  border: none;
  border-top: var(--border-width) solid var(--border-color-subtle);
  margin-block: var(--space-8);
}

ul, ol { padding-left: var(--space-6); }
li { margin-block: var(--space-1); }

blockquote {
  border-left: 3px solid var(--color-brand-muted);
  padding-left: var(--space-5);
  color: var(--text-muted);
  font-style: italic;
}

abbr[title] {
  text-decoration: underline dotted;
  cursor: help;
}

/* ---------- Focus -------------------------------------------------------- */

:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
  border-radius: var(--radius-xs);
}

/* Mouse users don't get a ring; keyboard users always do. */
:focus:not(:focus-visible) {
  outline: none;
}

.skip-link {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: var(--z-toast);
  padding: var(--space-3) var(--space-5);
  background: var(--color-brand);
  color: var(--color-on-brand);
  border-radius: var(--radius-sm);
  font-weight: var(--weight-semibold);
  transform: translateY(-200%);
  transition: transform var(--duration-fast) var(--ease-out);
}

.skip-link:focus {
  transform: translateY(0);
  color: var(--color-on-brand);
}

/* ---------- Layout primitives -------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.container--narrow { max-width: var(--container-narrow); }
.container--prose  { max-width: var(--container-prose); }

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

.section--tight { padding-block: var(--section-y-tight); }
.section--sunken { background: var(--color-surface-sunken); }
.section--surface { background: var(--color-surface); }
.section--inverse {
  background: var(--color-surface-inverse);
  color: color-mix(in srgb, var(--white) 82%, transparent);
}
.section--inverse h1,
.section--inverse h2,
.section--inverse h3,
.section--inverse h4 { color: var(--white); }
.section--brand {
  background: var(--gradient-brand);
  color: color-mix(in srgb, var(--white) 88%, transparent);
}
.section--brand h1,
.section--brand h2,
.section--brand h3 { color: var(--white); }

/* Auto-fitting grid. --grid-min sets the smallest acceptable column width;
   the browser decides the column count, so there are no media queries. */
.grid {
  display: grid;
  gap: var(--grid-gap, var(--space-6));
  grid-template-columns: repeat(auto-fit, minmax(min(var(--grid-min, 260px), 100%), 1fr));
}

.grid--2 { --grid-min: 380px; }
.grid--3 { --grid-min: 280px; }
.grid--4 { --grid-min: 210px; }
.grid--tight { --grid-gap: var(--space-4); }

.stack > * + * { margin-top: var(--stack-gap, var(--space-4)); }
.stack--sm { --stack-gap: var(--space-2); }
.stack--lg { --stack-gap: var(--space-6); }
.stack--xl { --stack-gap: var(--space-10); }

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

.cluster--center { justify-content: center; }
.cluster--between { justify-content: space-between; }

.split {
  display: grid;
  gap: clamp(var(--space-8), 5vw, var(--space-16));
  align-items: center;
  grid-template-columns: 1fr;
}

@media (min-width: 900px) {
  .split { grid-template-columns: 1fr 1fr; }
  .split--wide-left { grid-template-columns: 1.15fr 0.85fr; }
  .split--wide-right { grid-template-columns: 0.85fr 1.15fr; }
}

/* ---------- Utilities ---------------------------------------------------- */

.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;
}

.text-center { text-align: center; }
.text-balance { text-wrap: balance; }
.text-muted { color: var(--text-muted); }
.text-subtle { color: var(--text-subtle); }
.text-brand { color: var(--color-brand); }
.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); }

.lead {
  font-size: var(--text-xl);
  line-height: var(--leading-normal);
  color: var(--text-muted);
  max-width: 58ch;
}

.text-center .lead,
.section-head .lead { margin-inline: auto; }

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

.mt-0 { margin-top: 0; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mt-12 { margin-top: var(--space-12); }
.mb-0 { margin-bottom: 0; }
.mb-4 { margin-bottom: var(--space-4); }
.mb-8 { margin-bottom: var(--space-8); }
.mb-12 { margin-bottom: var(--space-12); }

.full-width { width: 100%; }

.no-wrap { white-space: nowrap; }

@media print {
  .site-header,
  .site-footer,
  .btn { display: none !important; }
}
