:root {
  --bg: #050509;
  --bg-elevated: #0e0e16;
  --bg-soft: #151521;
  --border-soft: #262636;
  --gold: #f1d48a;
  --gold-soft: #d6b96a;
  --text-main: #f5f5f7;
  --text-muted: #a0a0b5;
  --accent: #7b5cff;
}

/* ------------------------------
   Global reset & base
------------------------------ */

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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: var(--bg);
  color: var(--text-main);
  line-height: 1.6;
}

a {
  color: var(--gold);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ------------------------------
   Header
------------------------------ */

.site-header {
  border-bottom: 1px solid var(--border-soft);
  background: radial-gradient(circle at top, #171726 0, #050509 55%);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 0 1.3rem;
  gap: 1.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--gold-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  color: var(--gold);
  background: radial-gradient(circle at 30% 0, #3a2b10, #050509 60%);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-weight: 600;
  font-size: 1rem;
}

.brand-tagline {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
}

.nav-link {
  padding: 0.25rem 0.1rem;
  position: relative;
  color: var(--text-muted);
}

.nav-link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -0.25rem;
  width: 0;
  height: 2px;
  background-color: var(--gold);
  transition: width 0.18s ease-out;
}

.nav-link:hover::after,
.nav-link.active::after {
  width: 100%;
}

.nav-link.active {
  color: var(--gold);
}

/* ------------------------------
   Hero – two-layer field system
------------------------------ */

.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 3.5rem 0 3rem;

  perspective: 1200px;

  background:
    radial-gradient(circle at 50% 0%, #2b210c 0%, #050509 55%, #000000 100%);
}

/* BACK FIELD — lattice grid */

.hero::before {
  content: "";
  position: absolute;
  inset: -15%;
  z-index: 0;

  background-color: #050509;

  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cg fill='none' stroke='%23b8860b' stroke-opacity='0.22' stroke-width='0.6'%3E%3Cpath d='M0 50h200M0 100h200M0 150h200'/%3E%3Cpath d='M-50 0l250 200M0 0l250 200M50 0l250 200'/%3E%3Cpath d='M-50 200l250-200M0 200l250-200M50 200l250-200'/%3E%3C/g%3E%3C/svg%3E");

  background-size: 260px 260px;
  opacity: 0.55;
  filter: blur(0.3px);

  transform: translate3d(0, 0, -260px) scale(1.25);
  animation: lattice-drift 22s linear infinite alternate;
}

/* FRONT FIELD — resonance haze */

.hero::after {
  content: "";
  position: absolute;
  inset: -20%;
  z-index: 1;

  background:
    radial-gradient(circle at 50% 40%,
      rgba(255, 215, 128, 0.30) 0%,
      rgba(184, 134, 11, 0.14) 18%,
      rgba(0, 0, 0, 0.0) 48%);

  mix-blend-mode: screen;
  opacity: 0.65;

  transform: translate3d(0, 0, -80px) scale(1.03);
  animation: haze-pulse 18s ease-in-out infinite alternate;
}

/* Foreground content */

.hero-inner {
  position: relative;
  z-index: 2;
  display: grid;
  gap: 2.5rem;
  grid-template-columns: minmax(0, 2.1fr) minmax(0, 1.4fr);
  align-items: center;
  transform: translateZ(80px);
}

.hero-copy {
  max-width: 40rem;
}

.crest-logo {
  width: 200px;
  max-width: 40vw;
  display: block;
  margin: 0 0 1.5rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
}

.hero h1 {
  margin: 0 0 1.2rem;
  font-size: clamp(2.1rem, 4vw, 2.7rem);
  line-height: 1.1;
}

.hero-lead {
  margin: 0 0 1.7rem;
  color: var(--text-muted);
  max-width: 36rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1.4rem;
  border-radius: 999px;
  font-size: 0.9rem;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
}

.btn.primary {
  background: linear-gradient(135deg, #f1d48a, #e0b85c);
  color: #151515;
  font-weight: 600;
}

.btn.primary:hover {
  filter: brightness(1.05);
}

.btn.ghost {
  border-color: var(--border-soft);
  color: var(--gold-soft);
  background: #090912;
}

.btn.ghost:hover {
  border-color: var(--gold-soft);
}

/* ------------------------------
   Hero visual panel
------------------------------ */

.hero-panel {
  position: relative;
  background: radial-gradient(circle at top, #1f1f32 0, #050509 62%);
  border-radius: 1.4rem;
  border: 1px solid var(--border-soft);
  padding: 1.7rem 1.7rem 1.4rem;
  overflow: hidden;
  animation: resonance-breathe 22s ease-in-out infinite;
}

/* Toroidal halo behind panel */
.hero-panel::before {
  content: "";
  position: absolute;
  inset: -18%;
  border-radius: 2rem;
  background:
    radial-gradient(circle at 50% 30%,
      rgba(184, 134, 11, 0.18) 0%,
      rgba(184, 134, 11, 0.06) 30%,
      rgba(0, 0, 0, 0.0) 65%);
  opacity: 0.55;
  pointer-events: none;
  z-index: -1;
}

/* Orbit system */

.hero-orbit {
  position: relative;
  width: 100%;
  padding-bottom: 100%;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: hue-drift 160s linear infinite;
}

/* Concentric orbit rings */
.orbit-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid #2e2e46;
}

.ring-outer {
  width: 100%;
  height: 100%;
}

.ring-middle {
  width: 68%;
  height: 68%;
}

.ring-inner {
  width: 38%;
  height: 38%;
  border-color: #444469;
}

/* Golden-ratio spiral overlay */
.phi-spiral {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 68%;
  height: 68%;
  transform: translate(-50%, -50%) rotate(-18deg);
  opacity: 0.38;
  pointer-events: none;
}

.phi-spiral path {
  stroke: rgba(241, 212, 138, 0.6);
  stroke-width: 0.8;
  stroke-linecap: round;
}

/* Particle tracks (share middle-ring radius) */
.orbit-track {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 68%;
  height: 68%;
  margin-top: -34%;
  margin-left: -34%;
  border-radius: 50%;
  transform-origin: 50% 50%;
}

.track-1 {
  animation: electron-orbit 12s linear infinite;
}

.track-2 {
  animation: electron-orbit 18s linear infinite reverse;
}

/* Orbiting particle */

.orbit-dot {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #f1d48a;
  box-shadow: 0 0 12px rgba(241, 212, 138, 0.85);
  animation: electron-orbit 12s linear infinite,
             particle-flicker 4.5s ease-in-out infinite;
}

/* Δ core */

.orbit-core {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 42px;
  height: 42px;
  border-radius: 999px;

  background: radial-gradient(circle at 30% 0,
    #f1d48a,
    #a4761c 60%,
    #151521 100%);
  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 1.1rem;
  font-weight: 600;
  color: #151515;
  box-shadow: 0 0 24px rgba(241, 212, 138, 0.45);
  animation: core-resonance 18s ease-in-out infinite;
}

.hero-panel-caption {
  margin-top: 1.1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ------------------------------
   Sections & cards
------------------------------ */

section {
  padding: 2.5rem 0;
}

.section-lead {
  max-width: 34rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.pillars {
  background: radial-gradient(circle at top, #171726 0, #050509 65%);
  border-top: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
}

.pillars h2,
.streams h2 {
  margin-top: 0;
  margin-bottom: 0.8rem;
  font-size: 1.4rem;
}

.pillars-grid,
.streams-grid {
  display: grid;
  gap: 1.4rem;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  margin-top: 1.7rem;
}

.card {
  background: var(--bg-soft);
  border-radius: 1rem;
  padding: 1.2rem 1.3rem 1.1rem;
  border: 1px solid var(--border-soft);
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.4);
}

.card h3 {
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

.card p {
  margin: 0.15rem 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.card-tag {
  margin-top: 0.7rem;
  font-size: 0.8rem;
  color: var(--gold-soft);
}

/* Contact / footer block */

.contact-teaser {
  border-top: 1px solid var(--border-soft);
}

.contact-inner {
  display: flex;
  gap: 2.2rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

.contact-block {
  padding: 1.1rem 1.3rem;
  border-radius: 0.9rem;
  border: 1px solid var(--border-soft);
  background: #0c0c16;
  min-width: 240px;
}

.contact-label {
  margin: 0 0 0.3rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-muted);
}

.contact-email {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  color: var(--gold-soft);
}

.contact-email span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.contact-note {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Footer */

.site-footer {
  padding: 2rem 0;
  background: #050505;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.footer-inner {
  color: #aaa;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.9rem;
}

.footer-sub {
  opacity: 0.7;
  letter-spacing: 0.5px;
}

/* ------------------------------
   Responsive
------------------------------ */

@media (max-width: 800px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .nav {
    width: 100%;
    justify-content: flex-start;
  }

  .hero-inner {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero-panel {
    margin-top: 0.5rem;
  }
}

@media (max-width: 600px) {
  .hero {
    padding-top: 2.4rem;
  }

  .hero h1 {
    font-size: 1.8rem;
  }

  .footer-inner {
    align-items: flex-start;
  }
}

/* ------------------------------
   Toroidal lattice page
------------------------------ */

/* ——————————————————————————————— */
/* LATTICE FIELD PAGE */
/* ——————————————————————————————— */

.lattice-intro {
  padding: 6rem 0 1rem;
  text-align: center;
}

.lattice-layout {
  display: grid;
  gap: 3rem;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  align-items: center;
  padding-bottom: 5rem;
}

@media (max-width: 900px) {
  .lattice-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* MAIN FIELD CONTAINER */

.lattice-field {
  position: relative;
  width: min(480px, 80vw);
  height: min(480px, 80vw);
  margin: 0 auto;
  border-radius: 50%;
  transform-style: preserve-3d;
  perspective: 1200px;

  /* build-up */
  opacity: 0;
  transform: translateY(24px) scale(0.96);
  animation: field-reveal 1.4s ease-out forwards;

  /* gentle breath */
  animation: field-reveal 1.4s ease-out forwards,
             resonance-breathe 36s ease-in-out infinite;
}

/* space-time grid behind torus */

.lattice-field::before {
  content: "";
  position: absolute;
  inset: -22%;
  border-radius: 50%;
  background-image:
    linear-gradient(0deg, rgba(241,212,138,0.15) 1px, transparent 1px),
    linear-gradient(90deg, rgba(241,212,138,0.15) 1px, transparent 1px);
  background-size: 40px 40px;
  opacity: 0.25;
  filter: blur(0.4px);
  transform: translateZ(-120px);
}

/* TORUS SHELLS */

.torus-shell {
  position: absolute;
  inset: 10%;
  border-radius: 50%;
  border: 1px solid rgba(241, 212, 138, 0.22);
  transform-style: preserve-3d;
  transform-origin: 50% 50%;
  opacity: 0;
  animation:
    shell-reveal 1.2s ease-out forwards 0.4s,
    torus-spin 40s linear infinite;
}

.ring-b {
  inset: 17%;
  border-color: rgba(241, 212, 138, 0.18);
  animation-duration: 52s;
  animation-delay: 0.55s;
}

.ring-c {
  inset: 26%;
  border-color: rgba(241, 212, 138, 0.16);
  animation-duration: 64s;
  animation-delay: 0.7s;
}

/* TRIAD TRACKS (3 · 6 · 9) */

.torus-track {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 68%;
  height: 68%;
  margin-top: -34%;
  margin-left: -34%;
  border-radius: 50%;
  transform-origin: 50% 50%;
}

.triad-track {
  opacity: 0;
  animation:
    track-reveal 1s ease-out forwards 1.0s,
    torus-track-spin 18s linear infinite;
}

.triad-6 { animation-duration: 12s; }
.triad-9 { animation-duration: 9s; }

/* user track is controlled via JS only */

.user-track {
  opacity: 0;
  animation: track-reveal 1s ease-out forwards 1.1s;
}

/* PARTICLES */

.torus-particle {
  position: absolute;
  top: 0;
  left: 0%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f1d48a;
  box-shadow: 0 0 16px rgba(241, 212, 138, 0.9);
  animation: particle-flicker 5.5s ease-in-out infinite;
}

.user-particle {
  width: 10px;
  height: 10px;
}

/* φ CURVE */

.phi-curve {
  position: absolute;
  inset: 18%;
  opacity: 0;
  pointer-events: none;
  animation: phi-reveal 1s ease-out forwards 1.1s;
}

.phi-curve path {
  stroke: rgba(241, 212, 138, 0.55);
  stroke-width: 0.8;
  stroke-linecap: round;
}

/* Δ CORE */

.torus-core {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 60px;
  height: 60px;
  transform: translate(-50%, -50%) scale(0.8);
  border-radius: 50%;
  background: radial-gradient(circle at 30% 0,
    #f1d48a,
    #a4761c 65%,
    #050509 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 600;
  color: #151515;
  box-shadow:
    0 0 24px rgba(241, 212, 138, 0.75),
    0 0 72px rgba(241, 212, 138, 0.35);
  opacity: 0;
  animation:
    core-pop 1s cubic-bezier(0.16, 1, 0.3, 1) forwards 0.9s,
    core-resonance 24s ease-in-out infinite 1.9s;
}

/* SIDEBAR / CONTROLS */

.lattice-side {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.lattice-caption {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.lattice-controls {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: var(--bg-soft);
  border-radius: 1rem;
  padding: 1.2rem 1.3rem;
  border: 1px solid var(--border-soft);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.control-group label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

.control-group input[type="range"] {
  width: 100%;
}

.control-group small {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.control-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.control-inline {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.control-inline input {
  margin-right: 0.4rem;
}

/* CALM MODE — pause motion, keep image */

body.calm-mode .triad-track,
body.calm-mode .torus-shell,
body.calm-mode .lattice-field,
body.calm-mode .torus-particle,
body.calm-mode .hero-orbit,
body.calm-mode .orbit-track,
body.calm-mode .orbit-dot {
  animation-play-state: paused;
}

body.calm-mode {
  background-color: #030308;
}

/* ------------------------------
   Animations
------------------------------ */

@keyframes lattice-drift {
  0%   { transform: translate3d(-16px, -12px, -260px) scale(1.25); }
  50%  { transform: translate3d(8px, 10px, -260px) scale(1.25); }
  100% { transform: translate3d(14px, -6px, -260px) scale(1.25); }
}

@keyframes haze-pulse {
  0%   { opacity: 0.65; transform: translate3d(0, 0, -80px) scale(1.02); }
  50%  { opacity: 0.95; transform: translate3d(0, -6px, -90px) scale(1.08); }
  100% { opacity: 0.7;  transform: translate3d(0, 4px, -80px) scale(1.04); }
}

/* orbit electrons */

@keyframes electron-orbit {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* tiny flicker / jitter */

@keyframes particle-flicker {
  0%   { opacity: 0.9; box-shadow: 0 0 10px rgba(241, 212, 138, 0.8); }
  25%  { opacity: 0.7; box-shadow: 0 0 6px rgba(241, 212, 138, 0.5); }
  50%  { opacity: 1.0; box-shadow: 0 0 14px rgba(241, 212, 138, 0.95); }
  75%  { opacity: 0.8; box-shadow: 0 0 8px rgba(241, 212, 138, 0.65); }
  100% { opacity: 0.9; box-shadow: 0 0 10px rgba(241, 212, 138, 0.8); }
}

/* global breath */

@keyframes resonance-breathe {
  0%   { transform: scale(1.00); }
  50%  { transform: scale(1.03); }
  100% { transform: scale(1.00); }
}

/* Δ core resonance */

@keyframes core-resonance {
  0% {
    transform: translate(-50%, -50%) scale(1.00);
    box-shadow:
      0 0 18px rgba(241, 212, 138, 0.55),
      0 0 40px rgba(241, 212, 138, 0.18);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.06);
    box-shadow:
      0 0 26px rgba(241, 212, 138, 0.9),
      0 0 70px rgba(241, 212, 138, 0.35);
  }
  100% {
    transform: translate(-50%, -50%) scale(1.00);
    box-shadow:
      0 0 18px rgba(241, 212, 138, 0.55),
      0 0 40px rgba(241, 212, 138, 0.18);
  }
}

/* hue drift */

@keyframes hue-drift {
  0%   { filter: hue-rotate(0deg); }
  50%  { filter: hue-rotate(10deg); }
  100% { filter: hue-rotate(0deg); }
}

/* torus shell rotation */

/* ——————————————————————————————— */
/* ANIMATIONS */
/* ——————————————————————————————— */

@keyframes field-reveal {
  0%   { opacity: 0; transform: translateY(24px) scale(0.96); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes shell-reveal {
  0%   { opacity: 0; transform: scale(0.9); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes track-reveal {
  0%   { opacity: 0; transform: rotate(0deg) scale(0.8); }
  100% { opacity: 1; transform: rotate(0deg) scale(1); }
}

@keyframes phi-reveal {
  0%   { opacity: 0; transform: scale(0.8) rotate(-10deg); }
  100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

@keyframes core-pop {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  60%  { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1.0); }
}

@keyframes torus-spin {
  0%   { transform: rotateX(68deg) rotateZ(0deg); }
  100% { transform: rotateX(68deg) rotateZ(360deg); }
}

@keyframes torus-track-spin {
  0%   { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes particle-flicker {
  0%   { opacity: 0.9; box-shadow: 0 0 10px rgba(241, 212, 138, 0.8); }
  25%  { opacity: 0.7; box-shadow: 0 0 6px rgba(241, 212, 138, 0.5); }
  50%  { opacity: 1.0; box-shadow: 0 0 14px rgba(241, 212, 138, 0.95); }
  75%  { opacity: 0.8; box-shadow: 0 0 8px rgba(241, 212, 138, 0.65); }
  100% { opacity: 0.9; box-shadow: 0 0 10px rgba(241, 212, 138, 0.8); }
}

@keyframes resonance-breathe {
  0%   { transform: scale(1.00); }
  50%  { transform: scale(1.03); }
  100% { transform: scale(1.00); }
}

@keyframes core-resonance {
  0% {
    box-shadow:
      0 0 18px rgba(241, 212, 138, 0.55),
      0 0 40px rgba(241, 212, 138, 0.18);
  }
  50% {
    box-shadow:
      0 0 26px rgba(241, 212, 138, 0.9),
      0 0 70px rgba(241, 212, 138, 0.35);
  }
  100% {
    box-shadow:
      0 0 18px rgba(241, 212, 138, 0.55),
      0 0 40px rgba(241, 212, 138, 0.18);
  }
}

