/* ===========================================================
   BASE — reset, typography defaults, accessibility primitives.
   Loaded on every page, right after tokens.css.
   =========================================================== */

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

html {
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: auto; /* Lenis takes over smooth scrolling in JS */
}

body {
  min-height: 100svh;
  background: var(--color-bg);
  color: var(--color-fg);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
}

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

img { font-style: italic; } /* readable alt text if an image fails to load */

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

button { background: none; border: none; cursor: pointer; }

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

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

table { border-collapse: collapse; width: 100%; }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  text-wrap: balance;
}

p { text-wrap: pretty; }

/* ---------- Selection ---------- */
::selection {
  background: var(--color-purple);
  color: var(--color-paper);
}

/* ---------- Focus ---------- */
:focus { outline: none; }

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

/* ---------- Scrollbar (progressive enhancement, WebKit/Chromium/Firefox) ---------- */
html { scrollbar-color: var(--color-purple-dim) transparent; scrollbar-width: thin; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-purple-dim); border-radius: var(--radius-pill); }
::-webkit-scrollbar-thumb:hover { background: var(--color-purple); }

/* ---------- Accessibility utilities ---------- */
.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 {
  position: fixed;
  top: var(--space-3);
  left: var(--space-3);
  z-index: var(--z-toast);
  background: var(--color-purple);
  color: var(--color-paper);
  font-weight: 600;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  transform: translateY(-150%);
  transition: transform var(--duration-fast) var(--ease-out-quart);
}

.skip-link:focus {
  transform: translateY(0);
}

/* ---------- Reduced motion: the master switch ----------
   JS reads this same media query and disables GSAP/Lenis/WebGL work
   accordingly, but this rule guarantees CSS-only motion is also safe
   even if JS fails to load at all. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- No-JS fallback ----------
   Elements authored for scroll/JS reveal must be visible by default;
   JS adds the [data-animate] hidden state itself once it's confirmed running,
   so a failed script never hides content. See main.js: html.js class toggle. */
html:not(.js) [data-animate] {
  opacity: 1 !important;
  transform: none !important;
}
