/* Fleet handbook — static docs theme. No web fonts, no framework. */

:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --bg-code: #f2f4f7;
  --fg: #1d2330;
  --fg-muted: #5b6475;
  --border: #e2e6ec;
  --accent: #0f6f8f;
  --accent-soft: #e6f3f7;
  --note: #2463b8;
  --note-bg: #edf4fd;
  --warn: #a35a00;
  --warn-bg: #fdf4e6;
  --open: #7b4bb3;
  --open-bg: #f4eefb;
  --mark: #fff1a8;
  --shadow: 0 6px 24px rgba(20, 30, 50, .12);
  --topbar-h: 56px;
  --sidebar-w: 272px;
  --toc-w: 220px;
  --measure: 72ch;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161d;
    --bg-soft: #181d26;
    --bg-code: #1e2430;
    --fg: #dfe4ec;
    --fg-muted: #98a2b3;
    --border: #2a313d;
    --accent: #5cc0dd;
    --accent-soft: #15303a;
    --note: #7fb0f0;
    --note-bg: #16253a;
    --warn: #f0b660;
    --warn-bg: #2f2414;
    --open: #c3a2ee;
    --open-bg: #261d33;
    --mark: #5a4d10;
    --shadow: 0 6px 24px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #12161d;
  --bg-soft: #181d26;
  --bg-code: #1e2430;
  --fg: #dfe4ec;
  --fg-muted: #98a2b3;
  --border: #2a313d;
  --accent: #5cc0dd;
  --accent-soft: #15303a;
  --note: #7fb0f0;
  --note-bg: #16253a;
  --warn: #f0b660;
  --warn-bg: #2f2414;
  --open: #c3a2ee;
  --open-bg: #261d33;
  --mark: #5a4d10;
  --shadow: 0 6px 24px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 16px); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
code, pre, kbd { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; }

.skip { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--bg); padding: 8px 12px; }
.skip:focus { left: 8px; }

/* --- top bar -------------------------------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 650; color: var(--fg); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.edition {
  font-size: 12px; font-weight: 600; letter-spacing: .02em; white-space: nowrap;
  color: var(--open); background: var(--open-bg); border-radius: 999px; padding: 2px 9px;
}
.nav-toggle, .theme-toggle {
  flex: none; width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--fg); font-size: 18px; cursor: pointer;
}
.nav-toggle { display: none; }
.theme-toggle { margin-left: 4px; }
.nav-toggle:hover, .theme-toggle:hover { background: var(--bg-soft); }

.search { position: relative; margin-left: auto; width: min(380px, 40vw); }
.search input {
  width: 100%; height: 40px; padding: 0 34px 0 12px;
  font: inherit; font-size: 15px; color: var(--fg);
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px;
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: var(--bg); }
.search-key {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-size: 12px; color: var(--fg-muted); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px;
}
.search input:focus + .search-key, .search input:not(:placeholder-shown) + .search-key { display: none; }
.search-results {
  position: absolute; right: 0; top: calc(100% + 6px); width: min(560px, 92vw);
  max-height: 70vh; overflow-y: auto;
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
  padding: 6px;
}
.search-results a {
  display: block; padding: 8px 10px; border-radius: 6px; color: var(--fg); text-decoration: none;
}
.search-results a:hover, .search-results a.active { background: var(--accent-soft); }
.search-results .r-title { font-weight: 600; color: var(--accent); }
.search-results .r-where { font-size: 12px; color: var(--fg-muted); }
.search-results .r-snip { font-size: 14px; color: var(--fg-muted); display: block; margin-top: 2px; }
.search-results mark { background: var(--mark); color: inherit; border-radius: 2px; }
.search-results .r-empty { padding: 10px; color: var(--fg-muted); font-size: 14px; }

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

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  max-width: 1440px; margin: 0 auto;
}

.sidebar {
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h)); overflow-y: auto;
  padding: 20px 14px 40px 16px;
  border-right: 1px solid var(--border);
  font-size: 14.5px;
}
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar a, .sidebar .empty span {
  display: block; padding: 5px 10px; border-radius: 6px; color: var(--fg); text-decoration: none; line-height: 1.35;
}
.sidebar a:hover { background: var(--bg-soft); }
.sidebar a.current { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidebar .nav-home { font-weight: 600; margin-bottom: 8px; }
.sidebar .nav-domains > li { margin: 1px 0; }
.sidebar .nav-domains > li.open > a { font-weight: 600; }
.sidebar .empty span { color: var(--fg-muted); opacity: .7; }
.sidebar .nav-group {
  margin: 10px 0 2px 10px; font-size: 11.5px; font-weight: 650; letter-spacing: .06em;
  text-transform: uppercase; color: var(--fg-muted);
}
.sidebar .nav-pages { margin-left: 10px; border-left: 1px solid var(--border); padding-left: 4px; }
.sidebar .nav-pages a { font-size: 14px; }

.content { min-width: 0; padding: 28px 40px 64px; }
.content:focus { outline: none; }
.content > * { max-width: var(--measure); }

.toc {
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h)); overflow-y: auto;
  padding: 28px 16px; font-size: 13.5px;
}
.toc-title { margin: 0 0 6px; font-size: 11.5px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--fg-muted); }
.toc ul, .toc-inline ul { list-style: none; margin: 0; padding: 0; }
.toc a, .toc-inline a { display: block; padding: 3px 0 3px 10px; color: var(--fg-muted); text-decoration: none; border-left: 2px solid transparent; line-height: 1.35; }
.toc a:hover, .toc-inline a:hover { color: var(--accent); }
.toc a.active { color: var(--accent); border-left-color: var(--accent); }
.toc .toc-h3 a, .toc-inline .toc-h3 a { padding-left: 22px; }
.toc-inline { display: none; margin: 0 0 20px; border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; font-size: 14px; }
.toc-inline summary { cursor: pointer; font-weight: 600; }
.toc-inline .toc-title { display: none; }

.crumbs { font-size: 13.5px; color: var(--fg-muted); margin-bottom: 18px; }
.crumbs a { color: var(--fg-muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }

/* --- prose ---------------------------------------------------------------------------- */

