/* Shared styles for the kbforge docs site (index.html and reference.html).
   Deliberately plain: one accent colour, no gradients, thin rules, type doing the work.
   Colours are CSS variables so the site follows the reader's light/dark setting. */

:root {
  --bg: #fbfaf8; --bg-soft: #f2f0ec; --bg-code: #f2f0ec; --fg: #1b1b1a; --muted: #5f5d58;
  --border: #e2dfd8; --rule: #1b1b1a; --accent: #b4410e; --accent-soft: #f6e7de;
  --green: #2f6b3a; --amber: #8a5a00; --red: #b42318; --link: #1f4fa3;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151514; --bg-soft: #1d1d1b; --bg-code: #1d1d1b; --fg: #ecebe7; --muted: #a3a09a;
    --border: #2f2e2b; --rule: #ecebe7; --accent: #f08a4b; --accent-soft: #33231a;
    --green: #7cc28a; --amber: #e0b04a; --red: #f08178; --link: #8fb3f2;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 17px/1.6 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--link) 40%, transparent); }
a:hover { text-decoration-color: currentColor; }
img { max-width: 100%; }
code { overflow-wrap: anywhere; font-family: var(--mono); font-size: .84em; background: var(--bg-code); padding: .1em .35em; border-radius: 3px; }
pre { position: relative; margin: 16px 0 22px; padding: 16px 18px; background: var(--bg-code); border-radius: 4px; overflow-x: auto; font: 13.5px/1.65 var(--mono); }
pre code { background: none; padding: 0; font-size: inherit; overflow-wrap: normal; }
.copy { position: absolute; top: 8px; right: 8px; font: 12px var(--sans); padding: 3px 8px; border-radius: 3px; border: 1px solid var(--border); background: var(--bg); color: var(--muted); cursor: pointer; opacity: 0; transition: opacity .15s; }
pre:hover .copy, .copy:focus { opacity: 1; }
.c { color: var(--muted); }
.k { color: var(--fg); font-weight: 600; }
.s { color: var(--green); }

/* Top bar */
header.top { position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--border); }
header.top .inner { max-width: 1120px; margin: 0 auto; padding: 14px 32px; display: flex; align-items: baseline; gap: 28px; }
.brand { font: 700 17px var(--mono); color: var(--fg); text-decoration: none; letter-spacing: -.02em; }
.brand .name span { color: var(--accent); }
.brand .logo { display: none; }
header.top nav { margin-left: auto; display: flex; gap: 24px; font-size: 15px; }
header.top nav a { color: var(--muted); text-decoration: none; }
header.top nav a:hover { color: var(--fg); }
header.top nav a.here { color: var(--fg); }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 32px; }

/* Opening */
.hero { padding: 72px 0 24px; }
.hero h1 { font-size: clamp(34px, 4.6vw, 52px); line-height: 1.08; letter-spacing: -.03em; font-weight: 700; margin: 0 0 20px; max-width: 820px; }
.hero p.lead { font-size: 20px; line-height: 1.5; color: var(--muted); margin: 0 0 28px; max-width: 640px; }
.hero pre { max-width: 820px; }

