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

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

/* ---------- REDUCED MOTION ----------
   Spec §0, non-negotiable: with the preference on, every element is
   visible and nothing transitions. This matters double here — the site
   claims accessibility as a capability in Arsenal, so breaking it would
   contradict its own content. Individual components still add their own
   handling where stopping is not enough (see the marquee). */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .reveal, .op-card, .radar { opacity: 1 !important; transform: none !important; }
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* The header is fixed, so every anchor has to clear it. */
  scroll-padding-top: var(--nav-h);
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  padding-top: var(--nav-h);      /* the fixed header is out of flow */
  background: var(--bg-primary);
  color: var(--content-primary);
  font-family: var(--font-mono);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

/* ---------- GRID FIELD ----------
   The cartographic grid behind everything. Figma: 120px module, rules in
   border/default, the whole layer at 80%, and NO fill — the page's own
   bg/primary shows through. The standalone GRID component (125:591) does
   carry a bg/secondary plate, but that is its swatch on the canvas; every
   instance placed in a page frame has fill: none.

   Getting that wrong cost two bugs stacked on each other: the rules were
   drawn in border/subtle, which is the same value as bg/primary and so
   invisible, and the plate was added to make them show — which repainted
   the whole page from #f4efe7 to #f9f6f1 and flattened every card that
   sits on surface/card1.

   Fixed, so it never repaints on scroll and never grows with the
   document. Both themes use the same tokens, so dark mode follows. */
.grid-field {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.8;
  background-image:
    repeating-linear-gradient(to right,  var(--border-default) 0 1px, transparent 1px var(--grid-module)),
    repeating-linear-gradient(to bottom, var(--border-default) 0 1px, transparent 1px var(--grid-module));
}
/* On 2x displays the hairline is a true half pixel, as designed. */
@media (min-resolution: 2dppx) {
  .grid-field {
    background-image:
      repeating-linear-gradient(to right,  var(--border-default) 0 0.5px, transparent 0.5px var(--grid-module)),
      repeating-linear-gradient(to bottom, var(--border-default) 0 0.5px, transparent 0.5px var(--grid-module));
  }
}

/* ---------- RADAR ----------
   Spec §4. Markers drifting over the grid at 30% of scroll speed —
   validated against a real recording, so: subtle, not dramatic. Fixed
   layer above the grid field but under everything else. */
.radar {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.radar b {
  position: absolute;
  display: block;
  width: 28px; height: 28px;
  border: 1px solid var(--brand-primary);
  border-radius: 50%;
  opacity: 0.42;
}
/* The dot at the center of the ring. */
.radar b::after {
  content: "";
  position: absolute; inset: 0;
  margin: auto;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--brand-primary);
}
/* The sweep — independent of scroll, offset per point so they never
   pulse in unison. */
.radar b::before {
  content: "";
  position: absolute; inset: -1px;
  border: 1px solid var(--brand-primary);
  border-radius: 50%;
  transform-origin: 50% 50%;
  animation: sweep 3.2s var(--ease-out) infinite;
}
.radar b:nth-child(2)::before { animation-delay: 1.1s; }
.radar b:nth-child(3)::before { animation-delay: 2.2s; }

@keyframes sweep {
  0%   { transform: scale(1);   opacity: .55; }
  70%  { transform: scale(2.6); opacity: 0; }
  100% { transform: scale(2.6); opacity: 0; }
}

/* Third marker is desktop only — two below 1024. */
.radar b:nth-child(3) { display: none; }
@media (min-width: 1024px) { .radar b:nth-child(3) { display: block; } }

/* Margin coordinates — longitudes along the top, latitudes down the
   left, exactly as the design lays them out. Injected by site.js. */
.grid-field__label {
  position: absolute;
  font-size: var(--fs-map);
  line-height: var(--lh-map);
  letter-spacing: var(--ls-none);
  color: var(--border-default);
  white-space: nowrap;
}

@media (prefers-reduced-transparency: reduce) {
  .grid-field { opacity: 1; background-color: transparent; }
}

/* Icons come from the sprite in img/icons.svg. Phosphor exports are
   filled paths, so color travels through fill, not stroke. */
.ico { width: 1.5em; height: 1.5em; fill: currentColor; flex: none; }
.ico--sm { width: 1em; height: 1em; }
a { color: var(--content-link); text-decoration-thickness: 1px; text-underline-offset: 3px; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

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

.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: absolute; left: var(--margin-page); top: -100px;
  z-index: 100; background: var(--content-primary); color: var(--bg-primary);
  padding: var(--space-12) var(--space-20); transition: top var(--dur-fast);
}
.skip-link:focus { top: var(--space-12); }

