/* Atlantiraptor documentation. Colours follow the console's light and
   dark themes (gui/velociraptor/src/next/styles.css). */
:root {
  --canvas: #f6f7f9;
  --panel: #ffffff;
  --hover: #f0f2f5;
  --line: #e3e6eb;
  --line-strong: #cfd4dc;
  --fg: #14171c;
  --muted: #5b6472;
  --faint: #8a93a1;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --ok: #15803d;
  --ok-soft: #e8f6ec;
  --warn: #b45309;
  --warn-soft: #fdf3e3;
  --bad: #c81e1e;
  --bad-soft: #fdecec;
  --info: #0369a1;
  --info-soft: #e6f3fa;
  --code-bg: #f3f4f7;
  --shadow: 0 12px 32px -8px rgb(16 24 40 / 0.18), 0 4px 8px -4px rgb(16 24 40 / 0.08);
  --topbar: 56px;
  --sidebar-w: 272px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --canvas: #0d0f13;
    --panel: #14171c;
    --hover: #1e232a;
    --line: #252a32;
    --line-strong: #343b46;
    --fg: #e7eaee;
    --muted: #9aa3b1;
    --faint: #6b7482;
    --accent: #818cf8;
    --accent-soft: #23264a;
    --ok: #4ade80;
    --ok-soft: #12291b;
    --warn: #fbbf24;
    --warn-soft: #2d2410;
    --bad: #f87171;
    --bad-soft: #321616;
    --info: #38bdf8;
    --info-soft: #0f2534;
    --code-bg: #1a1e24;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --canvas: #0d0f13;
  --panel: #14171c;
  --hover: #1e232a;
  --line: #252a32;
  --line-strong: #343b46;
  --fg: #e7eaee;
  --muted: #9aa3b1;
  --faint: #6b7482;
  --accent: #818cf8;
  --accent-soft: #23264a;
  --ok: #4ade80;
  --ok-soft: #12291b;
  --warn: #fbbf24;
  --warn-soft: #2d2410;
  --bad: #f87171;
  --bad-soft: #321616;
  --info: #38bdf8;
  --info-soft: #0f2534;
  --code-bg: #1a1e24;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-padding-top: calc(var(--topbar) + 16px); }

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar);
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--fg); font-weight: 650; font-size: 17px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-sub { color: var(--muted); font-weight: 500; }
.menu-button, .theme-button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.menu-button:hover, .theme-button:hover { background: var(--hover); color: var(--fg); }
.menu-button { display: none; }
.topbar-links { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.github { color: var(--muted); display: inline-flex; padding: 8px; border-radius: 8px; }
.github:hover { color: var(--fg); background: var(--hover); }

/* Search */
.search { position: relative; flex: 1; max-width: 520px; margin-left: 24px; }
.search input {
  width: 100%; height: 36px; padding: 0 36px 0 34px;
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--canvas); color: var(--fg); font: inherit; font-size: 14px;
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: var(--panel); }
.search-icon { position: absolute; left: 11px; top: 10px; color: var(--faint); }
.search-key {
  position: absolute; right: 8px; top: 7px;
  font: 12px/20px ui-monospace, monospace; color: var(--faint);
  border: 1px solid var(--line-strong); border-radius: 4px; padding: 0 6px;
}
.search-results {
  position: absolute; top: 42px; left: 0; right: 0;
  max-height: min(70vh, 560px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); padding: 6px;
}
.search-results a { display: block; padding: 8px 10px; border-radius: 6px; color: var(--fg); }
.search-results a:hover, .search-results a.active { background: var(--accent-soft); text-decoration: none; }
.search-results .r-title { font-weight: 600; font-size: 14px; }
.search-results .r-section { color: var(--faint); font-size: 12px; margin-left: 6px; font-weight: 400; }
.search-results .r-text { display: block; color: var(--muted); font-size: 13px; line-height: 1.45; margin-top: 2px; }
.search-results mark { background: transparent; color: var(--accent); font-weight: 600; }
.search-results .r-empty { padding: 10px; color: var(--muted); font-size: 14px; }