.prose h1 { font-size: 2rem; line-height: 1.25; margin: 0 0 10px; letter-spacing: -.01em; }
.prose h2 { font-size: 1.4rem; line-height: 1.3; margin: 2.2em 0 .6em; padding-bottom: .25em; border-bottom: 1px solid var(--border); }
.prose h3 { font-size: 1.12rem; margin: 1.8em 0 .5em; }
.prose h2, .prose h3 { position: relative; }
.prose .anchor { margin-left: 8px; color: var(--fg-muted); text-decoration: none; opacity: 0; font-weight: 400; }
.prose h2:hover .anchor, .prose h3:hover .anchor, .prose .anchor:focus { opacity: 1; }
.prose p, .prose ul, .prose ol { margin: 0 0 1em; }
.prose ul, .prose ol { padding-left: 1.5em; }
.prose li { margin: .25em 0; }
.prose li > ul, .prose li > ol { margin: .25em 0 .4em; }
.prose code { font-size: .88em; background: var(--bg-code); padding: .12em .38em; border-radius: 4px; overflow-wrap: anywhere; }
.prose pre {
  background: var(--bg-code); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; overflow-x: auto; font-size: 13.5px; line-height: 1.5; margin: 0 0 1.2em;
}
.prose pre code { background: none; padding: 0; font-size: inherit; overflow-wrap: normal; }
.prose blockquote { margin: 0 0 1.2em; padding: 2px 16px; border-left: 3px solid var(--border); color: var(--fg-muted); }
.prose blockquote.lead { border: 0; padding: 0; font-size: 1.12rem; color: var(--fg-muted); margin-bottom: 1.6em; }
.prose blockquote > :last-child, .callout > :last-child { margin-bottom: 0; }

