/* ============================================================
   VISTEX — Base: reset, typography, layout primitives
   ============================================================ */

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 24px);
  -moz-tab-size: 4; tab-size: 4;
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* The header is position:fixed, so every page reserves its height here.
   Home opts out: its hero runs full-bleed under a transparent nav. */
body { padding-top: var(--header-h); }
body[data-page="home"] { padding-top: 0; }

body {
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: var(--lh-normal);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv02','cv03','cv04','cv11';
  overflow-x: hidden;
  transition: background var(--t-mid), color var(--t-mid);
}

img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }
/* <picture> is only a wrapper for the webp <source> — it must not affect layout,
   so the <img> inside is positioned/sized by the picture's parent as if bare. */
picture { display: contents; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
:where(h1,h2,h3,h4,h5,h6) { text-wrap: balance; }
:where(p) { text-wrap: pretty; }
::selection { background: color-mix(in srgb, var(--aqua-500) 30%, transparent); color: var(--text); }

/* ---------- Focus ---------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--r-xs);
}
:focus:not(:focus-visible) { outline: none; }

.skip-to-content {
  position: fixed; top: -100px; left: 16px; z-index: 999;
  background: var(--accent); color: var(--on-accent);
  padding: 12px 20px; border-radius: var(--r-sm); font-weight: 600;
  transition: top var(--t-fast);
}
.skip-to-content:focus { top: 16px; }

/* ---------- Grain: one SVG tile over the whole site ---------- */
body::after {
  content: ""; position: fixed; inset: 0; z-index: 60; pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}
[data-theme="dark"] body::after { mix-blend-mode: soft-light; }

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: var(--lh-snug);
  letter-spacing: var(--tr-tight);
}

.h-display {
  font-family: var(--font-display);
  font-size: var(--step-6);
  font-weight: 600;
  line-height: var(--lh-tight);
  letter-spacing: var(--tr-display);
}
.h-hero {
  font-family: var(--font-display);
  font-size: var(--step-7);
  font-weight: 600;
  line-height: 0.98;
  letter-spacing: -0.045em;
}
.h-section {
  font-family: var(--font-display);
  font-size: var(--step-4);
  font-weight: 600;
  line-height: var(--lh-snug);
  letter-spacing: var(--tr-display);
}
.h-sub {
  font-family: var(--font-display);
  font-size: var(--step-2);
  font-weight: 600;
  letter-spacing: var(--tr-tight);
}

.lede {
  font-size: var(--step-1);
  line-height: var(--lh-loose);
  color: var(--text-2);
  font-weight: 400;
}
.small { font-size: var(--step--1); }
.micro { font-size: var(--step--2); }

/* Technical register — the "laboratory" voice */
.mono {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: var(--tr-mono);
  font-variant-ligatures: none;
}
.label {
  font-family: var(--font-mono);
  font-size: var(--step--2);
  font-weight: 500;
  letter-spacing: var(--tr-label);
  text-transform: uppercase;
  color: var(--text-3);
}

/* Eyebrow — mono label with an index rule */
.eyebrow {
  display: inline-flex; align-items: center; gap: 12px;
  font-family: var(--font-mono);
  font-size: var(--step--2);
  font-weight: 500;
  letter-spacing: var(--tr-label);
  text-transform: uppercase;
  color: var(--accent);
}
.eyebrow::before {
  content: ""; width: 28px; height: 1px; flex: none;
  background: currentColor; opacity: .55;
}
.eyebrow--center { justify-content: center; }
.on-dark .eyebrow, .section--ink .eyebrow { color: var(--aqua-300); }

/* Gradient text — used once or twice per page, never more */
.text-grad {
  background: linear-gradient(105deg, var(--blue-600) 0%, var(--aqua-500) 55%, var(--aqua-400) 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
[data-theme="dark"] .text-grad {
  background: linear-gradient(105deg, var(--aqua-300) 0%, var(--aqua-500) 50%, var(--blue-300) 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Large + light rather than serif — keeps the rounded voice consistent */
.serif-quote {
  font-family: var(--font-quote);
  font-weight: 300;
  letter-spacing: -0.025em;
  line-height: 1.24;
}

/* ---------- Layout primitives ---------- */
.container {
  width: 100%; max-width: var(--container);
  margin-inline: auto; padding-inline: var(--gutter);
}
.container--narrow { max-width: var(--container-nr); }

.section { padding-block: var(--section-py); position: relative; }
.section--sm { padding-block: var(--section-py-sm); }
/* Tinted band. In dark mode this is now a genuinely raised surface (see the
   elevation ladder in tokens.css) plus a hairline, so section rhythm is
   legible instead of the whole page reading as one flat dark field. */
.section--tint {
  background: var(--bg-sunk);
  border-block: 1px solid var(--border-2);
}
.section--ink {
  background: var(--blue-900); color: #fff;
  --text: #fff; --text-2: rgba(255,255,255,.76); --text-3: rgba(255,255,255,.58);
  --border: rgba(255,255,255,.14); --surface: rgba(255,255,255,.06);
}
[data-theme="dark"] .section--ink { background: var(--surface); }

.stack   { display: grid; gap: var(--s-4); }
.stack-6 { display: grid; gap: var(--s-6); }
.stack-8 { display: grid; gap: var(--s-8); }
.row     { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.center  { text-align: center; }
.measure { max-width: var(--measure); }
.center .measure, .mx-auto { margin-inline: auto; }

.grid { display: grid; gap: var(--s-6); }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 1040px) { .grid-4 { grid-template-columns: repeat(3, minmax(0,1fr)); } }
@media (max-width: 900px)  { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 600px)  { .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0,1fr); } }

/* Editorial split — copy beside media */
.split {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: clamp(32px, 6vw, 88px); align-items: center;
}
.split--wide-copy { grid-template-columns: 1.15fr 1fr; }
.split.reverse .split-media { order: 2; }
@media (max-width: 880px) {
  .split, .split--wide-copy { grid-template-columns: 1fr; gap: var(--s-8); }
  .split.reverse .split-media { order: 0; }
}

/* Section heading block — the repeated "eyebrow + h2 + lede" unit */
.sec-head { display: grid; gap: var(--s-4); max-width: 46rem; }
.sec-head--center { justify-items: center; text-align: center; margin-inline: auto; }

/* Numbered section index, top-right of a band */
.sec-index {
  font-family: var(--font-mono); font-size: var(--step--2);
  letter-spacing: var(--tr-label); color: var(--text-4);
}

/* ---------- Utilities ---------- */
.no-scroll { overflow: hidden; }
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.hide-sm { display: inline; }
@media (max-width: 720px) { .hide-sm { display: none; } }

.rule { height: 1px; background: var(--border); border: 0; }
.rule-fade { height: 1px; border: 0;
  background: linear-gradient(90deg, transparent, var(--border), transparent); }

/* Below-the-fold sections skip layout work until near the viewport */
.cv-auto { content-visibility: auto; contain-intrinsic-size: auto 700px; }
