/* =========================================================
   Strategic Security v4 — v4-styles.css

   "The long watch." The page is one day at a lighthouse:
   night (hero) → dawn (premise) → day (principles) →
   storm (consequence) → clearing (practice) →
   twilight (perspective) → golden hour (closing) → night (footer).

   Hand-written CSS. No framework, no build step. Every animated
   rule lives behind prefers-reduced-motion: no-preference.
   ========================================================= */

/* --- Design tokens --- */
:root {
  /* Day-arc palette */
  --night:        #0A0908;
  --ink:          #14110C;
  --ink-soft:     #2B251D;
  --ink-mute:     #6E6151;
  --cream:        #F3EEE2;
  --cream-soft:   #F8F4EB;
  --parchment:    #EAE2CF;
  --parchment-d:  #DED3BC;
  --dawn:         #F1DCC7;
  --golden:       #F6E6CE;
  --twilight:     #14171F;
  --twilight-soft:#1C2029;

  /* Accents */
  --terracotta:   #C25A36;
  --terracotta-d: #9C4526;
  --apricot:      #E8B493;
  --apricot-l:    #F4D6BE;
  --gold:         #C9A24B;
  --rule:         #D8CDB6;
  --rule-dark:    rgba(243, 238, 226, 0.14);

  /* Type */
  --display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --serif:   "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --mono:    "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Fluid scale */
  --fs-display: min(clamp(2.9rem, 7.4vw + 0.4rem, 8.2rem), 11vh);
  --fs-h2:      clamp(2.2rem, 4.8vw, 4.4rem);
  --fs-quote:   clamp(2rem, 5.2vw, 4.6rem);
  --fs-lede:    clamp(1.1rem, 1.55vw, 1.4rem);
  --fs-prose:   clamp(1.1rem, 1.35vw, 1.3rem);
  --fs-small:   clamp(0.85rem, 1vw, 0.95rem);

  /* Rhythm */
  --max:     1360px;
  --measure: 66ch;
  --gutter:  clamp(1.25rem, 4.5vw, 4.5rem);
  --band:    clamp(6rem, 12vw, 12rem);
  --nav-h:   4.5rem;
  --radius:  22px;

  --ease-out:  cubic-bezier(0.22, 0.61, 0.21, 1);
  --ease-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body { margin: 0; padding: 0; }

html {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  scroll-padding-top: var(--nav-h);
  overflow-x: clip;
}

body {
  background: var(--night);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.6;
  overflow-x: clip;
  position: relative;
}

body.menu-open { overflow: hidden; }

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

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

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

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

::selection { background: var(--terracotta); color: var(--cream-soft); }

:focus-visible {
  outline: 2px solid var(--terracotta);
  outline-offset: 4px;
  border-radius: 2px;
}

.hero :focus-visible,
.chapter-cost :focus-visible,
.chapter-perspective :focus-visible,
.footer :focus-visible,
.nav :focus-visible,
.menu :focus-visible {
  outline-color: var(--apricot);
}

/* Skip link */
.skip {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 300;
  padding: 0.6rem 1rem;
  background: var(--cream-soft);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.8rem;
  border-radius: 999px;
  transform: translateY(-200%);
}

.skip:focus { transform: none; }

/* --- Film grain --- */
.grain {
  position: fixed;
  inset: -100%;
  width: 300%;
  height: 300%;
  pointer-events: none;
  z-index: 150;
  opacity: 0.42;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240' viewBox='0 0 240 240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.5  0 0 0 0 0.47  0 0 0 0 0.42  0 0 0 0.06 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

/* --- Custom cursor (script enables on fine pointers) --- */
.cursor {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 250;
  pointer-events: none;
  display: none;
  mix-blend-mode: difference;
}

html.has-cursor .cursor { display: block; }
html.has-cursor body { cursor: none; }
html.has-cursor a,
html.has-cursor button { cursor: none; }

.cursor-dot,
.cursor-ring {
  position: absolute;
  top: 0;
  left: 0;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.cursor-dot {
  width: 6px;
  height: 6px;
  background: #F8F4EB;
}

.cursor-ring {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(248, 244, 235, 0.9);
  opacity: 0.7;
}

.cursor.is-hover .cursor-ring {
  width: 64px;
  height: 64px;
  opacity: 1;
}

.cursor.is-hidden { opacity: 0; }

/* --- Reading progress --- */
.progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 70;
  pointer-events: none;
}

.progress-bar {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--terracotta), var(--apricot));
  transform: scaleX(0);
  transform-origin: left center;
}

/* =========================================================
   TYPOGRAPHY
   ========================================================= */
.display {
  font-family: var(--display);
  font-optical-sizing: auto;
  font-weight: 340;
  font-size: var(--fs-display);
  line-height: 0.96;
  letter-spacing: -0.032em;
  margin: 0 0 clamp(1.25rem, 2.6vw, 2rem);
  color: var(--cream-soft);
}

.display .line {
  display: block;
  overflow: hidden;
  padding: 0.12em 0.16em;
  margin: -0.12em -0.16em;
}