/* Sections: a heavy rule and a left-aligned heading, nothing else */
section.block { padding: 64px 0 0; }
section.block > .wrap > h2:first-child, section.block h2.head { border-top: 2px solid var(--rule); padding-top: 18px; }
h2 { font-size: clamp(26px, 3vw, 32px); letter-spacing: -.02em; line-height: 1.2; margin: 0 0 12px; font-weight: 700; }
h3 { font-size: 20px; margin: 32px 0 6px; letter-spacing: -.01em; }
p { margin: 10px 0; }
.sub { color: var(--muted); margin-top: 0; font-size: 18px; max-width: 680px; }
.kicker { font: 600 12px var(--mono); letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.measure { max-width: 680px; }

/* Video player */
.player { margin: 36px 0 0; }
.screen { position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: #111; border: 1px solid var(--border); }
.controls { display: flex; align-items: center; gap: 14px; margin-top: 10px; }
.controls button.play { width: 34px; height: 34px; border: 1px solid var(--rule); background: var(--bg); color: var(--fg); font-size: 12px; cursor: pointer; flex: none; display: grid; place-items: center; border-radius: 0; }
.controls button.play:hover { background: var(--fg); color: var(--bg); }
.timeline { position: relative; flex: 1; height: 4px; background: var(--border); cursor: pointer; display: flex; gap: 2px; }
.timeline .seg { position: relative; height: 100%; background: color-mix(in srgb, var(--muted) 25%, transparent); overflow: hidden; }
.timeline .seg i { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); }
.controls .time { font: 12.5px var(--mono); color: var(--muted); min-width: 84px; text-align: right; }
.chapters { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 10px; font-size: 14px; }
.chapters button { font: inherit; color: var(--muted); background: none; border: 0; padding: 2px 0; cursor: pointer; border-bottom: 1px solid transparent; }
.chapters button:hover { color: var(--fg); }
.chapters button.on { color: var(--fg); border-bottom-color: var(--accent); }
.player .note { font-size: 14px; color: var(--muted); margin-top: 12px; }

/* The pipeline, drawn as text */
.pipeline { display: flex; flex-wrap: wrap; align-items: stretch; margin: 28px 0 20px; border: 1px solid var(--border); }
.pipeline div { flex: 1 1 160px; padding: 14px 16px; border-right: 1px solid var(--border); position: relative; }
.pipeline div:last-child { border-right: 0; }
.pipeline b { display: block; font: 600 13px var(--mono); margin-bottom: 4px; }
.pipeline span { display: block; color: var(--muted); font-size: 14px; line-height: 1.45; }
.pipeline div:not(:last-child)::after { content: "→"; position: absolute; right: -8px; top: 12px; background: var(--bg); color: var(--muted); font-size: 13px; line-height: 1; padding: 2px 0; }

/* Two-column lists */
.cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px; margin-top: 20px; }
.cols h3 { margin-top: 0; font-size: 17px; }
.cols p { color: var(--muted); margin: 0; font-size: 16px; }

ol.cells { list-style: none; counter-reset: c; padding: 0; margin: 22px 0 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--border); }
ol.cells li { counter-increment: c; padding: 14px 18px 0 0; }
ol.cells li::before { content: counter(c); font: 600 13px var(--mono); color: var(--accent); display: block; margin-bottom: 2px; }
ol.cells a { color: var(--fg); font-weight: 600; text-decoration: none; }
ol.cells a:hover { text-decoration: underline; }
ol.cells span { display: block; color: var(--muted); font-size: 15px; }

/* Walkthrough rows: text on one side, screenshot on the other */
.row { display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 7fr); gap: 48px; align-items: start; padding: 40px 0; border-top: 1px solid var(--border); }
.row .text { position: sticky; top: 88px; }
.row .num { font: 600 12px var(--mono); text-transform: uppercase; letter-spacing: .04em; color: var(--accent); }
.row h3 { margin: 4px 0 10px; font-size: 22px; }
.row p { color: var(--muted); font-size: 16px; }
.row p b { color: var(--fg); font-weight: 600; }
.shot { margin: 0; }
.shot a { display: block; border: 1px solid var(--border); overflow: hidden; background: var(--bg); }
.shot img { display: block; width: 100%; height: auto; }
.shot.tall a { max-height: 620px; position: relative; }
.shot.tall a::after { content: "Open full size"; position: absolute; inset: auto 0 0; padding: 48px 0 12px; text-align: center; font: 13px var(--sans); color: var(--fg); background: linear-gradient(transparent, var(--bg) 75%); }
figcaption { font-size: 14px; color: var(--muted); margin-top: 8px; }
.shot + .shot { margin-top: 20px; }

