/* ==========================================================================
   base.css — Reset, typography, layout primitives
   Authority: PRD v1.1 §14.6, NFR-003, NFR-006, A11Y-002, A11Y-010, A11Y-011
   Low-specificity element and utility selectors only.
   ========================================================================== */

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

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

body {
  font-family: var(--font-body);
  font-size: var(--fs-300);
  line-height: var(--lh-normal);
  color: var(--c-text);
  background: var(--c-bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-kerning: normal;
  font-feature-settings: "kern" 1, "liga" 1;
}

/* Prevent unintended horizontal scroll at supported widths (NFR-003, AC-005) */
html, body { max-width: 100%; overflow-x: clip; }

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

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

/* --- Typography --- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: var(--lh-tight);
  color: var(--c-primary);
  font-weight: var(--fw-bold);
  text-wrap: balance;
}
h1 { font-size: var(--fs-800); letter-spacing: -0.015em; }
h2 { font-size: var(--fs-700); letter-spacing: -0.01em; }
h3 { font-size: var(--fs-500); line-height: var(--lh-snug); }
h4 { font-size: var(--fs-400); font-weight: var(--fw-semibold); }

p, li { max-width: var(--measure); }
p + p { margin-top: var(--sp-4); }
p { text-wrap: pretty; }

a {
  color: var(--c-accent);
  text-decoration-color: color-mix(in srgb, var(--c-accent) 45%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  transition: text-decoration-color var(--motion-fast) var(--motion-ease),
              color var(--motion-fast) var(--motion-ease);
}
a:hover { color: var(--color-accent-500); text-decoration-color: currentColor; }

strong { font-weight: var(--fw-semibold); }

ul, ol { padding-left: 1.25rem; }
li + li { margin-top: var(--sp-2); }

/* --- Focus (A11Y-004): visible, not color-only --- */
:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
  border-radius: 2px;
}
:focus:not(:focus-visible) { outline: none; }

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

.section { padding-block: var(--sp-8); }
.section--alt { background: var(--c-bg-alt); }
.section__lead { color: var(--c-text-muted); font-size: var(--fs-400); max-width: var(--measure); }

.stack > * + * { margin-top: var(--sp-4); }
.stack-lg > * + * { margin-top: var(--sp-6); }

/* Spacing utilities (NFR-006: no inline styles in HTML) */
.mt-6 { margin-top: var(--sp-6); }
.mt-7 { margin-top: var(--sp-7); }

.eyebrow {
  font-family: var(--font-body);
  font-size: var(--fs-100);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-accent);
  margin-bottom: var(--sp-2);
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
}
/* Signature: a short accent rule trailing every eyebrow — quiet thread tying
   the academic sections together. */
.eyebrow::after {
  content: "";
  width: 2rem;
  height: 2px;
  background: var(--c-accent);
  opacity: 0.5;
}

/* --- Skip link (FR-005, A11Y-003) --- */
.skip-link {
  position: absolute;
  left: var(--sp-2);
  top: -100px;
  z-index: var(--z-skiplink);
  background: var(--c-primary);
  color: var(--c-text-invert);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: top var(--motion-fast) var(--motion-ease);
}
.skip-link:focus { top: var(--sp-2); color: var(--c-text-invert); }

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

/* --- Reduced motion (A11Y-010) --- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
