/* ==========================================================================
   Base: reset, typography, focus, accessibility utilities
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + var(--space-16));
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  font-weight: 400;
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

main {
  flex: 1 0 auto;
}

/* Programmatic focus target after navigation; never show a ring on it. */
main:focus {
  outline: none;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: 700;
  line-height: var(--leading-tight);
  letter-spacing: -0.02em;
  text-wrap: balance;
}

h1 { font-size: clamp(var(--text-heading), 1.25rem + 4vw, var(--text-display)); letter-spacing: -0.03em; }
h2 { font-size: var(--text-heading); }
h3 { font-size: var(--text-heading-sm); line-height: var(--leading-snug); }
h4 { font-size: var(--text-lead); line-height: var(--leading-snug); }

p { margin: 0; }
ul, ol { margin: 0; }

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

img { height: auto; }

a {
  color: var(--color-link);
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-thickness: 2px;
}

address {
  font-style: normal;
}

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

[hidden] {
  display: none !important;
}

::selection {
  background: var(--color-brand);
  color: #fff;
}

/* Keyboard focus: always visible, 3:1+ against the surface it sits on. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

:where(input, select, textarea):focus-visible {
  outline-offset: 1px;
}

/* ---- Accessibility utilities ---------------------------------------------- */

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

.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-16);
  z-index: 100;
  padding: var(--space-12) var(--space-16);
  border-radius: var(--radius-control);
  background: #000;
  color: #fff;
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  top: var(--space-16);
  outline: 3px solid #fff;
  outline-offset: 2px;
  box-shadow: 0 0 0 5px #000;
}

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