/* ===========================================================================
   Mentat docs stylesheet.

   Port of the blog design (src/styles/global.css in the blog repo, an Astro
   site) onto the Jekyll-rendered docs, via the Morpheus docs port. Sections
   "design tokens" through "theme switch" are carried over verbatim; the final
   section adapts the design to the HTML that GitHub Pages' GFM pipeline emits
   for Markdown.

   Three theme states, and the order matters:
     1. bare :root            -> the complete light palette
     2. prefers-color-scheme  -> dark, but only when not explicitly set to light
     3. [data-theme="dark"]   -> explicit choice wins over the media query
   Every token is defined in state 1, so nothing depends on a media block
   being matched.
   =========================================================================== */

:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #f0f2f5;
  --ink: #14171c;
  --ink-2: #4a525e;
  --ink-3: #79828f;
  --line: #e1e5ea;
  --line-2: #cdd4dc;
  --accent: #2f6bff;
  --accent-soft: #e8efff;
  --accent-ink: #1e4fd1;
  --ok: #0f8a5f;
  --ok-soft: #e2f5ec;
  --warn: #a86400;
  --warn-soft: #fdf1dc;
  --hot: #c0392b;
  --hot-soft: #fdecea;
  --muted-soft: #eceef2;
  --code-bg: #14171c;
  --code-ink: #e6e9ee;
  --code-line: #2a2f38;
  --shadow: 0 1px 2px rgba(16, 20, 28, 0.06), 0 8px 24px rgba(16, 20, 28, 0.05);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1116;
    --panel: #161a21;
    --panel-2: #1d222b;
    --ink: #e8ebf0;
    --ink-2: #a7b0bd;
    --ink-3: #79838f;
    --line: #262c36;
    --line-2: #343c48;
    --accent: #6b98ff;
    --accent-soft: #17233c;
    --accent-ink: #a8c2ff;
    --ok: #4bd39a;
    --ok-soft: #12281f;
    --warn: #e0a33c;
    --warn-soft: #2a2113;
    --hot: #ff8c7a;
    --hot-soft: #2e1a18;
    --muted-soft: #1f242d;
    --code-bg: #0a0d12;
    --code-ink: #dde3ec;
    --code-line: #232a34;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 28px rgba(0, 0, 0, 0.3);
  }
}

:root[data-theme="dark"] {
  --bg: #0e1116;
  --panel: #161a21;
  --panel-2: #1d222b;
  --ink: #e8ebf0;
  --ink-2: #a7b0bd;
  --ink-3: #79838f;
  --line: #262c36;
  --line-2: #343c48;
  --accent: #6b98ff;
  --accent-soft: #17233c;
  --accent-ink: #a8c2ff;
  --ok: #4bd39a;
  --ok-soft: #12281f;
  --warn: #e0a33c;
  --warn-soft: #2a2113;
  --hot: #ff8c7a;
  --hot-soft: #2e1a18;
  --muted-soft: #1f242d;
  --code-bg: #0a0d12;
  --code-ink: #dde3ec;
  --code-line: #232a34;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 28px rgba(0, 0, 0, 0.3);
}

/* ---------- base ---------- */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.wrap {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px 96px;
  flex: 1;
}

/* ---------- masthead ---------- */

header.top {
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  padding: 40px 20px 34px;
  margin-bottom: 34px;
}

header.top .inner {
  max-width: 1180px;
  margin: 0 auto;
}

.kicker {
  font: 600 11.5px/1 var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-ink);
  margin-bottom: 14px;
}

h1 {
  font-size: clamp(26px, 4.4vw, 40px);
  line-height: 1.14;
  margin: 0 0 12px;
  letter-spacing: -0.022em;
  font-weight: 700;
}

.sub {
  color: var(--ink-2);
  max-width: 62ch;
  margin: 0;
}

.metarow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}

.chip {
  font: 500 12.5px/1 var(--mono);
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
}

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

.cols {
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
  gap: 36px;
  align-items: start;
}

@media (max-width: 900px) {
  .cols {
    grid-template-columns: 1fr;
    gap: 0;
  }

  nav.side {
    position: static !important;
    margin-bottom: 28px;
  }
}

nav.side {
  position: sticky;
  top: 20px;
  font-size: 13.5px;
}

nav.side .nav-h {
  font: 600 10.5px/1 var(--mono);
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 10px;
  padding-left: 11px;
}

nav.side a {
  display: block;
  padding: 6px 11px;
  color: var(--ink-2);
  text-decoration: none;
  border-left: 2px solid var(--line);
  line-height: 1.4;
}

