/* ==========================================================================
   Apex Cognition — Reset, typography, texture, a11y utilities
   ========================================================================== */

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

* { margin: 0; }

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

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-normal);
  font-synthesis-weight: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Global grain. Fixed so it reads as film texture over the page, not as
   something that scrolls with content. Pointer-events off so it never
   intercepts a click. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: var(--noise);
  background-size: 140px 140px;
  opacity: 0.16;
  mix-blend-mode: overlay;
  pointer-events: none;
  z-index: 999;
}

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

canvas { touch-action: pan-y; }

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

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

a { color: var(--accent-text); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--text); }

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

/* --- Headings -------------------------------------------------------- */

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: var(--tracking-display);
  line-height: var(--lh-snug);
  text-wrap: balance;
}

h1 { font-size: var(--fs-hero); line-height: var(--lh-tight); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); letter-spacing: -0.02em; }

p { text-wrap: pretty; }

/* --- Shared text roles ----------------------------------------------- */

.lead {
  font-size: var(--fs-lead);
  line-height: var(--lh-loose);
  color: var(--text-dim);
  max-width: var(--measure);
}

.prose { max-width: var(--measure); }
.prose p + p { margin-top: var(--space-5); }

/* Mono eyebrow label — the "quantified" tell, used above every section H2 */
.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-mono-label);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--accent-text);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.eyebrow::before {
  content: "";
  width: 24px;
  height: 1px;
  background: currentColor;
  opacity: 0.6;
  flex: none;
}

.eyebrow--amber { color: var(--accent-3); }

/* Any number, dose, price, or biomarker reads as data. */
.data,
.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.small-print {
  font-size: var(--fs-xs);
  line-height: var(--lh-normal);
  color: var(--text-dim);
}

.text-accent { color: var(--accent-text); }
.text-amber  { color: var(--accent-3); }
.text-dim    { color: var(--text-dim); }

/* --- Layout ---------------------------------------------------------- */

.section {
  position: relative;
  padding-block: var(--section-pad-y);
}

.shell {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
  position: relative;
  z-index: var(--z-content);
}

.shell--wide { max-width: var(--content-wide); }

.section-head { margin-bottom: var(--space-8); max-width: var(--measure); }
.section-head h2 + .lead { margin-top: var(--space-5); }

/* Hairline divider between sections, fading at the edges so it doesn't
   read as a hard table rule. */
.rule {
  height: 1px;
  border: 0;
  background: linear-gradient(90deg, transparent, var(--line-strong) 18%, var(--line-strong) 82%, transparent);
}

/* --- Accessibility --------------------------------------------------- */

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

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: var(--space-4);
  z-index: var(--z-skiplink);
  padding: var(--space-3) var(--space-5);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  border-radius: var(--r-md);
  transform: translateY(-200%);
  transition: transform var(--dur-fast) var(--ease);
}

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

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

/* --- Scroll-reveal base ---------------------------------------------- */
/* js/motion.js adds .is-visible. Kept here so content is styled correctly
   even if JS fails — see the no-js fallback below. */

.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition:
    opacity var(--dur-slow) var(--ease),
    transform var(--dur-slow) var(--ease);
  will-change: opacity, transform;
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* Staggered children */
.reveal[data-delay="1"] { transition-delay: 80ms; }
.reveal[data-delay="2"] { transition-delay: 160ms; }
.reveal[data-delay="3"] { transition-delay: 240ms; }
.reveal[data-delay="4"] { transition-delay: 320ms; }
.reveal[data-delay="5"] { transition-delay: 400ms; }

/* If JS never runs, nothing should stay invisible. */
.no-js .reveal { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }

  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
