/* Base styles: document defaults, text, focus, and the motion levels. Built only from tokens. */

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

html {
  /* The whole interface is sized in rem, so on very wide screens it scales up smoothly instead of
     leaving a small column in white space (Rule-21 Part A). It never goes below the reader's own size. */
  font-size: clamp(100%, 0.5vw + 0.5rem, 150%);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-padding-block-start: calc(var(--control-height) + var(--space-xl));
}

body {
  margin: 0;
  min-block-size: 100vh;
  min-block-size: 100dvh;
  background: var(--color-surface);
  color: var(--color-text);
  font: var(--weight-regular) var(--text-m) / var(--leading-normal) var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

h1,
h2,
h3,
h4,
p,
ul,
ol,
dl,
dd,
figure,
blockquote {
  margin: 0;
  padding: 0;
}

ul[class],
ol[class] {
  list-style: none;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-heading);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  text-wrap: balance;
}
h1 {
  font-size: var(--text-3xl);
}
h2 {
  font-size: var(--text-2xl);
}
h3 {
  font-size: var(--text-xl);
  line-height: var(--leading-snug);
}
h4 {
  font-size: var(--text-l);
  line-height: var(--leading-snug);
  letter-spacing: 0;
}

p,
li,
dd {
  max-inline-size: var(--measure);
}

a {
  color: var(--color-primary);
  text-underline-offset: 0.18em;
}

img,
svg,
video {
  display: block;
  max-inline-size: 100%;
  block-size: auto;
}

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

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

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: var(--focus-width) solid var(--color-focus);
  outline-offset: 3px;
  border-radius: var(--radius-s);
}

::selection {
  background: var(--color-primary);
  color: var(--color-on-primary);
}

.u-visually-hidden {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

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

.u-lead {
  font-size: var(--text-l);
  color: var(--color-text-muted);
}

.u-numeric {
  font-variant-numeric: tabular-nums;
}

/* The first thing a keyboard reaches. */
.c-skip-link {
  position: absolute;
  inset-inline-start: var(--space-xs);
  inset-block-start: -100vh;
  z-index: var(--z-toast);
  padding: var(--space-s) var(--space-m);
  background: var(--color-primary);
  color: var(--color-on-primary);
  border-radius: var(--radius-s);
}
.c-skip-link:focus {
  inset-block-start: calc(var(--space-xs) + var(--safe-top));
}

/* ---- Motion levels (Rule-04 Part C): off, subtle, standard, cinematic ----
   "Standard" is the default. A reduced-motion preference starts the page at "subtle": fades stay,
   movement goes. "Off" removes animation altogether. Components read --motion-distance for movement. */
:root {
  --motion-distance: 0.75rem;
}
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion="standard"]):not([data-motion="cinematic"]) {
    --motion-distance: 0rem;
    --duration-base: 200ms;
    --duration-slow: 200ms;
  }
}
:root[data-motion="subtle"] {
  --motion-distance: 0rem;
  --duration-base: 200ms;
  --duration-slow: 200ms;
}
:root[data-motion="off"] *,
:root[data-motion="off"] *::before,
:root[data-motion="off"] *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}

/* ---- Reveal on scroll: a section fades up once when it is first seen ----
   Only when JavaScript is running (the "js" class), so that nothing is ever hidden without it.
   A child can wait its turn with .u-reveal--2 and so on. */
.js .u-reveal {
  opacity: 0;
  translate: 0 var(--motion-distance);
}
.js .u-reveal.is-visible {
  opacity: 1;
  translate: none;
  transition:
    opacity var(--duration-slow) var(--ease-out),
    translate var(--duration-slow) var(--ease-out);
}
.js .u-reveal--2.is-visible {
  transition-delay: var(--stagger);
}
.js .u-reveal--3.is-visible {
  transition-delay: calc(var(--stagger) * 2);
}
:root[data-motion="off"] .u-reveal {
  opacity: 1;
  translate: none;
}
@media print {
  .js .u-reveal {
    opacity: 1;
    translate: none;
  }
}

/* ---- Windows high-contrast and other forced-colour modes: keep shapes visible ---- */
@media (forced-colors: active) {
  :focus-visible {
    outline-color: Highlight;
  }
}

@media print {
  body {
    background: #fff;
    color: #000;
  }
}
