/* Draughtsman documentation. One stylesheet, no external requests.
   Brand: Overpass red #e04832 (decoration, large type) and #c0392b where text sits on it or red is text on white;
   navy #151e33 for text and the dark theme (never pure black). Light and dark follow prefers-color-scheme. */

@font-face {
  font-family: "Inter";
  src: url("fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --bg-soft: #f4f6fa;
  --bg-sunk: #eceff5;
  --ink: #151e33;
  --ink-soft: #4a5468;
  --line: #d6dae4;
  --link: #c0392b;
  --link-hover: #8f2a1f;
  --accent: #e04832;
  --on-brand: #ffffff;
  --brand-solid: #c0392b;
  --code-bg: #f4f6fa;
  --ok-bg: #e7f4ea;
  --ok-ink: #14532d;
  --warn-bg: #fff4d6;
  --warn-ink: #5c3b00;
  --note-bg: #eef2fb;
  --focus: #151e33;
  --paper: #ffffff;
  --shadow: 0 1px 2px rgba(21, 30, 51, 0.08), 0 6px 20px rgba(21, 30, 51, 0.06);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --header-h: 64px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151e33;
    --bg-soft: #1b2540;
    --bg-sunk: #101829;
    --ink: #f2f2f2;
    --ink-soft: #aab3c5;
    --line: #2e3b56;
    --link: #ff8a78;
    --link-hover: #ffb3a6;
    --accent: #e04832;
    --code-bg: #101829;
    --ok-bg: #12301f;
    --ok-ink: #a6e3b9;
    --warn-bg: #3a2c0b;
    --warn-ink: #ffd98a;
    --note-bg: #1d2a4a;
    --focus: #f2f2f2;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
  }
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--header-h) + 16px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.65;
  font-feature-settings: "cv11", "ss03";
}
img, svg, video { max-width: 100%; height: auto; }

/* ---------- Skip link and focus ---------- */
.skip-link {
  position: absolute; left: 8px; top: -64px; z-index: 100;
  background: var(--brand-solid); color: var(--on-brand);
  padding: 10px 16px; border-radius: 6px; font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: 8px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50; height: var(--header-h);
  display: flex; align-items: center; gap: 16px; padding: 0 16px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.site-header::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: linear-gradient(90deg, var(--accent), transparent 40%); opacity: .9; pointer-events: none; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; letter-spacing: -0.01em; min-width: 0; }
.brand picture { display: flex; flex: none; }
.brand img { display: block; height: 48px; width: auto; }
.brand .logo-mark { display: none; }
.brand .brand-sub { font-weight: 500; color: var(--ink-soft); padding-left: 10px; border-left: 1px solid var(--line); white-space: nowrap; }
.header-spacer { flex: 1; }
.header-link { color: var(--ink); text-decoration: none; font-size: .9rem; font-weight: 500; padding: 6px 8px; border-radius: 6px; }
.header-link:hover { background: var(--bg-soft); }
.nav-toggle {
  display: none; align-items: center; gap: 8px; font: inherit; font-weight: 600; font-size: .9rem;
  background: var(--bg-soft); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; cursor: pointer;
}
.nav-toggle .bars { width: 16px; height: 2px; background: currentColor; position: relative; display: inline-block; }
.nav-toggle .bars::before, .nav-toggle .bars::after { content: ""; position: absolute; left: 0; width: 16px; height: 2px; background: currentColor; }
.nav-toggle .bars::before { top: -5px; } .nav-toggle .bars::after { top: 5px; }

