/* doc.css — clean reading theme for the long-form pages (spec, rationale,
   examples).  The landing page keeps its own CRT styling; these pages trade
   the scanlines and glow for a calm, high-contrast typeset look so the prose
   is actually readable.  Code blocks stay monospace and keep the warm palette. */

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

:root {
  --bg:       #16120e;   /* warm near-black, no purple cast */
  --panel:    #1e1813;   /* code blocks and surfaces */
  --border:   #382c20;   /* hairlines */
  --text:     #e8ded0;   /* body prose */
  --muted:    #b3a48d;   /* intro, summaries, blockquote */
  --heading:  #f6ead7;   /* headings */
  --accent:   #ff8a2a;   /* links, rules */
  --accent-2: #ffb060;   /* inline code, hover */

  --serif: 'Charter', 'Iowan Old Style', 'Palatino Linotype', Palatino,
           Georgia, 'Times New Roman', serif;
  --sans:  ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto,
           'Helvetica Neue', Arial, sans-serif;
  --mono:  ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas,
           'DejaVu Sans Mono', monospace;
}

html {
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.7;
  scroll-behavior: smooth;
  scroll-padding-top: 4rem;   /* anchors clear the sticky nav */
  -webkit-text-size-adjust: 100%;
}

body { min-height: 100vh; overflow-y: scroll; }

::selection { background: var(--accent); color: var(--bg); }

/* ── nav ── */

nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.2rem;
  background: rgba(22, 18, 14, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
  padding: 0.7rem 2rem;
}

nav a {
  color: var(--muted);
  text-decoration: none;
  font-family: var(--sans);
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  transition: color 0.15s;
}

nav a:hover { color: var(--accent-2); }

nav .toc {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.66rem;
  letter-spacing: 0.1em;
}

/* ── article ── */

article {
  max-width: 74ch;
  margin: 0 auto;
  padding: 3.5rem 2rem 7rem;
}

article h1 {
  font-family: var(--sans);
  font-size: clamp(2rem, 5vw, 2.7rem);
  font-weight: 600;
  line-height: 1.2;
  color: var(--heading);
  margin-bottom: 1.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--accent);
}

article h2 {
  font-family: var(--sans);
  font-size: 1.45rem;
  font-weight: 600;
  color: var(--heading);
  margin: 3rem 0 0.85rem;
}

article h3 {
  font-family: var(--sans);
  font-size: 1.18rem;
  font-weight: 600;
  color: var(--accent-2);
  margin: 2.1rem 0 0.6rem;
}

article h4 {
  font-family: var(--sans);
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
  margin: 1.6rem 0 0.45rem;
}

article p { margin-bottom: 1.1rem; }

article ul, article ol { margin: 0.6rem 0 1.1rem 1.6rem; }
article li { margin-bottom: 0.4rem; }
article li > ul, article li > ol { margin-bottom: 0.2rem; }

article a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(255, 138, 42, 0.45);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.15s;
}

article a:hover { text-decoration-color: var(--accent); }

article strong { color: var(--heading); font-weight: 700; }
article em { font-style: italic; }

/* ── code ── */

article code {
  font-family: var(--mono);
  font-size: 0.86em;
  color: var(--accent-2);
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 0.1em 0.36em;
  border-radius: 4px;
}

article pre {
  font-family: var(--mono);
  font-size: 0.84rem;
  line-height: 1.6;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.05rem 1.25rem;
  margin: 1rem 0 1.4rem;
  overflow-x: auto;
}

article pre code {
  font-size: inherit;
  color: var(--text);
  background: none;
  border: none;
  padding: 0;
  border-radius: 0;
}

/* ── blockquote, rule, table ── */

article blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.1rem 0 0.1rem 1.1rem;
  margin: 1.1rem 0;
  color: var(--muted);
  font-style: italic;
}

article hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

article table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.2rem 0;
  font-size: 0.92rem;
}

article th, article td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.85rem;
  text-align: left;
}

article th { color: var(--heading); font-family: var(--sans); font-weight: 600; }

/* ── examples page ── */

article > p.intro {
  color: var(--muted);
  font-size: 1.02rem;
  margin-bottom: 3rem;
}

section.example { margin-bottom: 3.5rem; }

section.example h2 {
  font-size: 1.3rem;
  margin: 0 0 0.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

section.example h2 .name {
  font-family: var(--mono);
  font-size: 0.95rem;
  color: var(--accent-2);
}

section.example .summary {
  color: var(--muted);
  font-size: 0.96rem;
  margin: 0.7rem 0 1rem;
  white-space: pre-wrap;
}

pre.source { margin: 0; }

.raw-link {
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  margin-left: 0.8rem;
  vertical-align: middle;
}

.raw-link:hover { color: var(--accent-2); }

/* Fallback regex highlighter classes (used only when tree-sitter is missing,
   e.g. local dev).  CI highlights with the real grammar, which emits inline
   colours from editors/tree-sitter-ral/.tsconfig/config.json. */
pre.source .comment          { color: var(--muted); font-style: italic; }
pre.source .string           { color: #e0bb70; }
pre.source .keyword          { color: #ffb060; }
pre.source .function-builtin { color: #ff7a15; }
pre.source .variable         { color: #ffd17a; }
pre.source .number           { color: #ffa050; }
pre.source .operator         { color: #ff9a3c; }
