@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg: #05070e;
  --text: #e6e8f0;
  --muted: #9aa3b8;
  --muted-2: #7a8499;
  --accent-1: #8b9cff;
  --accent-2: #a78bfa;
  --accent-3: #60a5fa;
  --card: rgba(16,21,36,0.6);
  --border: rgba(139,156,255,0.14);
  --border-hover: rgba(139,156,255,0.28);
  --code-bg: rgba(139,156,255,0.1);
  --nav-h: 56px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
    color: var(--accent-1);
}

/* ── Background ────────────────────────────────────── */

.bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(900px 600px at 15% -5%, rgba(96,165,250,0.18), transparent 60%),
    radial-gradient(800px 500px at 85% 0%, rgba(167,139,250,0.16), transparent 60%),
    radial-gradient(700px 500px at 50% 120%, rgba(139,156,255,0.13), transparent 60%),
    #05070e;
}
.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.035'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
  pointer-events: none;
}

/* ── Navigation ────────────────────────────────────── */

.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  background: rgba(5,7,14,0.80);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(139,156,255,0.08);
}

.nav-logo {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 0%, #c7d2ff 55%, #8b9cff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 4px;
  align-items: center;
}

.nav-links a {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 8px;
  transition: color 0.18s, background 0.18s;
}

.nav-links a:hover {
  color: var(--text);
  background: rgba(255,255,255,0.05);
}

.nav-links a[aria-current="page"] {
  color: var(--accent-1);
  background: rgba(139,156,255,0.08);
}

/* ── Corner orbs ───────────────────────────────────── */

.corner-orb {
  position: fixed;
  top: calc(var(--nav-h) + 12px);
  width: 210px;
  height: 210px;
  z-index: 2;
  pointer-events: none;
  background: transparent;
  filter: saturate(1.3) brightness(0.9);
  opacity: 0.96;
}
.corner-orb.left  { left: 18px; }
.corner-orb.right { right: 18px; }
.corner-orb canvas { width: 100%; height: 100%; display: block; }

@media (max-width: 1279px) {
  .corner-orb { display: none; }
}

@media (max-width: 720px) {
  .corner-orb { width: 140px; height: 140px; }
  .corner-orb.left  { left: 12px; }
  .corner-orb.right { right: 12px; }
}

/* ── Layout ────────────────────────────────────────── */

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 24px 120px;
  position: relative;
  z-index: 10;
}

/* ── Heroes ────────────────────────────────────────── */

.hero {
  min-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 0 60px;
}

/* Smaller hero for interior pages */
.page-hero {
  min-height: 38vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: calc(var(--nav-h) + 64px) 0 48px;
}

.eyebrow {
  font-size: 0.85rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted-2);
  font-weight: 500;
  margin-bottom: 24px;
}

/* ── Typography ────────────────────────────────────── */

h1 {
  font-size: clamp(4.5rem, 14vw, 8.5rem);
  line-height: 0.9;
  margin: 0 0 24px;
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(180deg, #ffffff 15%, #c7d2ff 55%, #8b9cff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 20px 40px rgba(99,102,241,0.15));
}

h1 a {
  color: inherit;
  text-decoration: none;
}

/* Page/article title — smaller, no drop shadow */
.page-hero h1 {
  font-size: clamp(2.2rem, 5.5vw, 3.6rem);
  line-height: 1.08;
  filter: none;
  margin-bottom: 20px;
}

.sub {
  font-size: clamp(1.15rem, 2.5vw, 1.5rem);
  font-weight: 500;
  color: var(--text);
  margin: 0 0 12px;
  max-width: 720px;
}

.tag {
  font-size: 1.05rem;
  color: var(--muted);
  margin: 0 0 36px;
  max-width: 640px;
}

/* ── Buttons / CTA ─────────────────────────────────── */

.cta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 999px;
  font-weight: 500;
  font-size: 0.95rem;
  text-decoration: none;
  transition: all 0.2s ease;
  backdrop-filter: blur(6px);
}
.btn:hover {
  border-color: var(--border-hover);
  background: rgba(255,255,255,0.06);
  transform: translateY(-1px);
}
.btn.primary {
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  color: #060816;
  border: none;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(139,156,255,0.25), inset 0 1px 0 rgba(255,255,255,0.2);
}
.btn.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 32px rgba(139,156,255,0.32);
}

