/* Spice3f5 manual.  Colours are tokens; dark values apply when the system
 * prefers dark (unless the reader chose light) or the reader chose dark. */

:root {
  --bg: #fbfaf7; --surface: #ffffff; --text: #1d1f23; --muted: #5d6470;
  --border: #e3e0d8; --accent: #1f5f8b; --accent-soft: #e6eff6;
  --ok: #2d6a3e; --ok-soft: #e4f2e7; --todo: #8a5a00; --todo-soft: #fbf1dc;
  --code-bg: #f3f1ec;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171a; --surface: #1c1f23; --text: #e6e6e3; --muted: #9aa1ab;
    --border: #2e3238; --accent: #7fb6de; --accent-soft: #1d2c38;
    --ok: #8fcf9f; --ok-soft: #1c2b20; --todo: #e0b35c; --todo-soft: #2e2618;
    --code-bg: #23272c;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15171a; --surface: #1c1f23; --text: #e6e6e3; --muted: #9aa1ab;
  --border: #2e3238; --accent: #7fb6de; --accent-soft: #1d2c38;
  --ok: #8fcf9f; --ok-soft: #1c2b20; --todo: #e0b35c; --todo-soft: #2e2618;
  --code-bg: #23272c;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
code, pre { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .88em; }
code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; }
pre { background: var(--code-bg); padding: 12px 14px; border-radius: 8px; overflow-x: auto; line-height: 1.45; }
pre code { background: none; padding: 0; }

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.theme-toggle {
  font: inherit; font-size: .85rem; color: var(--muted); background: none;
  border: 1px solid var(--border); border-radius: 6px; padding: 3px 10px; cursor: pointer;
}
.theme-toggle:hover { color: var(--text); }

/* Layout: sidebar beside the page on wide screens, above it on narrow */
.layout { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
main { min-width: 0; padding: 24px 0 64px; }
.sidebar { padding-top: 16px; }
.sidebar summary { cursor: pointer; font-weight: 600; color: var(--muted); }
.sidebar ul { list-style: none; margin: 8px 0 0; padding: 0; }
.sidebar li a {
  display: block; padding: 4px 10px; border-radius: 6px;
  color: var(--text); text-decoration: none;
}
.sidebar li a:hover { background: var(--code-bg); }
.sidebar li a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
@media (min-width: 900px) {
  .layout { display: grid; grid-template-columns: 220px 1fr; gap: 40px; }
  .sidebar { position: sticky; top: 0; align-self: start; max-height: 100vh; overflow-y: auto; padding-top: 24px; }
  .sidebar summary { display: none; }
}

/* Text */
h1 { font-size: 1.9rem; line-height: 1.2; margin: 0 0 8px; }
h2 { font-size: 1.3rem; margin: 40px 0 12px; }
h3 { font-size: 1.05rem; margin: 28px 0 8px; }
main { max-width: 860px; }
.lede { color: var(--muted); margin: 0 0 24px; }
.stub {
  background: var(--todo-soft); border-left: 4px solid var(--todo);
  border-radius: 8px; padding: 10px 14px;
}

/* Home page section cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-top: 16px; }
.card {
  display: block; padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text); text-decoration: none;
}
.card:hover { border-color: var(--accent); }
.card-title { display: block; font-weight: 600; color: var(--accent); margin-bottom: 4px; }
.card-desc { display: block; font-size: .92rem; color: var(--muted); }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; vertical-align: top; padding: 8px 12px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
td code { white-space: nowrap; }

.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.todo { background: var(--todo-soft); color: var(--todo); }

.footer {
  border-top: 1px solid var(--border); color: var(--muted); font-size: .85rem;
  padding: 16px; text-align: center;
}

/* Search */
.topbar { gap: 16px; }
.search { position: relative; flex: 1; max-width: 420px; }
.search input {
  width: 100%; font: inherit; font-size: .92rem; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 5px 10px;
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.search-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 10;
  list-style: none; margin: 0; padding: 4px; max-height: 70vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .15);
}
.search-results a { display: block; padding: 6px 8px; border-radius: 6px; text-decoration: none; color: var(--text); }
.search-results a:hover, .search-results a:focus { background: var(--accent-soft); }
.hit-title { display: block; font-weight: 600; color: var(--accent); }
.hit-text { display: block; font-size: .82rem; color: var(--muted); }
.search-results .none { padding: 6px 8px; color: var(--muted); }
@media (max-width: 600px) { .brand { display: none; } }

