/* ==========================================================================
   BASE — reset, typography, primitives
   ========================================================================== */

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

* { margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: auto; /* handled by Lenis */
  overflow-x: clip;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--f-body);
  font-size: var(--t-base);
  line-height: 1.6;
  font-weight: 400;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  min-height: 100vh;
  font-feature-settings: "ss01", "cv05";
}

body.is-locked { overflow: hidden; }

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

button, input, select, textarea { font: inherit; color: inherit; background: none; border: none; }
button { cursor: pointer; }

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

ul, ol { list-style: none; }

::selection { background: var(--volt); color: #04150b; }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--volt);
  outline-offset: 3px;
  border-radius: 1px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--ink); }
::-webkit-scrollbar-thumb { background: #23262f; border: 2px solid var(--ink); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #363b47; }

/* ---------- Typography primitives ---------- */

.display {
  font-family: var(--f-display);
  font-weight: 900;
  font-stretch: 125%;
  line-height: 0.84;
  letter-spacing: -0.035em;
  text-transform: uppercase;
  text-wrap: balance;
}

.display--tight { line-height: 0.78; letter-spacing: -0.045em; }

h1, h2, h3, h4 { font-weight: 700; line-height: 1.1; letter-spacing: -0.02em; text-wrap: balance; }

.h-mega { font-size: var(--t-mega); }
.h-1    { font-size: var(--t-4xl); }
.h-2    { font-size: var(--t-3xl); }
.h-3    { font-size: var(--t-2xl); }
.h-4    { font-size: var(--t-xl); }

.eyebrow {
  font-family: var(--f-mono);
  font-size: var(--t-label);
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--fg-3);
  display: inline-flex;
  align-items: center;
  gap: 0.7em;
}
.eyebrow::before {
  content: "";
  width: 1.9em; height: 1px;
  background: currentColor;
  opacity: 0.55;
  flex: none;
}
.eyebrow--plain::before { display: none; }
.eyebrow--volt { color: var(--volt); }

.lede {
  font-size: var(--t-lg);
  line-height: 1.55;
  color: var(--fg-2);
  letter-spacing: -0.012em;
  max-width: var(--maxw-text);
}

.mono {
  font-family: var(--f-mono);
  font-size: var(--t-label);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.muted { color: var(--fg-3); }
.dim   { color: var(--fg-2); }
.volt  { color: var(--volt); }

.chrome-text {
  background: var(--grad-chrome);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

.outline-text {
  color: transparent;
  -webkit-text-stroke: 1px rgba(255,255,255,0.28);
}
@supports not (-webkit-text-stroke: 1px white) {
  .outline-text { color: var(--fg-4); }
}

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

.shell { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }
.shell--wide { max-width: 1860px; }
.shell--narrow { max-width: 1080px; }
.bleed { width: 100%; padding-inline: var(--gutter); }

.section { padding-block: var(--section); position: relative; }
.section--tight { padding-block: clamp(3.5rem, 7vh, 6rem); }
.section--flush-top { padding-top: 0; }
.section--flush-bottom { padding-bottom: 0; }

.rule { height: 1px; background: var(--line); border: 0; width: 100%; }

.grid { display: grid; gap: var(--s-6); }
.stack > * + * { margin-top: var(--s-4); }

.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: 0; left: 50%;
  transform: translate(-50%, -120%);
  z-index: 999;
  background: var(--volt); color: #04150b;
  padding: 0.85rem 1.5rem;
  font-family: var(--f-mono); font-size: var(--t-label);
  letter-spacing: 0.15em; text-transform: uppercase; font-weight: 600;
  transition: transform var(--d-1) var(--e-out);
}
.skip-link:focus-visible { transform: translate(-50%, 0); outline-offset: -4px; }

/* ---------- Section header pattern ---------- */

.sec-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-5);
  align-items: end;
  margin-bottom: clamp(2.5rem, 6vh, 5rem);
}
@media (min-width: 900px) {
  .sec-head { grid-template-columns: minmax(0,1.35fr) minmax(0,1fr); gap: var(--s-8); }
  .sec-head__aside { padding-bottom: 0.6rem; }
}
.sec-head__title { margin-top: var(--s-4); }
.sec-head__index {
  font-family: var(--f-mono);
  font-size: var(--t-label);
  color: var(--fg-4);
  letter-spacing: 0.2em;
}

/* ---------- Media primitives ---------- */

.media {
  position: relative;
  overflow: hidden;
  background: var(--bg-3);
  isolation: isolate;
}
.media > img, .media > video {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.media--1x1  { aspect-ratio: 1/1; }
.media--4x5  { aspect-ratio: 4/5; }
.media--3x4  { aspect-ratio: 3/4; }
.media--3x2  { aspect-ratio: 3/2; }
.media--16x9 { aspect-ratio: 16/9; }
.media--21x9 { aspect-ratio: 21/9; }

/* Parallax inner: image is oversized and vertically centred, so JS can
   translate it either way inside the fixed frame without exposing an edge. */
.media--px > img, .media--px > video {
  height: 132%;
  position: absolute;
  top: -16%; left: 0;
  will-change: transform;
}

.tint::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(5,6,10,.15) 0%, rgba(5,6,10,.55) 62%, rgba(5,6,10,.88) 100%);
  pointer-events: none; z-index: 1;
}
.tint--soft::after { background: linear-gradient(180deg, rgba(5,6,10,.05), rgba(5,6,10,.45)); }
.tint--flat::after { background: rgba(5,6,10,.42); }

.grain::before {
  content: ""; position: absolute; inset: -50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='.42'/%3E%3C/svg%3E");
  opacity: 0.05; pointer-events: none; z-index: 3;
  mix-blend-mode: overlay;
  animation: grain 7s steps(6) infinite;
}
@keyframes grain {
  0%,100% { transform: translate(0,0); }
  16% { transform: translate(-4%, -3%); }
  33% { transform: translate(3%, -5%); }
  50% { transform: translate(-2%, 4%); }
  66% { transform: translate(5%, 2%); }
  83% { transform: translate(-3%, 3%); }
}

/* Scanline / atmosphere */
.atmos {
  position: absolute; inset: 0; pointer-events: none; z-index: 2;
  background:
    radial-gradient(120% 80% at 50% 0%, transparent 40%, rgba(5,6,10,.6) 100%),
    repeating-linear-gradient(to bottom, rgba(255,255,255,.014) 0 1px, transparent 1px 3px);
}

/* ---------- Reduced motion ---------- */
@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;
  }
  .grain::before { animation: none; }
  .media--px > img, .media--px > video {
    height: 100%; top: 0; transform: none !important;
  }
}
