/* ─── System font stacks ─────────────────────────────
   No network font requests: immediate first paint, and the
   CSP's font-src stays trivially 'self' with nothing to host.
   Display type leans on heavy system sans for scale contrast
   against monospace technical annotations. ────────────── */
:root {
  --font-display: -apple-system, 'SF Pro Display', 'Segoe UI', system-ui, Roboto, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Code', 'Roboto Mono', 'JetBrains Mono', Consolas, monospace;
}

@property --shimmer-pos {
  syntax: '<percentage>';
  inherits: false;
  initial-value: -40%;
}

:root {
  --ink:      #06070a;
  --void:     #030405;
  --steel:    #eef1f4;
  --amber:    #ff7a45;
  --amber-dim: rgba(255,122,69,0.5);
  --teal:     #4ce0c7;
  --teal-dim: rgba(76,224,199,0.5);
  --line:     rgba(238,241,244,0.09);
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--ink);
  color: var(--steel);
  font-family: var(--font-display);
  font-weight: 400;
  overflow-x: hidden;
}

/* ─── Stress-field canvas ────────────────────────────── */
#stress-canvas {
  position: fixed;
  inset: 0;
  width: 100%; height: 100%;
  z-index: 0;
}

/* ─── Grain texture ──────────────────────────────────── */
.grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ─── Vignette ────────────────────────────────────────── */
.vignette {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 0%, transparent 45%, rgba(3,4,5,0.55) 100%),
    linear-gradient(to bottom, rgba(3,4,5,0.15), transparent 15%, transparent 85%, rgba(3,4,5,0.4));
}

/* ─── Fixed drafting mark ────────────────────────────── */
.mark {
  position: fixed;
  top: 1.8rem; left: 1.8rem;
  z-index: 100;
  width: 30px; height: 30px;
  opacity: 0.85;
  transition: opacity 0.3s, transform 0.3s;
}
.mark:hover { opacity: 1; transform: translateY(-2px); }
.mark svg { width: 100%; height: 100%; }

/* ─── Load spine ──────────────────────────────────────── */
.spine {
  position: fixed;
  top: 0; bottom: 0;
  left: 2.4rem;
  z-index: 90;
  width: 1px;
  pointer-events: none;
}
.spine-track {
  position: absolute;
  inset: 0;
  background: var(--line);
}
.spine-fill {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 0%;
  background: linear-gradient(to bottom, var(--teal), var(--amber));
  box-shadow: 0 0 12px 1px rgba(255,122,69,0.4);
  transition: height 0.1s linear;
}
.spine-fill::after {
  content: '';
  position: absolute;
  bottom: -3px; left: -3px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 10px 2px var(--amber);
}

/* ─── Fixed drafting stamp ────────────────────────────── */
.stamp {
  position: fixed;
  bottom: 1.8rem; right: 1.8rem;
  z-index: 100;
  border: 1px solid var(--line);
  background: rgba(6,7,10,0.55);
  backdrop-filter: blur(6px);
  padding: 0.85rem 1.1rem;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.1em;
}
.stamp dl { display: flex; flex-direction: column; gap: 0.35rem; }
.stamp dl > div { display: flex; gap: 1.4rem; justify-content: space-between; }
.stamp dt { color: rgba(238,241,244,0.35); text-transform: uppercase; }
.stamp dd { color: rgba(238,241,244,0.75); text-transform: uppercase; text-align: right; }
#stamp-status { color: var(--amber); transition: color 0.4s; }

/* ─── MAIN / SECTIONS ─────────────────────────────────── */
main { position: relative; z-index: 10; }
section {
  position: relative;
  min-height: 100svh;
  padding: 0 4rem 0 6.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* ─── HERO ────────────────────────────────────────────── */
.hero { gap: 1.6rem; }

.side-label {
  position: absolute;
  top: 3rem;
  left: 6.5rem;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--amber);
  animation: rise 1.4s cubic-bezier(0.16,1,0.3,1) both;
}

