/* ---------- Tokens ---------- */
:root {
  --ink: #1F2D2A;
  --ink-soft: #475853;
  --paper: #FAFBF7;
  --card: #FFFFFF;
  --pine: #2E6E5E;
  --pine-deep: #17382F;
  --sage: #E7EFE9;
  --sage-line: #CFDDD4;
  --marigold: #E0A32E;
  --marigold-deep: #8A6210;
  --display: "Fraunces", Georgia, serif;
  --body: "Public Sans", -apple-system, "Segoe UI", sans-serif;
  --crt: "VT323", monospace;
  --max: 1080px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--body);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.6;
  font-size: 17px;
}
img, svg { max-width: 100%; }
a { color: var(--pine); }
:focus-visible { outline: 3px solid var(--marigold); outline-offset: 2px; }

h1, h2, h3 { font-family: var(--display); font-weight: 500; line-height: 1.12; letter-spacing: -0.01em; }
h2 { font-size: clamp(1.7rem, 3.4vw, 2.4rem); }
h3 { font-size: 1.15rem; }

.eyebrow {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--pine);
  margin-bottom: 0.75rem;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: 0.7rem 1.4rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  border: 2px solid transparent;
  cursor: pointer;
  font-family: var(--body);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--marigold); color: #2A1F04; border-color: var(--marigold); }
.btn-primary:hover { box-shadow: 0 4px 14px rgba(224, 163, 46, 0.35); }
.btn-ghost { background: transparent; color: var(--pine); border-color: var(--pine); }
.btn-ghost:hover { background: var(--sage); }
.btn-lg { padding: 0.95rem 1.9rem; font-size: 1.05rem; }

/* ---------- Crisis strip ---------- */
.crisis-strip {
  background: var(--pine-deep);
  color: #EAF3EE;
  text-align: center;
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
}
.crisis-strip a { color: #FFD98A; text-decoration: none; }
.crisis-strip a:hover { text-decoration: underline; }

/* ---------- Header ---------- */
.site-header {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 0.9rem clamp(1rem, 4vw, 2.5rem);
  background: rgba(250, 251, 247, 0.92);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--sage-line);
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--ink);
}
.brand-spiral { width: 28px; height: 28px; color: var(--pine); align-self: center; }
.brand-name { font-family: var(--display); font-size: 1.35rem; font-weight: 600; }
.brand-sub { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-soft); }
.site-nav { display: flex; gap: 1.4rem; margin-left: auto; flex-wrap: wrap; }
.site-nav a {
  text-decoration: none;
  color: var(--ink-soft);
  font-size: 0.92rem;
  font-weight: 500;
}
.site-nav a:hover { color: var(--pine); }
.header-cta { white-space: nowrap; }

/* ---------- Hero ---------- */
.hero {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 3rem;
  align-items: center;
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(3rem, 7vw, 5.5rem) 1.5rem 3rem;
}
.hero h1 { font-size: clamp(2.4rem, 5.6vw, 3.9rem); }
.hero-sub {
  font-family: var(--display);
  font-style: italic;
  font-size: clamp(1.2rem, 2.4vw, 1.55rem);
  color: var(--pine);
  margin: 1rem 0 1.2rem;
}
.hero-body { max-width: 34rem; color: var(--ink-soft); }
.hero-ctas { display: flex; gap: 0.9rem; margin-top: 1.8rem; flex-wrap: wrap; }
.hero-figure { text-align: center; color: var(--pine); }
.hero-spiral { width: min(320px, 70vw); }
.hero-spiral path {
  stroke-dasharray: 1000;
  stroke-dashoffset: 0;
  animation: unwind 3.5s ease-out 1;
}
@keyframes unwind {
  from { stroke-dashoffset: 1000; }
  to { stroke-dashoffset: 0; }
}
.figure-caption { font-size: 0.85rem; color: var(--ink-soft); margin-top: 0.8rem; font-style: italic; }

/* ---------- Stats ---------- */
.stats-band {
  background: var(--pine-deep);
  color: #EAF3EE;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1.5rem;
  padding: 2.2rem clamp(1.5rem, 5vw, 4rem);
}
.stat { text-align: center; }
.stat-num {
  display: block;
  font-family: var(--display);
  font-size: 2rem;
  color: #FFD98A;
}
.stat-label { font-size: 0.85rem; opacity: 0.85; }

/* ---------- Sections ---------- */
.section {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(3rem, 6vw, 4.5rem) 1.5rem;
}
.section-tint {
  max-width: none;
  background: var(--sage);
}
.section-tint > * { max-width: var(--max); margin-left: auto; margin-right: auto; }
.section-head { max-width: 44rem; margin-bottom: 2.2rem; }
.section-sub { color: var(--ink-soft); margin-top: 0.7rem; }