/* Sidebar: pages of the current section */
.sidebar .subnav { margin: 2px 0 6px 12px; border-left: 1px solid var(--border); }
.sidebar .subnav a { font-size: .9rem; padding: 2px 10px; }
.sidebar .subnav.commands { columns: 2; column-gap: 4px; }
.sidebar .subnav.commands a { padding: 1px 8px; }
.sidebar .subnav.commands code { background: none; padding: 0; }

/* Device pages */
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 20px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }
.note { background: var(--accent-soft); border-left: 4px solid var(--accent); border-radius: 8px; padding: 10px 14px; }
table.devparams td:nth-child(2) { white-space: nowrap; color: var(--muted); }
table.devparams td:nth-child(4) { color: var(--muted); font-size: .88em; }
table.devparams td:first-child { white-space: normal; }
table.devparams td:first-child code { white-space: nowrap; }

/* Example plots (inline SVG from util/mkexamples.py) */
:root {
  --c0: #1f6fb4; --c1: #d1603d; --c2: #2e8b57; --c3: #8e44ad;
  --c4: #b8860b; --c5: #c2185b; --c6: #00838f; --c7: #5d4037;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --c0: #6cb2eb; --c1: #f08a68; --c2: #6fcf97; --c3: #c39bd3;
    --c4: #e6c35c; --c5: #f48fb1; --c6: #4dd0e1; --c7: #bcaaa4;
  }
}
:root[data-theme="dark"] {
  --c0: #6cb2eb; --c1: #f08a68; --c2: #6fcf97; --c3: #c39bd3;
  --c4: #e6c35c; --c5: #f48fb1; --c6: #4dd0e1; --c7: #bcaaa4;
}
figure.plot { margin: 20px 0; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
figure.plot svg { display: block; width: 100%; height: auto; }
svg.plot .grid { stroke: var(--border); stroke-width: 1; }
svg.plot .frame { fill: none; stroke: var(--muted); stroke-width: 1; }
svg.plot .tick, svg.plot .axis { fill: var(--muted); font: 11px system-ui, sans-serif; }
svg.plot .axis { font-size: 12px; }
svg.plot polyline { fill: none; stroke-width: 1.6; stroke-linejoin: round; }
.s0 { stroke: var(--c0); background: var(--c0); } .s1 { stroke: var(--c1); background: var(--c1); }
.s2 { stroke: var(--c2); background: var(--c2); } .s3 { stroke: var(--c3); background: var(--c3); }
.s4 { stroke: var(--c4); background: var(--c4); } .s5 { stroke: var(--c5); background: var(--c5); }
.s6 { stroke: var(--c6); background: var(--c6); } .s7 { stroke: var(--c7); background: var(--c7); }
figure.plot figcaption { font-size: .9rem; margin-top: 6px; }
ul.legend { list-style: none; padding: 0; margin: 4px 0 0; display: flex; flex-wrap: wrap; gap: 4px 16px; }
ul.legend li { display: flex; align-items: center; gap: 6px; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .85rem; }
.swatch { display: inline-block; width: 16px; height: 3px; border-radius: 2px; }
pre.deck { max-height: 32em; overflow: auto; }

/* The command index: usage strings wrap so the table fits the page */
table.commands td:nth-child(2) { width: 38%; }
table.commands td:nth-child(2) code { white-space: normal; overflow-wrap: anywhere; }
table.commands td:first-child code { white-space: normal; }

/* All commands, on the interpreter section page */
.command-list { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 4px 12px; }

/* Converted manual text */
.on-page { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 16px; margin: 0 0 24px; }
.on-page ul { margin: 0; padding-left: 18px; }
.see-also { color: var(--muted); font-size: .92rem; }
.label { font-weight: 600; margin: 20px 0 6px; }
main h2 { padding-top: 12px; border-top: 1px solid var(--border); }
main h1 + h2, .on-page + h2 { border-top: none; }
dl.defs dt { margin-top: 10px; }
dl.defs dd { margin-left: 24px; }
dl.hang { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; }
dl.hang dt { font-weight: 600; }
dl.hang dd { margin: 0; }
table.params td:first-child { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .88em; white-space: nowrap; }
pre.math, pre.unparsed { border-left: 3px solid var(--border); }
math { font-family: "Cambria Math", "STIX Two Math", "Latin Modern Math", math; }
math[display="block"] { display: block; margin: 16px 0; font-size: 1.15em; overflow-x: auto; overflow-y: hidden; padding: 4px 0; }

@media print {
  .topbar, .sidebar, .footer { display: none; }
  .layout { display: block; }
}
