/* MUR documentation site — hand-maintained static CSS, no build step. */

:root {
  --bg: #ffffff;
  --bg-soft: #f6f8fa;
  --bg-sink: #eef2f6;
  --fg: #1c2530;
  --fg-muted: #5a6b7c;
  --border: #d9e1e8;
  --accent: #0b6e9e;
  --accent-soft: #e8f3f9;
  --accent-fg: #07506f;
  --warn-bg: #fff8e6;
  --warn-border: #e8c76a;
  --code-bg: #f2f5f8;
  --sidebar-w: 16.5rem;
  --maxw: 54rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12171d;
    --bg-soft: #1a212a;
    --bg-sink: #202934;
    --fg: #dfe6ed;
    --fg-muted: #93a3b3;
    --border: #2b3643;
    --accent: #58b4e0;
    --accent-soft: #14303f;
    --accent-fg: #8fd0f0;
    --warn-bg: #2e2717;
    --warn-border: #6d5a24;
    --code-bg: #1b222b;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- layout ---------- */

.layout { display: flex; min-height: 100vh; align-items: flex-start; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  padding: 1.5rem 0 3rem;
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
}

.brand {
  display: block;
  padding: 0 1.25rem 1.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
  color: var(--fg);
}
.brand:hover { text-decoration: none; }
.brand strong { display: block; font-size: 1.15rem; letter-spacing: -0.01em; }
.brand span { display: block; font-size: 0.8rem; color: var(--fg-muted); margin-top: 0.15rem; }

.nav-group {
  padding: 0 1.25rem;
  margin: 1.25rem 0 0.4rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

.sidebar nav a {
  display: block;
  padding: 0.35rem 1.25rem;
  color: var(--fg);
  font-size: 0.92rem;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: var(--bg-sink); text-decoration: none; }
.sidebar nav a[aria-current="page"] {
  border-left-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-fg);
  font-weight: 600;
}

main {
  flex: 1 1 auto;
  min-width: 0;
  padding: 2.5rem 2.5rem 6rem;
}
.content { max-width: var(--maxw); }

/* ---------- typography ---------- */

h1 { font-size: 2.1rem; line-height: 1.2; letter-spacing: -0.02em; margin: 0 0 0.35rem; }
h2 {
  font-size: 1.4rem; letter-spacing: -0.01em;
  margin: 2.75rem 0 0.85rem; padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}
h3 { font-size: 1.1rem; margin: 1.85rem 0 0.6rem; }
p, li { color: var(--fg); }
.lede { font-size: 1.12rem; color: var(--fg-muted); margin: 0 0 2rem; }

code, pre, .mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
               "Liberation Mono", monospace;
}
code { background: var(--code-bg); padding: 0.12em 0.38em; border-radius: 3px; font-size: 0.88em; }
pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.9rem 1.1rem;
  overflow-x: auto;
  font-size: 0.86rem;
  line-height: 1.55;
}
pre code { background: none; padding: 0; font-size: inherit; }

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; margin: 1.1rem 0; }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--bg-soft); font-weight: 600; white-space: nowrap; }
tbody tr:hover { background: var(--bg-soft); }

/* ---------- callouts ---------- */

.note, .warn {
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  background: var(--bg-soft);
  border-radius: 0 6px 6px 0;
  padding: 0.85rem 1.1rem;
  margin: 1.35rem 0;
  font-size: 0.94rem;
}
.warn { border-left-color: var(--warn-border); background: var(--warn-bg); }
.note > :first-child, .warn > :first-child { margin-top: 0; }
.note > :last-child,  .warn > :last-child  { margin-bottom: 0; }

/* ---------- cards ---------- */

.cards { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); margin: 1.5rem 0; }
.card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.1rem 1.2rem;
  background: var(--bg-soft);
}
.card h3 { margin: 0 0 0.4rem; font-size: 1rem; }
.card p { margin: 0; font-size: 0.9rem; color: var(--fg-muted); }

.stats { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); margin: 1.75rem 0; }
.stat { border: 1px solid var(--border); border-radius: 8px; padding: 0.9rem 1rem; background: var(--bg-soft); }
.stat b { display: block; font-size: 1.5rem; letter-spacing: -0.02em; color: var(--accent-fg); }
.stat span { font-size: 0.82rem; color: var(--fg-muted); }

/* ---------- on-page table of contents ---------- */

.toc {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
  padding: 1rem 1.25rem;
  margin: 0 0 2.25rem;
  font-size: 0.9rem;
}
.toc b {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 0.6rem;
}
.toc ul {
  margin: 0;
  padding: 0;
  list-style: none;
  columns: 2;
  column-gap: 2rem;
}
.toc li { margin: 0.2rem 0; break-inside: avoid; }

@media (max-width: 620px) {
  .toc ul { columns: 1; }
}

/* ---------- figures ---------- */

figure.figure {
  margin: 1.75rem 0;
  padding: 0;
}
figure.figure img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
}
figure.figure figcaption {
  margin-top: 0.6rem;
  font-size: 0.84rem;
  color: var(--fg-muted);
}

/* Anchored headings land clear of the top of the viewport. */
h2[id], h3[id], h4[id] { scroll-margin-top: 1rem; }

/* ---------- mermaid ---------- */

/* Diagrams keep their original light palette — several carry explicit pastel
   fills from the source markdown, which would be unreadable on a dark page —
   so the figure always renders on a light surface regardless of page theme. */
figure.diagram {
  margin: 1.5rem 0;
  padding: 1.1rem;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
}
figure.diagram pre.mermaid { background: none; border: none; padding: 0; margin: 0; text-align: center; }
figure.diagram figcaption {
  margin-top: 0.75rem; padding-top: 0.6rem;
  border-top: 1px solid #e3e8ee;
  font-size: 0.84rem; color: #55636f; text-align: left;
}
pre.mermaid:not([data-processed]) { visibility: hidden; }

/* ---------- footer ---------- */

footer {
  max-width: var(--maxw);
  margin-top: 4rem; padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem; color: var(--fg-muted);
}
footer a { color: var(--fg-muted); text-decoration: underline; }

/* ---------- mobile ---------- */

.menu-btn {
  display: none;
  position: fixed; top: 0.75rem; left: 0.75rem; z-index: 30;
  background: var(--bg-soft); color: var(--fg);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 0.45rem 0.7rem; font-size: 0.95rem; cursor: pointer;
}

@media (max-width: 820px) {
  .menu-btn { display: block; }
  .sidebar {
    position: fixed; z-index: 20; top: 0; bottom: 0; left: 0;
    max-height: none; transform: translateX(-100%);
    transition: transform 0.18s ease-out;
    box-shadow: 0 0 2rem rgba(0,0,0,0.18);
  }
  .sidebar.open { transform: translateX(0); }
  main { padding: 3.75rem 1.25rem 4rem; }
}