/* Tabs */
.tabs { margin-top: 20px; }
.tablist { display: flex; gap: 24px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.tablist button { font: 15px var(--sans); color: var(--muted); background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 0; cursor: pointer; margin-bottom: -1px; }
.tablist button[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); }
.tabpanel[hidden] { display: none; }
.tabpanel .row { border-top: 0; }

/* Callouts, badges, tables */
.callout { padding: 2px 0 2px 16px; border-left: 3px solid var(--border); margin: 18px 0; font-size: 15.5px; color: var(--muted); }
.callout.warn { border-left-color: var(--amber); }
.callout.good { border-left-color: var(--green); }
.callout b { color: var(--fg); }
.legend { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 16px; margin: 14px 0; font-size: 14.5px; }
.legend div { display: flex; gap: 10px; align-items: baseline; color: var(--muted); }
.badge { display: inline-block; font: 600 11px var(--mono); letter-spacing: .02em; text-transform: uppercase; padding: 0 5px; border-radius: 2px; color: var(--c); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent); white-space: nowrap; }
.table-wrap { overflow-x: auto; margin: 14px 0 22px; border-top: 1px solid var(--rule); }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { text-align: left; padding: 10px 14px 10px 0; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font: 600 12px var(--mono); text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
td code { white-space: nowrap; }
details { border-top: 1px solid var(--border); padding: 12px 0; margin: 0; }
details:last-of-type { border-bottom: 1px solid var(--border); }
details summary { cursor: pointer; font-weight: 600; }
details[open] summary { margin-bottom: 8px; }

/* Closing links */
.next { margin-top: 72px; border-top: 2px solid var(--rule); padding-top: 18px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; }
.next a { display: block; color: var(--fg); text-decoration: none; }
.next a b { display: block; font-size: 18px; }
.next a span { color: var(--muted); font-size: 15px; }
.next a:hover b { text-decoration: underline; text-underline-offset: 3px; }

/* Reference page layout: sidebar + content */
.layout { max-width: 1120px; margin: 0 auto; padding: 0 32px; display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 56px; }
aside.toc { position: sticky; top: 64px; align-self: start; padding: 40px 0; max-height: calc(100vh - 64px); overflow-y: auto; font-size: 14.5px; }
aside.toc .label { font: 600 11.5px var(--mono); letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 20px 0 6px; }
aside.toc a { display: block; padding: 3px 0 3px 12px; border-left: 2px solid var(--border); color: var(--muted); text-decoration: none; }
aside.toc a:hover { color: var(--fg); }
aside.toc a.active { color: var(--fg); border-left-color: var(--accent); }
.layout main { padding: 40px 0 80px; min-width: 0; max-width: 820px; }
.layout main h2 { margin-top: 56px; padding-top: 18px; border-top: 2px solid var(--rule); }
.layout main h1 { font-size: 40px; letter-spacing: -.03em; margin: 6px 0 10px; line-height: 1.1; }

footer { max-width: 1120px; margin: 72px auto 0; padding: 20px 32px 48px; color: var(--muted); font-size: 14px; border-top: 1px solid var(--border); }
footer a { color: var(--muted); }

@media (max-width: 960px) {
  .row { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .row .text { position: static; }
  ol.cells { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout { grid-template-columns: minmax(0, 1fr); padding: 0 20px; }
  aside.toc { display: none; }
}
@media (max-width: 640px) {
  .cols, .next, .legend { grid-template-columns: minmax(0, 1fr); }
  .pipeline { flex-direction: column; }
  .pipeline div { border-right: 0; border-bottom: 1px solid var(--border); }
  .pipeline div:not(:last-child)::after { content: "↓"; right: auto; left: 16px; top: auto; bottom: -9px; padding: 0 4px; }
  .wrap, header.top .inner { padding-left: 20px; padding-right: 20px; }
  header.top nav { gap: 16px; }
  header.top nav a.opt { display: none; }
  .controls .time { display: none; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
