/* ============================================================================
   THE FORT — BASE: reset, typography, layout grid, section rhythm,
   blueprint detailing, reveal start-states, reduced-motion floor.
   ============================================================================ */

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  /* NOTE: native smooth-scroll intentionally omitted — Lenis owns scroll.
     A no-JS fallback is added via .no-js below. */
}

html.no-js {
  scroll-behavior: smooth;
}

body {
  background:
    radial-gradient(1200px 640px at 70% -10%, rgba(37, 99, 235, 0.12), transparent 58%),
    linear-gradient(180deg, var(--color-bg), var(--color-bg-sunken));
  color: var(--color-text-secondary);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-feature-settings: "cv05" 1, "cv08" 1, "ss03" 1, "tnum" 1;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Page-load: body starts invisible to avoid FOUC; intro/app removes it.
   no-js and reduced-motion paths reveal immediately (see below + app.js). */
html.is-loading body {
  opacity: 0;
}
html.no-js body,
html.fonts-failed body {
  opacity: 1;
}

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

a {
  color: inherit;
}

/* Global keyboard focus ring (steel) — consumes --focus-ring.
   Per-component focus styles (nav underline, spine node stroke) layer on top. */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

::selection {
  background: rgba(37, 99, 235, 0.28);
  color: var(--color-text);
}

/* ---- Headings & text ------------------------------------------------------ */
h1,
h2,
h3,
h4 {
  color: var(--color-text);
  font-family: var(--font-display);
  font-weight: 560;
  text-wrap: balance;
}

h1 {
  font-size: var(--fs-display);
  line-height: var(--lh-display);
  letter-spacing: var(--tr-display);
}

h2 {
  font-size: var(--fs-h2);
  line-height: var(--lh-h2);
  letter-spacing: var(--tr-h2);
  max-width: 20ch;
}

h3 {
  font-size: var(--fs-h3);
  line-height: var(--lh-h3);
  letter-spacing: 0;
}

p {
  text-wrap: pretty;
}

strong {
  color: var(--color-text);
  font-weight: 600;
}

/* ---- Eyebrow / mono label ------------------------------------------------- */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--fs-mono-label);
  font-weight: 500;
  letter-spacing: var(--tr-label);
  text-transform: uppercase;
}

.eyebrow::before {
  content: "// ";
  color: var(--accent-interface);
  white-space: pre;
}

.eyebrow--review::before { color: var(--accent-review); }
.eyebrow--positive::before { color: var(--accent-positive); }
.eyebrow--refusal::before { color: var(--accent-refusal); }

.mono {
  font-family: var(--font-mono);
  font-size: var(--fs-mono-data);
  letter-spacing: var(--tr-data);
}

.lede {
  color: var(--color-text);
  font-size: var(--fs-lede);
  line-height: 1.45;
  max-width: 42ch;
}

.measure {
  max-width: 62ch;
}

/* ---- Skip link ------------------------------------------------------------ */
.skip-link {
  position: fixed;
  left: 16px;
  top: 12px;
  z-index: 100;
  transform: translateY(-180%);
  background: var(--p-paper);
  color: var(--p-text-on-paper);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: transform var(--dur) var(--ease-out);
}
.skip-link:focus {
  transform: translateY(0);
}

/* ---- Layout: container & 12-col grid -------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.container--narrow {
  max-width: var(--container);
}
.container--narrow > * {
  max-width: min(var(--container-narrow), 100%);
}
.container--wide { max-width: var(--container-wide); }

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--grid-gap);
}

/* ---- Section rhythm & bands ----------------------------------------------- */
.section {
  position: relative;
  padding-block: var(--section-pad);
  border-top: 1px solid var(--color-hairline);
  box-shadow: inset 0 1px 0 var(--color-bevel);
}
.section--band-1 {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.64), rgba(245,247,250,0.18)),
    var(--color-band-1);
  color: #3c4654;
  --color-text: #11161d;
  --color-text-secondary: #2f3743;
  --color-text-muted: #566170;
  --color-text-faint: #6f7a89;
  --color-surface: rgba(255, 255, 255, 0.72);
  --color-surface-raised: #ffffff;
  --color-bg-sunken: #dfe5ed;
  --color-hairline: rgba(17, 22, 29, 0.08);
  --color-border: rgba(17, 22, 29, 0.13);
  --color-border-strong: rgba(17, 22, 29, 0.22);
  --color-bevel: rgba(255, 255, 255, 0.75);
  --shadow-card: 0 18px 48px -34px rgba(17, 22, 29, 0.42);
}
.section--band-2 {
  background:
    radial-gradient(900px 520px at 78% 8%, rgba(37, 99, 235, 0.14), transparent 58%),
    linear-gradient(180deg, #1a2028, #151a21);
}
.section--sunken {
  background:
    linear-gradient(180deg, rgba(8, 11, 16, 0.92), rgba(17, 22, 29, 0.96)),
    var(--color-bg-sunken);
}

/* Section contrast is positional, not semantic: hero/page-hero stays dark,
   then every following content section alternates light / dark in page order. */
main > .section:nth-of-type(even),
main > .cta-band:nth-of-type(even) {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.68), rgba(245,247,250,0.20)),
    var(--p-bg-1);
  color: #3c4654;
  --color-text: #11161d;
  --color-text-secondary: #2f3743;
  --color-text-muted: #566170;
  --color-text-faint: #6f7a89;
  --color-surface: rgba(255, 255, 255, 0.72);
  --color-surface-raised: #ffffff;
  --color-bg-sunken: #dfe5ed;
  --color-hairline: rgba(17, 22, 29, 0.08);
  --color-border: rgba(17, 22, 29, 0.13);
  --color-border-strong: rgba(17, 22, 29, 0.22);
  --color-bevel: rgba(255, 255, 255, 0.75);
  --shadow-card: 0 18px 48px -34px rgba(17, 22, 29, 0.42);
}

