/* ==========================================================================
   BASE — reset, document defaults, typography, layout primitives, a11y
   Depends on: tokens.css
   ========================================================================== */

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

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Offset for the sticky header when jumping to an in-page anchor */
  scroll-padding-top: calc(var(--header-h) + var(--sp-md));
  -moz-tab-size: 4;
  tab-size: 4;
}

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

body {
  min-height: 100svh;
  background-color: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font-body);
  font-size: var(--fs-md);
  font-weight: var(--fw-regular);
  line-height: var(--lh-relaxed);
  font-synthesis-weight: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

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

img { background-color: var(--c-bg-subtle); }

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

p, h1, h2, h3, h4, h5, h6, li, figcaption, dd, dt { overflow-wrap: break-word; }

ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }

:target { scroll-margin-top: calc(var(--header-h) + var(--sp-md)); }

/* ---------- Typography -------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  color: var(--c-heading);
  font-weight: var(--fw-bold);
  line-height: var(--lh-heading);
  letter-spacing: var(--ls-tight);
  text-wrap: balance;
}

h1 { font-size: var(--fs-4xl); line-height: var(--lh-tight); letter-spacing: var(--ls-tighter); }
h2 { font-size: var(--fs-3xl); line-height: var(--lh-snug); }
h3 { font-size: var(--fs-2xl); }
h4 { font-size: var(--fs-xl); }
h5 { font-size: var(--fs-lg); }
h6 {
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
}

p { text-wrap: pretty; }

a {
  color: var(--c-link);
  text-decoration-color: color-mix(in srgb, currentColor 38%, transparent);
  text-underline-offset: 0.18em;
  text-decoration-thickness: from-font;
  transition: color var(--dur-fast) var(--ease-out),
              text-decoration-color var(--dur-fast) var(--ease-out);
}
a:hover { color: var(--c-link-hover); text-decoration-color: currentColor; }

strong, b { font-weight: var(--fw-semibold); }
em, i { font-style: italic; }

small { font-size: var(--fs-xs); }

blockquote {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  line-height: var(--lh-normal);
  font-style: italic;
  color: var(--c-heading);
}

figure { margin: 0; }

hr {
  border: 0;
  border-top: var(--bw) solid var(--c-border);
  margin-block: var(--sp-xl);
}

::selection {
  background-color: var(--p-mist);
  color: var(--p-deep);
}

/* ---------- Focus ------------------------------------------------------- */
/* A single, highly visible ring. Never remove it — WCAG 2.4.7 / 2.4.11. */
:focus-visible {
  outline: 3px solid var(--c-focus);
  outline-offset: 3px;
  border-radius: var(--r-xs);
}
:focus:not(:focus-visible) { outline: none; }

/* On dark sections the ring switches to the light variant */
.is-inverse :focus-visible,
:is(.section--dark, .access-panel, .cta-band) :focus-visible {
  outline-color: var(--c-focus-inverse);
}

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

.skip-link {
  position: absolute;
  top: var(--sp-2xs);
  left: var(--sp-2xs);
  z-index: var(--z-skiplink);
  display: inline-block;
  padding: var(--sp-xs) var(--sp-md);
  background-color: var(--c-bg-inverse);
  color: var(--c-text-inverse);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  text-decoration: none;
  border-radius: var(--r-sm);
  box-shadow: var(--sh-lg);
  transform: translateY(calc(-100% - var(--sp-lg)));
  transition: transform var(--dur-fast) var(--ease-out);
}
.skip-link:focus { transform: translateY(0); color: var(--c-text-inverse); }

/* ---------- Layout primitives ------------------------------------------ */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.container--wide   { max-width: var(--container-wide); }
.container--narrow { max-width: var(--container-narrow); }

.section { padding-block: var(--section-y); }
.section--tight { padding-block: var(--section-y-tight); }
.section--flush-top { padding-block-start: 0; }
.section--flush-bottom { padding-block-end: 0; }

.section--sand    { background-color: var(--c-bg-sand); }
.section--subtle  { background-color: var(--c-bg-subtle); }

/* --- Dark surfaces ------------------------------------------------------
   Three blocks render on the deep-lake ground: full-width dark sections, the
   accessibility panel and the CTA band. They share one selector group so a
   colour rule is never written for one and silently forgotten on the others.
   To add a fourth dark block, add its class to every `:is(...)` group that
   mentions these three (base.css and components.css).
   ------------------------------------------------------------------------ */
:is(.section--dark, .access-panel, .cta-band) {
  background-color: var(--c-bg-inverse);
  color: var(--c-text-inverse-muted);
}
:is(.section--dark, .access-panel, .cta-band) :is(h1, h2, h3, h4, h5) { color: var(--c-text-inverse); }
/* Plain links on dark surfaces turn to mist. Components carry their own
   colours and must NOT be recoloured here — a `.btn` inside the accessibility
   panel has to stay white on clay, not mist on clay. Any new dark-surface
   component belongs in this :not() list. */
:is(.section--dark, .access-panel, .cta-band) a:not(.btn, .link-arrow, .contact-tile, .chip, .icon-btn, .brand, .skip-link) { color: var(--p-mist); }
:is(.section--dark, .access-panel, .cta-band) a:not(.btn, .link-arrow, .contact-tile, .chip, .icon-btn, .brand, .skip-link):hover { color: var(--p-white); }

.stack > * + * { margin-block-start: var(--flow, var(--sp-md)); }
.stack--sm { --flow: var(--sp-sm); }
.stack--lg { --flow: var(--sp-lg); }
.stack--xl { --flow: var(--sp-xl); }

.prose { max-width: var(--measure); }
.prose--narrow { max-width: var(--measure-narrow); }
.prose > * + * { margin-block-start: var(--sp-md); }
.prose h2 { margin-block-start: var(--sp-xl); }
.prose h3 { margin-block-start: var(--sp-lg); }
.prose ul, .prose ol { padding-inline-start: 1.35em; }
.prose li + li { margin-block-start: var(--sp-2xs); }

.grid { display: grid; gap: var(--grid-gap); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); }

.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-sm);
  align-items: center;
}
.cluster--center { justify-content: center; }

.text-center { text-align: center; }
.mx-auto { margin-inline: auto; }

/* Utility: hide only when JS is available (progressive enhancement) */
.js .js-hidden { display: none; }
.no-js .no-js-hidden { display: none; }
