/* TokenCap — Forged Shadows design tokens */
:root {
  --abyss: #070b13;
  --obsidian: #0a0a0a;
  --silver: #5a5e65;
  --iron: #2c2f33;
  --bone: #e5e7eb;
  --ember: #b8864b;
  --rust: #a4472f;

  --title: "Cinzel", "Cormorant Garamond", serif;
  --display: "Syne", "Space Grotesk", system-ui, sans-serif;
  --sans: "Geist", "Inter", system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", monospace;

  --rail: clamp(9rem, 14vw, 13rem); /* width reserved for the chapter index */
  --gutter: clamp(1.5rem, 5vw, 6rem);
  --ease-heavy: cubic-bezier(0.7, 0, 0.2, 1);

  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--abyss);
  color: var(--bone);
  font: 300 1rem/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
/* Film grain over everything, very quiet */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  opacity: 0.06;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

img { display: block; max-width: 100%; }
code { font-family: var(--mono); font-size: 0.82em; }
em { font-style: italic; }
:focus-visible { outline: 1px solid var(--ember); outline-offset: 4px; }

.skip-link {
  position: absolute; left: 1rem; top: -3rem; z-index: 100;
  padding: .5rem 1rem; background: var(--bone); color: var(--abyss);
}
.skip-link:focus { top: 1rem; }

/* ——— Micro-typography ——— */
.micro {
  margin: 0;
  font: 400 0.625rem/1.4 var(--sans);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--silver);
}
.eyebrow {
  margin: 0 0 1.25rem;
  font: 500 0.72rem/1.2 var(--mono);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ember);
  opacity: .9;
}
.display {
  margin: 0;
  font: 700 clamp(2.1rem, 3.8vw, 3.5rem)/1.08 var(--display);
  letter-spacing: -0.025em;
}
.display em {
  font-style: normal;
  color: var(--silver);
  font-weight: 500;
}
.body { max-width: 34rem; color: rgba(229, 231, 235, .72); }
.body code { color: var(--bone); }

/* ——— Chapter index (fixed left rail) ——— */
.chapters {
  position: fixed;
  left: var(--gutter);
  top: 50%;
  transform: translateY(-50%);
  z-index: 40;
}
.chapters__meta { margin-bottom: 2.5rem; }
.chapters ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.1rem; }
.chapters a {
  display: grid;
  grid-template-columns: 1.6rem auto;
  align-items: baseline;
  color: var(--silver);
  text-decoration: none;
  transition: color .6s var(--ease-heavy);
}
.chapters__num { font: 500 .75rem/1 var(--mono); color: var(--ember); opacity: .75; }
.chapters__label {
  font: 400 .625rem/1 var(--sans);
  letter-spacing: .24em;
  text-transform: uppercase;
  position: relative;
  padding-left: 0;
  transition: padding .6s var(--ease-heavy);
}
.chapters__label::before {
  content: "";
  position: absolute; left: 0; top: 50%;
  width: 0; height: 1px; background: var(--ember);
  transition: width .6s var(--ease-heavy);
}
.chapters a:hover, .chapters a[aria-current="true"] { color: var(--bone); }
.chapters a[aria-current="true"] .chapters__label { padding-left: 1.6rem; }
.chapters a[aria-current="true"] .chapters__label::before { width: 1rem; }

/* ——— FOLD I: The Aegis ——— */
.aegis {
  height: 100vh;
  min-height: 40rem;
  position: relative;
}
.aegis__stage {
  position: relative;
  height: 100%;
  min-height: 40rem;
  overflow: hidden;
  isolation: isolate;
  --p: 0;
  --lx: 30%; --ly: 22%; /* key-light position, set by JS */
}

