/* ============================================================
   kingmaker — design system (exact michele.it palette + grain,
   with a deep-navy dark mode)
   ============================================================ */

@font-face {
  font-family: "Exposure";
  src: url("fonts/Exposure-VAR.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* light — "paper" (matches poke.com / michele.it) */
  --paper: #fffdfa;
  --ink: #000000;
  --ink-soft: #6b6b6b;
  --rule: #ece8de;
  --grain-opacity: 0.04;

  --font-display: "Exposure", ui-serif, Georgia, serif;
  --font-sans: "Inter", system-ui, -apple-system, sans-serif;
  --font-serif: "Fraunces", ui-serif, Georgia, serif;

  --pad-x: clamp(24px, 6vw, 104px);
  --maxw: 1180px;
  --ease: cubic-bezier(0.22, 0.61, 0.20, 1);
}

html[data-theme="dark"] {
  --paper: #0b1a30;       /* deep navy */
  --ink: #fffdfa;          /* the light-mode paper white */
  --ink-soft: rgba(255, 253, 250, 0.55);
  --rule: rgba(255, 253, 250, 0.14);
  --grain-opacity: 0.05;
}

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

html { scroll-behavior: smooth; }

body {
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  transition: background-color 0.7s var(--ease), color 0.7s var(--ease);
}

/* paper-grain overlay — matches michele.it (mix-blend difference) */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  background-image: url("textures/paper-noise.webp");
  background-size: 120px 120px;
  background-repeat: repeat;
  opacity: var(--grain-opacity);
  mix-blend-mode: difference;
  pointer-events: none;
  z-index: 200;
}

/* ---------- layout ---------- */
.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 var(--pad-x); }

section.chapter {
  min-height: 100svh;
  display: flex;
  align-items: center;
  padding: clamp(96px, 14vh, 200px) 0;
  position: relative;
}
section.chapter .wrap { width: 100%; }

/* ---------- typography ---------- */
.display {
  font-family: var(--font-display);
  font-weight: 600;
  font-variation-settings: "EXPO" -10;
  letter-spacing: -0.03em;
  line-height: 0.98;
}

.eyebrow {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: clamp(20px, 4vh, 40px);
  display: flex;
  align-items: center;
  gap: 0.8em;
}
.eyebrow::before {
  content: "";
  width: 28px;
  height: 1px;
  background: currentColor;
  opacity: 0.6;
}

h2.display { font-size: clamp(2.4rem, 7vw, 6rem); max-width: 16ch; }

.lead {
  font-size: clamp(1.15rem, 2.1vw, 1.6rem);
  line-height: 1.5;
  max-width: 36ch;
  color: var(--ink);
  margin-top: clamp(24px, 4vh, 44px);
}
.body {
  font-size: clamp(1.05rem, 1.5vw, 1.3rem);
  line-height: 1.65;
  max-width: 58ch;
  color: var(--ink-soft);
  margin-top: clamp(20px, 3vh, 36px);
}
.body strong, .lead strong { color: var(--ink); font-weight: 600; }
.body em, .lead em { font-style: italic; }
.body p + p { margin-top: 1.1em; }

/* a quiet, single supporting fact */
.fact {
  margin-top: clamp(32px, 5vh, 56px);
  padding-top: clamp(18px, 3vh, 26px);
  border-top: 1px solid var(--rule);
  font-family: var(--font-serif);
  font-size: clamp(1rem, 1.5vw, 1.25rem);
  font-style: italic;
  color: var(--ink-soft);
  max-width: 46ch;
}
.fact b { font-style: normal; font-weight: 600; color: var(--ink); }

/* ---------- header ---------- */
header.top {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: clamp(18px, 2.4vh, 28px) var(--pad-x);
  pointer-events: none;
}
header.top .mark {
  font-family: var(--font-display);
  font-weight: 600;
  font-variation-settings: "EXPO" -10;
  letter-spacing: -0.02em;
  font-size: 1.35rem;
  color: var(--ink);
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.5s var(--ease), transform 0.5s var(--ease);
  pointer-events: auto;
  text-decoration: none;
}
header.top.scrolled .mark { opacity: 1; transform: none; }

/* theme toggle */
.toggle {
  pointer-events: auto;
  margin-left: auto;
  width: 42px; height: 42px;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: border-color 0.4s var(--ease), background-color 0.4s var(--ease), transform 0.3s var(--ease);
}
.toggle:hover { border-color: var(--ink-soft); transform: rotate(-12deg); }
.toggle svg { width: 18px; height: 18px; display: none; }
html[data-theme="light"] .toggle .moon { display: block; }
html[data-theme="dark"]  .toggle .sun  { display: block; }