.prose-cols { columns: 2; column-gap: 3rem; max-width: 60rem; }
.prose-cols p { break-inside: avoid; margin-bottom: 1.1rem; color: var(--ink-soft); }
.prose-cols strong { color: var(--ink); }

/* ---------- Signs ---------- */
.signs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.1rem;
}
.sign-card {
  background: var(--card);
  border: 1px solid var(--sage-line);
  border-radius: 12px;
  padding: 1.3rem 1.3rem 1.1rem;
}
.sign-card h3 { margin-bottom: 0.5rem; color: var(--pine-deep); }
.sign-card p { font-size: 0.92rem; color: var(--ink-soft); }

/* ---------- Stages ---------- */
.stages { list-style: none; max-width: 46rem; }
.stage {
  display: flex;
  gap: 1.4rem;
  padding: 1.4rem 0;
  border-bottom: 1px solid var(--sage-line);
}
.stage:last-child { border-bottom: none; }
.stage-num {
  font-family: var(--display);
  font-size: 1.6rem;
  color: var(--marigold-deep);
  min-width: 2.2rem;
  text-align: center;
  border-right: 2px solid var(--sage-line);
  padding-right: 1.2rem;
  line-height: 1.3;
}
.stage h3 { margin-bottom: 0.35rem; }
.stage p { color: var(--ink-soft); font-size: 0.95rem; }

