/* event-docs.css — shared design system for the kaldamus entity-reference docs
   (docs.html + event-*.html). Dark "Liquid Glass" theme, deliberately mirroring
   the real app's own tokens in ui/public/css/style.css (--bg-primary, --accent-blue,
   --accent-gold, glass surfaces) rather than the light slide-deck palette used by
   deck.css. One deliberate dark theme only, no light-mode variant — same posture
   as the app itself. Pair with event-docs.js for the Mermaid CDN loader, which
   reads its palette live from the custom properties below.

   Page format is fixed — see docs/HTML_DOC_STANDARD.md and the DOC STANDARD
   components at the foot of this file. */

:root {
  --bg-primary: #0b0e1a;
  --bg-secondary: #0a1628;
  --glass-bg: rgba(255,255,255,0.055);
  --glass-bg-strong: rgba(16,20,38,0.6);
  --glass-border: rgba(255,255,255,0.14);
  --glass-border-soft: rgba(255,255,255,0.08);
  --border-subtle: rgba(255,255,255,0.07);
  --text-primary: #e0e0e0;
  --text-secondary: #a9adba;
  --text-muted: rgba(255,255,255,0.5);
  --event: #5a8fd4;
  --factor: #c9a84c;
  --factor-dim-bg: rgba(201,168,76,0.14);
  --factor-lo: #8a713a;
  --factor-mid: #c9a84c;
  --factor-hi: #f0c968;
  --warn: #c98500;
  --radius-md: 12px; --radius-lg: 16px;
  --font-display: 'New York', ui-serif, Georgia, 'Times New Roman', serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', system-ui, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Monaco, 'Cascadia Code', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background-color: var(--bg-primary);
  background-image:
    radial-gradient(60% 50% at 10% 0%, rgba(64,108,190,0.14) 0%, rgba(64,108,190,0) 60%),
    radial-gradient(55% 55% at 95% 100%, rgba(201,168,76,0.09) 0%, rgba(201,168,76,0) 62%),
    radial-gradient(70% 55% at 85% 15%, rgba(90,143,212,0.06) 0%, rgba(90,143,212,0) 60%);
  background-attachment: fixed;
  background-repeat: no-repeat;
  color: var(--text-primary);
  font-family: var(--font-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(201,168,76,0.35); }

.page {
  max-width: 900px;
  margin: 0 auto;
  padding: 56px 24px 96px;
}

/* ── header ─────────────────────────────────────────── */

.eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--factor);
  margin: 0 0 14px;
}

h1.title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(32px, 5vw, 46px);
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin: 0 0 16px;
  text-wrap: balance;
  color: #f2f0e8;
}

.thesis {
  font-size: 18px;
  max-width: 62ch;
  color: var(--text-secondary);
  margin: 0 0 28px;
  text-wrap: pretty;
}

/* ── nav ────────────────────────────────────────────── */

nav.section-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border-soft);
  border-radius: var(--radius-lg);
  margin-bottom: 44px;
  position: sticky;
  top: 16px;
  z-index: 10;
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
}

nav.section-nav a {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 999px;
  transition: background 0.15s, color 0.15s;
}

nav.section-nav a:hover, nav.section-nav a:focus-visible {
  background: var(--factor-dim-bg);
  color: var(--factor);
  outline: none;
}

/* ── sections ───────────────────────────────────────── */

section { margin-bottom: 76px; scroll-margin-top: 76px; }

.section-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 14px;
}

.section-num {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
}

h2.section-title {
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 500;
  margin: 0;
  color: #f0eee6;
}

section > p.lede {
  font-size: 16px;
  color: var(--text-secondary);
  max-width: 68ch;
  margin: 20px 0 28px;
}

p { max-width: 68ch; }
section p:not(.lede) { color: var(--text-primary); font-size: 15px; }

code {
  font-family: var(--font-mono);
  font-size: 0.89em;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 4px;
  padding: 0.1em 0.4em;
  color: #dcd6c4;
  white-space: nowrap;
}

/* ── diagram cards (mermaid + hand-built SVG) ────────── */

.diagram-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin: 28px 0;
  overflow-x: auto;
  box-shadow: 0 8px 28px rgba(0,0,0,0.3);
}
.diagram-card .cap {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 4px;
}
pre.mermaid { margin: 0; min-width: 560px; }

/* ── tables ─────────────────────────────────────────── */

.table-wrap { overflow-x: auto; margin: 24px 0; border-radius: var(--radius-md); border: 1px solid var(--glass-border); }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; background: var(--glass-bg); min-width: 560px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border-subtle); }
th { font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); font-weight: 600; background: rgba(255,255,255,0.03); }
td { color: var(--text-secondary); }
td code { white-space: nowrap; }
tr:last-child td { border-bottom: none; }
td.num, th.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; color: var(--text-primary); }
td.hero-cell { color: var(--text-primary); font-family: var(--font-mono); font-size: 13px; }

/* ── radial diagram (hand-built SVG) ─────────────────── */