/* ── Sections ──────────────────────────────────────── */

section {
  padding: 72px 0;
  scroll-margin-top: calc(var(--nav-h) + 24px);
}
section + section { padding-top: 0; }

h2 {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 0 0 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}
h2::before {
  content: "";
  flex-shrink: 0;
  width: 28px;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-1), transparent);
  border-radius: 2px;
}

p.lead {
  font-size: 1.1rem;
  color: #d6daf0;
  margin: 0 0 20px;
}

/* ── Code / formula ────────────────────────────────── */

.formula {
  margin: 28px 0 8px;
  padding: 18px 20px;
  background: linear-gradient(180deg, rgba(139,156,255,0.08), rgba(139,156,255,0.03));
  border: 1px solid var(--border);
  border-radius: 14px;
  text-align: center;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.98rem;
  color: #c9d4ff;
}

code {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--code-bg);
  color: #c7d2fe;
  padding: 0.18em 0.45em;
  border-radius: 6px;
  font-size: 0.92em;
  border: 1px solid rgba(139,156,255,0.12);
}

/* ── Why list ──────────────────────────────────────── */

.why {
  list-style: none;
  padding: 0;
  margin: 28px 0 0;
  display: grid;
  gap: 14px;
}
.why li {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 14px;
  padding: 18px 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  backdrop-filter: blur(8px);
  transition: border-color 0.2s, transform 0.2s;
}
.why li:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
}
.why .n {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(139,156,255,0.12);
  color: var(--accent-1);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.8rem;
  font-weight: 500;
}