/* Layout */
.layout { display: flex; align-items: flex-start; }
.sidebar {
  position: sticky; top: var(--topbar);
  width: var(--sidebar-w); flex: none;
  height: calc(100vh - var(--topbar)); overflow-y: auto;
  padding: 16px 12px 40px;
  border-right: 1px solid var(--line);
  background: var(--panel);
  font-size: 14px;
}
.nav-section summary {
  list-style: none; cursor: pointer;
  padding: 6px 10px; margin-top: 4px;
  font-size: 12px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); border-radius: 6px;
}
.nav-section summary::-webkit-details-marker { display: none; }
.nav-section summary::after { content: "▸"; float: right; color: var(--faint); transition: transform .15s; }
.nav-section[open] summary::after { transform: rotate(90deg); }
.nav-section summary:hover { background: var(--hover); }
.sidebar ul { list-style: none; margin: 2px 0 8px; padding: 0; }
.sidebar li a { display: block; padding: 5px 10px 5px 14px; border-radius: 6px; color: var(--fg); line-height: 1.4; }
.sidebar li a:hover { background: var(--hover); text-decoration: none; }
.sidebar li a.current { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.content { flex: 1; min-width: 0; display: flex; justify-content: center; gap: 40px; padding: 32px 40px 64px; }
.article { min-width: 0; width: 100%; max-width: 820px; }
.toc {
  position: sticky; top: calc(var(--topbar) + 32px);
  width: 220px; flex: none; max-height: calc(100vh - var(--topbar) - 64px); overflow-y: auto;
  font-size: 13px;
}
.toc-title { margin: 0 0 8px; font-weight: 650; color: var(--muted); text-transform: uppercase; font-size: 12px; letter-spacing: .04em; }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc li a { display: block; padding: 3px 12px; color: var(--muted); line-height: 1.4; }
.toc li a:hover { color: var(--accent); text-decoration: none; }
.toc li.toc-l3 a { padding-left: 24px; }
.toc li a.active { color: var(--accent); border-left: 2px solid var(--accent); margin-left: -1px; }

/* Article typography */
.crumbs { font-size: 13px; color: var(--faint); margin-bottom: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.crumbs a { color: var(--muted); }
.article h1 { font-size: 2.1rem; line-height: 1.2; margin: 0 0 20px; letter-spacing: -0.015em; }
.article h2 { font-size: 1.45rem; line-height: 1.3; margin: 2.2em 0 .6em; padding-top: .4em; border-top: 1px solid var(--line); letter-spacing: -0.01em; }
.article h3 { font-size: 1.15rem; margin: 1.8em 0 .5em; }
.article h4 { font-size: 1rem; margin: 1.6em 0 .4em; }
.article h2 + h3 { margin-top: .8em; }
.article p, .article ul, .article ol { margin: 0 0 1em; }
.article li { margin: .25em 0; }
.article li > p { margin: 0 0 .4em; }
.article img { max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; }
.article figure { margin: 1.4em 0 1.6em; }
.article figure a { display: block; }
.article figure img { display: block; margin: 0 auto; }
.article figcaption { margin-top: .5em; font-size: .875rem; color: var(--muted); text-align: center; }
.article hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.article strong { font-weight: 650; }

code, pre, kbd { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; }
.article code { font-size: .875em; background: var(--code-bg); padding: .12em .38em; border-radius: 4px; overflow-wrap: anywhere; }
.article pre {
  background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 14px 16px; overflow-x: auto; font-size: 13.5px; line-height: 1.55; margin: 0 0 1.2em;
}
.article pre code { background: none; padding: 0; font-size: inherit; overflow-wrap: normal; }
.article kbd { font-size: .85em; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 .4em; background: var(--panel); }

.table-wrap { overflow-x: auto; margin: 0 0 1.2em; border: 1px solid var(--line); border-radius: 8px; }
.article table { border-collapse: collapse; width: 100%; font-size: 14px; }
.article th, .article td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.article th { background: var(--hover); font-weight: 600; white-space: nowrap; }
.article tr:last-child td { border-bottom: 0; }

.article blockquote { margin: 0 0 1.2em; padding: 10px 16px; border-left: 4px solid var(--line-strong); background: var(--hover); border-radius: 0 8px 8px 0; color: var(--fg); }
.article blockquote p:last-child { margin-bottom: 0; }
.callout-note, .callout-important { border-left-color: var(--info) !important; background: var(--info-soft) !important; }
.callout-tip { border-left-color: var(--ok) !important; background: var(--ok-soft) !important; }
.callout-warning { border-left-color: var(--warn) !important; background: var(--warn-soft) !important; }
.callout-atlantiraptor { border-left-color: var(--accent) !important; background: var(--accent-soft) !important; }
.callout strong:first-child { display: block; margin-bottom: 2px; }

/* Cards on the home page */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin: 1.2em 0 1.6em; }
.cards a { display: block; padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--fg); }
.cards a:hover { border-color: var(--accent); text-decoration: none; }
.cards b { display: block; color: var(--accent); margin-bottom: 4px; }
.cards span { color: var(--muted); font-size: 14px; line-height: 1.5; }

.pager { display: flex; justify-content: space-between; gap: 16px; margin: 48px 0 0; }
.pager a { flex: 1; max-width: 50%; padding: 12px 16px; border: 1px solid var(--line); border-radius: 10px; color: var(--fg); background: var(--panel); }
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager span { display: block; font-size: 12px; color: var(--faint); }
.pager-next { text-align: right; margin-left: auto; }

.page-footer { margin-top: 48px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--faint); }
.page-footer p { margin: 0 0 .6em; }

/* Narrow screens */
@media (max-width: 1180px) { .toc { display: none; } }
@media (max-width: 900px) {
  .menu-button { display: inline-flex; }
  .sidebar {
    position: fixed; left: 0; top: var(--topbar); z-index: 30;
    transform: translateX(-100%); transition: transform .2s;
    box-shadow: var(--shadow); width: min(85vw, 320px);
  }
  body.nav-open .sidebar { transform: none; }
  .content { padding: 24px 16px 48px; }
  .search { margin-left: 0; }
  .brand-sub, .search-key { display: none; }
}
@media (max-width: 560px) {
  .topbar { gap: 8px; padding: 0 8px; }
  .brand span { display: none; }
  .article h1 { font-size: 1.7rem; }
  .github { display: none; }
  .pager { flex-direction: column; }
  .pager a { max-width: none; }
}