.radial-wrap { display: flex; justify-content: center; }
.radial-wrap svg { width: 100%; max-width: 560px; height: auto; }
.radial-cat-label { font-family: var(--font-mono); font-size: 12.5px; fill: var(--text-secondary); }
.radial-hub-label { font-family: var(--font-mono); font-size: 13px; fill: #241d0c; font-weight: 600; }

/* ── footer ─────────────────────────────────────────── */

footer {
  border-top: 1px solid var(--border-subtle);
  padding-top: 28px;
  margin-top: 90px;
}
footer h4 {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 14px;
}
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 6px 24px;
}
.file-row { display: flex; gap: 10px; font-size: 13px; padding: 5px 0; border-bottom: 1px solid var(--border-subtle); }
.file-row code { flex: none; background: none; border: none; padding: 0; color: #b9c3d9; }
.file-row span { color: var(--text-muted); }

/* ══ DOC STANDARD components (see docs/HTML_DOC_STANDARD.md) ══════════════
   The format every entity-reference page follows: each section is
   header → structure (diagram / mapping table) → parallel Concept‖Example
   streams (highlighted lead row + brief detail rows). Cross-references pool
   in .page-refs at the page foot; no volatile counts anywhere in the body. */

/* ── parallel Concept ‖ Example streams ─────────────────
   Two columns synced row-by-row (each concept is one grid row, so the
   streams can never drift). A central divider + subtle row rules, no outer
   box. The lead row carries the section's takeaway, highlighted in place. */
.parallel {
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(0, 0.94fr);
  margin: 8px 0 4px;
}
.parallel > div { padding: 12px 0; border-top: 1px solid rgba(255,255,255,0.09); }
.parallel > .col-l { border-right: 1px solid var(--glass-border-soft); padding-right: 30px; }
.parallel > .col-r { padding-left: 30px; }
.parallel > .head { padding: 0 0 11px; border-top: none; }
.head { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-muted); }
.head.col-r { padding-left: 30px; }
.col-l { font-size: 14.5px; line-height: 1.55; color: var(--text-primary); }
.col-r { font-family: var(--font-mono); font-size: 12.5px; line-height: 1.5; color: var(--text-secondary); align-self: start; }
.col-r code { background: none; border: none; padding: 0; white-space: normal; color: #b9c3d9; font-size: 1em; }
.col-r .n { color: var(--text-muted); }
.parallel > .lead { background: rgba(90,143,212,0.07); }
.parallel > .col-l.lead { font-size: 15.5px; font-weight: 600; color: #f0eee6; padding: 13px 30px 13px 16px; border-left: 2px solid var(--event); }
.parallel > .col-l.lead code { background: rgba(255,255,255,0.07); }
.parallel > .col-r.lead { padding-top: 13px; padding-bottom: 13px; }

@media (max-width: 640px) {
  .parallel { grid-template-columns: 1fr; }
  .parallel > .head { display: none; }
  .parallel > .col-l { border-right: none; padding-right: 0; }
  .parallel > .col-r { padding-left: 0; border-left: 2px solid var(--glass-border-soft); padding-left: 12px; margin: 2px 0 10px; }
  .parallel > .col-l.lead { padding-right: 16px; }
  .parallel > .col-r.lead { padding-left: 12px; }
}

/* ── field-mapping table (section-lead entity definitions) ──
   e.g. Prediction → Event: gold source column, muted transform, blue
   target column. Used where a section needs to define entities + mappings. */
.maptable code { background: none; border: none; padding: 0; white-space: nowrap; font-size: 0.95em; }
.maptable th.p, .maptable td.p, .maptable td.p code { color: #d3b866; }
.maptable th.e, .maptable td.e, .maptable td.e code { color: #8fb4e6; }
.maptable td.t { color: var(--text-secondary); font-size: 12.5px; }
.maptable td.t code { color: var(--text-primary); white-space: normal; }
.maptable td.gone { color: var(--text-muted); }
.maptable td.gone code { color: var(--text-secondary); }
.maptable .n { color: var(--text-muted); font-family: var(--font-body); font-size: 11.5px; }
.tablenote { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-muted); margin: 9px 2px 0; line-height: 1.7; }
.tablenote code { color: #b9c3d9; }

/* ── page-level See also (all cross-references pooled at the foot) ──
   Links for sibling pages; plain .ref labels for PROJECT.md sections
   (no rendered web target). Keeps every reference out of the prose. */
.page-refs { border-top: 1px solid var(--border-subtle); padding-top: 28px; margin-top: 90px; }
.page-refs h4 { font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); margin: 0 0 14px; }
.page-refs .links { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 4px 24px; }
.page-refs a, .page-refs .ref { display: flex; gap: 10px; font-family: var(--font-mono); font-size: 12.5px; color: var(--text-secondary); text-decoration: none; padding: 6px 0; border-bottom: 1px solid var(--border-subtle); }
.page-refs a:hover { color: var(--factor); }
.page-refs .tgt { color: #b9c3d9; flex: none; }
.page-refs a:hover .tgt { color: var(--factor); }
.page-refs .desc { color: var(--text-muted); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