/* ---------- Page grid ---------- */
.layout {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr) 230px;
  gap: 0 40px;
  max-width: 1400px; margin: 0 auto; padding: 0 24px;
}
.sidebar {
  position: sticky; top: var(--header-h); align-self: start;
  max-height: calc(100vh - var(--header-h)); overflow-y: auto;
  padding: 24px 8px 32px 0; font-size: .93rem;
}
.sidebar h2 { font-size: .74rem; text-transform: uppercase; letter-spacing: .09em; color: var(--ink-soft); margin: 22px 0 6px; font-weight: 700; }
.sidebar h2:first-child { margin-top: 0; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li a {
  display: block; padding: 5px 10px; margin: 1px 0; border-radius: 6px; color: var(--ink); text-decoration: none; border-left: 3px solid transparent;
}
.sidebar li a:hover { background: var(--bg-soft); }
.sidebar li a[aria-current="page"] { background: var(--bg-soft); font-weight: 650; border-left-color: var(--accent); }

main { padding: 32px 0 64px; min-width: 0; }
.toc-col { position: sticky; top: var(--header-h); align-self: start; max-height: calc(100vh - var(--header-h)); overflow-y: auto; padding: 32px 0; font-size: .86rem; }
.toc-col h2 { font-size: .74rem; text-transform: uppercase; letter-spacing: .09em; color: var(--ink-soft); margin: 0 0 8px; font-weight: 700; }
.toc-col ol, .toc-col ul { list-style: none; padding: 0; margin: 0; }
.toc-col li a { display: block; padding: 3px 0 3px 12px; color: var(--ink-soft); text-decoration: none; border-left: 2px solid var(--line); line-height: 1.4; }
.toc-col li.sub a { padding-left: 26px; }
.toc-col li a:hover { color: var(--ink); }
.toc-col li a[aria-current="true"] { color: var(--ink); border-left-color: var(--accent); font-weight: 600; }
.toc-col:empty { display: none; }

/* ---------- Prose ---------- */
.prose { max-width: 760px; }
.prose > :first-child { margin-top: 0; }
.eyebrow { font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; color: var(--link); margin: 0 0 6px; }
h1 { font-size: 2.15rem; line-height: 1.2; letter-spacing: -0.02em; margin: 0 0 12px; font-weight: 750; }
.lede { font-size: 1.15rem; color: var(--ink-soft); margin: 0 0 24px; line-height: 1.55; }
h2 { font-size: 1.5rem; line-height: 1.3; letter-spacing: -0.015em; margin: 2.4em 0 .6em; font-weight: 700; padding-top: .4em; border-top: 1px solid var(--line); }
h2:first-of-type { }
h3 { font-size: 1.15rem; line-height: 1.35; margin: 1.8em 0 .4em; font-weight: 650; }
h4 { font-size: 1rem; margin: 1.4em 0 .3em; font-weight: 650; }
h2 .anchor, h3 .anchor { margin-left: .4em; font-weight: 400; color: var(--ink-soft); text-decoration: none; opacity: 0; font-size: .85em; }
h2:hover .anchor, h3:hover .anchor, .anchor:focus { opacity: 1; }
p, ul, ol, dl, table, pre, figure, details, .callout { margin: 0 0 1.1em; }
ul, ol { padding-left: 1.4em; }
li { margin: .25em 0; }
li > ul, li > ol { margin: .25em 0; }
a { color: var(--link); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--link-hover); text-decoration-thickness: 2px; }
a.ext::after { content: " (external)"; font-size: .8em; color: var(--ink-soft); }
strong { font-weight: 650; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }

code, kbd, samp { font-family: var(--mono); font-size: .88em; font-variant-ligatures: none; }
:not(pre) > code { background: var(--code-bg); border: 1px solid var(--line); border-radius: 5px; padding: .08em .35em; overflow-wrap: anywhere; }
kbd { background: var(--bg-soft); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: .05em .4em; white-space: nowrap; }
pre {
  background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px;
  overflow-x: auto; line-height: 1.5; font-size: .86rem; tab-size: 2;
}
pre code { font-size: inherit; background: none; border: 0; padding: 0; }
pre.output { border-left: 4px solid var(--accent); }
.pre-label { display: block; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); font-weight: 700; margin: 0 0 4px; }

