/*
 * KPD user guide stylesheet.
 *
 * The look follows the app's About box: a dark, dotted "canvas" header with
 * teal and purple glows, IBM Plex type, role colours from the palettes.
 * Tokens live on :root (light) and are redefined for dark mode.
 * Layout: header / sidebar (site.js builds both) / article / on-this-page.
 */

@font-face { font-family: 'IBM Plex Sans'; font-weight: 400; font-display: swap; src: url('fonts/ibm-plex-sans-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Sans'; font-weight: 500; font-display: swap; src: url('fonts/ibm-plex-sans-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Sans'; font-weight: 600; font-display: swap; src: url('fonts/ibm-plex-sans-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 400; font-display: swap; src: url('fonts/ibm-plex-mono-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 600; font-display: swap; src: url('fonts/ibm-plex-mono-latin-600-normal.woff2') format('woff2'); }

:root {
  --font-ui: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --bg: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-muted: #f1f5f9;
  --text: #0f172a;
  --text-muted: #475569;
  --text-faint: #94a3b8;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --accent-soft: #ccfbf1;
  --link: #0f766e;
  --chrome: #0b1220;
  --chrome-text: #e2e8f0;
  --chrome-muted: #94a3b8;
  --code-bg: #f1f5f9;
  --tip-bg: #f0fdfa;  --tip-border: #14b8a6;
  --note-bg: #eff6ff; --note-border: #3b82f6;
  --warn-bg: #fff7ed; --warn-border: #f97316;

  /* Role colours, as on the canvas. */
  --source: #16a34a; --sink: #c2410c; --topic: #2563eb; --dlq: #dc2626;
  --processing: #7c3aed; --client: #be185d; --governance: #475569;

  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 2px rgb(15 23 42 / 0.06), 0 4px 16px rgb(15 23 42 / 0.06);
  --header-h: 56px;
  --sidebar-w: 272px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0f1623; --bg-subtle: #131c2c; --bg-muted: #1a2436;
    --text: #e2e8f0; --text-muted: #a3b1c6; --text-faint: #64748b;
    --border: #243045; --border-strong: #334155;
    --accent: #2dd4bf; --accent-strong: #5eead4; --accent-soft: #134e4a; --link: #5eead4;
    --code-bg: #1a2436;
    --tip-bg: #0f2a2a; --note-bg: #10203a; --warn-bg: #2a1a0f;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 4px 16px rgb(0 0 0 / 0.25);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #0f1623; --bg-subtle: #131c2c; --bg-muted: #1a2436;
  --text: #e2e8f0; --text-muted: #a3b1c6; --text-faint: #64748b;
  --border: #243045; --border-strong: #334155;
  --accent: #2dd4bf; --accent-strong: #5eead4; --accent-soft: #134e4a; --link: #5eead4;
  --code-bg: #1a2436;
  --tip-bg: #0f2a2a; --note-bg: #10203a; --warn-bg: #2a1a0f;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 4px 16px rgb(0 0 0 / 0.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.65 var(--font-ui); -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* The dotted dark "canvas" used by the header and the home hero (as in the About box). */
.canvas-bg {
  color: var(--chrome-text);
  background:
    radial-gradient(circle at 1px 1px, rgb(148 163 184 / 0.16) 1px, transparent 0) 0 0 / 16px 16px,
    radial-gradient(120% 90% at 0% 0%, rgb(20 184 166 / 0.22), transparent 60%),
    radial-gradient(90% 80% at 100% 100%, rgb(124 58 237 / 0.22), transparent 60%),
    var(--chrome);
}

/* ---- header -------------------------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 20; height: var(--header-h);
  display: flex; align-items: center; gap: 14px; padding: 0 20px;
  border-bottom: 1px solid rgb(255 255 255 / 0.06);
}
.site-header .brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 600; white-space: nowrap; }
.site-header .brand:hover { text-decoration: none; }
.site-header .brand svg { color: #5eead4; flex: none; }
.site-header .brand small { font-weight: 400; color: var(--chrome-muted); }
.site-header .version {
  font-family: var(--font-mono); font-size: 12px; color: #5eead4;
  border: 1px solid rgb(94 234 212 / 0.35); border-radius: 999px; padding: 1px 8px;
}
.site-header .spacer { flex: 1; }
.site-header .head-link { color: var(--chrome-muted); font-size: 13.5px; white-space: nowrap; }
.site-header .head-link:hover { color: #fff; text-decoration: none; }
.icon-btn {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px;
  border: 0; background: transparent; color: var(--chrome-muted); cursor: pointer;
}
.icon-btn:hover { background: rgb(255 255 255 / 0.08); color: #fff; }
.menu-btn { display: none; }

/* ---- layout -------------------------------------------------------------------- */
.layout { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: calc(100vh - var(--header-h)); }
.sidebar {
  position: sticky; top: var(--header-h); height: calc(100vh - var(--header-h)); overflow-y: auto;
  border-right: 1px solid var(--border); background: var(--bg-subtle); padding: 16px 12px 40px;
}
.sidebar .filter {
  width: 100%; padding: 7px 10px; margin-bottom: 14px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--bg); color: var(--text); font: inherit; font-size: 13.5px;
}
.sidebar .filter:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.search-results { margin: -6px 0 14px; }
.sr-note { margin: 0 2px 8px; font-size: 12.5px; color: var(--text-muted); }
.sr {
  display: block; padding: 8px 10px; margin-bottom: 4px; border-radius: var(--radius);
  color: var(--text); font-size: 13px; line-height: 1.4; text-decoration: none; border: 1px solid transparent;
}
.sr:hover, .sr:focus { background: var(--bg); border-color: var(--border); text-decoration: none; outline: none; }
.sr:focus { border-color: var(--accent); }
.sr b { display: block; font-weight: 600; }
.sr-page { display: block; font-size: 11.5px; color: var(--accent); margin-top: 1px; }
.sr-snip { display: block; color: var(--text-muted); margin-top: 3px; font-size: 12.5px; }
.sr mark, mark.hit { background: rgb(250 204 21 / 0.45); color: inherit; border-radius: 2px; padding: 0 1px; }
.search-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0 0 16px; padding: 8px 12px; border-radius: var(--radius); background: var(--bg-subtle);
  border: 1px solid var(--border); font-size: 13.5px; color: var(--text-muted);
}
.search-bar button { border: 1px solid var(--border-strong); background: var(--bg); color: var(--text); border-radius: var(--radius); padding: 3px 10px; font: inherit; font-size: 12.5px; cursor: pointer; }
main.doc h2, main.doc h3 { scroll-margin-top: calc(var(--header-h) + 16px); }
.nav-section { margin-bottom: 14px; }
.nav-section > span,
.nav-head {
  display: block; padding: 0 10px 4px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-faint);
}
.nav-head {
  display: flex; align-items: center; gap: 6px; width: 100%; margin: 0; padding: 4px 10px; border: 0; border-radius: 6px;
  background: none; font-family: inherit; text-align: left; cursor: pointer;
}
.nav-head:hover { color: var(--text); background: var(--bg-muted); }
.nav-head:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.nav-head .chev { flex: none; transition: transform 0.15s ease; }
.nav-section.collapsed { margin-bottom: 4px; }
.nav-section.collapsed .chev { transform: rotate(-90deg); }
.nav-pages[hidden] { display: none; }
.nav-tools { display: flex; gap: 4px; justify-content: flex-end; margin: -4px 0 8px; }
.nav-tools button {
  border: 0; background: none; padding: 2px 6px; border-radius: 5px; font: inherit; font-size: 12px;
  color: var(--text-faint); cursor: pointer;
}
.nav-tools button:hover { color: var(--text); background: var(--bg-muted); }
@media (prefers-reduced-motion: reduce) { .nav-head .chev { transition: none; } }
.nav-section a {
  display: block; padding: 5px 10px; border-radius: 6px; color: var(--text-muted); font-size: 14px; line-height: 1.4;
  border-left: 2px solid transparent;
}
.nav-section a:hover { background: var(--bg-muted); color: var(--text); text-decoration: none; }
.nav-section a.current { color: var(--accent); background: var(--accent-soft); font-weight: 500; border-left-color: var(--accent); border-radius: 0 6px 6px 0; }
.nav-empty { padding: 4px 10px; color: var(--text-faint); font-size: 13px; }
/* Sections and entries under a palette reference page (PALETTE_NAV in site.js). */
.nav-row { display: flex; align-items: flex-start; }
.nav-row > a { flex: 1; min-width: 0; }
.nav-fold {
  flex: none; display: grid; place-items: center; width: 20px; height: 29px; margin-right: -4px; padding: 0; border: 0;
  border-radius: 5px; background: none; color: var(--text-faint); cursor: pointer;
}
.nav-fold:hover { color: var(--text); background: var(--bg-muted); }
.nav-fold:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.nav-fold .chev { transition: transform 0.15s ease; }
.nav-fold[aria-expanded="false"] .chev { transform: rotate(-90deg); }
.nav-groups, .nav-items { margin-left: 16px; border-left: 1px solid var(--border); padding-left: 2px; }
.nav-groups[hidden], .nav-items[hidden] { display: none; }
.nav-groups .nav-fold { height: 25px; }
.nav-section .nav-groups a { font-size: 13px; padding: 3px 8px; }
.nav-section .nav-items a { font-size: 12.5px; padding: 2px 8px; color: var(--text-muted); }
.nav-section .nav-items a:hover { color: var(--text); }
.nav-section .nav-tree a.here { color: var(--accent); background: var(--accent-soft); }
@media (prefers-reduced-motion: reduce) { .nav-fold .chev { transition: none; } }

.content { display: grid; grid-template-columns: minmax(0, 820px) 220px; gap: 40px; padding: 36px 44px 64px; justify-content: start; }
.doc { min-width: 0; }
.toc { position: sticky; top: calc(var(--header-h) + 28px); align-self: start; font-size: 13px; max-height: calc(100vh - var(--header-h) - 56px); overflow-y: auto; }
.toc b { display: block; margin-bottom: 6px; font-size: 11.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-faint); }
.toc a { display: block; padding: 3px 0 3px 10px; color: var(--text-muted); border-left: 2px solid var(--border); }
.toc a:hover { color: var(--text); text-decoration: none; }
.toc a.active { color: var(--accent); border-left-color: var(--accent); }

