:root {
  --bg: #05060d;
  --bg-2: #0a0d1c;
  --ink: #eef1ff;
  --muted: #9aa3c7;
  --gold: #f5c761;
  --pitru: #5ad1c9;   /* teal - ancestors */
  --dev: #8b9cff;     /* indigo - devas */
  --brahma: #ff9d5c;  /* saffron - Brahma */
  --card: rgba(255, 255, 255, 0.04);
  --card-brd: rgba(255, 255, 255, 0.10);
  --maxw: 1080px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: radial-gradient(ellipse at 50% -10%, #131734 0%, var(--bg-2) 45%, var(--bg) 100%);
  color: var(--ink);
  line-height: 1.65;
  overflow-x: hidden;
}

#starfield {
  position: fixed;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
}

h1, h2, h3 { font-family: 'Cinzel', serif; font-weight: 700; line-height: 1.15; letter-spacing: 0.01em; }
em { color: var(--gold); font-style: normal; }

/* ---------- HERO ---------- */
.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  position: relative;
}
.hero-inner { max-width: 760px; }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.28em;
  font-size: 0.72rem;
  color: var(--gold);
  margin-bottom: 1.4rem;
}
.hero h1 {
  font-size: clamp(2.8rem, 8vw, 5.8rem);
  background: linear-gradient(180deg, #fff 0%, var(--gold) 140%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 60px rgba(245, 199, 97, 0.25);
}
.subtitle {
  font-size: clamp(1rem, 2.2vw, 1.25rem);
  color: var(--muted);
  margin: 1.6rem auto 2.4rem;
  max-width: 620px;
  font-weight: 300;
}
.cta {
  display: inline-block;
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--card-brd);
  padding: 0.8rem 1.8rem;
  border-radius: 100px;
  font-size: 0.9rem;
  letter-spacing: 0.05em;
  transition: all 0.3s ease;
  background: var(--card);
  backdrop-filter: blur(6px);
}
.cta:hover { border-color: var(--gold); color: var(--gold); transform: translateY(-2px); }
.scroll-hint {
  position: absolute;
  bottom: 2rem;
  width: 22px; height: 36px;
  border: 2px solid var(--muted);
  border-radius: 20px;
}
.scroll-hint::after {
  content: '';
  position: absolute;
  top: 6px; left: 50%;
  width: 3px; height: 7px;
  background: var(--muted);
  border-radius: 3px;
  transform: translateX(-50%);
  animation: scrolldot 1.6s infinite;
}
@keyframes scrolldot { 0% { opacity: 0; transform: translate(-50%, 0);} 40% { opacity: 1;} 80% { opacity: 0; transform: translate(-50%, 12px);} 100%{opacity:0;} }

/* ---------- SECTIONS ---------- */
.section {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 6rem 1.5rem;
}
.section-head { max-width: 720px; margin-bottom: 3rem; }
.tag {
  display: inline-block;
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 1rem;
}
.section h2 { font-size: clamp(1.6rem, 4vw, 2.6rem); margin-bottom: 1rem; }
.lead { color: var(--muted); font-size: 1.08rem; font-weight: 300; }
.caption { text-align: center; color: var(--muted); font-size: 0.85rem; margin-top: 1.2rem; }

/* ---------- RATIO CARDS ---------- */
.ratio-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.4rem; }
.ratio-card {
  background: var(--card);
  border: 1px solid var(--card-brd);
  border-radius: 18px;
  padding: 1.8rem;
  position: relative;
  overflow: hidden;
  transition: transform 0.3s ease, border-color 0.3s ease;
}
.ratio-card:hover { transform: translateY(-4px); }
.ratio-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--accent);
}
.ratio-card[data-accent=pitru] { --accent: var(--pitru); }
.ratio-card[data-accent=dev] { --accent: var(--dev); }
.ratio-card[data-accent=brahma] { --accent: var(--brahma); }
.ratio-card:hover { border-color: var(--accent); }
.ratio-card h3 { font-size: 1.5rem; color: var(--accent); }
.realm-sub { color: var(--muted); font-size: 0.85rem; margin-bottom: 1.2rem; }
.ratio { font-size: 1.05rem; margin-bottom: 0.8rem; }
.ratio span { color: var(--accent); font-weight: 600; }
.note { color: var(--muted); font-size: 0.9rem; font-weight: 300; }
.note strong { color: var(--ink); }

/* ---------- ORBIT MAP ---------- */
.orbit-wrap { display: flex; flex-direction: column; align-items: center; gap: 1.5rem; }
#orbitMap { max-width: 100%; height: auto; filter: drop-shadow(0 0 40px rgba(139,156,255,0.15)); }
.legend { display: flex; flex-wrap: wrap; gap: 0.6rem 1.4rem; justify-content: center; }
.legend .item { display: flex; align-items: center; gap: 0.5rem; font-size: 0.88rem; color: var(--muted); }
.legend .dot { width: 11px; height: 11px; border-radius: 50%; box-shadow: 0 0 8px currentColor; }

