/* =========================================================
   BASE.CSS — Resets, typography defaults, accessibility helpers
========================================================= */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: auto; /* smooth scroll applied conditionally via JS + .smooth-scroll class */
}

html.smooth-scroll { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  color: var(--color-text);
  background: var(--color-background);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

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

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-tight);
  color: var(--color-text);
  line-height: var(--lh-tight);
}

/* Fluid headings: scale smoothly between breakpoints instead of
   jumping at fixed media queries — reads as considered on every
   viewport from a 390px phone to a 1440px desktop. */
h1 { font-size: clamp(2.25rem, 1.5rem + 3.2vw, var(--fs-5xl)); letter-spacing: var(--tracking-tighter); }
h2 { font-size: clamp(1.625rem, 1.25rem + 1.6vw, var(--fs-3xl)); }
h3 { font-size: clamp(1.375rem, 1.15rem + 0.9vw, var(--fs-2xl)); }
h4 { font-size: var(--fs-xl); }

p { margin: 0; color: var(--color-text-secondary); }

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

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

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

input, textarea, select { font-family: inherit; font-size: inherit; }

/* ---------- FOCUS STATES (accessibility) ---------- */
:focus { outline: none; }

:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-radius: var(--radius-sm);
}

a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
  box-shadow: var(--shadow-focus);
}

/* ---------- SCREEN-READER-ONLY HELPERS ---------- */
.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;
}

/* ---------- SKIP LINK ---------- */
.skip-link {
  position: absolute;
  top: -48px;
  left: var(--space-4);
  z-index: var(--z-toast);
  background: var(--color-text);
  color: var(--color-text-inverse);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  transition: top var(--transition-fast);
}

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

/* ---------- SELECTION ---------- */
::selection {
  background: var(--color-primary-200);
  color: var(--color-primary-900);
}

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

/* ---------- HIGH CONTRAST TEXT UTILITIES ---------- */
.text-muted   { color: var(--color-text-muted); }
.text-secondary { color: var(--color-text-secondary); }
.text-inverse { color: var(--color-text-inverse); }

/* ---------- LAZY IMAGE FADE-IN ---------- */
img[loading="lazy"] {
  opacity: 0;
  transition: opacity var(--transition-slow);
}
img.gl-loaded {
  opacity: 1;
}