/* ---- article typography ---------------------------------------------------------- */
.doc .crumb { font-size: 13px; color: var(--text-faint); margin-bottom: 6px; }
.doc h1 { font-size: 34px; line-height: 1.2; margin: 0 0 10px; letter-spacing: -0.01em; }
.doc .lead { font-size: 17.5px; color: var(--text-muted); margin: 0 0 26px; }
.doc h2 { font-size: 22px; margin: 40px 0 10px; padding-top: 6px; letter-spacing: -0.005em; }
.doc h3 { font-size: 17px; margin: 28px 0 6px; }
.doc h2 a.anchor, .doc h3 a.anchor { margin-left: 8px; color: var(--text-faint); opacity: 0; font-weight: 400; }
.doc h2:hover a.anchor, .doc h3:hover a.anchor { opacity: 1; }
.doc p, .doc li { color: var(--text); }
.doc ul, .doc ol { padding-left: 22px; }
.doc li { margin: 4px 0; }
.doc code { font-family: var(--font-mono); font-size: 0.86em; background: var(--code-bg); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; }
.doc pre { background: var(--chrome); color: #e2e8f0; border-radius: var(--radius); padding: 14px 16px; overflow-x: auto; font-size: 13.5px; line-height: 1.55; }
.doc pre code { background: none; border: 0; padding: 0; color: inherit; font-size: inherit; }
.doc kbd {
  font-family: var(--font-mono); font-size: 0.82em; padding: 1px 6px; border-radius: 5px;
  border: 1px solid var(--border-strong); border-bottom-width: 2px; background: var(--bg); white-space: nowrap;
}
.doc .ui { font-weight: 600; }
.doc .hint { color: var(--text-muted); font-size: 14px; }
.doc table { width: 100%; border-collapse: collapse; margin: 14px 0 22px; font-size: 14px; }
.doc th, .doc td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.doc th { font-weight: 600; background: var(--bg-subtle); border-bottom-color: var(--border-strong); }
.table-wrap { overflow-x: auto; }

/* Palette reference (generated by scripts/build-palette-docs.ts). */
.doc .pal-kind { margin: -6px 0 8px; font-size: 13px; color: var(--text-faint); }
.doc .pal-pic { margin: 6px 0 10px; }
.doc .pal-pic img { display: block; max-width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--border); }
.doc .pal-links { font-size: 14px; color: var(--text-muted); }
.doc .pal-links > span { display: inline-block; min-width: 92px; font-weight: 600; color: var(--text); }
.doc .pal-docs { font-size: 14px; }
.doc .pal-docs a::after { content: ' \2197'; }
.doc .muted { color: var(--text-faint); }