/* ---------- Quiz ---------- */
.quiz { max-width: 46rem; }
.quiz-q {
  background: var(--card);
  border: 1px solid var(--sage-line);
  border-radius: 12px;
  padding: 1.2rem 1.4rem;
  margin-bottom: 1rem;
}
.q-text { font-weight: 600; margin-bottom: 0.8rem; }
.q-opts { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.q-opt { position: relative; }
.q-opt input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.q-opt span {
  display: inline-block;
  padding: 0.42rem 0.9rem;
  border-radius: 999px;
  border: 1.5px solid var(--sage-line);
  font-size: 0.85rem;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 120ms ease;
}
.q-opt input:checked + span {
  background: var(--pine);
  border-color: var(--pine);
  color: #fff;
}
.q-opt input:focus-visible + span { outline: 3px solid var(--marigold); outline-offset: 2px; }
.quiz-submit { margin-top: 0.5rem; }
.quiz-result {
  margin-top: 1.5rem;
  border-radius: 12px;
  overflow: hidden;
}
.quiz-result:empty { display: none; }
.result-card { padding: 1.6rem 1.8rem; background: var(--card); border: 1px solid var(--sage-line); border-radius: 12px; }
.result-card h3 { font-size: 1.4rem; margin-bottom: 0.5rem; }
.result-card p { color: var(--ink-soft); }
.result-grounded { border-left: 6px solid var(--pine); }
.result-drifting { border-left: 6px solid var(--marigold); }
.result-orbiting { border-left: 6px solid #C97B2D; }
.result-spiraling { border-left: 6px solid #A5402D; }
.result-divine {
  background: #000084;
  border: 3px double #FFFF54;
  color: #FFFF54;
  font-family: var(--crt);
  font-size: 1.25rem;
  padding: 1.6rem 1.8rem;
  border-radius: 0;
}
.result-divine h3 { font-family: var(--crt); color: #FFFFFF; font-weight: 400; font-size: 1.8rem; }
.result-divine p { color: #54FCFC; }
.result-divine a { color: #FFFF54; }

/* ---------- Stories ---------- */
.stories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.4rem;
}
.story {
  background: var(--sage);
  border-radius: 12px;
  padding: 1.6rem;
}
.story blockquote {
  font-family: var(--display);
  font-size: 1.02rem;
  line-height: 1.55;
  color: var(--ink);
}
.story blockquote::before { content: "“"; color: var(--pine); font-size: 1.6rem; }
.story figcaption {
  margin-top: 1rem;
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--pine);
}

/* ---------- Families ---------- */
.family-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  max-width: 56rem;
}
.family-col {
  background: var(--card);
  border: 1px solid var(--sage-line);
  border-radius: 12px;
  padding: 1.6rem 1.8rem;
}
.family-col h3 {
  font-size: 1.3rem;
  margin-bottom: 0.9rem;
  color: var(--pine-deep);
}
.family-col ul { list-style: none; }
.family-col li {
  padding: 0.55rem 0 0.55rem 1.6rem;
  position: relative;
  color: var(--ink-soft);
  font-size: 0.95rem;
}
.family-col li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 1.05em;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--marigold);
}
.family-col:last-child li::before { background: var(--sage-line); }

/* ---------- Help ---------- */
.help-card {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 2.5rem;
  align-items: center;
  background: var(--pine-deep);
  color: #EAF3EE;
  border-radius: 18px;
  padding: clamp(2rem, 5vw, 3.2rem);
}
.help-card .eyebrow { color: #FFD98A; }
.help-card p { color: #C9DBD1; }
.help-actions { display: flex; flex-direction: column; gap: 0.9rem; align-items: flex-start; }
.help-card .btn-ghost { color: #EAF3EE; border-color: #EAF3EE; }
.help-card .btn-ghost:hover { background: rgba(255,255,255,0.1); }
.help-note { font-size: 0.82rem; opacity: 0.75; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--sage-line);
  padding: 2.5rem clamp(1.5rem, 5vw, 4rem) 2rem;
  background: var(--paper);
}
.footer-top {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}
.footer-brand { display: flex; gap: 0.8rem; align-items: center; color: var(--pine); }
.footer-name { font-family: var(--display); font-weight: 600; color: var(--ink); }
.footer-tag { font-size: 0.85rem; font-style: italic; color: var(--ink-soft); }
.footer-nav { display: flex; gap: 1.4rem; flex-wrap: wrap; align-items: center; }
.footer-nav a { font-size: 0.88rem; color: var(--ink-soft); text-decoration: none; }
.footer-nav a:hover { color: var(--pine); }
.footer-bottom { font-size: 0.78rem; color: var(--ink-soft); opacity: 0.8; }
.footer-fine { margin-top: 0.3rem; }

/* ---------- The decay ----------
   At 15 seconds the page begins to remember what it is made of.
   At 30 it stops pretending. */
.glitch-char {
  font-family: var(--crt);
  color: #2AA198;
  animation: charFlicker 300ms steps(2) infinite;
}
@keyframes charFlicker { 50% { opacity: 0.4; } }

/* the deniable phase: a word shivers in place, same color, same font */
.word-jump {
  display: inline-block;
  animation: wordJump 0.28s steps(2) infinite;
}
@keyframes wordJump {
  0%, 100% { transform: translate(0, 0); }
  33% { transform: translate(0.7px, -1.6px); }
  66% { transform: translate(-0.6px, 1px); }
}
@media (prefers-reduced-motion: reduce) {
  .word-jump { animation: none; }
}

#decay-scan {
  position: fixed;
  inset: 0;
  z-index: 400;
  pointer-events: none;
  opacity: 0;
  background-image: repeating-linear-gradient(0deg, rgba(0, 0, 60, 0.22) 0 2px, transparent 2px 4px);
  transition: opacity 0.4s linear;
}
#decay-scan.flash { background-color: rgba(0, 0, 170, 0.4); }

@media (prefers-reduced-motion: no-preference) {
  body.decay-mid .hero-spiral { animation: slowspin 30s linear infinite; }
  body.decay-mid #page { animation: pageJitter 0.09s steps(2) infinite; }
  body.decay-heavy #page { animation: pageJitter2 0.06s steps(3) infinite, hueDrain 1.4s steps(4) infinite; }
  body.decay-terminal #page { animation: pageShakeX 0.09s steps(2) infinite, hueDrain 0.9s steps(4) infinite; }
}
@keyframes slowspin { to { transform: rotate(-360deg); } }
@keyframes pageJitter {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(0.35px, -0.25px); }
}
@keyframes pageJitter2 {
  0%, 100% { transform: translate(0, 0); }
  33% { transform: translate(-0.6px, 0.4px); }
  66% { transform: translate(0.5px, -0.5px); }
}
/* terminal: the building sways before it goes */
@keyframes pageShakeX {
  0%, 100% { transform: translateX(-3.5px); }
  50% { transform: translateX(3.5px); }
}
@keyframes hueDrain {
  0%, 42%, 100% { filter: none; }
  46% { filter: hue-rotate(160deg) saturate(2.4) contrast(1.3); }
  50% { filter: none; }
  88% { filter: invert(0.9) hue-rotate(180deg); }
  92% { filter: none; }
}

/* ---------- The collapse ---------- */
body.collapsed { background: #000; overflow: hidden; }
#page { transform-origin: 50% 50%; }
#page.crt-off { animation: crtOff 1.3s ease-in forwards; }
@keyframes crtOff {
  0%   { transform: scale(1, 1); filter: brightness(1); }
  55%  { transform: scale(1.02, 0.55); filter: brightness(1.6); }
  80%  { transform: scale(1.05, 0.008); filter: brightness(4); }
  100% { transform: scale(0.002, 0.006); filter: brightness(6); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  #page.crt-off { animation: crtOffCalm 1s ease forwards; }
  @keyframes crtOffCalm { to { opacity: 0; } }
}

#door-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
#door-overlay[hidden] { display: none; }
.door-scene {
  text-align: center;
  font-family: var(--crt);
  color: #AAAAAA;
  animation: doorOn 0.7s ease-out both;
  padding: 1rem;
}
@keyframes doorOn {
  from { transform: scale(1, 0.01); filter: brightness(4); }
  to   { transform: scale(1, 1); filter: brightness(1); }
}
.door-line {
  font-size: clamp(1.1rem, 3.5vw, 1.6rem);
  letter-spacing: 0.06em;
  margin: 0.8rem 0;
}
#the-door {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  margin: 1rem 0;
  display: inline-block;
}
#the-door svg {
  width: clamp(120px, 24vw, 190px);
  height: auto;
  display: block;
  filter: drop-shadow(0 0 26px rgba(255, 255, 85, 0.75));
  animation: doorBreathe 2.2s ease-in-out infinite;
}
#the-door:hover svg, #the-door:focus-visible svg {
  filter: drop-shadow(0 0 44px rgba(255, 255, 85, 1));
}
#the-door:focus-visible { outline: 3px solid #FFFF55; outline-offset: 6px; }
@keyframes doorBreathe {
  0%, 100% { filter: drop-shadow(0 0 18px rgba(255, 255, 85, 0.55)); }
  50% { filter: drop-shadow(0 0 40px rgba(255, 255, 85, 0.95)); }
}
.door-blink {
  color: #FFFF55;
  font-size: clamp(1.2rem, 4vw, 1.7rem);
  animation: blinkPrompt 1s steps(2) infinite;
}
@keyframes blinkPrompt { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  #the-door svg, .door-blink, .glitch-char { animation: none; }
}