/* ---------- TYPE PRIMITIVES ---------- */
.t-display {
  font-family: var(--font-serif); font-weight: var(--weight-semibold);
  font-size: var(--fs-display); line-height: var(--lh-display);
  margin: 0; letter-spacing: -0.01em;
}
.t-title-1 {
  font-family: var(--font-serif); font-weight: var(--weight-semibold);
  font-size: var(--fs-title-1); line-height: var(--lh-title-1); margin: 0;
}
.t-title-2 {
  font-family: var(--font-serif); font-weight: var(--weight-semibold);
  font-size: var(--fs-title-2); line-height: var(--lh-title-2); margin: 0;
}
.t-title-3 {
  font-family: var(--font-serif); font-weight: var(--weight-regular);
  font-size: var(--fs-title-3); line-height: var(--lh-title-3); margin: 0;
}
.t-body {
  font-size: var(--fs-body); line-height: var(--lh-body);
  max-width: var(--layout-measure); margin: 0;
}
.t-callout {
  font-size: var(--fs-callout); line-height: var(--lh-callout);
  letter-spacing: var(--ls-label); text-transform: uppercase; margin: 0;
}
.t-caption {
  font-size: var(--fs-caption); line-height: var(--lh-caption);
  letter-spacing: var(--ls-label); margin: 0;
}
.t-footnote {
  font-size: var(--fs-footnote); line-height: var(--lh-footnote);
  letter-spacing: var(--ls-label); text-transform: uppercase; margin: 0;
}

.c-secondary { color: var(--content-secondary); }
.c-tertiary  { color: var(--content-tertiary); }
.c-brand     { color: var(--brand-primary); }

/* ---------- LAYOUT PRIMITIVES ---------- */
.section {
  padding-block: var(--padding-section);
  display: grid;
  justify-items: center;
}
/* min-width: 0 alongside the width, or a grid item can still refuse to
   shrink below its content and push the page sideways. */
/* :not(.bleed) is not a filter — both rules already partitioned the
   children. It is there for SPECIFICITY: at `.section > *` this rule sits
   at 0,1,0, so any later single-class rule setting a width silently beat
   it and the section went full bleed. At 0,2,0 it wins. */
.section > *:not(.bleed) { width: min(var(--layout-content), 100% - var(--margin-page) * 2); min-width: 0; }

/* Breaks the central box for bands that need the full width. */
.section > .bleed { width: min(var(--layout-bleed), 100% - var(--margin-page) * 2); min-width: 0; }

/* Asymmetric split: 640 reading column + 304 reference column. */
/* .split now lives in components.css, sized from the case study's own
   Figma columns. The old definition here was shadowed and unused. */

.stack   { display: grid; gap: var(--space-24); align-content: start; }
.stack-s { display: grid; gap: var(--space-12); align-content: start; }
.stack-l { display: grid; gap: var(--space-40); align-content: start; }

.pair {
  display: grid; gap: var(--layout-gutter-pair);
  grid-template-columns: 1fr;
}
@media (min-width: 768px) { .pair { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }

/* ---------- SECTION RAIL ---------- */
.rail {
  display: flex; align-items: baseline; gap: var(--space-12);
  color: var(--brand-primary);
  border-bottom: 1px solid var(--border-strong);
  padding-bottom: var(--space-12);
}
.rail__num { font-variant-numeric: tabular-nums; }

/* ---------- MEDIA SLOTS ---------- */
/* Content images carry the same 32px radius as the cards. The only
   square image in the file is the full-bleed cover, which has no edges
   of its own to round. */
.media {
  background: var(--surface-card1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-default);
  overflow: hidden;
}
.media img { width: 100%; height: 100%; object-fit: cover; }
.media.r-cover { border-radius: 0; }
.r-3-2  { aspect-ratio: 3 / 2; }
.r-4-3  { aspect-ratio: 4 / 3; }
.r-1-1  { aspect-ratio: 1 / 1; }
.r-cover{ aspect-ratio: 375 / 220; }
@media (min-width: 1024px) { .r-cover { aspect-ratio: 1440 / 640; } }

figure { margin: 0; display: grid; gap: var(--space-8); }
figcaption {
  font-size: var(--fs-footnote); line-height: var(--lh-footnote);
  letter-spacing: var(--ls-label); text-transform: uppercase;
  color: var(--content-tertiary);
}