.doc figure { margin: 18px 0 26px; }
.doc figure img { display: block; border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); background: #fff; }
.doc figcaption { margin-top: 8px; font-size: 13px; color: var(--text-muted); }

.callout { margin: 18px 0; padding: 12px 16px; border-radius: var(--radius); border-left: 4px solid; font-size: 14.5px; }
.callout > :first-child { margin-top: 0; } .callout > :last-child { margin-bottom: 0; }
.callout b:first-child { display: block; margin-bottom: 2px; }
.callout.tip { background: var(--tip-bg); border-color: var(--tip-border); }
.callout.note { background: var(--note-bg); border-color: var(--note-border); }
.callout.warn { background: var(--warn-bg); border-color: var(--warn-border); }

.steps { counter-reset: step; list-style: none; padding-left: 0; }
.steps > li { position: relative; padding-left: 42px; margin: 14px 0; }
.steps > li::before {
  counter-increment: step; content: counter(step); position: absolute; left: 0; top: 1px;
  width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 14px;
}

/* Cards (the About box's principles). */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin: 18px 0 26px; }
.card {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: 1px solid var(--border);
  border-radius: var(--radius-lg); background: var(--bg-subtle); color: inherit;
}
a.card:hover { text-decoration: none; border-color: var(--accent); box-shadow: var(--shadow); }
.card .ico { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); }
.card b { display: block; font-size: 14.5px; color: var(--text); }
.card p { margin: 3px 0 0; font-size: 13.5px; color: var(--text-muted); line-height: 1.5; }