/* ---------- FORMULA ---------- */
.formula {
  background: var(--card);
  border: 1px solid var(--card-brd);
  border-radius: 18px;
  padding: 2.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2.5rem;
  justify-content: center;
}
.formula-main {
  font-family: 'Cinzel', serif;
  font-size: clamp(2.4rem, 7vw, 4rem);
  color: var(--gold);
  text-shadow: 0 0 30px rgba(245,199,97,0.35);
}
.formula-key { list-style: none; color: var(--muted); font-size: 0.95rem; }
.formula-key li { margin-bottom: 0.5rem; padding-left: 1.2rem; position: relative; }
.formula-key li::before { content: '\25C6'; position: absolute; left: 0; color: var(--gold); font-size: 0.7rem; top: 4px; }
.formula-key strong { color: var(--ink); }
.dim { color: var(--muted); font-style: italic; }

/* formula steps for clarity */
.formula-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1.6rem;
}
.fstep {
  display: flex;
  gap: 0.9rem;
  align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--card-brd);
  border-radius: 14px;
  padding: 1.1rem 1.2rem;
}
.fstep .n {
  flex: 0 0 auto;
  width: 30px; height: 30px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--gold);
  color: #10121f;
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 0.95rem;
}
.fstep p { font-size: 0.92rem; color: var(--muted); }
.fstep b { color: var(--ink); }

/* orbit view toggle */
.orbit-toggle { display: inline-flex; gap: 0.3rem; background: var(--card); border: 1px solid var(--card-brd); border-radius: 100px; padding: 0.3rem; }
.orbit-toggle button {
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  padding: 0.55rem 1.3rem;
  border-radius: 100px;
  cursor: pointer;
  transition: all 0.25s ease;
}
.orbit-toggle button.active { background: var(--gold); color: #10121f; font-weight: 600; }
.orbit-toggle button:not(.active):hover { color: var(--ink); }

/* ---------- DERIVATIONS ---------- */
.derive-track { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.4rem; }
.derive-card {
  background: var(--card);
  border: 1px solid var(--card-brd);
  border-radius: 18px;
  padding: 2rem;
  border-top: 3px solid var(--accent);
}
.derive-card[data-accent=pitru] { --accent: var(--pitru); }
.derive-card[data-accent=dev] { --accent: var(--dev); }
.derive-card[data-accent=brahma] { --accent: var(--brahma); }
.derive-card h3 { color: var(--accent); font-size: 1.4rem; margin-bottom: 1.2rem; }
.steps { list-style: none; margin-bottom: 1.6rem; }
.steps li { padding: 0.55rem 0; border-bottom: 1px dashed rgba(255,255,255,0.08); font-size: 0.95rem; }
.steps li:last-child { border-bottom: none; }
.steps .k {
  display: inline-block;
  min-width: 78px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-right: 0.6rem;
}
.steps b { color: var(--gold); }
.result { display: flex; align-items: baseline; gap: 0.5rem; }
.counter { font-family: 'Cinzel', serif; font-size: 2.8rem; color: var(--accent); text-shadow: 0 0 24px var(--accent); }
.unit { color: var(--muted); font-size: 1rem; }
.anchor { color: var(--muted); font-size: 0.85rem; margin-top: 0.4rem; font-style: italic; }

/* ---------- LADDER ---------- */
.ladder { display: flex; flex-direction: column; gap: 0.5rem; }
.ladder .rung {
  display: grid;
  grid-template-columns: 130px 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 1rem;
  background: var(--card);
  border: 1px solid var(--card-brd);
  border-radius: 10px;
}
.ladder .rung .scale { color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.ladder .bar { height: 8px; border-radius: 6px; background: linear-gradient(90deg, transparent, var(--c)); transform-origin: left; }
.ladder .place { font-size: 0.9rem; white-space: nowrap; }
.ladder .place b { color: var(--c); }

/* ---------- TABLES ---------- */
.table-wrap { overflow-x: auto; border-radius: 14px; border: 1px solid var(--card-brd); }
table { width: 100%; border-collapse: collapse; min-width: 520px; }
th, td { padding: 0.9rem 1.1rem; text-align: left; font-size: 0.92rem; }
thead th { background: rgba(255,255,255,0.05); font-family: 'Cinzel', serif; font-size: 0.82rem; letter-spacing: 0.04em; color: var(--gold); }
tbody tr { border-top: 1px solid rgba(255,255,255,0.06); }
tbody tr:hover { background: rgba(255,255,255,0.03); }
tbody td b { color: var(--ink); }
tr.hl { background: rgba(245,199,97,0.06); }

.closing { text-align: center; font-size: 1.15rem; color: var(--ink); margin-top: 2.5rem; max-width: 700px; margin-left: auto; margin-right: auto; font-weight: 300; }

/* ---------- REFS ---------- */
.refs ol { color: var(--muted); font-size: 0.9rem; padding-left: 1.2rem; }
.refs li { margin-bottom: 0.6rem; }
.refs a { color: var(--dev); text-decoration: none; }
.refs a:hover { text-decoration: underline; }
.disclaimer { margin-top: 2rem; color: var(--muted); font-size: 0.82rem; font-style: italic; opacity: 0.8; }

footer { text-align: center; padding: 3rem 1.5rem; color: var(--muted); font-size: 0.85rem; border-top: 1px solid var(--card-brd); }

/* ---------- REVEAL ANIMATION ---------- */
.reveal { opacity: 0; transform: translateY(30px); transition: opacity 0.8s ease, transform 0.8s ease; }
.reveal.visible { opacity: 1; transform: none; }

@media (max-width: 600px) {
  .section { padding: 4rem 1.2rem; }
  .ladder .rung { grid-template-columns: 90px 1fr; }
  .ladder .place { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
}
