/* ============================================================
   SAGECORE — living core · sagecore.ai (nucleo-vivo)
   One fixed WebGL core behind everything; sections scroll past
   and the PAGE THEME LERPS dark<->light driven by scroll (JS sets
   --th 0..1 each frame; every color derives from it).
   PERF: never animate filter/backdrop on fullscreen layers.
   ============================================================ */

:root {
  /* --th: 0 = dark, 1 = light (set by JS every frame) */
  --th: 0;
  --gold: #ffc862;
  --gold-soft: #ffe0a0;
  --gold-hot: #fff3d6;
  --gold-deep: #c8962f;
  --glow: 255, 200, 98;

  /* theme-derived (JS also sets these, fallbacks here) */
  --bg: #05070c;
  --ink: #eaf6ff;
  --ink-dim: #7d93ad;
  --ink-faint: #55708c;
  --line: rgba(160, 200, 235, 0.14);
  --card-bg: rgba(13, 19, 33, 0.72);

  --font-num: "Orbitron", "Rajdhani", monospace;
  --font-tech: "Rajdhani", "Inter", sans-serif;
  --font-body: "Inter", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}
body { overflow-x: hidden; }

::selection { background: rgba(var(--glow), 0.25); }

/* ---------- fixed layers ---------- */

#stage { position: fixed; inset: 0; z-index: 1; }
#stage canvas { display: block; width: 100%; height: 100%; }

/* the original night gradient — a soft cool pool behind the core.
   JS fades it with the theme (opacity = 1 - --th via inline style). */
#glow {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 80% 55% at 50% 34%, #322718 0%, rgba(40, 31, 19, 0.75) 40%, transparent 72%),
    radial-gradient(ellipse 120% 50% at 50% 108%, rgba(30, 23, 14, 0.9) 0%, transparent 65%);
}

#grain {
  position: fixed; inset: -50%;
  z-index: 5; pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grainShift 9s steps(6) infinite;
}
@keyframes grainShift {
  0% { transform: translate(0, 0); } 20% { transform: translate(-4%, 3%); }
  40% { transform: translate(3%, -5%); } 60% { transform: translate(-3%, -2%); }
  80% { transform: translate(4%, 4%); } 100% { transform: translate(0, 0); }
}

main, #nav, #footer { position: relative; z-index: 2; }

/* ---------- instrument HUD (fixed, quiet) ---------- */

#ihud { position: fixed; inset: 0; z-index: 4; pointer-events: none; opacity: 0; transition: opacity 1.2s ease; }
#ihud.on { opacity: 1; }
.ih {
  position: absolute;
  font-family: var(--font-tech);
  font-weight: 600; font-size: 0.62rem;
  letter-spacing: 0.3em; text-transform: uppercase;
  color: var(--ink-faint);
}
.ih-tl { top: 4.2rem; left: clamp(1.2rem, 4vw, 3rem); }
.ih-tr { top: 4.2rem; right: clamp(1.2rem, 4vw, 3rem); }
.ih-bl { bottom: 1.4rem; left: clamp(1.2rem, 4vw, 3rem); }
.ih-br { bottom: 1.4rem; right: clamp(1.2rem, 4vw, 3rem); }
.ih-deg {
  bottom: 1.3rem; left: 50%; transform: translateX(-50%);
  font-family: var(--font-num); font-size: 0.72rem;
  letter-spacing: 0.18em; color: var(--ink-dim);
  border-top: 1px solid var(--line);
  padding-top: 0.45rem; min-width: 4.5rem; text-align: center;
}

/* ---------- nav ---------- */

#nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 8;
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem clamp(1.2rem, 4vw, 3rem);
  border-bottom: 1px solid transparent;
}
#nav.scrolled { border-bottom-color: var(--line); }
.nav-brand { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; }
.nav-word {
  font-family: var(--font-num); font-weight: 700; font-size: 0.9rem;
  letter-spacing: 0.22em; color: var(--ink);
}
.nav-word em { font-style: normal; color: var(--gold-deep); }
.nav-links { display: flex; gap: 1.8rem; }
.nav-links a {
  font-family: var(--font-tech); font-weight: 600; font-size: 0.72rem;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--ink-dim); text-decoration: none;
  transition: color 0.25s;
}
.nav-links a:hover { color: var(--ink); }

/* ---------- panels (sections) ---------- */

.panel {
  position: relative;
  min-height: 100vh; min-height: 100svh;
  padding: clamp(6rem, 14vh, 10rem) clamp(1.3rem, 5vw, 4.5rem);
  display: flex; flex-direction: column; justify-content: center;
}
.panel-tall { min-height: 130vh; }