.page-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 14px !important; font-size: 13.5px; color: var(--fg-muted); }
.tag { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 1px 9px; background: var(--bg-soft); border: 1px solid var(--border); color: var(--fg-muted); white-space: nowrap; vertical-align: middle; }
.tag-howto { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.tag-internal { color: var(--open); background: var(--open-bg); border-color: transparent; }

.callout { margin: 0 0 1.2em; padding: 12px 16px; border-radius: 8px; border-left: 4px solid var(--note); background: var(--note-bg); }
.callout.note, .callout.tip { border-color: var(--note); background: var(--note-bg); }
.callout.warning, .callout.important { border-color: var(--warn); background: var(--warn-bg); }
.callout.warning > p:first-child strong:first-child, .callout.important > p:first-child strong:first-child { color: var(--warn); }
.callout.note > p:first-child strong:first-child, .callout.tip > p:first-child strong:first-child { color: var(--note); }
.callout.open-q { border-color: var(--open); background: var(--open-bg); }
.callout.open-q strong { color: var(--open); }

.table-wrap { overflow-x: auto; margin: 0 0 1.3em; border: 1px solid var(--border); border-radius: 8px; }
.prose table { border-collapse: collapse; width: 100%; font-size: 14.5px; line-height: 1.5; }
.prose th, .prose td { padding: 8px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.prose th { background: var(--bg-soft); font-weight: 650; white-space: nowrap; }
.prose tbody tr:last-child td { border-bottom: 0; }
.prose tbody tr:hover td { background: var(--bg-soft); }

.diagram { margin: 0 0 1.3em; }
.diagram figcaption { font-size: 12.5px; color: var(--fg-muted); margin-top: 4px; }
.diagram svg { max-width: none; height: auto; }
pre.mermaid[data-processed="true"] { background: none; border: 0; padding: 0; text-align: center; overflow-x: auto; }

.cite { font-size: .72em; line-height: 0; margin-left: 1px; }
.cite a { text-decoration: none; }
.xref-missing { border-bottom: 1px dotted var(--fg-muted); cursor: help; }
.xref-missing::after { content: " (not written yet)"; font-size: .8em; color: var(--fg-muted); }

/* home + domain index */
.intro { font-size: 1.1rem; color: var(--fg-muted); max-width: 64ch; }
.cards { list-style: none; padding: 0 !important; margin: 24px 0 0; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.content > .prose:has(.cards) { max-width: none; }
.card { margin: 0 !important; padding: 16px 18px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); transition: border-color .12s; }
.card:hover { border-color: var(--accent); }
.card h2 { margin: 0 0 6px !important; padding: 0 !important; border: 0 !important; font-size: 1.05rem !important; }
.card h2 a { text-decoration: none; }
.card p { margin: 0 0 6px !important; font-size: 14.5px; color: var(--fg-muted); }
.card .counts { font-size: 13px; margin: 0 !important; }
.card.empty { opacity: .6; }
.card.empty:hover { border-color: var(--border); }
.page-list { list-style: none; padding: 0 !important; }
.page-list li { margin: 0 0 14px !important; }
.page-list a { font-weight: 600; font-size: 1.04rem; }
.page-list p { margin: 2px 0 0 !important; color: var(--fg-muted); font-size: 15px; }
.muted { color: var(--fg-muted); }

/* sources + footer */
.sources { margin-top: 3em; padding-top: 1em; border-top: 1px solid var(--border); font-size: 14px; }
.sources h2 { font-size: 1.1rem; margin: 0 0 4px; }
.src-note { color: var(--fg-muted); margin: 0 0 10px; font-size: 13px; }
.sources ol { list-style: none; padding: 0; margin: 0; }
.sources li { margin: 0 0 8px; padding-left: 2.4em; text-indent: -2.4em; }
.sources li:target { background: var(--accent-soft); border-radius: 6px; }
.src-n { display: inline-block; width: 2.2em; text-indent: 0; color: var(--fg-muted); font-variant-numeric: tabular-nums; }
.src-title { font-weight: 600; }
.src-meta { color: var(--fg-muted); }
.sources h3 { font-size: 1rem; margin: 1.4em 0 4px; }
.src-code { font-size: 12.5px; background: none; padding: 0; overflow-wrap: anywhere; }
.src-path { display: block; text-indent: 0; font-size: 12.5px; color: var(--fg-muted); background: none; padding: 0; overflow-wrap: anywhere; }
.pagefoot { margin-top: 3em; padding-top: 14px; border-top: 1px solid var(--border); font-size: 13px; color: var(--fg-muted); }
.pagefoot code { font-size: 12.5px; }

.backdrop { display: none; }

/* --- narrower screens ----------------------------------------------------------------- */

@media (max-width: 1200px) {
  .layout { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .toc { display: none; }
  .toc-inline { display: block; }
}

@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .layout { display: block; }
  .sidebar {
    position: fixed; z-index: 40; top: var(--topbar-h); left: 0; bottom: 0;
    height: auto; width: min(320px, 86vw);
    background: var(--bg); box-shadow: var(--shadow);
    transform: translateX(-105%); transition: transform .18s ease;
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .backdrop { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 35; background: rgba(0, 0, 0, .35); }
  .content { padding: 20px 16px 48px; }
  .prose h1 { font-size: 1.6rem; }
  .search { width: auto; flex: 1; min-width: 0; }
  .search-key { display: none; }
  .search-results { position: fixed; left: 8px; right: 8px; top: calc(var(--topbar-h) + 4px); width: auto; }
}

@media (max-width: 520px) {
  .topbar { gap: 8px; padding: 0 10px; }
  .brand, .edition { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}

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

@media print {
  :root { --fg: #000; --fg-muted: #444; --bg: #fff; --bg-soft: #f4f4f4; --bg-code: #f4f4f4; --border: #ccc; --accent: #000; }
  .topbar, .sidebar, .toc, .toc-inline, .backdrop, .skip, .anchor { display: none !important; }
  .layout { display: block; }
  .content { padding: 0; }
  .content > * { max-width: none; }
  body { font-size: 11pt; }
  a { color: inherit; }
  .prose a[href^="http"]::after { content: " (" attr(href) ")"; font-size: .85em; color: #444; }
  .prose h2, .prose h3 { break-after: avoid; }
  .table-wrap { overflow: visible; border: 0; }
  .prose table, .prose pre, .callout { break-inside: avoid; }
  .prose th, .prose td { border: 1px solid #ccc; }
}
