/* Causal Set Emergence — aligned with the erdos-193.q5m.ai design system. */
:root {
  --background: 0 0% 100%;
  --foreground: 222.2 84% 4.9%;
  --muted-fg: 215.4 16.3% 46.9%;
  --border: 214.3 31.8% 91.4%;
  --card: 0 0% 100%;
  --accent: 210 40% 96.1%;
  --link: 217 91% 45%;
  --radius: .5rem;
  --ink: hsl(var(--foreground));
  --muted: hsl(var(--muted-fg));
  --paper: hsl(var(--background));
  --line: hsl(var(--border));
  --teal: hsl(var(--link));
  --teal-soft: #bfdbfe;
  --coral: #dc6548;
  --gold: #c58a16;
  --night: #04060d;
  --night-2: #08111f;
  --card-shadow: 0 8px 28px rgb(15 23 42 / .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: 222.2 84% 4.9%;
    --foreground: 210 40% 98%;
    --muted-fg: 215 20.2% 65.1%;
    --border: 217.2 32.6% 17.5%;
    --card: 222.2 84% 6.5%;
    --accent: 217.2 32.6% 17.5%;
    --link: 213 94% 68%;
    --teal-soft: #183657;
    --coral: #ed8068;
    --gold: #e6ad43;
    --card-shadow: none;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: hsl(var(--foreground));
  background: hsl(var(--background));
  font: 17px/1.65 "Outfit", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
body::before { display: none; }
a { color: hsl(var(--link)); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { width: min(920px, calc(100% - 48px)); margin-inline: auto; }

/* Compact shared masthead. */
nav {
  position: static;
  border: 0;
  background: transparent;
  backdrop-filter: none;
}
.nav-inner {
  min-height: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  padding: 40px 0 28px;
}
.brand {
  gap: 0;
  color: hsl(var(--foreground));
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.01em;
  text-transform: none;
}
.brand-mark { display: none; }
.brand a { color: inherit; text-decoration: none; }
.brand a span { color: hsl(var(--muted-fg)); font-weight: 500; }
.nav-links { display: flex; gap: 16px; font-size: 15px; font-weight: 500; }
.nav-links a { color: hsl(var(--muted-fg)); }
.nav-links a:hover { color: hsl(var(--foreground)); text-decoration: none; }
.nav-links a[aria-current="page"] { color: hsl(var(--foreground)); font-weight: 700; }

header { min-height: 0; padding: 18px 0 64px; }
.hero { grid-template-columns: 1.05fr .95fr; gap: 28px; }
.eyebrow {
  color: hsl(var(--muted-fg));
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
}
h1, h2, h3 {
  font-family: "Outfit", ui-sans-serif, system-ui, sans-serif;
  color: hsl(var(--foreground));
  font-weight: 700;
}
h1 {
  max-width: 660px;
  margin: 8px 0 14px;
  font-size: clamp(32px, 5vw, 48px);
  line-height: 1.05;
  letter-spacing: -.035em;
}
h1 em { color: hsl(var(--link)); font-style: normal; }
.lede {
  max-width: 64ch;
  margin: 0 0 20px;
  color: hsl(var(--muted-fg));
  font: 17px/1.65 "Outfit", ui-sans-serif, system-ui, sans-serif;
}
.scroll-cue {
  margin-top: 4px;
  color: hsl(var(--foreground));
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}
.scroll-cue span {
  width: 30px;
  height: 30px;
  border-color: hsl(var(--border));
}
.hero-stage {
  width: 100%;
  max-width: 430px;
  min-height: 430px;
  justify-self: center;
  border: 1px solid #263750;
  border-radius: 18px;
  box-shadow: 0 18px 55px rgb(15 23 42 / .16);
}
.hero-viz-title {
  position: absolute;
  z-index: 4;
  top: 15px;
  left: 16px;
  display: flex;
  flex-direction: column;
  color: #fff;
  pointer-events: none;
}
.hero-viz-title strong { font: 600 15px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; }
.hero-viz-title span { margin-top: 3px; color: #91a3bb; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.hero-viz-axis {
  position: absolute;
  z-index: 4;
  top: 50px;
  right: 14px;
  bottom: 38px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #8191aa;
  font-size: 9px;
  letter-spacing: .1em;
  text-transform: uppercase;
  pointer-events: none;
}
.hero-viz-axis::before {
  content: "";
  position: absolute;
  top: 17px;
  bottom: 17px;
  left: 50%;
  border-left: 1px solid rgb(145 163 187 / .28);
}

section { padding: 56px 0; }
section + section { border-top: 1px solid hsl(var(--border)); }
.section-head {
  display: block;
  margin-bottom: 24px;
}
.section-head > div { margin-bottom: 8px; }
.section-head h2 {
  margin: 0;
  font-size: clamp(28px, 4vw, 38px);
  line-height: 1.12;
  letter-spacing: -.025em;
}
.section-head p {
  max-width: 70ch;
  color: hsl(var(--muted-fg));
  font-size: 17px;
}
.dark {
  color: hsl(var(--foreground));
  background: transparent;
}
.dark .eyebrow, .dark .section-head p, .dark .muted { color: hsl(var(--muted-fg)); }

/* Cards use the restrained bordered surfaces from Erdos 193. */
.pillars, .quantum-grid { gap: 12px; }
.pillar, .quantum-card {
  min-height: 0;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 18px;
  color: hsl(var(--foreground));
  background: hsl(var(--card));
  box-shadow: none;
}
.number {
  color: hsl(var(--link));
  font: 700 13px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.pillar h3 {
  margin: 30px 0 8px;
  font-size: 20px;
  letter-spacing: -.01em;
}
.pillar p, .quantum-card p { color: hsl(var(--muted-fg)); font-size: 15px; }
.formula {
  margin-top: 18px;
  border-top: 1px solid hsl(var(--border));
  padding-top: 12px;
  color: hsl(var(--foreground));
  font-size: 12px;
}

.levels { grid-template-columns: 1fr 52px 1fr; gap: 12px; }
.level {
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 24px;
  background: hsl(var(--card));
  box-shadow: none;
}
.level.deep { color: #eef5ff; background: #04060d; border-color: #263750; }
.level.deep h3 { color: #eef5ff; }
.level-tag { padding: 4px 8px; font-size: 10px; }
.level h3 { margin: 24px 0 8px; font-size: 25px; }
.level ul { margin-top: 18px; }
.level li { padding: 8px 0; font-size: 14px; }
.emerge-arrow { font-size: 10px; }

.concept-lab { margin-top: 38px; gap: 12px; }
.concept-copy, .concept-art,
.diamond-demo, .lab-shell,
.not-equal, .chart-card {
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--card));
  box-shadow: none;
}
.concept-copy { padding: 24px; }
.tabs { margin-bottom: 28px; }
.tab, .diamond-toggle {
  padding: 7px 11px;
  border-color: hsl(var(--border));
  color: hsl(var(--muted-fg));
  font-size: 13px;
}
.tab[aria-selected="true"], .diamond-toggle[aria-pressed="true"] {
  color: white;
  border-color: hsl(var(--link));
  background: hsl(var(--link));
}
.concept-copy h3 { font-size: 25px; }
.concept-copy p { color: hsl(var(--muted-fg)); font-size: 15px; }
.concept-art { min-height: 390px; border-radius: var(--radius); background: #e8eef2; }
#conceptSvg { display: none !important; }
.three-stage { position: relative; overflow: hidden; background: #04060d; }
.three-stage canvas { display: block; width: 100%; height: 100%; cursor: grab; }
.three-stage canvas:active { cursor: grabbing; }
#conceptStage { width: 100%; min-height: 390px; }
.three-loading { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; color: #b9c6dc; background: #04060d; font-size: 12px; }
.three-hint { position: absolute; right: 10px; bottom: 9px; z-index: 4; border-radius: 6px; padding: 4px 7px; color: #aab9d0; background: rgb(4 6 13 / .72); font-size: 10px; }

/* The Three.js locality lab replaces the earlier two separate SVG demos. */
#locality .diamond-demo, #locality .lab-shell, #locality > .wrap > p[style] { display: none; }
.locality-three-lab { display: grid; grid-template-columns: minmax(0, 1fr) 290px; overflow: hidden; border: 1px solid hsl(var(--border)); border-radius: var(--radius); background: hsl(var(--card)); }
.locality-stage { min-height: 570px; }
.locality-toolbar { position: absolute; z-index: 5; top: 11px; left: 11px; display: flex; flex-wrap: wrap; align-items: center; gap: 7px; max-width: calc(100% - 22px); }
.locality-toolbar label, .locality-toolbar button { border: 1px solid #263750; border-radius: 7px; padding: 6px 9px; color: #c3cee0; background: rgb(4 6 13 / .82); font: 600 11px Outfit, sans-serif; }
.locality-toolbar label { display: flex; align-items: center; gap: 8px; }
.locality-toolbar input { width: 105px; accent-color: #56b4e9; }
.locality-toolbar button { cursor: pointer; }
.locality-three-readout { border-left: 1px solid hsl(var(--border)); padding: 24px 20px; }
.locality-three-readout h3 { margin: 8px 0 10px; font-size: 24px; }
.locality-three-readout p { color: hsl(var(--muted-fg)); font-size: 14px; }
.locality-legend { display: grid; gap: 6px; margin: 18px 0; color: hsl(var(--muted-fg)); font-size: 11px; }
.locality-legend span::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: #7f90aa; }
.locality-legend .related::before { background: #56b4e9; }
.locality-legend .linked::before { background: #ed8068; }
.locality-three-readout .stat { border-color: hsl(var(--border)); }
.locality-three-note { margin: 10px 0 0; color: hsl(var(--muted-fg)); font-size: 12px; }

.diamond-demo { margin-bottom: 14px; }
.diamond-art { min-height: 360px; background: #e8eef2; }
#diamondSvg { height: 360px; }
.diamond-copy { padding: 24px; border-color: hsl(var(--border)); }
.diamond-copy h3 { margin: 6px 0 8px; font-size: 25px; }
.diamond-copy p { color: hsl(var(--muted-fg)); font-size: 15px; }
.diamond-status, .callout {
  border-left: 3px solid hsl(var(--link));
  border-radius: 0 var(--radius) var(--radius) 0;
  background: hsl(var(--accent));
}
.lab-bar { border-color: hsl(var(--border)); background: hsl(var(--accent)); }
.control { font-size: 12px; }
.legend { font-size: 11px; }
#causalSvg { background: #f1eee6; }
.lab-readout { border-color: hsl(var(--border)); }
.lab-readout h3 { font-size: 22px; }
.lab-readout p { color: hsl(var(--muted-fg)); }
.readout-label { color: hsl(var(--link)); font-size: 10px; }
.stat { border-color: hsl(var(--border)); }

/* The observer is a process embedded in each history, not one privileged dot. */
.observer-lab {
  overflow: hidden;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--card));
}
.observer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid hsl(var(--border));
  padding: 14px 16px;
  background: hsl(var(--accent));
}
.observer-bar .eyebrow { margin: 0 0 2px; font-size: 9px; }
.observer-bar strong { display: block; font-size: 14px; }
.observer-controls { display: flex; gap: 6px; flex-wrap: wrap; }
.observer-toggle {
  cursor: pointer;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  padding: 7px 10px;
  color: hsl(var(--muted-fg));
  background: hsl(var(--card));
  font-size: 12px;
  font-weight: 600;
}
.observer-toggle:hover { background: hsl(var(--accent)); }
.observer-toggle[aria-pressed="true"] {
  border-color: hsl(var(--link));
  color: white;
  background: hsl(var(--link));
}
#observerSvg { display: block; width: 100%; height: auto; background: #04060d; }
.observer-readout {
  border-top: 1px solid hsl(var(--border));
  padding: 13px 16px;
  color: hsl(var(--muted-fg));
  background: hsl(var(--accent));
  font-size: 13px;
}
.observer-readout strong { color: hsl(var(--foreground)); }
.observer-concepts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 12px;
}
.observer-concepts article {
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 16px;
  background: hsl(var(--card));
}
.observer-concepts article > span {
  color: hsl(var(--link));
  font: 700 10px ui-monospace, SFMono-Regular, Menlo, monospace;
}
.observer-concepts h3 { margin: 18px 0 5px; font-size: 17px; }
.observer-concepts p { margin: 0; color: hsl(var(--muted-fg)); font-size: 14px; }
.observer-caveat {
  margin-top: 18px;
  border-left: 3px solid #c58a16;
  padding: 12px 14px;
  color: hsl(var(--muted-fg));
  background: hsl(var(--accent));
  font-size: 13px;
}
.observer-caveat strong { color: hsl(var(--foreground)); }

.quantum-card { border-top-width: 3px; border-top-color: hsl(var(--link)); }
.quantum-card:nth-child(2) { border-top-color: var(--coral); }
.quantum-card:nth-child(3) { border-top-color: var(--gold); }
.quantum-card h3 { font-size: 19px; }
.not-equal { padding: 20px 24px; }
.not-equal b { color: var(--coral); font-family: Georgia, serif; }
.not-equal h3 { font-size: 18px; }
.not-equal p { color: hsl(var(--muted-fg)); font-size: 15px; }

.repo-bridge { gap: 34px; }
.repo-bridge h2 {
  margin: 8px 0 12px;
  font-size: clamp(28px, 4vw, 38px);
  line-height: 1.12;
  letter-spacing: -.025em;
}
.repo-bridge p { color: hsl(var(--muted-fg)); }
.equation {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-color: #263750;
  border-radius: var(--radius);
  padding: 18px;
  color: #d9e4f5;
  background: #04060d;
  font-size: 13px;
}
.equation span {
  color: #91a3bb;
  font: 600 10px/1.2 "Outfit", sans-serif;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.equation strong { color: #fff; font-size: 15px; font-weight: 500; }
.repo-link { display: inline-block; margin-top: 18px; font-size: 14px; font-weight: 600; }
.chart-card { padding: 20px; background: #f5f1e8; }
.chart-card h3 { color: #17201e; font-size: 18px; }

#split-diamond { margin-top: 48px; border-top: 1px solid var(--line); padding-top: 32px; }
#split-diamond .section-head p { margin-top: 10px; }
.gluing-panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 310px), 1fr)); gap: 16px; }
.gluing-card { min-width: 0; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: hsl(var(--card)); }
.gluing-card h3 { margin: 0; font-size: 21px; }
.gluing-card p, #split-diamond > p { font-size: 15px; }
.gluing-card .gluing-note { color: var(--muted); font-size: 13px; }
.gluing-choice { min-width: 0; margin: 0; padding: 8px 12px 0; border: 1px solid var(--line); border-radius: var(--radius); }
.gluing-choice legend, .gluing-plot figcaption { font-weight: 600; font-size: 14px; }
.gluing-choice input { accent-color: var(--teal); }
.gluing-choice label { display: inline-block; padding: 8px 12px 8px 4px; cursor: pointer; }
.gluing-view svg, .gluing-plot svg { display: block; width: 100%; height: auto; }
#glue-a:checked ~ .gluing-view .from-b, #glue-b:checked ~ .gluing-view .from-a { display: none; }
.gluing-plot { margin: 16px 0 0; }
.gluing-plot text { fill: currentColor; font-size: 14px; }
#gluing-values { margin-top: 8px; font-size: 14px; }
#gluing-values summary { cursor: pointer; color: var(--teal); padding-block: 5px; }
#gluing-values table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
#gluing-values th, #gluing-values td { padding: 4px; border-bottom: 1px solid var(--line); text-align: right; }
#gluing-values th:first-child { text-align: left; }

footer { border-color: hsl(var(--border)); }
.sitefoot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-top: 1px solid hsl(var(--border));
  padding-block: 24px 34px;
  color: hsl(var(--muted-fg));
  font-size: 13px;
}
.sitefoot .right { display: flex; align-items: center; gap: 18px; }
.sitefoot a { display: inline-flex; align-items: center; gap: 6px; color: hsl(var(--muted-fg)); }
.sitefoot a:hover { color: hsl(var(--foreground)); text-decoration: none; }
.footer-icon { width: 17px; height: 17px; flex: none; }

@media (max-width: 850px) {
  .hero, .section-head, .concept-lab, .repo-bridge { grid-template-columns: 1fr; }
  .nav-links { display: flex; }
  .hero { padding-top: 0; }
  .hero-stage { width: min(100%, 430px); }
  .pillars, .quantum-grid { grid-template-columns: 1fr; }
  .levels { grid-template-columns: 1fr; }
  .emerge-arrow { min-height: 36px; }
  .diamond-demo, .causal-grid, .locality-three-lab { grid-template-columns: 1fr; }
  .locality-three-readout { border-left: 0; border-top: 1px solid hsl(var(--border)); }
  .locality-stage { min-height: 500px; }
  .observer-bar { align-items: flex-start; flex-direction: column; }
  .observer-concepts { grid-template-columns: 1fr; }
  .diamond-copy, .lab-readout { border-left: 0; border-top: 1px solid hsl(var(--border)); }
}

@media (max-width: 600px) {
  .wrap { width: min(100% - 32px, 920px); }
  .nav-inner { gap: 12px; padding: 24px 0 18px; }
  .brand { font-size: 13px; }
  .brand a span { display: none; }
  .nav-links { display: flex; gap: 12px; font-size: 13px; }
  header { padding-bottom: 44px; }
  section { padding: 42px 0; }
  h1 { font-size: 36px; }
  .causal-grid { margin-inline: 0; }
  #causalSvg { height: 440px; }
  .hero-stage { min-height: 360px; }
  #conceptStage { min-height: 350px; }
  .locality-stage { min-height: 440px; }
  .sitefoot { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