/* ── Tables ────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  margin: 24px 0 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(8,12,24,0.5);
  backdrop-filter: blur(6px);
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
}
th, td {
  padding: 14px 18px;
  text-align: left;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
th {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-2);
  font-weight: 600;
  background: rgba(255,255,255,0.02);
}
tr:last-child td { border-bottom: none; }
td:nth-child(2) {
  font-family: "JetBrains Mono", monospace;
  color: #dbe2ff;
}
.note {
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: 10px;
}

/* ── Card grid ─────────────────────────────────────── */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 24px;
}
.card {
  position: relative;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  min-height: 190px;
  transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
  backdrop-filter: blur(10px);
  text-decoration: none;
  color: inherit;
}
.card:hover {
  transform: translateY(-4px);
  border-color: var(--border-hover);
  box-shadow: 0 16px 40px rgba(5,8,18,0.6), 0 0 0 1px rgba(139,156,255,0.08) inset;
}
.card-head { margin-bottom: 8px; }
.part {
  font-size: 0.75rem;
  color: var(--accent-3);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.card h3 {
  margin: 4px 0 0;
  font-size: 1.12rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.card p {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 10px 0 18px;
  flex-grow: 1;
}
.dl {
  align-self: flex-start;
  font-size: 0.88rem;
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(139,156,255,0.1);
  color: #c7d2fe;
  text-decoration: none;
  border: 1px solid rgba(139,156,255,0.18);
  transition: all 0.18s ease;
  font-weight: 500;
}
.dl:hover {
  background: rgba(139,156,255,0.18);
  color: white;
  transform: translateY(-1px);
}

/* ── Callout / paper card ──────────────────────────── */

.callout {
  margin-top: 20px;
  padding: 28px 24px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(139,156,255,0.08), rgba(139,156,255,0.03));
  border: 1px solid var(--border);
  text-align: center;
}
.paper-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
  padding: 24px 28px;
  background: linear-gradient(135deg, rgba(139,156,255,0.11), rgba(167,139,250,0.07));
  border: 1px solid rgba(139,156,255,0.28);
  border-radius: 16px;
  margin: 0 0 20px;
  backdrop-filter: blur(10px);
}
.paper-card-text .part { font-size: 0.75rem; color: var(--accent-1); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.paper-card-text h3 { margin: 4px 0 8px; font-size: 1.15rem; font-weight: 600; letter-spacing: -0.01em; }
.paper-card-text p { color: var(--muted); font-size: 0.95rem; margin: 0; max-width: 620px; }

/* ── Derivation tower (dl) ─────────────────────────── */

/* Wrapper supplies the vertical rhythm; dl itself has no self-margin */
.tower-wrap { margin: 28px 0 12px; }

dl.derivation-tower { margin: 0; }

dl.derivation-tower dt {
  margin-top: 14px;
  padding: 12px 18px;
  background: linear-gradient(180deg, rgba(139,156,255,0.10), rgba(139,156,255,0.04));
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 14px 14px 0 0;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.97rem;
  color: #c9d4ff;
  font-weight: 500;
  letter-spacing: 0.01em;
}

dl.derivation-tower dt:first-child { margin-top: 0; }

dl.derivation-tower dd {
  margin: 0;
  padding: 13px 18px 18px;
  background: rgba(8,12,24,0.50);
  border: 1px solid var(--border);
  border-top: 1px solid rgba(139,156,255,0.06);
  border-radius: 0 0 14px 14px;
  color: #c4cae2;
  font-size: 0.97rem;
  line-height: 1.78;
}

/* Sector colour accents — palette from visualizations/triangles.html */
dl.derivation-tower dt.d2          { border-left: 3px solid #00aaff; }
dl.derivation-tower dt.d3          { border-left: 3px solid #00ff44; }
dl.derivation-tower dt.d4          { border-left: 3px solid #ff6600; }
dl.derivation-tower dt.d5          { border-left: 3px solid #cc00ff; }
dl.derivation-tower dt.d6          { border-left: 3px solid #ff0000; }
dl.derivation-tower dt.d10         { border-left: 3px solid #ffdd00; }
dl.derivation-tower dt.d2  + dd   { border-left: 3px solid #00aaff; }
dl.derivation-tower dt.d3  + dd   { border-left: 3px solid #00ff44; }
dl.derivation-tower dt.d4  + dd   { border-left: 3px solid #ff6600; }
dl.derivation-tower dt.d5  + dd   { border-left: 3px solid #cc00ff; }
dl.derivation-tower dt.d6  + dd   { border-left: 3px solid #ff0000; }
dl.derivation-tower dt.d10 + dd   { border-left: 3px solid #ffdd00; }

@media (max-width: 640px) {
  dl.derivation-tower dt,
  dl.derivation-tower dd { padding-left: 14px; padding-right: 14px; }
}

/* ── Prose ─────────────────────────────────────────── */

.prose {
  margin-top: 28px;
  color: #c4cae2;
  font-size: 1.02rem;
  line-height: 1.82;
}
.prose p { margin: 0 0 1.35em; }
.prose p:last-child { margin-bottom: 0; }
.prose strong { color: var(--text); font-weight: 600; }
.prose em { color: #dbe2ff; font-style: italic; }
.prose h3 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  margin: 2em 0 0.6em;
  letter-spacing: -0.01em;
}
.prose ul, .prose ol {
  padding-left: 1.4em;
  margin: 0 0 1.35em;
}
.prose li { margin-bottom: 0.4em; }

/* ── Sector stack visual ───────────────────────────── */

.sector-stack {
  margin: 32px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sector-row {
  display: grid;
  grid-template-columns: 60px 1fr auto;
  align-items: center;
  gap: 14px;
}
.sector-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.82rem;
  color: var(--muted-2);
  font-weight: 500;
}
.sector-bar-wrap {
  height: 32px;
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.06);
}
.sector-bar {
  height: 100%;
  border-radius: 7px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  white-space: nowrap;
  transition: width 0.4s ease;
}
.sector-particles {
  font-size: 0.88rem;
  color: var(--muted);
  white-space: nowrap;
  text-align: right;
  min-width: 100px;
}
.sector-new-dirs {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.75rem;
  color: var(--accent-1);
  opacity: 0.7;
}

/* ── Footer ────────────────────────────────────────── */

footer {
  max-width: 900px;
  margin: 40px auto 0;
  padding: 32px 24px 60px;
  color: var(--muted-2);
  font-size: 0.9rem;
  text-align: center;
  border-top: 1px solid rgba(255,255,255,0.06);
}
footer a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px dotted rgba(154,163,184,0.4);
}
footer a:hover {
  color: var(--text);
  border-bottom-color: var(--text);
}

/* ── Responsive ────────────────────────────────────── */

@media (max-width: 640px) {
  main { padding: 0 18px 80px; }
  section { padding: 56px 0; }
  .hero { min-height: 80vh; padding-top: 60px; }
  .why li { grid-template-columns: 24px 1fr; }
  .site-nav { padding: 0 18px; }
  .sector-row { grid-template-columns: 48px 1fr; }
  .sector-particles { display: none; }
}
