/* ================================================================
   base.css - reset, base typography, a11y helpers, page frame.
   References tokens only.
   ================================================================ */

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

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

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-body);
  font-weight: var(--fw-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  padding-bottom: calc(var(--dock-h) + 18px); /* clearance for the fixed dock */
}

/* Ambient "fog" ember - one fixed glow pinned just above the dock,
   painted behind all content (z-index -1 sits above the canvas
   background, below in-flow content). Was the per-divider glow. */
body::before {
  content: "";
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--dock-h);
  height: var(--glow-h);
  z-index: -1;
  pointer-events: none;
  background: var(--glow-bg);
}

/* Film grain overlay - inline SVG turbulence, no external fetch. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  opacity: var(--noise-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 160px 160px;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

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

h1, h2, h3, h4 {
  line-height: 1.1;
}

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

/* ---------------- a11y helpers ---------------- */

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

.skip-link {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 100;
  padding: 0.75rem 1.25rem;
  background: var(--bg-raised);
  color: var(--ink);
  border: 1px solid var(--accent-bright);
  border-radius: var(--radius);
  font-size: var(--text-micro);
  font-weight: var(--fw-medium);
  letter-spacing: var(--track-nav);
  text-transform: uppercase;
  text-decoration: none;
  transform: translateY(-200%);
  transition: transform 0.2s var(--ease);
}
.skip-link:focus-visible {
  transform: none;
}

/* Honor the hidden attribute even on flex/grid containers. */
[hidden] {
  display: none !important;
}

/* One consistent focus ring across all targets. */
:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 3px;
}
:focus:not(:focus-visible) {
  outline: none;
}

/* ---------------- Section reveals (JS adds .js to <html>) -------
   Content is visible by default; only when JS is present do we hide
   [data-reveal] until it is revealed. Reduced-motion shows all. */
html.js [data-reveal] {
  opacity: 0;
  transform: translateY(28px);
  transition:
    opacity var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}
html.js [data-reveal].is-revealed {
  opacity: 1;
  transform: none;
}

/* ---------------- Reduced motion ---------------- */
@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;
    scroll-behavior: auto !important;
  }
  html.js [data-reveal] {
    opacity: 1;
    transform: none;
  }
}