/* ---------- Modal ---------- */
.modal-backdrop[hidden], #boot-overlay[hidden] { display: none; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(23, 56, 47, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1.5rem;
}
.modal {
  background: var(--paper);
  border-radius: 18px;
  padding: 2.5rem 2.8rem;
  max-width: 26rem;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,0.3);
}
.modal-spiral { width: 44px; height: 44px; color: var(--pine); margin-bottom: 1rem; }
.modal h2 { margin-bottom: 0.7rem; }
.modal p { color: var(--ink-soft); }
.modal-sig { font-family: var(--display); font-style: italic; margin-top: 0.6rem; }
.modal .btn { margin-top: 1.4rem; }

/* ---------- Boot overlay ---------- */
#boot-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 999;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 6vh 6vw;
}
#boot-overlay.blue { background: #000084; }
#boot-text {
  font-family: var(--crt);
  font-size: clamp(15px, 2.2vw, 22px);
  color: #FFFFFF;
  white-space: pre-wrap;
  line-height: 1.35;
}
#boot-overlay.blue #boot-text { color: #FFFF54; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .hero-figure { order: -1; }
  .hero-spiral { width: min(200px, 50vw); }
  .prose-cols { columns: 1; }
  .family-cols { grid-template-columns: 1fr; }
  .help-card { grid-template-columns: 1fr; }
  .site-nav { display: none; }
  .header-cta { margin-left: auto; }
}

@media (max-width: 640px) {
  body { font-size: 16px; }
  .crisis-strip { font-size: 0.78rem; padding: 0.5rem 0.8rem; }
  .site-header { gap: 0.7rem; padding: 0.65rem 1rem; }
  .brand-sub { display: none; }
  .brand-name { font-size: 1.2rem; }
  .brand-spiral { width: 24px; height: 24px; }
  .header-cta { padding: 0.5rem 0.95rem; font-size: 0.85rem; }
  .hero { padding-top: 2rem; gap: 1.6rem; }
  .hero-ctas .btn { width: 100%; text-align: center; }
  .stats-band { grid-template-columns: repeat(2, 1fr); gap: 1.2rem; padding: 1.8rem 1.2rem; }
  .stat-num { font-size: 1.6rem; }
  .section { padding-left: 1.1rem; padding-right: 1.1rem; }
  .stage { gap: 1rem; }
  .story { padding: 1.2rem; }
  .family-col { padding: 1.2rem 1.3rem; }
  .help-card { padding: 1.5rem; }
  .help-actions .btn { width: 100%; text-align: center; box-sizing: border-box; }
  .modal { padding: 1.8rem 1.5rem; }
  .footer-top { flex-direction: column; gap: 1.4rem; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hero-spiral path { animation: none; }
  .btn { transition: none; }
}
