/* Trellaris documentation — shared styles.
   Self-contained (no external fonts/CDN) so the docs container has no egress. */

:root {
  --bg: #ffffff;
  --surface: #f7f8fa;
  --surface-2: #eef0f4;
  --border: #dcdfe6;
  --text: #1a1c20;
  --muted: #5b6270;
  --primary: #2f5bd7;
  --primary-soft: #eaf0ff;
  --green: #1f7a4d;
  --amber: #9a6400;
  --red: #b3261e;
  --code-bg: #f2f4f8;
  --radius: 10px;
  --sidebar-w: 250px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1a1d22;
    --surface-2: #22262d;
    --border: #2e333c;
    --text: #e8eaee;
    --muted: #9aa2b1;
    --primary: #7fa2ff;
    --primary-soft: #1b2540;
    --green: #5ad19b;
    --amber: #e0b25c;
    --red: #ff8a80;
    --code-bg: #1b1f26;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  font-size: 16px;
  line-height: 1.65;
}

code, pre, .mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; }

/* ── layout ─────────────────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

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

.brand { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.25rem; text-decoration: none; color: var(--text); }
.brand-mark {
  /* The Trellaris mark. Every page's markup carries a literal "T" as the
     placeholder this replaced; the text is pushed out of view rather than
     edited out of a dozen HTML files. */
  width: 30px; height: 30px; flex: 0 0 30px;
  background: url("mark.svg") no-repeat center / contain;
  text-indent: -999em; overflow: hidden;
}
.brand-name { font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em; }
.brand-sub { color: var(--muted); font-size: 0.78rem; margin: 0 0 1.5rem 2.3rem; }

.nav-group { margin-bottom: 1.25rem; }
.nav-title {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); font-weight: 700; margin: 0 0 0.4rem 0.5rem;
}
.sidebar a.nav-link {
  display: block; padding: 0.38rem 0.5rem; border-radius: 7px;
  color: var(--text); text-decoration: none; font-size: 0.92rem;
}
.sidebar a.nav-link:hover { background: var(--surface-2); }
.sidebar a.nav-link.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

.content { flex: 1 1 auto; min-width: 0; padding: 2.5rem 3rem 5rem; max-width: 900px; }

/* ── typography ─────────────────────────────────────────────────────────── */
h1 { font-size: 2.1rem; line-height: 1.2; letter-spacing: -0.02em; margin: 0 0 0.5rem; }
h2 {
  font-size: 1.35rem; letter-spacing: -0.01em; margin: 2.5rem 0 0.75rem;
  padding-top: 0.5rem; border-top: 1px solid var(--border);
}
h3 { font-size: 1.05rem; margin: 1.75rem 0 0.5rem; }
p { margin: 0.75rem 0; }
.lead { font-size: 1.08rem; color: var(--muted); margin-bottom: 1.5rem; }
a { color: var(--primary); }
ul, ol { padding-left: 1.35rem; }
li { margin: 0.35rem 0; }
strong { font-weight: 650; }

.eyebrow {
  display: inline-block; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--primary); background: var(--primary-soft);
  padding: 0.2rem 0.55rem; border-radius: 99px; margin-bottom: 0.8rem;
}