/* Tables: wrapped in .table-wrap so they scroll instead of breaking the page */
.table-wrap { overflow-x: auto; margin: 0 0 1.2em; border: 1px solid var(--line); border-radius: 8px; }
.table-wrap:focus-visible { outline: 3px solid var(--focus); }
table { border-collapse: collapse; width: 100%; font-size: .93rem; margin: 0; }
th, td { text-align: left; vertical-align: top; padding: 9px 12px; border-bottom: 1px solid var(--line); }
th { background: var(--bg-soft); font-weight: 650; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td code, th code { white-space: normal; }

/* Callouts and badges */
.callout { border-left: 4px solid var(--accent); background: var(--note-bg); border-radius: 0 8px 8px 0; padding: 12px 16px; }
.callout > :last-child { margin-bottom: 0; }
.callout .callout-title { display: block; font-weight: 700; margin-bottom: 4px; }
.callout.warn { background: var(--warn-bg); color: var(--warn-ink); border-left-color: #b7791f; }
.callout.warn a { color: inherit; }
.callout.ok { background: var(--ok-bg); color: var(--ok-ink); border-left-color: #2f855a; }
.badge { display: inline-block; font-size: .74rem; font-weight: 700; letter-spacing: .03em; padding: 1px 9px; border-radius: 999px; vertical-align: middle; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok-ink); }
.badge.warn { background: var(--warn-bg); color: var(--warn-ink); }
.badge.no { background: var(--bg-sunk); color: var(--ink-soft); border: 1px solid var(--line); }

/* Steps */
ol.steps { list-style: none; counter-reset: step; padding-left: 0; }
ol.steps > li { counter-increment: step; position: relative; padding-left: 44px; margin: 0 0 1.2em; }
ol.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: 0; width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand-solid); color: var(--on-brand); font-weight: 700; display: grid; place-items: center; font-size: .9rem;
}
ol.steps > li > :last-child { margin-bottom: 0; }
ol.steps > li > h2, ol.steps > li > h3 { border: 0; margin: 0 0 .5em; padding: 0; font-size: 1.15rem; line-height: 1.35; letter-spacing: 0; }

/* Figures */
figure { margin: 1.6em 0; }
figure img { display: block; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); background: var(--paper); }
figure.diagram img { background: #ffffff; padding: 8px; }
figure.hero img { box-shadow: none; border-radius: 12px; }
figcaption { font-size: .86rem; color: var(--ink-soft); margin-top: 8px; line-height: 1.5; }
.fig-links { font-size: .86rem; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin: 0 0 1.4em; padding: 0; list-style: none; }
.cards li { margin: 0; }
.card { display: block; height: 100%; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-soft); color: var(--ink); text-decoration: none; }
.card:hover { border-color: var(--accent); }
.card strong { display: block; margin-bottom: 4px; color: var(--link); }
.card span { font-size: .9rem; color: var(--ink-soft); display: block; line-height: 1.45; }

/* Page footer */
.pager { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 3em; padding-top: 1.2em; border-top: 1px solid var(--line); }
.pager a { display: block; padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; min-width: 190px; }
.pager a:hover { border-color: var(--accent); }
.pager small { display: block; color: var(--ink-soft); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
.pager .next { margin-left: auto; text-align: right; }
.site-footer { border-top: 1px solid var(--line); background: var(--bg-soft); padding: 24px; font-size: .88rem; color: var(--ink-soft); }
.site-footer .inner { max-width: 1400px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 8px 28px; justify-content: space-between; }
.site-footer a { color: var(--ink-soft); }
.site-footer a:hover { color: var(--ink); }
.site-footer .footer-brand { flex: 0 0 100%; display: block; line-height: 0; }
.site-footer .footer-brand picture { display: inline-block; }
.site-footer .footer-brand img { display: block; height: 40px; width: auto; margin-left: -5px; } /* the artwork has a little built-in margin; this lines the compass up with the text below */

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .layout { grid-template-columns: 250px minmax(0, 1fr); }
  .toc-col { display: none; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 0 16px; }
  .nav-toggle { display: inline-flex; }
  .brand .brand-sub { display: none; }
  .brand img { height: 40px; }
  .header-link { display: none; }
  .sidebar { position: static; max-height: none; overflow: visible; padding: 16px 0 0; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
  .js .sidebar { display: none; position: fixed; z-index: 40; inset: var(--header-h) 0 0 0; background: var(--bg); padding: 16px; margin: 0; overflow-y: auto; max-height: none; border: 0; }
  .js.nav-open .sidebar { display: block; }
  .js.nav-open body { overflow: hidden; }
  .nav-toggle { display: none; }
  .js .nav-toggle { display: inline-flex; }
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.3rem; }
  main { padding-top: 20px; }
  .pager a { min-width: 0; flex: 1 1 100%; }
  .pager .next { text-align: left; margin-left: 0; }
}
/* Very narrow phones: the compass alone, so the Menu button is never squeezed. */
@media (max-width: 359px) {
  .brand .logo-wide { display: none; }
  .brand .logo-mark { display: flex; }
  .brand img { height: 36px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
@media print {
  .site-header, .sidebar, .toc-col, .pager, .skip-link, .nav-toggle { display: none !important; }
  .layout { display: block; padding: 0; }
  body { background: #fff; color: #000; }
}
