/* Base layer: reset, document typography, focus and motion guards, and the
   layout primitives pages compose. Everything reads tokens. */

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

* {
  margin: 0;
}

html {
  scroll-behavior: smooth;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--surface-page);
  color: var(--ink-body);
  font-family: var(--font-ui);
  font-size: var(--text-md);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

h1,
h2,
h3,
h4 {
  color: var(--ink-strong);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-heading);
  text-wrap: balance;
}

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

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

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

p {
  text-wrap: pretty;
}

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

pre {
  background: var(--surface-sunken);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  line-height: var(--leading-body);
  overflow-x: auto;
  padding: var(--space-3) var(--space-4);
}

pre code {
  font-size: inherit;
}

a {
  color: var(--accent-strong);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

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

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

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

:focus-visible {
  border-radius: var(--radius-sm);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* [hidden] is a UA display:none that any display rule overrides — keep the
   escape hatch explicit so hidden always wins. */
[hidden] {
  display: none !important;
}

/* Reduced motion: no movement, anywhere. Transitions collapse to zero. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: var(--dur-instant) !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: var(--dur-instant) !important;
  }

  html {
    scroll-behavior: auto;
  }
}

/* Skip link — first tabbable element on every page. */
.skip-link {
  background: var(--surface-raised);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
  color: var(--ink-strong);
  font-weight: var(--weight-medium);
  inset-block-start: var(--space-3);
  inset-inline-start: var(--space-3);
  padding: var(--space-2) var(--space-4);
  position: fixed;
  transform: translateY(-200%);
  transition: transform var(--dur-2) var(--ease-out);
  z-index: var(--z-skip);
}

.skip-link:focus-visible {
  transform: none;
}

/* ── Layout primitives ─────────────────────────────────────────────── */

.container {
  margin-inline: auto;
  max-width: var(--container);
  padding-inline: var(--space-5);
}

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

.stack {
  display: flex;
  flex-direction: column;
}

.stack > * + * {
  margin-block-start: var(--stack-gap, var(--space-4));
}

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

.grid {
  display: grid;
  gap: var(--grid-gap, var(--space-5));
}

.visually-hidden {
  clip: rect(0 0 0 0);
  border: 0;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

/* Shared micro-utilities used by JS-rendered fragments. */
.is-error {
  color: var(--danger);
}

.is-hidden {
  display: none !important;
}