/* Role colour chips, as on the canvas. */
.chip { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.chip i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 56px; padding-top: 20px; border-top: 1px solid var(--border); }
.pager a { display: flex; flex-direction: column; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius); max-width: 48%; }
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager small { color: var(--text-faint); font-size: 12px; }
.pager .next { margin-left: auto; text-align: right; }

.site-footer { padding: 26px 44px; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 13px; background: var(--bg-subtle); }
.site-footer b { color: var(--text); }

/* ---- home hero ------------------------------------------------------------------- */
.hero { border-radius: var(--radius-lg); padding: 30px 30px 24px; margin: 0 0 30px; overflow: hidden; }
.hero h1 { color: #fff; font-size: 38px; margin: 0; }
.hero .tag { color: var(--chrome-muted); font-size: 17px; margin: 6px 0 18px; }
.hero .version { font-family: var(--font-mono); font-size: 13px; color: #5eead4; margin-left: 10px; vertical-align: middle; }
.hero svg { display: block; width: 100%; height: auto; margin: 6px 0 12px; }
.hero .actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 8px; font-weight: 500; font-size: 14.5px; border: 1px solid transparent; }
.btn:hover { text-decoration: none; }
.btn.primary { background: #14b8a6; color: #04201d; }
.btn.primary:hover { background: #2dd4bf; }
.btn.ghost { color: #e2e8f0; border-color: rgb(226 232 240 / 0.25); }
.btn.ghost:hover { border-color: #e2e8f0; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 0 0 26px; }
.stat { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-subtle); }
.stat b { display: block; font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12.5px; color: var(--text-muted); }

/* Hero pipeline (same idea as the About box): nodes, wires and moving records. */
.hp-node { fill: #111a2b; stroke-width: 1.5; }
.hp-label { fill: #e2e8f0; font: 600 11px var(--font-mono); }
.hp-sub { fill: #94a3b8; font: 10px var(--font-ui); }
.hp-wire { stroke: #64748b; stroke-width: 1.5; fill: none; }
.hp-err { stroke: #ef4444; stroke-width: 1.5; stroke-dasharray: 5 4; fill: none; }
@media (prefers-reduced-motion: reduce) { .hero svg .dots { display: none; } }

/* Author card (About page). */
.author { display: flex; gap: 18px; align-items: center; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-subtle); margin: 16px 0 24px; }
.author img { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--accent); }
.author b { font-size: 18px; }
.author p { margin: 2px 0; color: var(--text-muted); }

/* Change history. */
.release { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.release .v { font-family: var(--font-mono); font-weight: 600; color: var(--accent); }
.release .d { display: block; font-size: 12.5px; color: var(--text-faint); font-family: var(--font-ui); font-weight: 400; }
.release b { display: block; }
.release ul { margin: 6px 0 0; }
.release p { margin: 4px 0 0; color: var(--text-muted); }

/* ---- design size chart (design-size.html) ------------------------------------------ */
.size-chart { margin: 14px 0 6px; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.size-row { display: grid; grid-template-columns: 130px minmax(120px, 1fr) minmax(0, 1.6fr); gap: 14px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--border); font-size: 14px; }
.size-row:first-child { border-top: 0; }
.size-n { font-weight: 600; }
.size-bar { position: relative; display: flex; align-items: center; gap: 8px; }
.size-bar i { display: block; height: 12px; width: var(--w); min-width: 6px; border-radius: 6px; background: var(--c); }
.size-bar b { font-family: var(--font-mono); font-size: 13px; font-weight: 600; white-space: nowrap; }
.size-say { color: var(--text-muted); }
.size-row.ok { --c: #14b8a6; }
.size-row.slow { --c: #f59e0b; }
.size-row.bad { --c: #ef4444; }
.size-note { font-size: 13px; color: var(--text-faint); }
@media (max-width: 640px) {
  .size-row { grid-template-columns: minmax(0, 1fr); gap: 4px; }
}

/* ---- small screens --------------------------------------------------------------- */
@media (max-width: 1180px) {
  .content { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: grid; }
  .sidebar { position: fixed; top: var(--header-h); left: 0; z-index: 15; width: min(86vw, 320px); transform: translateX(-100%); transition: transform 0.18s ease; box-shadow: var(--shadow); }
  body.nav-open .sidebar { transform: none; }
  .content { padding: 24px 16px 48px; }
  .site-header { padding: 0 10px; gap: 8px; }
  .site-header .head-link, .site-header .brand small { display: none; }
  .site-footer { padding: 20px 16px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .release { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .doc h1 { font-size: 28px; }
  .hero { padding: 22px 18px 18px; }
  .hero h1 { font-size: 30px; }
}
@media print {
  .site-header, .sidebar, .toc, .pager { display: none !important; }
  .layout, .content { display: block; padding: 0; }
}