nav.side a:hover {
  color: var(--ink);
  border-left-color: var(--line-2);
  background: var(--panel-2);
}

/* Marks the page you are already on in the site group. */
nav.side a[aria-current="page"] {
  color: var(--accent-ink);
  border-left-color: var(--accent);
}

nav.side .gap {
  height: 14px;
}

/* ---------- sections ---------- */

section {
  margin: 0 0 44px;
  scroll-margin-top: 20px;
}

.sec-head {
  border-bottom: 2px solid var(--ink);
  padding-bottom: 9px;
  margin-bottom: 20px;
}

.sec-num {
  font: 600 11.5px/1 var(--mono);
  letter-spacing: 0.13em;
  color: var(--ink-3);
  display: block;
  margin-bottom: 6px;
}

h2 {
  font-size: clamp(20px, 2.6vw, 26px);
  margin: 0;
  letter-spacing: -0.015em;
  font-weight: 700;
}

h3 {
  font-size: 17px;
  margin: 30px 0 10px;
  letter-spacing: -0.01em;
  font-weight: 650;
}

h4 {
  font-size: 14.5px;
  margin: 20px 0 7px;
  font-weight: 650;
}

p {
  margin: 0 0 13px;
}

ul,
ol {
  margin: 0 0 14px;
  padding-left: 22px;
}

li {
  margin-bottom: 6px;
}

li::marker {
  color: var(--ink-3);
}

strong {
  font-weight: 650;
  color: var(--ink);
}

a {
  color: var(--accent-ink);
}

code {
  font-family: var(--mono);
  font-size: 0.875em;
  background: var(--muted-soft);
  padding: 1.5px 5px;
  border-radius: 4px;
  border: 1px solid var(--line);
}

/* ---------- cards and callouts ---------- */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 22px 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.card.tight {
  padding: 16px 18px;
}

.card > *:last-child {
  margin-bottom: 0;
}

.callout {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 14px 17px;
  margin: 0 0 16px;
  font-size: 14.5px;
}

.callout.warn {
  border-left-color: var(--warn);
  background: var(--warn-soft);
}

.callout.hot {
  border-left-color: var(--hot);
  background: var(--hot-soft);
}

.callout.ok {
  border-left-color: var(--ok);
  background: var(--ok-soft);
}

.callout p:last-child {
  margin-bottom: 0;
}

.callout .lbl {
  font: 600 10.5px/1 var(--mono);
  letter-spacing: 0.11em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 7px;
  color: var(--ink-3);
}

/* ---------- badges ---------- */

.badge {
  display: inline-block;
  font: 600 10.5px/1.5 var(--mono);
  letter-spacing: 0.05em;
  padding: 3.5px 8px;
  border-radius: 5px;
  text-transform: uppercase;
  white-space: nowrap;
  border: 1px solid transparent;
}

.b-hot {
  background: var(--hot-soft);
  color: var(--hot);
  border-color: var(--hot);
}

.b-ok {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: var(--ok);
}

.b-accent {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.b-warn {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: var(--warn);
}

.b-muted {
  background: var(--muted-soft);
  color: var(--ink-2);
  border-color: var(--line-2);
}

/* ---------- disclosure ---------- */

details {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 9px;
  background: var(--panel-2);
}

details[open] {
  background: var(--panel);
}

summary {
  cursor: pointer;
  padding: 10px 14px;
  font: 600 13px/1.4 var(--sans);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink-2);
}

summary::-webkit-details-marker {
  display: none;
}

summary::before {
  content: "+";
  font-family: var(--mono);
  font-weight: 700;
  color: var(--accent-ink);
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-2);
  border-radius: 4px;
  font-size: 12px;
  flex: none;
}

details[open] summary::before {
  content: "\2212";
}

details[open] summary {
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}

.det-body {
  padding: 15px 16px 3px;
}

.det-body > *:last-child {
  margin-bottom: 12px;
}

/* ---------- code ---------- */

pre {
  background: var(--code-bg);
  color: var(--code-ink);
  border: 1px solid var(--code-line);
  border-radius: 8px;
  padding: 15px 17px;
  overflow-x: auto;
  margin: 0 0 14px;
  font-family: var(--mono);
  font-size: 12.9px;
  line-height: 1.62;
  tab-size: 2;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  color: inherit;
}

.codelbl {
  font: 600 10.5px/1 var(--mono);
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 6px;
}

/* Mermaid diagrams are built client-side from ```mermaid fenced blocks; the
   container is hidden until the SVG renders, and scrolls if too wide. */