main > .section:nth-of-type(odd),
main > .cta-band:nth-of-type(odd) {
  background:
    radial-gradient(900px 520px at 78% 8%, rgba(37, 99, 235, 0.14), transparent 58%),
    linear-gradient(180deg, #1a2028, #151a21);
  color: var(--p-text-secondary);
  --color-text: var(--p-text);
  --color-text-secondary: var(--p-text-secondary);
  --color-text-muted: var(--p-text-muted);
  --color-text-faint: var(--p-text-faint);
  --color-surface: var(--p-surface-1);
  --color-surface-raised: var(--p-surface-2);
  --color-bg-sunken: var(--p-bg-sunken);
  --color-hairline: var(--p-hairline);
  --color-border: var(--p-border);
  --color-border-strong: var(--p-border-strong);
  --color-bevel: var(--p-border-bevel);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.section-head {
  margin-bottom: var(--space-7);
  max-width: 64ch;
}
.section-head p {
  margin-top: var(--space-3);
  color: var(--color-text-muted);
  max-width: 60ch;
}

/* Two-column split used across pages */
.split {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(300px, 1fr);
  gap: clamp(var(--space-6), 5vw, var(--space-8));
  align-items: start;
}
.split p { color: var(--color-text-muted); max-width: 56ch; }
.split p + p { margin-top: var(--space-4); }

/* ---- Blueprint detailing (the richness layer; asset-free) ----------------- */
/* Faint measurement substrate behind opted-in sections */
.section--grid::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--color-hairline) 1px, transparent 1px),
    linear-gradient(90deg, var(--color-hairline) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(120% 90% at 50% 0%, #000 35%, transparent 78%);
          mask-image: radial-gradient(120% 90% at 50% 0%, #000 35%, transparent 78%);
  opacity: 0.62;
}

/* Top-edge measurement scanline */
.section--scan::after {
  content: "";
  position: absolute;
  top: -1px;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--grad-edge);
  pointer-events: none;
  animation: edge-scan 8s var(--ease-in-out) infinite;
}

@keyframes edge-scan {
  0%, 100% { opacity: 0.34; transform: scaleX(0.72); }
  50% { opacity: 0.9; transform: scaleX(1); }
}

/* Section register mark (mono coordinate label) */
.register {
  position: absolute;
  top: var(--space-5);
  right: max(var(--gutter), calc((100vw - var(--container)) / 2 + var(--gutter)));
  color: var(--color-text-faint);
  font-family: var(--font-mono);
  font-size: var(--fs-mono-label);
  letter-spacing: var(--tr-label);
  text-transform: uppercase;
  pointer-events: none;
}

/* ---- Reveal start-states (added only when motion is allowed) -------------- */
/* Elements default to visible. The JS reveal modules add [data-reveal] start
   states ONLY when motion is permitted, guaranteeing no stuck-invisible content
   if JS fails or reduced-motion is on. */
html.motion-ready [data-reveal] {
  opacity: 0;
  transform: translateY(26px);
  will-change: transform, opacity;
}
html.motion-ready [data-reveal-clip] {
  clip-path: inset(0 0 100% 0);
  will-change: clip-path;
}
html.motion-ready [data-reveal-lines] .line-inner {
  transform: translateY(115%);
}
html.motion-ready [data-reveal-lines] .line {
  overflow: hidden;
}

/* ---- Utilities ------------------------------------------------------------ */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}
.stack > * + * { margin-top: var(--space-4); }
.text-muted { color: var(--color-text-muted); }
.text-faint { color: var(--color-text-faint); }
[hidden] { display: none !important; }

/* ---- Responsive grid relaxation ------------------------------------------- */
@media (max-width: 1024px) {
  .grid { grid-template-columns: repeat(8, 1fr); }
}
@media (max-width: 768px) {
  .container,
  .container--wide,
  .container--narrow {
    max-width: 100%;
  }
  .section {
    overflow: hidden;
  }
  .register {
    display: none;
  }
  .split {
    grid-template-columns: minmax(0, 1fr);
  }
  .split > *,
  .section-head {
    min-width: 0;
  }
  h2 { max-width: 28ch; }
}
@media (max-width: 560px) {
  :root { --grid-gap: 16px; }
  h1,
  h2,
  h3,
  p,
  .lede,
  .measure,
  .section-head,
  .section-head p,
  .split p {
    max-width: 100%;
    overflow-wrap: break-word;
  }
}

/* ---- Reduced-motion floor (CSS-level; JS guard covers GSAP inline styles) -- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