/* ---------- hero ---------- */
.hero { min-height: 100svh; display: flex; flex-direction: column; justify-content: center; padding: 0 0 clamp(60px,10vh,120px); }
.hero .wordmark {
  font-family: var(--font-display);
  font-weight: 600;
  font-variation-settings: "EXPO" -10;
  letter-spacing: -0.04em;
  line-height: 0.9;
  font-size: clamp(4.2rem, 15vw, 13rem);
}
.hero .tagline {
  font-size: clamp(1.2rem, 2.3vw, 1.9rem);
  line-height: 1.4;
  max-width: 24ch;
  margin-top: clamp(24px, 4vh, 40px);
  color: var(--ink-soft);
}
.hero .tagline b { color: var(--ink); font-weight: 600; }

.scrollcue {
  position: absolute;
  bottom: clamp(28px, 5vh, 48px);
  left: var(--pad-x);
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  display: flex; align-items: center; gap: 0.7em;
}
.scrollcue .line { width: 1px; height: 34px; background: currentColor; opacity: 0.5; animation: cue 2.4s var(--ease) infinite; transform-origin: top; }
@keyframes cue { 0%,100% { transform: scaleY(0.4); opacity: 0.2; } 50% { transform: scaleY(1); opacity: 0.6; } }

/* ---------- source vs extension ---------- */
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(28px, 5vw, 80px); margin-top: clamp(40px, 6vh, 72px); }
.duo .col h3 {
  font-family: var(--font-sans);
  font-size: 0.82rem; font-weight: 600; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--ink-soft); margin-bottom: 1em;
}
.duo .col.source h3 { color: var(--ink); }
.duo .col p { font-size: clamp(1.02rem, 1.4vw, 1.22rem); line-height: 1.6; color: var(--ink-soft); max-width: 38ch; }
.duo .col.source p { color: var(--ink); }
.closer { margin-top: clamp(40px, 6vh, 72px); font-family: var(--font-display); font-weight: 600; font-variation-settings: "EXPO" -10; letter-spacing: -0.02em; font-size: clamp(1.5rem, 3.4vw, 2.8rem); line-height: 1.1; max-width: 22ch; }

/* ---------- model pillars ---------- */
.pillars { display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(24px, 3.5vw, 56px); margin-top: clamp(44px, 6vh, 76px); }
.pillars .p .n { font-family: var(--font-serif); font-style: italic; color: var(--ink-soft); font-size: 1rem; margin-bottom: 0.8em; }
.pillars .p h4 { font-size: 1.35rem; font-weight: 600; margin-bottom: 0.5em; letter-spacing: -0.01em; }
.pillars .p p { color: var(--ink-soft); font-size: 1.02rem; line-height: 1.55; }

/* ---------- close ---------- */
.close .big { font-size: clamp(3rem, 11vw, 9rem); }
.cta {
  display: inline-block;
  margin-top: clamp(32px, 5vh, 52px);
  font-family: var(--font-serif);
  font-size: clamp(1.3rem, 2.6vw, 2rem);
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.15em;
  transition: border-color 0.4s var(--ease), opacity 0.3s var(--ease);
}
.cta:hover { border-color: var(--ink); }

/* ---------- footer ---------- */
footer.foot {
  border-top: 1px solid var(--rule);
  padding: clamp(40px, 8vh, 80px) 0;
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 16px;
}
footer.foot .fmark { font-family: var(--font-display); font-weight: 600; font-variation-settings: "EXPO" -10; font-size: 1.3rem; }
footer.foot a { font-family: var(--font-serif); color: var(--ink-soft); text-decoration: none; transition: color 0.3s var(--ease); }
footer.foot a:hover { color: var(--ink); }
footer.foot .note { font-size: 0.82rem; color: var(--ink-soft); letter-spacing: 0.04em; }