.display .line-inner { display: block; }

.display em {
  font-style: italic;
  font-weight: 320;
  font-variation-settings: "SOFT" 40, "WONK" 1;
  color: var(--apricot);
}

.h2 {
  font-family: var(--display);
  font-optical-sizing: auto;
  font-weight: 400;
  font-size: var(--fs-h2);
  line-height: 1.02;
  letter-spacing: -0.024em;
  margin: 0 0 clamp(1.5rem, 2.5vw, 2rem);
  color: var(--ink);
  text-wrap: balance;
}

.h2 em { font-style: italic; color: var(--terracotta-d); }

.h2.light { color: var(--cream); }

.eyebrow {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin: 0 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.eyebrow::before,
.eyebrow::after {
  content: "";
  width: 2.5rem;
  height: 1px;
  background: currentColor;
  opacity: 0.6;
}

.hero-eyebrow,
.light-eyebrow {
  color: var(--apricot);
  justify-content: center;
}

.hero-eyebrow { margin-bottom: 1.2rem; }

.prose {
  font-family: var(--serif);
  font-size: var(--fs-prose);
  line-height: 1.7;
  color: var(--ink-soft);
  margin: 0 0 1.35rem;
  max-width: var(--measure);
}

.prose em { font-style: italic; color: var(--ink); }

.prose.subtle { color: var(--ink-mute); }

.prose.light { color: rgba(243, 238, 226, 0.82); }
.prose.light em { color: var(--apricot); }

.prose.center {
  text-align: center;
  max-width: 38rem;
  margin-left: auto;
  margin-right: auto;
}

.prose-opener::first-letter {
  font-family: var(--display);
  font-weight: 500;
  font-size: 3.6em;
  line-height: 0.8;
  float: left;
  padding: 0.08em 0.14em 0 0;
  color: var(--terracotta-d);
}

/* =========================================================
   NAVIGATION
   ========================================================= */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 var(--gutter);
  color: var(--cream);
}

.nav::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, rgba(10, 9, 8, 0.86), rgba(10, 9, 8, 0.62));
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid rgba(243, 238, 226, 0.08);
  opacity: 0;
}

.nav.is-scrolled::before { opacity: 1; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  font-family: var(--display);
  font-size: 1.1rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand-mark { color: var(--apricot); display: inline-flex; }

.nav-links {
  display: flex;
  align-items: center;
  gap: clamp(1.2rem, 2.6vw, 2.4rem);
}

.nav-links a {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(243, 238, 226, 0.72);
  position: relative;
  padding: 0.4rem 0;
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
}

.nav-index {
  font-size: 0.62rem;
  color: var(--apricot);
  opacity: 0.75;
}

.nav-links a:hover,
.nav-links a.is-active { color: var(--cream-soft); }

.nav-links a::after,
.footer-col a::after,
.menu-links a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--apricot);
  transform: scaleX(0);
  transform-origin: left center;
}

.nav-links a:hover::after,
.nav-links a:focus-visible::after,
.nav-links a.is-active::after,
.footer-col a:hover::after,
.footer-col a:focus-visible::after,
.menu-links a:hover::after,
.menu-links a:focus-visible::after {
  transform: scaleX(1);
}

/* Menu toggle (small screens) */
.menu-toggle {
  display: none;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cream);
  padding: 0.5rem 0;
}

.menu-toggle-icon {
  display: inline-flex;
  flex-direction: column;
  gap: 5px;
  width: 22px;
}

.menu-toggle-icon span {
  display: block;
  height: 1px;
  background: currentColor;
  transform-origin: center;
}

.menu-toggle[aria-expanded="true"] .menu-toggle-icon span:first-child { transform: translateY(3px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] .menu-toggle-icon span:last-child { transform: translateY(-3px) rotate(-45deg); }

.menu {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: var(--night);
  color: var(--cream);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--nav-h) var(--gutter) 3rem;
  background-image: radial-gradient(60rem 30rem at 50% 110%, rgba(194, 90, 54, 0.28), transparent 65%);
}

.menu[hidden] { display: none; }

