/* ==========================================================================
   Base — reset, typography, base elements, focus styles, skip link
   ========================================================================== */

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

* {
  margin: 0;
}

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

html[data-theme="dark"] {
  color-scheme: dark;
}

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

body {
  min-height: 100vh;
  background: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  font-weight: var(--weight-regular);
  line-height: var(--leading-body);
  letter-spacing: var(--tracking-normal);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

h1,
h2,
h3,
h4 {
  font-family: var(--font-sans);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--color-ink);
}

h1 {
  font-size: var(--text-h1);
  line-height: var(--leading-display);
}

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

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

h4 {
  font-size: var(--text-h4);
}

p {
  color: var(--color-ink-80);
}

a {
  color: inherit;
  text-decoration: none;
}

ul,
ol {
  list-style: none;
  padding: 0;
}

button {
  font-family: inherit;
  cursor: pointer;
}

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

svg {
  flex-shrink: 0;
}

/* Focus visibility — WCAG AA */
:focus {
  outline: none;
}

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

/* Skip link */
.skip-link {
  position: absolute;
  top: -48px;
  left: var(--space-4);
  z-index: var(--z-nav);
  padding: var(--space-2) var(--space-4);
  background: var(--color-paper);
  color: var(--color-ink);
  border: var(--border-hairline);
  border-radius: var(--radius-1);
  font-size: var(--text-body-sm);
  transition: top var(--motion-fast) var(--easing-standard);
}

.skip-link:focus-visible {
  top: var(--space-4);
}

/* Screen-reader-only utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Selection */
::selection {
  background: var(--color-accent-wash);
  color: var(--color-accent-strong);
}

/* Prose utility */
.prose {
  max-width: var(--container-prose);
}

.prose p + p {
  margin-top: var(--space-4);
}