.mermaid {
  margin: 0 0 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  overflow-x: auto;
  text-align: center;
}

.mermaid svg {
  max-width: 100%;
  height: auto;
}

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

.tw {
  overflow-x: auto;
  margin: 0 0 16px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13.8px;
  min-width: 460px;
}

th,
td {
  text-align: left;
  padding: 9px 13px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  font: 600 11px/1.4 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  background: var(--panel-2);
  white-space: nowrap;
}

tr:last-child td {
  border-bottom: none;
}

td code {
  font-size: 12.4px;
}

/* ---------- misc ---------- */

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 760px) {
  .grid2 {
    grid-template-columns: 1fr;
  }
}

.keyrow {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin: 0 0 6px;
}

.keyrow > span {
  font-size: 12.8px;
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

hr.soft {
  border: none;
  border-top: 1px solid var(--line);
  margin: 26px 0;
}

.tiny {
  font-size: 12.9px;
  color: var(--ink-3);
}

.qlist {
  counter-reset: q;
  list-style: none;
  padding-left: 0;
}

.qlist > li {
  counter-increment: q;
  position: relative;
  padding-left: 32px;
  margin-bottom: 13px;
}

.qlist > li::before {
  content: counter(q);
  position: absolute;
  left: 0;
  top: 1px;
  font: 600 11px/20px var(--mono);
  width: 20px;
  height: 20px;
  text-align: center;
  background: var(--muted-soft);
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--ink-3);
}

footer {
  border-top: 1px solid var(--line);
  margin-top: 44px;
  padding-top: 22px;
  color: var(--ink-3);
  font-size: 13px;
}

footer p {
  margin: 0;
}

/* ---------- theme switch ---------- */

.themebtn {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 60;
  font: 600 11.5px/1 var(--mono);
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid var(--line-2);
  background: var(--panel);
  color: var(--ink-2);
  box-shadow: var(--shadow);
}

.themebtn:hover {
  color: var(--accent-ink);
  border-color: var(--accent);
}

/* ---------- consent banner ---------- */

.consent {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 13.5px;
  color: var(--ink-2);
}

.consent[hidden] {
  display: none;
}

.consent-text {
  margin: 0;
  max-width: 64ch;
}

.consent-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.consent-btn {
  font: 600 12px/1 var(--mono);
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid var(--line-2);
}

.consent-btn:hover {
  color: var(--accent-ink);
  border-color: var(--accent);
}

.consent-accept {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.consent-decline {
  background: var(--panel-2);
  color: var(--ink-2);
  border-color: var(--line);
}

@media (max-width: 640px) {
  .consent {
    flex-direction: column;
    align-items: stretch;
  }

  .consent-actions {
    justify-content: flex-end;
  }
}

/* ---------- markdown content adaptations ----------
   The blog authors content as hand-written HTML inside Astro components;
   the docs are Jekyll-rendered Markdown. These rules map the same design
   onto the tags the GitHub Pages GFM pipeline emits, scoped to the content
   column so masthead and side-nav styling is untouched. */

/* The masthead already renders the page title; the H1 inside the rendered
   Markdown duplicates it and is hidden. */
main > h1:first-child {
  display: none;
}

/* Standalone section headings get the .sec-head look (2px ink rule). */
main h2 {
  border-bottom: 2px solid var(--ink);
  padding-bottom: 9px;
  margin: 42px 0 18px;
}

main h3 {
  margin: 30px 0 10px;
}

/* Blockquote (GFM `>`) — a tinted panel with an accent edge. */
main blockquote {
  margin: 0 0 16px;
  padding: 10px 16px;
  border-left: 3px solid var(--accent);
  background: var(--panel-2);
  border-radius: 0 8px 8px 0;
  color: var(--ink-2);
}

main blockquote p:last-child {
  margin-bottom: 0;
}

main blockquote code {
  background: var(--panel);
  border-color: var(--line);
}

/* Horizontal rule (Markdown `---`). */
main hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 26px 0;
}

/* Images scale to the column. */
main img {
  max-width: 100%;
  height: auto;
}

/* ---------- print ---------- */

@media print {
  .themebtn,
  nav.side {
    display: none !important;
  }

  .cols {
    grid-template-columns: 1fr;
  }

  details {
    border: none;
  }

  details > summary {
    display: none;
  }

  .det-body {
    padding: 0;
  }

  details > .det-body {
    display: block !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  pre {
    background: #f4f4f4;
    color: #000;
    border-color: #ccc;
  }
}