/* ── code ───────────────────────────────────────────────────────────────── */
code {
  background: var(--code-bg); border: 1px solid var(--border);
  padding: 0.1rem 0.34rem; border-radius: 5px; font-size: 0.87em;
}
pre {
  background: var(--code-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.1rem; overflow-x: auto;
  font-size: 0.85rem; line-height: 1.6; margin: 1rem 0;
}
pre code { background: none; border: none; padding: 0; font-size: inherit; }
.pre-label {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin: 1.25rem 0 -0.5rem;
}

/* ── tables ─────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; margin: 1rem 0; }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th, td { border: 1px solid var(--border); padding: 0.55rem 0.7rem; text-align: left; vertical-align: top; }
th { background: var(--surface-2); font-weight: 650; }

/* ── cards ──────────────────────────────────────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; margin: 1.25rem 0; }
.card {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem; background: var(--surface); text-decoration: none; color: var(--text);
  display: block;
}
a.card:hover { border-color: var(--primary); }
.card h3 { margin: 0 0 0.3rem; font-size: 1rem; }
.card p { margin: 0; font-size: 0.87rem; color: var(--muted); }

/* ── callouts ───────────────────────────────────────────────────────────── */
.note {
  border-left: 3px solid var(--primary); background: var(--primary-soft);
  padding: 0.85rem 1rem; border-radius: 0 var(--radius) var(--radius) 0; margin: 1.25rem 0;
  font-size: 0.93rem;
}
.note.warn { border-left-color: var(--amber); background: color-mix(in srgb, var(--amber) 10%, transparent); }
.note-title { font-weight: 700; display: block; margin-bottom: 0.2rem; }

/* ── badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block; font-size: 0.73rem; font-weight: 650;
  padding: 0.1rem 0.5rem; border-radius: 99px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.badge.read { color: var(--green); border-color: color-mix(in srgb, var(--green) 40%, transparent); }
.badge.write { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 40%, transparent); }
.badge.destructive { color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, transparent); }

/* ── step list (samples) ────────────────────────────────────────────────── */
.steps { list-style: none; padding: 0; margin: 1.25rem 0; counter-reset: step; }
.steps > li {
  position: relative; padding-left: 2.6rem; margin-bottom: 1.4rem; counter-increment: step;
}
.steps > li::before {
  content: counter(step);
  position: absolute; left: 0; top: 0.05rem;
  width: 1.8rem; height: 1.8rem; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: grid; place-items: center; font-size: 0.82rem; font-weight: 700;
}
.steps h3 { margin: 0 0 0.2rem; font-size: 0.98rem; }

/* ── figures & diagrams ─────────────────────────────────────────────────── */
/* Diagrams are inline SVG so they inherit the theme tokens above and the
   container still makes no outbound requests. */
.figure { margin: 1.75rem 0; }
.figure svg { display: block; width: 100%; height: auto; font-family: inherit; }
.figure figcaption {
  color: var(--muted); font-size: 0.82rem; margin-top: 0.6rem; text-align: center;
}

.dg-box { fill: var(--surface); stroke: var(--border); stroke-width: 1; }
.dg-box-alt { fill: var(--surface-2); stroke: var(--border); stroke-width: 1; }
.dg-box-key { fill: var(--primary-soft); stroke: var(--primary); stroke-width: 1.5; }
.dg-frame { fill: none; stroke: var(--border); stroke-width: 1; stroke-dasharray: 6 5; }
.dg-t { fill: var(--text); font-size: 13.5px; font-weight: 650; }
.dg-s { fill: var(--muted); font-size: 11.5px; }
.dg-l {
  fill: var(--muted); font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
}
.dg-k { fill: var(--primary); font-size: 13.5px; font-weight: 700; }
.dg-line { stroke: var(--border); stroke-width: 1.4; fill: none; }
.dg-flow { stroke: var(--primary); stroke-width: 1.6; fill: none; }

/* ── footer ─────────────────────────────────────────────────────────────── */
.footer {
  margin-top: 3.5rem; padding-top: 1.25rem; border-top: 1px solid var(--border);
  color: var(--muted); font-size: 0.85rem;
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}

/* ── responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 800px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--border); }
  .content { padding: 1.75rem 1.25rem 3rem; }
}

/* ── explicit theme toggle (adds to the prefers-color-scheme default) ────── */
/* The media block above is the default; these let a reader override it, and
   the choice persists in localStorage (set pre-paint in each page's <head>). */
:root[data-theme="dark"] {
  --bg: #14161a; --surface: #1a1d22; --surface-2: #22262d; --border: #2e333c;
  --text: #e8eaee; --muted: #9aa2b1; --primary: #7fa2ff; --primary-soft: #1b2540;
  --green: #5ad19b; --amber: #e0b25c; --red: #ff8a80; --code-bg: #1b1f26;
}
:root[data-theme="light"] {
  --bg: #ffffff; --surface: #f7f8fa; --surface-2: #eef0f4; --border: #dcdfe6;
  --text: #1a1c20; --muted: #5b6270; --primary: #2f5bd7; --primary-soft: #eaf0ff;
  --green: #1f7a4d; --amber: #9a6400; --red: #b3261e; --code-bg: #f2f4f8;
}

.theme-toggle {
  display: inline-flex; align-items: center; gap: 0.4rem;
  margin: 0.25rem 0 1.25rem 0; padding: 0.35rem 0.65rem;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--muted);
  font-size: 0.82rem; font-family: inherit; cursor: pointer; width: 100%;
}
.theme-toggle:hover { color: var(--text); border-color: var(--primary); }
.theme-toggle .tt-light { display: none; }
:root[data-theme="dark"] .theme-toggle .tt-dark { display: none; }
:root[data-theme="dark"] .theme-toggle .tt-light { display: inline; }

/* ── screenshots ────────────────────────────────────────────────────────── */
.shot { margin: 1.75rem 0; }
.shot img {
  display: block; width: 100%; height: auto;
  border: 1px solid var(--border); border-radius: var(--radius);
}
.shot figcaption { color: var(--muted); font-size: 0.82rem; margin-top: 0.55rem; }