/* ---------- ecosystem graph ---------- */
.graph { position: relative; width: min(76vw, 470px); aspect-ratio: 1; margin: clamp(36px, 6vh, 64px) auto clamp(6px, 2vh, 16px); }
.graph-lines { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.graph-lines line { stroke: var(--rule); stroke-width: 1; vector-effect: non-scaling-stroke; }
.ring { position: absolute; inset: 0; }
.node { position: absolute; transform: translate(-50%, -50%); }
.node-c { display: flex; flex-direction: column; align-items: center; gap: 8px; animation: gfloat 6s ease-in-out infinite alternate; }
.ico { width: clamp(42px, 8.5vw, 56px); height: clamp(42px, 8.5vw, 56px); border-radius: 50%; background: var(--paper); border: 1px solid var(--rule); display: grid; place-items: center; color: var(--ink); }
.ico svg { width: 50%; height: 50%; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.lbl { font-size: 0.72rem; letter-spacing: 0.05em; color: var(--ink-soft); }
.graph-hub { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: clamp(58px, 12vw, 78px); height: clamp(58px, 12vw, 78px); border-radius: 50%; background: var(--ink); color: var(--paper); display: grid; place-items: center; z-index: 2; }
.graph-hub svg { width: 46%; height: 46%; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.graph-hub svg circle { fill: currentColor; stroke: none; }
.graph-hub::after { content: ""; position: absolute; inset: -7px; border-radius: 50%; border: 1px solid var(--rule); animation: gpulse 3.6s ease-out infinite; }
@keyframes gpulse { 0% { transform: scale(1); opacity: 0.5; } 100% { transform: scale(1.55); opacity: 0; } }
@keyframes gfloat { from { transform: translateY(-4px); } to { transform: translateY(4px); } }
@media (prefers-reduced-motion: reduce) { .node-c, .graph-hub::after { animation: none; } }
@media (max-width: 600px) { .lbl { display: none; } }

/* ---------- reveal-on-scroll ---------- */
.reveal { opacity: 0; transform: translateY(30px); transition: opacity 0.9s var(--ease), transform 0.9s var(--ease); }
.reveal.in { opacity: 1; transform: none; }
.reveal.d1 { transition-delay: 0.08s; }
.reveal.d2 { transition-delay: 0.16s; }
.reveal.d3 { transition-delay: 0.24s; }
.reveal.d4 { transition-delay: 0.32s; }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .duo { grid-template-columns: 1fr; gap: 36px; }
  .pillars { grid-template-columns: 1fr; gap: 32px; }
  h2.display { max-width: 14ch; }
  .scrollcue { display: none; }
}

/* ---------- password gate ---------- */
html:not(.unlocked) body { overflow: hidden; height: 100vh; }
.gate {
  position: fixed; inset: 0; z-index: 300;
  background: var(--paper);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  transition: opacity 0.7s var(--ease), visibility 0.7s var(--ease);
}
.gate::after {
  content: ""; position: absolute; inset: 0;
  background-image: url("textures/paper-noise.webp"); background-size: 120px 120px; background-repeat: repeat;
  opacity: var(--grain-opacity); mix-blend-mode: difference; pointer-events: none;
}
html.unlocked .gate { opacity: 0; visibility: hidden; pointer-events: none; }
.gate-inner { position: relative; display: flex; flex-direction: column; align-items: center; gap: clamp(26px, 6vh, 52px); text-align: center; }
.gate-inner.wrong { animation: gate-shake 0.42s; }
@keyframes gate-shake { 0%,100% { transform: translateX(0); } 18%,58% { transform: translateX(-9px); } 38%,78% { transform: translateX(9px); } }
.gate-mark { font-family: var(--font-display); font-weight: 600; font-variation-settings: "EXPO" -10; letter-spacing: -0.03em; font-size: clamp(1.8rem, 4.4vw, 3rem); line-height: 1; }
.typer {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  min-width: min(56vw, 230px); min-height: 1.7em;
  border-bottom: 1.5px solid var(--rule); padding: 4px 12px 12px; cursor: text;
  transition: border-color 0.4s var(--ease);
}
.typer:focus-within { border-color: var(--ink-soft); }
.typer-dots {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 1.4rem; letter-spacing: 0.26em; color: var(--ink); line-height: 1; white-space: pre;
}
.caret { display: inline-block; width: 2px; height: 1.35rem; background: var(--ink); margin-left: 4px; opacity: 0; }
.typer:focus-within .caret { animation: caret-blink 1.06s steps(2) infinite; }
@keyframes caret-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
.gate-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; background: transparent; outline: none; cursor: text; font-size: 16px; }
.gate-hint { font-family: var(--font-serif); font-style: italic; font-size: 1rem; color: var(--ink-soft); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .gate-inner.wrong { animation: none; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .scrollcue .line { animation: none; }
  * { transition-duration: 0.001ms !important; }
}