.menu-links {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.menu-links a {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  gap: 1rem;
  align-self: flex-start;
  font-family: var(--display);
  font-size: clamp(2.4rem, 9vw, 4rem);
  font-weight: 340;
  letter-spacing: -0.025em;
  line-height: 1.1;
  padding: 0.15em 0;
}

.menu-index {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  color: var(--apricot);
}

.menu-tag {
  margin: 3rem 0 0;
  font-family: var(--display);
  font-style: italic;
  font-weight: 340;
  color: rgba(243, 238, 226, 0.55);
}

/* =========================================================
   BUTTONS
   ========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 1rem 1.8rem;
  border-radius: 999px;
  border: 1px solid transparent;
  position: relative;
  will-change: transform;
}

.btn-primary {
  background: var(--cream-soft);
  color: var(--ink);
}

.btn-primary:hover {
  background: var(--apricot);
  color: var(--ink);
}

.btn-ghost {
  border-color: rgba(243, 238, 226, 0.5);
  color: var(--cream-soft);
}

.btn-ghost:hover {
  border-color: var(--apricot);
  background: rgba(243, 238, 226, 0.08);
}

/* =========================================================
   HERO — the living lighthouse
   ========================================================= */
.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: var(--night);
  background-image:
    radial-gradient(60% 45% at 50% 82%, rgba(194, 90, 54, 0.38), transparent 70%),
    linear-gradient(180deg, #0A0908 0%, #120E0C 55%, #2A1912 90%, #4A2619 100%);
  color: var(--cream-soft);
  overflow: clip;
  isolation: isolate;
}

.scene {
  position: absolute;
  inset: 0;
  z-index: 0;
  will-change: transform;
}

.scene-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.scene-lighthouse {
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: max(100%, 1400px);
  height: auto;
  will-change: transform;
}

.hill-far { fill: #1A130F; }
.hill-near { fill: #070605; }

.scene-haze {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(110% 70% at 50% 40%, transparent 40%, rgba(10, 9, 8, 0.55) 100%),
    linear-gradient(180deg, rgba(10, 9, 8, 0.55) 0%, transparent 28%);
}

.hero-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 62rem;
  margin: 0 auto;
  padding: calc(var(--nav-h) + 1vh) var(--gutter) clamp(200px, 24vh, 280px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  will-change: transform, opacity;
}

.lede {
  font-family: var(--serif);
  font-size: var(--fs-lede);
  line-height: 1.55;
  color: rgba(243, 238, 226, 0.84);
  margin: 0 0 2.2rem;
  max-width: 46rem;
  text-wrap: pretty;
}

.hero-actions {
  display: flex;
  gap: 0.9rem;
  flex-wrap: wrap;
  justify-content: center;
}

.hero-scroll {
  position: absolute;
  z-index: 2;
  right: clamp(1.25rem, 4vw, 3.5rem);
  bottom: clamp(2rem, 5vh, 3.5rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  color: rgba(243, 238, 226, 0.7);
}

.hero-scroll-label {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  writing-mode: vertical-rl;
}

.hero-scroll-line {
  display: block;
  width: 1px;
  height: 4.5rem;
  background: rgba(243, 238, 226, 0.22);
  overflow: hidden;
  position: relative;
}

/* =========================================================
   MARQUEE — horizon band
   ========================================================= */
.marquee {
  background: var(--ink);
  color: var(--cream);
  border-top: 1px solid rgba(194, 90, 54, 0.45);
  border-bottom: 1px solid rgba(194, 90, 54, 0.45);
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.marquee-track {
  display: flex;
  align-items: center;
  gap: 2.6rem;
  padding: 1.4rem 0;
  white-space: nowrap;
  width: max-content;
  font-family: var(--display);
  font-style: italic;
  font-weight: 320;
  font-size: clamp(2.2rem, 4.6vw, 4.4rem);
  letter-spacing: -0.02em;
  line-height: 1;
}

.marquee-track span:nth-child(odd) {
  color: var(--terracotta);
  font-style: normal;
  font-size: 0.5em;
  transform: translateY(-0.1em);
}

.marquee-track span:nth-child(4n + 2) {
  color: transparent;
  -webkit-text-stroke: 1px rgba(243, 238, 226, 0.6);
  font-style: normal;
  font-weight: 300;
}

/* =========================================================
   CHAPTERS — full-bleed tonal bands
   ========================================================= */
.chapter {
  position: relative;
  padding: var(--band) var(--gutter);
  overflow: clip;
}

.chapter-inner {
  position: relative;
  z-index: 1;
  max-width: var(--max);
  margin: 0 auto;
}

.chapter-grid {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: clamp(1.5rem, 5vw, 6rem);
  align-items: start;
}

/* Oversized ghost numerals, parallaxed by script */
.ghost {
  position: absolute;
  z-index: 0;
  right: -0.04em;
  top: -0.08em;
  font-family: var(--display);
  font-weight: 300;
  font-size: clamp(14rem, 36vw, 42rem);
  line-height: 0.8;
  letter-spacing: -0.07em;
  color: transparent;
  -webkit-text-stroke: 1px rgba(20, 17, 12, 0.11);
  pointer-events: none;
  user-select: none;
  will-change: transform;
}

.ghost-light { -webkit-text-stroke-color: rgba(243, 238, 226, 0.08); }

.chapter-label {
  position: sticky;
  top: calc(var(--nav-h) + 2rem);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border-top: 1px solid var(--ink);
  padding-top: 1rem;
}

.chapter-label .num {
  font-family: var(--display);
  font-weight: 300;
  font-size: clamp(3.6rem, 6vw, 5.6rem);
  line-height: 0.9;
  letter-spacing: -0.04em;
  color: transparent;
  -webkit-text-stroke: 1px var(--ink-mute);
}

.chapter-label .label {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-mute);
}

.chapter-label.light { border-top-color: rgba(243, 238, 226, 0.4); }
.chapter-label.light .num { -webkit-text-stroke-color: rgba(243, 238, 226, 0.45); }
.chapter-label.light .label { color: rgba(243, 238, 226, 0.55); }

.chapter-body { max-width: var(--measure); }

/* --- 01 Premise — dawn --- */
.chapter-premise {
  background: var(--cream);
  background-image:
    radial-gradient(70rem 32rem at 50% -10rem, rgba(232, 180, 147, 0.6), transparent 66%),
    linear-gradient(180deg, var(--dawn) 0%, var(--cream) 34%, var(--cream) 100%);
}

.pull-quote {
  margin: 3.6rem 0 0;
  padding: 2.4rem 2.4rem 2.4rem 4.6rem;
  border-left: 2px solid var(--terracotta);
  background: linear-gradient(135deg, var(--cream-soft), rgba(232, 180, 147, 0.18));
  border-radius: 4px var(--radius) var(--radius) 4px;
  position: relative;
}

.pull-quote .mark {
  position: absolute;
  top: 0.1rem;
  left: 1.1rem;
  font-family: var(--display);
  font-size: 5.5rem;
  line-height: 1;
  color: var(--terracotta);
}

.pull-quote p {
  margin: 0;
  font-family: var(--display);
  font-style: italic;
  font-weight: 360;
  font-size: clamp(1.45rem, 2.3vw, 2.05rem);
  line-height: 1.32;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-wrap: balance;
}

/* --- 02 Principles — day, the stack --- */
.chapter-principles {
  background: var(--parchment);
  background-image: linear-gradient(180deg, var(--cream) 0%, var(--parchment) 14%, var(--parchment) 100%);
  padding-bottom: clamp(4rem, 8vw, 8rem);
}

.stack {
  position: relative;
  z-index: 1;
  max-width: var(--max);
  margin: clamp(3rem, 6vw, 5rem) auto 0;
}

.stack-card {
  position: sticky;
  top: calc(var(--nav-h) + 2.5vh);
  margin-bottom: 4vh;
  min-height: 72vh;
  display: flex;
  border-radius: var(--radius);
  border: 1px solid rgba(20, 17, 12, 0.09);
  box-shadow:
    0 -8px 30px rgba(20, 17, 12, 0.06),
    0 40px 70px -40px rgba(20, 17, 12, 0.35);
  transform-origin: 50% 0;
  overflow: clip;
  color: var(--ink);
  transform: scale(calc(1 - var(--p, 0) * 0.07)) translateY(calc(var(--p, 0) * -1.2rem));
  filter: brightness(calc(1 - var(--p, 0) * 0.3));
}

.stack-card[data-tone="1"] { background: var(--cream-soft); }
.stack-card[data-tone="2"] { background: #F5E7D3; }
.stack-card[data-tone="3"] { background: #EFE5D2; }
.stack-card[data-tone="4"] { background: #F2E4D5; }
.stack-card[data-tone="5"] { background: #EDE3CE; }

.stack-card-emph {
  background: var(--ink);
  background-image: radial-gradient(60rem 30rem at 85% 110%, rgba(194, 90, 54, 0.32), transparent 65%);
  color: var(--cream);
  border-color: rgba(243, 238, 226, 0.12);
}

.stack-card-inner {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: clamp(1.5rem, 4vw, 4rem);
  align-items: center;
  padding: clamp(2.2rem, 5vw, 5rem);
}

.stack-num {
  font-family: var(--display);
  font-style: italic;
  font-weight: 300;
  font-variation-settings: "SOFT" 30, "WONK" 1;
  font-size: clamp(7rem, 20vw, 21rem);
  line-height: 0.82;
  letter-spacing: -0.05em;
  color: transparent;
  -webkit-text-stroke: 1.5px var(--terracotta);
  justify-self: start;
}

.stack-card-emph .stack-num {
  -webkit-text-stroke-color: var(--apricot);
  color: var(--apricot);
}

.stack-num-mark {
  -webkit-text-stroke: 0;
  display: block;
  width: clamp(9rem, 18vw, 15rem);
}

.stack-num-mark svg { width: 100%; height: auto; }

.stack-text h3 {
  font-family: var(--display);
  font-weight: 420;
  font-size: clamp(1.9rem, 3.4vw, 3.3rem);
  line-height: 1.06;
  letter-spacing: -0.022em;
  margin: 0 0 1.2rem;
  text-wrap: balance;
}

.stack-card-emph h3 { font-style: italic; font-weight: 380; }

.stack-text p {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.05rem, 1.35vw, 1.28rem);
  line-height: 1.64;
  color: var(--ink-soft);
  max-width: 34rem;
}

.stack-card-emph p { color: rgba(243, 238, 226, 0.76); }

/* --- 03 Consequence — storm --- */
.chapter-cost {
  background: var(--night);
  color: var(--cream);
}

.cost-glow {
  position: absolute;
  z-index: 0;
  width: 62vw;
  aspect-ratio: 1;
  border-radius: 50%;
  pointer-events: none;
  will-change: transform;
}

.cost-glow-a {
  top: -22vw;
  right: -14vw;
  background: radial-gradient(circle, rgba(194, 90, 54, 0.28) 0%, transparent 62%);
}

.cost-glow-b {
  bottom: -26vw;
  left: -18vw;
  background: radial-gradient(circle, rgba(96, 112, 132, 0.2) 0%, transparent 62%);
}

.cost-glow-c {
  top: 30%;
  left: 30%;
  width: 40vw;
  background: radial-gradient(circle, rgba(232, 180, 147, 0.1) 0%, transparent 60%);
}

.cost-grid {
  margin-top: clamp(3.4rem, 7vw, 5.5rem);
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.6rem;
  perspective: 1200px;
}

.cost-card {
  position: relative;
  border: 1px solid var(--rule-dark);
  background:
    radial-gradient(28rem 18rem at var(--mx, 50%) var(--my, 50%), rgba(232, 180, 147, 0.12), transparent 60%),
    rgba(243, 238, 226, 0.035);
  padding: 2.6rem 2.4rem 2.8rem;
  border-radius: var(--radius);
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transform-style: preserve-3d;
  will-change: transform;
}

.cost-card:hover { border-color: rgba(232, 180, 147, 0.45); }

.cost-line {
  display: block;
  width: 2.6rem;
  height: 2px;
  background: var(--terracotta);
  margin-bottom: 1.6rem;
  transform-origin: left center;
}

.cost-card:hover .cost-line { width: 4rem; background: var(--apricot); }

.cost-card h4 {
  font-family: var(--display);
  font-weight: 420;
  font-style: italic;
  font-size: clamp(1.45rem, 2.1vw, 1.9rem);
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0 0 0.8rem;
  color: var(--cream);
  text-wrap: balance;
}

.cost-card p {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.62;
  color: rgba(243, 238, 226, 0.72);
}

/* --- 04 Practice — clearing, a ledger with a rail --- */
.chapter-practice { background: var(--cream); }

.practice {
  margin-top: clamp(3rem, 6vw, 5rem);
  position: relative;
  padding-left: 3.5rem;
  counter-reset: practice;
}

/* The rail and its drawn fill (script sets --progress) */
.practice::before,
.practice::after {
  content: "";
  position: absolute;
  left: 0.75rem;
  top: 0;
  bottom: 0;
  width: 1px;
}

.practice::before { background: var(--rule); }

.practice::after {
  background: linear-gradient(180deg, var(--apricot), var(--terracotta));
  transform: scaleY(var(--progress, 0));
  transform-origin: top center;
}

.practice-step {
  display: grid;
  grid-template-columns: 10rem minmax(0, 1fr);
  gap: 2rem;
  padding: 2.5rem 0.5rem 2.5rem 0;
  border-bottom: 1px solid var(--rule);
  align-items: start;
  position: relative;
}

.practice-step:first-child { border-top: 1px solid var(--rule); }

.practice-step::before {
  counter-increment: practice;
  content: counter(practice, decimal-leading-zero);
  position: absolute;
  right: 0.5rem;
  top: 2.3rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  color: var(--ink-mute);
  opacity: 0.6;
}

.practice-node {
  position: absolute;
  left: calc(-3.5rem + 0.75rem - 5px);
  top: 3rem;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--cream);
  border: 1px solid var(--ink-mute);
}

.practice-step.is-past .practice-node {
  background: var(--terracotta);
  border-color: var(--terracotta);
  box-shadow: 0 0 0 6px rgba(194, 90, 54, 0.16);
}

.practice .step {
  font-family: var(--display);
  font-style: italic;
  font-weight: 360;
  font-variation-settings: "SOFT" 30, "WONK" 1;
  font-size: clamp(1.5rem, 2.2vw, 2rem);
  line-height: 1;
  color: var(--terracotta);
  padding-top: 0.3rem;
}

.practice h4 {
  font-family: var(--display);
  font-weight: 460;
  font-size: clamp(1.4rem, 2vw, 1.8rem);
  line-height: 1.18;
  letter-spacing: -0.015em;
  margin: 0 0 0.6rem;
  color: var(--ink);
}

.practice p {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.08rem;
  line-height: 1.64;
  color: var(--ink-soft);
  max-width: 40rem;
}

/* --- 05 Perspective — twilight, the plate --- */
.chapter-perspective {
  background: var(--twilight);
  background-image: linear-gradient(180deg, var(--twilight) 0%, var(--twilight-soft) 100%);
  color: var(--cream);
  padding: 0 0 var(--band);
}

.plate {
  position: relative;
  min-height: 92vh;
  min-height: 92svh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: clip;
  isolation: isolate;
}

.plate-img {
  position: absolute;
  inset: -12% 0;
  width: 100%;
  height: 124%;
  object-fit: cover;
  object-position: center 55%;
  z-index: 0;
  filter: saturate(1.05) contrast(1.02);
  will-change: transform;
}

.plate-scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    radial-gradient(70% 60% at 50% 50%, rgba(20, 23, 31, 0.38) 0%, rgba(20, 23, 31, 0.72) 100%),
    linear-gradient(180deg, rgba(20, 23, 31, 0.5) 0%, rgba(20, 23, 31, 0.16) 40%, rgba(20, 23, 31, 0.95) 100%);
}

.perspective-inner {
  position: relative;
  z-index: 2;
  max-width: 66rem;
  margin: 0 auto;
  text-align: center;
  padding: calc(var(--band) + var(--nav-h)) var(--gutter) var(--band);
}

.big-quote {
  margin: 0 auto 1.8rem;
  max-width: 58rem;
}

.big-quote p {
  margin: 0;
  font-family: var(--display);
  font-weight: 340;
  font-size: var(--fs-quote);
  line-height: 1.08;
  letter-spacing: -0.024em;
  color: var(--cream);
  text-wrap: balance;
}

.big-quote em {
  font-style: italic;
  font-variation-settings: "SOFT" 40, "WONK" 1;
  color: var(--apricot);
}

.big-quote .w { display: inline-block; }

.attribution {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: rgba(243, 238, 226, 0.6);
  margin: 0;
}

.perspective-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.4rem;
  text-align: left;
  margin-top: -3rem;
  padding: 0 var(--gutter);
  max-width: calc(var(--max) + 2 * var(--gutter));
}

.p-card {
  background: rgba(243, 238, 226, 0.05);
  border: 1px solid rgba(243, 238, 226, 0.13);
  border-radius: var(--radius);
  padding: 2.2rem 2rem 2.4rem;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.p-card:hover {
  background: rgba(243, 238, 226, 0.09);
  border-color: rgba(232, 180, 147, 0.4);
}

.p-card h5 {
  font-family: var(--display);
  font-style: italic;
  font-weight: 380;
  font-variation-settings: "SOFT" 40, "WONK" 1;
  font-size: 1.7rem;
  margin: 0 0 0.8rem;
  color: var(--apricot);
}

.p-card p {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.02rem;
  line-height: 1.6;
  color: rgba(243, 238, 226, 0.78);
}

/* --- Closing — golden hour --- */
.chapter-closing {
  background: var(--cream);
  background-image:
    radial-gradient(64rem 30rem at 50% 118%, rgba(232, 180, 147, 0.62), transparent 66%),
    linear-gradient(180deg, var(--cream) 0%, var(--golden) 100%);
  text-align: center;
  padding-top: clamp(7rem, 15vw, 14rem);
  padding-bottom: clamp(7rem, 15vw, 14rem);
}

.closing-inner {
  max-width: 58rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
}

.display-sm {
  font-family: var(--display);
  font-weight: 360;
  font-size: clamp(2.3rem, 5.6vw, 4.9rem);
  line-height: 1.05;
  letter-spacing: -0.028em;
  margin: 0;
  color: var(--ink);
  text-wrap: balance;
}

.display-sm em {
  font-style: italic;
  font-variation-settings: "SOFT" 40, "WONK" 1;
  color: var(--terracotta-d);
}

/* The light sweeps across the closing words */
.shine,
.shine em {
  background-size: 260% 100%;
  background-position: 100% 0;
  -webkit-background-clip: text;
  background-clip: text;
}

.shine {
  color: transparent;
  background-image: linear-gradient(100deg, var(--ink) 0%, var(--ink) 42%, var(--gold) 50%, var(--ink) 58%, var(--ink) 100%);
}

.shine em {
  color: transparent;
  background-image: linear-gradient(100deg, var(--terracotta-d) 0%, var(--terracotta-d) 42%, var(--apricot) 50%, var(--terracotta-d) 58%, var(--terracotta-d) 100%);
}

/* =========================================================
   FOOTER — night again
   ========================================================= */
.footer {
  background: var(--night);
  color: var(--cream);
  padding: clamp(4rem, 8vw, 6rem) var(--gutter) 2rem;
  border-top: 1px solid rgba(194, 90, 54, 0.3);
}

.footer-grid {
  max-width: var(--max);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.4fr 1fr 1.6fr;
  gap: 3rem;
  padding-bottom: 3.4rem;
  border-bottom: 1px solid var(--rule-dark);
}

.footer-col h6 {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(243, 238, 226, 0.48);
  margin: 0 0 1.1rem;
}

.footer-col ul li { margin-bottom: 0.6rem; }

.footer-col a {
  color: rgba(243, 238, 226, 0.85);
  font-size: 0.98rem;
  position: relative;
  padding-bottom: 2px;
}

.footer-col a:hover { color: var(--apricot); }

.brand-footer { color: var(--cream); margin-bottom: 1.1rem; }

.brand-footer .brand-mark { color: var(--apricot); }

.footer-tag {
  margin: 0;
  font-family: var(--display);
  font-style: italic;
  font-weight: 340;
  font-size: 1rem;
  color: rgba(243, 238, 226, 0.6);
  max-width: 18rem;
  line-height: 1.5;
}

.footer-col .small {
  margin: 0;
  font-family: var(--serif);
  font-size: 0.94rem;
  line-height: 1.62;
  color: rgba(243, 238, 226, 0.6);
  max-width: 34rem;
}

.footer-base {
  max-width: var(--max);
  margin: 0 auto;
  padding-top: 1.7rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: rgba(243, 238, 226, 0.45);
}

.footer-base p { margin: 0; }

.footer-base .muted { font-family: var(--display); font-style: italic; font-size: 0.9rem; letter-spacing: 0; }

/* =========================================================
   MOTION — everything animated lives here
   ========================================================= */
@media (prefers-reduced-motion: no-preference) {

  html { scroll-behavior: smooth; }

  /* Hero entrance: lines rise out of a mask, the rest settles in */
  .js .display .line-inner {
    transform: translateY(112%);
    animation: rise-line 1.35s var(--ease-expo) forwards;
  }
  .js .display .line:nth-child(1) .line-inner { animation-delay: 0.55s; }
  .js .display .line:nth-child(2) .line-inner { animation-delay: 0.68s; }
  .js .display .line:nth-child(3) .line-inner { animation-delay: 0.81s; }

  .js .hero-eyebrow,
  .js .lede,
  .js .hero-actions,
  .js .hero-scroll,
  .js .nav {
    opacity: 0;
    animation: settle 1.2s var(--ease-out) forwards;
  }
  .js .hero-eyebrow { animation-delay: 0.4s; }
  .js .lede { animation-delay: 1.15s; }
  .js .hero-actions { animation-delay: 1.35s; }
  .js .hero-scroll { animation-delay: 1.8s; }
  .js .nav { animation-delay: 1.6s; animation-name: settle-flat; }

  /* Scroll reveals */
  .js [data-reveal] {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 1s var(--ease-out), transform 1s var(--ease-out);
    will-change: opacity, transform;
  }

  .js [data-reveal].is-visible {
    opacity: 1;
    transform: none;
  }

  .js .cost-grid [data-reveal]:nth-child(2),
  .js .perspective-cards [data-reveal]:nth-child(2) { transition-delay: 0.12s; }
  .js .cost-grid [data-reveal]:nth-child(3),
  .js .perspective-cards [data-reveal]:nth-child(3) { transition-delay: 0.24s; }
  .js .cost-grid [data-reveal]:nth-child(4) { transition-delay: 0.36s; }

  /* The cost line draws before its card's words arrive */
  .js .cost-card .cost-line { transform: scaleX(0); transition: transform 0.9s var(--ease-expo) 0.2s, width 0.4s var(--ease-out), background 0.4s ease; }
  .js .cost-card.is-visible .cost-line { transform: scaleX(1); }

  /* Once revealed, the cost cards hand their transform back to the pointer tilt */
  .js .cost-card[data-reveal].is-visible {
    transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
    transition: opacity 1s var(--ease-out), transform 0.25s var(--ease-out), border-color 0.35s ease;
  }

  /* Word-by-word quote */
  .js .big-quote .w {
    opacity: 0;
    transform: translateY(0.35em) rotate(1.5deg);
    transition: opacity 0.8s var(--ease-out), transform 0.9s var(--ease-expo);
    transition-delay: calc(var(--i, 0) * 55ms);
  }
  .js .big-quote.is-visible .w { opacity: 1; transform: none; }

  /* Drifting marquee */
  .marquee-track { animation: drift 48s linear infinite; }

  /* Scroll cue */
  .hero-scroll-line::after {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 45%;
    background: var(--apricot);
    animation: fall 2.6s var(--ease-soft) infinite;
  }

  /* Storm glows drift */
  .cost-glow-a { animation: drift-a 26s ease-in-out infinite alternate; }
  .cost-glow-b { animation: drift-b 32s ease-in-out infinite alternate; }
  .cost-glow-c { animation: drift-c 22s ease-in-out infinite alternate; }

  /* The light sweeps across the closing words */
  .shine, .shine em { animation: shine 7s var(--ease-soft) infinite; }

  /* The lamp keeps watch in the footer */
  .brand-pulse { animation: pulse 3.2s ease-in-out infinite; transform-origin: center; transform-box: fill-box; }

  /* Living grain */
  .grain { animation: grain 0.9s steps(6) infinite; }

  /* Interface transitions */
  .nav::before { transition: opacity 0.5s ease; }
  .nav-links a, .footer-col a, .menu-links a { transition: color 0.25s ease; }
  .nav-links a::after, .footer-col a::after, .menu-links a::after { transition: transform 0.45s var(--ease-out); }
  .menu-toggle-icon span { transition: transform 0.4s var(--ease-out); }
  .btn { transition: background 0.35s ease, color 0.35s ease, border-color 0.35s ease, transform 0.5s var(--ease-expo); }
  .cursor-dot { transition: transform 0.08s linear; }
  .cursor-ring { transition: width 0.35s var(--ease-out), height 0.35s var(--ease-out), opacity 0.3s ease; }
  .cursor { transition: opacity 0.3s ease; }
  .progress-bar { transition: transform 0.12s linear; }
  .stack-card { transition: box-shadow 0.4s ease; }
  .cost-card { transition: border-color 0.35s ease, transform 0.25s var(--ease-out); }
  .cost-line { transition: width 0.4s var(--ease-out), background 0.4s ease; }
  .practice-node { transition: background 0.4s ease, border-color 0.4s ease, box-shadow 0.5s var(--ease-out); }
  .practice::after { transition: transform 0.25s linear; }
  .practice-step { transition: background 0.3s ease; }
  .p-card { transition: background 0.3s ease, border-color 0.3s ease, transform 0.4s var(--ease-out); }
  .p-card:hover { transform: translateY(-4px); }
  .skip { transition: transform 0.3s var(--ease-out); }
  .scene, .hero-inner, .scene-lighthouse, .plate-img, .ghost { transition: none; }

  .menu.is-open .menu-links a {
    animation: settle 0.9s var(--ease-expo) both;
  }
  .menu.is-open .menu-links a:nth-child(2) { animation-delay: 0.06s; }
  .menu.is-open .menu-links a:nth-child(3) { animation-delay: 0.12s; }
  .menu.is-open .menu-links a:nth-child(4) { animation-delay: 0.18s; }
  .menu.is-open .menu-links a:nth-child(5) { animation-delay: 0.24s; }
}

@keyframes rise-line {
  from { transform: translateY(112%); }
  to   { transform: none; }
}

@keyframes settle {
  from { opacity: 0; transform: translateY(26px); }
  to   { opacity: 1; transform: none; }
}

@keyframes settle-flat {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes drift {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

@keyframes fall {
  0%   { transform: translateY(-110%); }
  60%  { transform: translateY(240%); }
  100% { transform: translateY(240%); }
}

@keyframes drift-a {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(-12vw, 10vw) scale(1.15); }
}

@keyframes drift-b {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(14vw, -8vw) scale(1.1); }
}

@keyframes drift-c {
  from { transform: translate(0, 0); }
  to   { transform: translate(-10vw, -14vw); }
}

@keyframes shine {
  0%   { background-position: 100% 0; }
  55%  { background-position: 0% 0; }
  100% { background-position: 0% 0; }
}

@keyframes pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.8); }
  50%      { opacity: 1; transform: scale(1); }
}

@keyframes grain {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-4%, 3%); }
  40%  { transform: translate(3%, -5%); }
  60%  { transform: translate(-5%, -2%); }
  80%  { transform: translate(4%, 4%); }
  100% { transform: translate(0, 0); }
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 1100px) {
  .chapter-grid { grid-template-columns: 200px minmax(0, 1fr); }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 2.2rem; }
  .perspective-cards { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 900px) {
  .nav-links { display: none; }
  .menu-toggle { display: inline-flex; }
}