.eyebrow {
  margin: 0 0 1.1rem;
  font-family: var(--font-tech); font-weight: 700; font-size: 0.7rem;
  letter-spacing: 0.42em; text-transform: uppercase;
  color: var(--gold-deep);
}
.eyebrow::before {
  content: ""; display: inline-block;
  width: 2.2rem; height: 1px; margin-right: 0.9rem; vertical-align: middle;
  background: linear-gradient(90deg, var(--gold-deep), transparent);
}
.big-line {
  margin: 0;
  font-family: var(--font-num); font-weight: 700;
  font-size: clamp(2rem, 5.2vw, 3.8rem);
  line-height: 1.12; letter-spacing: 0.04em;
  color: var(--ink);
}
.lead {
  margin: 1.4rem 0 0; max-width: 34rem;
  font-size: clamp(0.95rem, 1.6vw, 1.05rem); line-height: 1.85;
  color: var(--ink-dim);
}
.lead strong { color: var(--ink); font-weight: 600; }
.lead.dim { color: var(--ink-faint); font-size: 0.88rem; }

.section-head { max-width: 46rem; }

/* ---------- 01 hero ---------- */

#hero { align-items: center; justify-content: flex-end; text-align: center; padding-bottom: 12vh; }
.hero-copy { position: relative; z-index: 2; }
.hero-word {
  margin: 0;
  font-family: var(--font-num); font-weight: 900;
  font-size: clamp(2.2rem, 6.8vw, 5rem);
  letter-spacing: 0.3em; margin-right: -0.3em;
  color: var(--ink);
  text-shadow: 0 0 1.6rem rgba(var(--glow), 0.35), 0 0 4.5rem rgba(var(--glow), 0.15);
}
.hero-word em {
  font-style: normal;
  background: linear-gradient(180deg, var(--gold-hot), var(--gold) 55%, #e09a3a);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-kicker {
  margin: 1.1rem 0 0;
  font-family: var(--font-tech); font-weight: 600;
  font-size: clamp(0.72rem, 1.5vw, 0.9rem);
  letter-spacing: 0.34em; text-transform: uppercase;
  color: var(--gold);
}
.hero-tagline {
  margin: 0.55rem 0 0;
  font-family: var(--font-tech); font-weight: 500;
  font-size: clamp(1rem, 2.2vw, 1.35rem); letter-spacing: 0.14em;
  color: var(--ink);
}
.scroll-cue {
  position: absolute; bottom: 4.6rem; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 0.55rem;
  opacity: 0.6;
}
.cue-line {
  width: 1px; height: 3rem;
  background: linear-gradient(180deg, transparent, rgba(var(--glow), 0.8));
  animation: cueDrop 2.6s ease-in-out infinite; transform-origin: top;
}
@keyframes cueDrop {
  0% { transform: scaleY(0); opacity: 0; }
  35% { transform: scaleY(1); opacity: 1; }
  75% { transform: scaleY(1); opacity: 1; }
  100% { transform: scaleY(1); opacity: 0; }
}
.cue-label {
  font-family: var(--font-tech); font-size: 0.62rem; font-weight: 600;
  letter-spacing: 0.36em; text-transform: uppercase; color: var(--ink-faint);
}

/* ---------- 02 core (split: copy left, stats right, core center-right) ---------- */

.panel-split {
  display: grid;
  grid-template-columns: minmax(0, 30rem) 1fr minmax(0, 14rem);
  align-items: center; gap: 2rem;
}
.split-copy { grid-column: 1; }
.split-stats {
  grid-column: 3;
  display: flex; flex-direction: column; gap: 2.2rem;
  text-align: right;
}
.stat-n {
  display: block;
  font-family: var(--font-num); font-weight: 700;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  color: var(--ink); letter-spacing: 0.06em;
}
.stat-l {
  display: block; margin-top: 0.3rem;
  font-family: var(--font-tech); font-weight: 600; font-size: 0.66rem;
  letter-spacing: 0.24em; text-transform: uppercase; color: var(--ink-faint);
}

/* ---------- 03 constellation ---------- */

#constellation .section-head { margin-bottom: 3rem; }
.grid {
  margin-top: 1rem;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.3rem;
  position: relative; z-index: 2;
}
.card {
  position: relative; display: flex; flex-direction: column;
  padding: 1.7rem 1.6rem 1.5rem;
  border-radius: 1rem;
  border: 1px solid var(--line);
  background: var(--card-bg);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: transform 0.35s cubic-bezier(.2,.7,.3,1), border-color 0.35s, box-shadow 0.35s;
}
.card.live:hover {
  transform: translateY(-5px);
  border-color: rgba(var(--glow), 0.35);
  box-shadow: 0 1.4rem 3rem rgba(0, 0, 0, 0.4), 0 0 2.2rem rgba(var(--glow), 0.10);
}
.card-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1.25rem; }
.logo-slot { width: 3.2rem; height: 3.2rem; display: grid; place-items: center; }
.pmark {
  display: block; width: 100%; height: 100%;
  background: linear-gradient(155deg, #dab35f 0%, #b8862a 52%, #85601a 100%);
  -webkit-mask: var(--logo) center / contain no-repeat;
          mask: var(--logo) center / contain no-repeat;
}
.badge {
  display: inline-flex; align-items: center; gap: 0.45rem;
  font-family: var(--font-tech); font-weight: 700; font-size: 0.58rem;
  letter-spacing: 0.26em; text-transform: uppercase;
  padding: 0.28rem 0.75rem; border-radius: 2rem; border: 1px solid;
}
.badge-live { color: #6fdf9e; border-color: rgba(74, 222, 128, 0.3); background: rgba(20, 45, 30, 0.35); }
.badge-live .dot {
  width: 0.42rem; height: 0.42rem; border-radius: 50%;
  background: #4ade80; box-shadow: 0 0 0.55rem rgba(74, 222, 128, 0.9);
  animation: liveBlink 1.8s ease-in-out infinite;
}
@keyframes liveBlink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.badge-soon { color: #d9b877; border-color: rgba(217, 184, 119, 0.28); background: rgba(42, 32, 14, 0.35); }
.card-name {
  margin: 0 0 0.6rem;
  font-family: var(--font-num); font-weight: 700; font-size: 1.08rem;
  letter-spacing: 0.1em; color: var(--ink);
}
.card-name em { font-style: normal; color: var(--gold-deep); }
.card-desc { margin: 0 0 1.4rem; flex: 1; font-size: 0.85rem; line-height: 1.7; color: var(--ink-dim); }
.card-domain {
  font-family: var(--font-tech); font-weight: 600; font-size: 0.72rem;
  letter-spacing: 0.2em; text-transform: lowercase;
  color: var(--gold-deep); text-decoration: none; opacity: 0.85;
  transition: opacity 0.25s;
}
.card-domain:hover { opacity: 1; }
.card-domain.muted { color: var(--ink-faint); opacity: 0.6; cursor: default; }
.card.coming { opacity: 0.75; border-style: dashed; }
.card.ghost {
  border: 1px dashed var(--line); background: transparent;
  backdrop-filter: none; -webkit-backdrop-filter: none;
  display: grid; place-items: center; min-height: 14rem;
}
.ghost-inner { text-align: center; padding: 1rem; }
.ghost-plus {
  display: block; font-family: var(--font-num); font-weight: 500;
  font-size: 2rem; color: var(--ink-faint); margin-bottom: 0.6rem;
}
.ghost-line {
  margin: 0; font-family: var(--font-tech); font-size: 0.76rem;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-faint);
}

/* ---------- 04 thesis ---------- */

.pillars { margin-top: 3.2rem; display: grid; grid-template-columns: repeat(3, 1fr); gap: 2.6rem; }
.pillar { border-top: 1px solid var(--line); padding-top: 1.4rem; }
.pillar-num {
  font-family: var(--font-num); font-weight: 500; font-size: 0.72rem;
  letter-spacing: 0.3em; color: var(--gold-deep);
}
.pillar h3 {
  margin: 0.7rem 0;
  font-family: var(--font-tech); font-weight: 700; font-size: 1.08rem;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink);
}
.pillar p { margin: 0; font-size: 0.88rem; line-height: 1.75; color: var(--ink-dim); }

/* ---------- 05 dissolve ---------- */

#dissolve { align-items: center; text-align: center; }
.dissolve-line {
  margin: 0;
  font-family: var(--font-tech); font-weight: 500;
  font-size: clamp(1.1rem, 2.6vw, 1.7rem);
  letter-spacing: 0.2em; line-height: 2; text-transform: uppercase;
  color: var(--ink-dim);
}

/* ---------- 06 creed ---------- */

#creed { align-items: center; text-align: center; }
.creed-line {
  margin: 0;
  font-family: var(--font-num); font-weight: 700;
  font-size: clamp(1.4rem, 3.8vw, 2.6rem);
  letter-spacing: 0.08em; line-height: 1.7; color: var(--ink);
  text-shadow: 0 0 2.4rem rgba(var(--glow), 0.12);
}
.creed-line .dim { color: var(--ink-faint); }
.creed-line .gold {
  background: linear-gradient(180deg, var(--gold-hot), var(--gold) 60%, #e09a3a);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ---------- 07 contact ---------- */

#contact .section-head { margin-bottom: 2.4rem; }
#contact { max-width: 52rem; margin: 0 auto; width: 100%; }
.contact-form { display: flex; flex-direction: column; gap: 0.85rem; max-width: 40rem; }
.cf-row { display: flex; gap: 0.85rem; }
.cf-row > input { flex: 1; min-width: 0; }
.contact-form input, .contact-form textarea {
  width: 100%; padding: 0.85rem 1rem; border-radius: 12px;
  background: rgba(150, 162, 182, 0.10);
  border: 1px solid var(--line);
  color: var(--ink); font-family: var(--font-body); font-size: 0.95rem;
  outline: none; transition: border-color 0.18s, box-shadow 0.18s;
}
.contact-form textarea { resize: vertical; min-height: 5.5rem; line-height: 1.6; }
.contact-form input::placeholder, .contact-form textarea::placeholder { color: var(--ink-faint); }
.contact-form input:focus, .contact-form textarea:focus {
  border-color: rgba(var(--glow), 0.7);
  box-shadow: 0 0 0 3px rgba(var(--glow), 0.12);
}
.cf-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.cf-foot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 0.3rem; }
.cf-status { font-size: 0.85rem; color: var(--ink-dim); min-height: 1.2em; }
.cf-status.ok { color: #4ade80; }
.cf-status.err { color: #ff9a7a; }
#cf-send {
  padding: 0.72rem 1.7rem; border: 0; border-radius: 11px; cursor: pointer;
  font-family: var(--font-tech); font-weight: 700; font-size: 0.92rem;
  letter-spacing: 0.14em; text-transform: uppercase; color: #241704;
  background: linear-gradient(180deg, var(--gold-hot), var(--gold) 55%, #e79f36);
  box-shadow: 0 8px 22px rgba(var(--glow), 0.22);
  transition: filter 0.18s, transform 0.06s;
}
#cf-send:hover { filter: brightness(1.06); }
#cf-send:active { transform: translateY(1px); }
#cf-send:disabled { opacity: 0.55; cursor: default; }

/* ---------- footer ---------- */

#footer {
  border-top: 1px solid var(--line);
  padding: 3rem clamp(1.3rem, 4vw, 3rem) 2.4rem;
  display: grid; grid-template-columns: 1fr auto; gap: 1.6rem 3rem; align-items: center;
}
.foot-brand { display: flex; align-items: center; gap: 1rem; }
.foot-tag { margin: 0.3rem 0 0; font-size: 0.78rem; color: var(--ink-faint); }
.foot-links { display: flex; flex-wrap: wrap; gap: 1.6rem; align-items: center; justify-content: flex-end; }
.foot-links a {
  font-family: var(--font-tech); font-weight: 600; font-size: 0.76rem;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--ink-dim); text-decoration: none; transition: color 0.25s;
}
.foot-links a:hover { color: var(--gold-soft); }
.foot-soon {
  font-family: var(--font-tech); font-size: 0.72rem;
  letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-faint);
}
.foot-legal {
  grid-column: 1 / -1; margin: 0.6rem 0 0;
  font-family: var(--font-tech); font-size: 0.72rem;
  letter-spacing: 0.14em; color: var(--ink-faint); text-transform: uppercase;
}

/* ---------- reveal ---------- */

.reveal { opacity: 0; transform: translateY(26px); transition: opacity 0.9s ease, transform 0.9s cubic-bezier(.2,.7,.3,1); }
.reveal.in { opacity: 1; transform: none; }
body.no3d .reveal { opacity: 1; transform: none; }
body.no3d #stage { display: none; }

/* ---------- responsive ---------- */

@media (max-width: 1080px) {
  .panel-split { grid-template-columns: 1fr; gap: 3rem; }
  .split-stats { flex-direction: row; flex-wrap: wrap; text-align: left; gap: 2rem 3rem; grid-column: 1; }
}
@media (max-width: 980px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .pillars { grid-template-columns: 1fr; gap: 1.8rem; }
}
@media (max-width: 620px) {
  .grid { grid-template-columns: 1fr; }
  .nav-links { gap: 1rem; }
  .nav-links a { letter-spacing: 0.12em; font-size: 0.64rem; }
  #footer { grid-template-columns: 1fr; }
  .foot-links { justify-content: flex-start; }
  .ih-tl, .ih-bl { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  #grain, .cue-line, .badge-live .dot { animation: none !important; }
  html { scroll-behavior: auto; }
}