.aegis__shield {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  z-index: 0;
}
.aegis__shield img {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, calc(-50% - 2vh)); /* elevate shield to give breathing room to foot copy */
  width: min(100vw, 118vh);
  height: auto;
  max-width: none;
  /* Seamless edges into the abyss */
  -webkit-mask-image: radial-gradient(ellipse 50% 50% at 50% 50%, #000 60%, transparent 100%);
          mask-image: radial-gradient(ellipse 50% 50% at 50% 50%, #000 60%, transparent 100%);
  filter: saturate(.85) contrast(1.08) brightness(.92);
}

/* The shield stays still — the light moves across it */
.aegis__light {
  position: absolute; inset: 0; z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(circle at var(--lx) var(--ly), rgba(255, 236, 205, .12), transparent 24%),
    radial-gradient(ellipse 110% 90% at calc(100% - var(--lx)) calc(100% - var(--ly)), rgba(3, 5, 10, .85), transparent 62%);
  mix-blend-mode: soft-light;
}
.aegis__volley { position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; pointer-events: none; }

.aegis__copy, .aegis__foot {
  position: absolute; z-index: 3;
  left: 50%;
  transform: translateX(-50%);
  width: min(64rem, 92vw);
  text-align: center;
}
.aegis__copy { top: clamp(3.5rem, 8vh, 6rem); }
.aegis__foot { bottom: clamp(2rem, 6vh, 4rem); }
.aegis__copy .eyebrow { margin-bottom: .5rem; }
.aegis__title {
  margin: 0;
  font: 400 clamp(3.2rem, 8vw, 6.5rem)/.95 var(--title);
  letter-spacing: .18em;
  text-transform: uppercase;
  padding-left: .18em; /* optically recenter tracked caps */
  background: linear-gradient(180deg, #ffffff 25%, #d1d5db 65%, #7b808b 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 20px rgba(0, 0, 0, 0.5));
}
.aegis__lede {
  margin: 0 auto;
  max-width: 34rem;
  font-size: .95rem;
  line-height: 1.6;
  color: rgba(229, 231, 235, .72);
}
.aegis__lede em { font-style: normal; font-family: var(--mono); color: var(--rust); }

.rune-button {
  display: inline-block;
  margin-top: 1.5rem;
  padding: .85rem 1.4rem;
  font: 400 .78rem/1 var(--mono);
  color: var(--bone);
  text-decoration: none;
  border: 1px solid rgba(90, 94, 101, .55);
  background: rgba(7, 11, 19, .55);
  backdrop-filter: blur(6px);
  transition: border-color .5s var(--ease-heavy), color .5s var(--ease-heavy);
}
.rune-button span { color: var(--ember); margin-right: .4rem; }
.rune-button:hover { border-color: var(--ember); }


/* ——— Shared section layout (content clears the rail) ——— */
.forge, .allies, .docs {
  position: relative;
  padding: clamp(8rem, 18vh, 16rem) var(--gutter) clamp(8rem, 18vh, 16rem) calc(var(--rail) + var(--gutter));
}

/* ——— FOLD II: The Forge ——— */
.forge { background: linear-gradient(180deg, var(--abyss), var(--obsidian) 70%); margin-top: 0; }
.forge__grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: clamp(2rem, 6vw, 6rem);
  align-items: start;
}
.forge__copy { grid-column: 1 / span 5; }
.forge__copy .display { margin-bottom: 2.5rem; }
.ledger { margin: 3.5rem 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 1.75rem 2rem; }
.ledger div { border-top: 1px solid rgba(90, 94, 101, .3); padding-top: .9rem; }
.ledger dd { margin: .4rem 0 0; font: 600 1.15rem/1.2 var(--display); color: var(--bone); }

.terminal {
  grid-column: 7 / span 6;
  margin: 3rem 0 0;
  border: 1px solid rgba(90, 94, 101, .28);
  background: rgba(10, 10, 10, .9);
  box-shadow: 0 40px 120px -40px rgba(0, 0, 0, .9);
  position: relative;
}
.terminal__bar {
  display: flex; align-items: center; gap: .45rem;
  padding: .8rem 1rem;
  border-bottom: 1px solid rgba(90, 94, 101, .2);
  position: relative; z-index: 2;
}
.terminal__bar span { width: .55rem; height: .55rem; border-radius: 50%; background: var(--iron); }
.terminal__bar p { margin-left: auto; }
.terminal__body {
  margin: 0; padding: 1.5rem 1.25rem;
  min-height: 22rem;
  font: 400 .78rem/1.85 var(--mono);
  color: rgba(229, 231, 235, .7);
  white-space: pre-wrap;
  overflow: hidden;
}
.terminal__body .ok { color: var(--silver); }
.terminal__body .cost { color: var(--ember); }
.terminal__body .pace { color: #d4a373; font-weight: 500; text-shadow: 0 0 12px rgba(212, 163, 115, .25); }
.terminal__body .verdict { color: var(--rust); text-shadow: 0 0 18px rgba(164, 71, 47, .45); }
.terminal__body .caret { display: inline-block; width: .5em; background: var(--bone); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.terminal figcaption { padding: 0 1.25rem 1rem; }

/* ——— III: The Allies ——— */
.allies { background: var(--obsidian); }
.allies__head { margin-bottom: clamp(4rem, 9vh, 7rem); max-width: 52rem; }
.roster { list-style: none; margin: 0; padding: 0; border-top: 1px solid rgba(90, 94, 101, .3); }
.roster__row {
  display: grid;
  grid-template-columns: 3rem minmax(12rem, 1.2fr) minmax(10rem, .9fr) minmax(0, 1.6fr);
  gap: 1.5rem;
  align-items: baseline;
  padding: 1.75rem 0;
  border-bottom: 1px solid rgba(90, 94, 101, .3);
  transition: background .6s var(--ease-heavy), padding .6s var(--ease-heavy);
}
.roster__row:hover { background: linear-gradient(90deg, rgba(184, 134, 75, .05), transparent 70%); padding-left: 1rem; }
.roster__name { margin: 0; font: 600 clamp(1.2rem, 1.8vw, 1.55rem)/1.15 var(--display); letter-spacing: -0.01em; }
.roster__how { color: rgba(229, 231, 235, .6); overflow-wrap: anywhere; }
.footnote { margin-top: 2rem; }

/* ——— IV: The Scroll (docs) ——— */
.docs { background: linear-gradient(180deg, var(--obsidian), var(--abyss)); }
.docs__grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: clamp(2rem, 6vw, 6rem); }
.docs__grid > header { grid-column: 1 / span 5; }
.steps { grid-column: 6 / span 7; list-style: none; margin: 0; padding: 0; display: grid; gap: 2.5rem; }
.steps li { display: grid; grid-template-columns: 2.5rem 1fr; row-gap: .6rem; }
.steps .micro { font: 500 0.78rem/1.6 var(--mono); letter-spacing: 0.05em; text-transform: none; color: var(--ember); grid-row: span 2; }
.steps p { margin: 0; }
.steps code { color: rgba(229, 231, 235, .55); overflow-wrap: anywhere; }
.docs__link {
  grid-column: 6 / span 7;
  justify-self: start;
  margin-top: 1rem;
  font: 600 clamp(1.25rem, 2.2vw, 1.75rem)/1.1 var(--display);
  letter-spacing: -0.01em;
  color: var(--bone);
  text-decoration: none;
  border-bottom: 1px solid var(--silver);
  padding-bottom: .4rem;
  transition: border-color .6s var(--ease-heavy), letter-spacing .6s var(--ease-heavy), color .6s var(--ease-heavy);
}
.docs__link:hover { border-color: var(--ember); color: #fff; letter-spacing: .01em; }

.colophon {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: 2.5rem var(--gutter) 2.5rem calc(var(--rail) + var(--gutter));
  border-top: 1px solid rgba(90, 94, 101, .2);
}

/* Reveal-on-enter for editorial blocks */
[data-reveal] { opacity: 0; transform: translateY(2.5rem); transition: opacity 1.4s var(--ease-heavy), transform 1.4s var(--ease-heavy); }
[data-reveal].is-in { opacity: 1; transform: none; }

/* ——— Narrow screens: rail collapses into a top strip ——— */
@media (max-width: 900px) {
  :root { --rail: 0rem; }
  .chapters {
    top: 0; left: 0; right: 0; transform: none;
    padding: 1rem var(--gutter);
    background: linear-gradient(180deg, rgba(7, 11, 19, .92), transparent);
  }
  .chapters__meta { display: none; }
  .chapters ol { grid-auto-flow: column; justify-content: space-between; }
  .chapters__label { font-size: .55rem; }
  .chapters a[aria-current="true"] .chapters__label { padding-left: 0; }
  .chapters a[aria-current="true"] .chapters__label::before { display: none; }
  .corner--tl, .corner--br { display: none; }
  .aegis__shield img { width: 170vw; transform: translate(-50%, calc(-50% - 2vh)); }
  .aegis__title { font-size: 2.4rem; }
  .chapters ol { justify-content: start; gap: 1.5rem; }
  .chapters a:not([aria-current="true"]) .chapters__label { display: none; }
  .forge__copy, .terminal, .docs__grid > header, .steps, .docs__link { grid-column: 1 / -1; }
  .roster__row { grid-template-columns: 2rem 1fr; }
  .roster__route, .roster__how { grid-column: 2; }
}

/* ——— Respect reduced motion: no dive, no volley, no reveals ——— */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .aegis { height: auto; }
  .aegis__stage { position: relative; --p: 0 !important; }
  .forge { margin-top: 0; }
  [data-reveal] { opacity: 1; transform: none; transition: none; }
  .terminal__body .caret { animation: none; }
}

/* ——— Integration Tabs ——— */
.integration-tab {
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  color: var(--silver);
  cursor: pointer;
  transition: color 0.4s var(--ease-heavy), transform 0.4s var(--ease-heavy);
}
.integration-tab:hover, .integration-tab:focus-visible {
  color: var(--bone);
  transform: translateY(-2px);
}
.integration-tab[aria-pressed="true"] {
  color: #fff;
  transform: translateY(-2px);
  filter: drop-shadow(0 0 8px rgba(255,255,255,0.3));
}