@media (max-width: 768px) {
  :root { --nav-h: 4rem; }

  .hero-inner { padding-bottom: clamp(170px, 24vh, 240px); }

  .hero-scroll { display: none; }

  .scene-lighthouse { width: max(100%, 1300px); }

  .chapter-grid { grid-template-columns: 1fr; gap: 1.6rem; }

  .chapter-label {
    position: static;
    flex-direction: row;
    align-items: baseline;
    gap: 1rem;
  }

  .chapter-label .num { font-size: 2.6rem; }

  .stack-card { min-height: 0; top: calc(var(--nav-h) + 1.5vh); margin-bottom: 3vh; }

  .stack-card-inner {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 2rem 1.5rem 2.4rem;
  }

  .stack-num { font-size: clamp(5rem, 24vw, 8rem); }

  .cost-grid { grid-template-columns: 1fr; }

  .practice { padding-left: 2.2rem; }

  .practice-node { left: calc(-2.2rem + 0.75rem - 5px); top: 2.4rem; }

  .practice-step { grid-template-columns: 1fr; gap: 0.5rem; padding: 1.9rem 0.5rem 1.9rem 0; }

  .practice-step::before { top: 1.8rem; }

  .perspective-cards { grid-template-columns: 1fr; margin-top: -1rem; }

  .footer-grid { grid-template-columns: 1fr; }

  .footer-base { flex-direction: column; gap: 0.4rem; }
}

@media (max-width: 480px) {
  body { font-size: 16px; }

  .brand-name { font-size: 0.95rem; }

  .display { font-size: min(clamp(2.5rem, 12.5vw, 3.4rem), 11vh); }

  .hero-inner { padding-bottom: clamp(140px, 20vh, 200px); }

  .hero-actions { width: 100%; }

  .hero-actions .btn { width: 100%; }

  .pull-quote { padding: 1.6rem 1.4rem 1.6rem 3rem; }

  .pull-quote .mark { font-size: 3.6rem; left: 0.6rem; }

  .prose-opener::first-letter { font-size: 2.8em; }

  .ghost { font-size: 11rem; }
}

/* Short viewports: keep the headline and the lighthouse apart */
@media (max-height: 640px) {
  .hero-inner { padding-bottom: 150px; }
  .scene-lighthouse { width: max(100%, 1100px); }
}