.wordmark {
  display: flex;
  flex-direction: column;
  animation: rise 1.6s 0.1s cubic-bezier(0.16,1,0.3,1) both;
}
.w-load {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(4.5rem, 13vw, 11.5rem);
  line-height: 0.86;
  letter-spacing: -0.035em;
  background:
    linear-gradient(
      90deg,
      transparent calc(var(--shimmer-pos) - 14%),
      rgba(255,255,255,0.95) var(--shimmer-pos),
      transparent calc(var(--shimmer-pos) + 14%)
    ),
    linear-gradient(120deg, var(--steel) 15%, var(--amber) 60%, var(--teal) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer 9s 2s linear infinite;
}
.w-bearing {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: clamp(1.1rem, 2.6vw, 1.9rem);
  letter-spacing: 0.5em;
  text-transform: uppercase;
  color: rgba(238,241,244,0.4);
  margin-top: 0.9rem;
  margin-left: 0.15em;
}
@keyframes shimmer {
  0%     { --shimmer-pos: -40%; animation-timing-function: ease-in-out; }
  20%    { --shimmer-pos: 140%; }
  20.01% { --shimmer-pos: -40%; }
  100%   { --shimmer-pos: -40%; }
}

.dimension {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-top: 0.6rem;
  color: rgba(238,241,244,0.4);
  animation: rise 1.8s 0.35s cubic-bezier(0.16,1,0.3,1) both;
}
.dim-line {
  width: 44px; height: 1px;
  background: currentColor;
  position: relative;
}
.dim-line::before {
  content: '';
  position: absolute;
  top: -4px;
  width: 1px; height: 9px;
  background: currentColor;
}
.dim-line:first-child::before { right: 0; }
.dim-line:last-child::before { left: 0; }
.dim-label {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  white-space: nowrap;
}

.hero-sub {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1rem, 1.6vw, 1.25rem);
  color: rgba(238,241,244,0.55);
  max-width: 30ch;
  margin-top: 0.4rem;
  animation: rise 2s 0.5s cubic-bezier(0.16,1,0.3,1) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(28px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── MANIFESTO ───────────────────────────────────────── */
.manifesto {
  align-items: flex-end;
  text-align: right;
  padding-right: 6.5rem;
  padding-left: 4rem;
  gap: 1.2rem;
}
.callout {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--teal);
}
.statement {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.8rem, 4.6vw, 3.6rem);
  line-height: 1.25;
  letter-spacing: -0.01em;
  max-width: 18ch;
  color: rgba(238,241,244,0.88);
}
.statement em {
  font-style: normal;
  color: var(--amber);
}

/* ─── PRINCIPLES INDEX ────────────────────────────────── */
.index {
  min-height: auto;
  padding: 10rem 4rem 10rem 6.5rem;
  gap: 7rem;
  justify-content: flex-start;
}
.entry {
  position: relative;
  max-width: 34ch;
}
.entry-num {
  display: block;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(3.6rem, 8vw, 6rem);
  line-height: 1;
  color: transparent;
  -webkit-text-stroke: 1px rgba(238,241,244,0.16);
  margin-bottom: -0.3em;
}
.entry h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.4rem, 2.4vw, 1.9rem);
  letter-spacing: -0.01em;
  margin-bottom: 0.7rem;
  color: var(--steel);
}
.entry p {
  font-size: 0.95rem;
  line-height: 1.75;
  color: rgba(238,241,244,0.5);
}
.entry-left { align-self: flex-start; }
.entry-right {
  align-self: flex-end;
  text-align: right;
  margin-right: 1.5rem;
}
.entry-right .entry-num { -webkit-text-stroke-color: rgba(76,224,199,0.22); }
.entry-left .entry-num { -webkit-text-stroke-color: rgba(255,122,69,0.22); }

/* ─── CLOSING ─────────────────────────────────────────── */
.closing {
  align-items: center;
  text-align: center;
  padding-left: 4rem;
  gap: 1.4rem;
}
.closing-mark { width: 34px; height: 34px; opacity: 0.7; }
.closing-line {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.6rem, 3.4vw, 2.4rem);
  line-height: 1.3;
  color: rgba(238,241,244,0.85);
}
.closing-stamp {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(238,241,244,0.3);
}

/* ─── Scroll-driven reveal ────────────────────────────── */
.reveal {
  opacity: 0;
  transition: opacity 1s ease, transform 1s cubic-bezier(0.16,1,0.3,1);
}
.entry-left.reveal { transform: translateX(-32px); }
.entry-right.reveal { transform: translateX(32px); }
.manifesto .reveal { transform: translateY(24px); }
.closing .reveal { transform: translateY(20px); }
.reveal.visible { opacity: 1; transform: none; }

/* ─── Responsive ──────────────────────────────────────── */
@media (max-width: 900px) {
  section { padding-left: 5.5rem; padding-right: 2.2rem; }
  .manifesto { padding-left: 2.2rem; padding-right: 5.5rem; }
  .index { padding-left: 5.5rem; padding-right: 2.2rem; gap: 5rem; }
  .spine { left: 1.9rem; }
}
@media (max-width: 640px) {
  .mark { top: 1.2rem; left: 1.2rem; width: 24px; height: 24px; }
  .spine { left: 1.3rem; }
  section { padding-left: 3.2rem; padding-right: 1.4rem; }
  .side-label {
    top: auto;
    bottom: 100%;
    margin-bottom: 1.6rem;
    left: 3.2rem;
    max-width: 12rem;
  }
  .manifesto { padding-left: 1.4rem; padding-right: 3.2rem; text-align: left; align-items: flex-start; }
  .statement { max-width: 22ch; }
  .index { padding-left: 3.2rem; padding-right: 1.4rem; gap: 4rem; }
  .entry-right { text-align: left; align-self: flex-start; margin-right: 0; }
  .stamp {
    left: 1.2rem; right: 1.2rem; bottom: 1.2rem;
    padding: 0.65rem 0.85rem;
  }
  .stamp dl > div:nth-child(3) { display: none; }
}

/* ─── Reduced motion ──────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  #stress-canvas { display: none; }
}
