/* ==========================================================================
   MissNoHit Documentation — no dependencies, light/dark via data-theme
   ========================================================================== */

:root {
  --font-sans: "Segoe UI Variable Text", "Segoe UI", -apple-system, "Inter", Roboto, "Helvetica Neue", sans-serif;
  --font-mono: "Cascadia Code", "JetBrains Mono", Consolas, "SF Mono", Menlo, monospace;

  --bg: #ffffff;
  --bg-soft: #f6f8fa;
  --bg-inset: #f0f3f6;
  --border: #e3e8ee;
  --border-strong: #cdd5de;

  --ink: #1d2633;
  --ink-2: #4a5568;
  --ink-3: #798599;

  --accent: #2a78d6;
  --accent-strong: #1c5cab;
  --accent-soft: #eaf2fc;

  --good: #2f7d4f;
  --good-soft: #e9f5ee;
  --warn: #9a6700;
  --warn-soft: #fdf3d7;
  --danger: #c93c3c;
  --danger-soft: #fbebeb;

  --code-bg: #f6f8fa;
  --code-border: #e3e8ee;

  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 16px rgba(16,24,40,.06);
  --shadow-lg: 0 8px 40px rgba(16,24,40,.18);

  --topbar-h: 56px;
  --radius: 10px;
}

[data-theme="dark"] {
  --bg: #0f141a;
  --bg-soft: #151c24;
  --bg-inset: #1a222c;
  --border: #253040;
  --border-strong: #35455a;

  --ink: #e6ecf3;
  --ink-2: #a9b6c6;
  --ink-3: #77869a;

  --accent: #3987e5;
  --accent-strong: #6da7ec;
  --accent-soft: #16283f;

  --good: #58b380;
  --good-soft: #14291d;
  --warn: #e0a93e;
  --warn-soft: #2d2410;
  --danger: #e06c6c;
  --danger-soft: #331717;

  --code-bg: #131a22;
  --code-border: #223042;

  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
  --shadow-lg: 0 8px 40px rgba(0,0,0,.55);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15.5px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

/* ---------- Top bar ---------- */

.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  z-index: 50;
}

.menu-btn {
  display: none;
  background: none; border: none; color: var(--ink-2);
  padding: 6px; border-radius: 6px; cursor: pointer;
}
.menu-btn:hover { background: var(--bg-inset); }

.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 650; }
.brand:hover { text-decoration: none; }
.brand-mark { border-radius: 6px; flex: none; }
.brand-name { font-size: 16px; letter-spacing: -.01em; }
.brand-version {
  font-size: 11.5px; font-weight: 600; color: var(--accent);
  background: var(--accent-soft); border-radius: 99px; padding: 1px 8px;
}

.search-btn {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  width: min(340px, 32vw);
  padding: 6px 10px;
  font: inherit; font-size: 13.5px; color: var(--ink-3);
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; transition: border-color .15s;
}
.search-btn:hover { border-color: var(--border-strong); }
.search-btn span { flex: 1; text-align: left; }
kbd {
  font-family: var(--font-sans); font-size: 11px; color: var(--ink-3);
  border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 5px; padding: 1px 6px; background: var(--bg);
}

.topbar-right { display: flex; align-items: center; gap: 6px; }
.top-link {
  color: var(--ink-2); font-size: 13.5px; font-weight: 550;
  padding: 5px 9px; border-radius: 6px;
}
.top-link:hover { color: var(--ink); background: var(--bg-inset); text-decoration: none; }

.theme-btn {
  background: none; border: 1px solid var(--border); color: var(--ink-2);
  width: 32px; height: 32px; border-radius: 8px; cursor: pointer;
  display: grid; place-items: center;
}
.theme-btn:hover { background: var(--bg-inset); }
.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

/* ---------- Layout ---------- */

.layout {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr) 220px;
  max-width: 1400px;
  margin: 0 auto;
  padding-top: var(--topbar-h);
}

/* ---------- Sidebar ---------- */

.sidebar {
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 22px 14px 40px 20px;
  border-right: 1px solid var(--border);
  scrollbar-width: thin;
}

.nav-section { margin-bottom: 22px; }
.nav-section-title {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--ink-3);
  padding: 0 10px; margin: 0 0 6px;
}
.nav-link {
  display: block; padding: 5px 10px; margin: 1px 0;
  border-radius: 7px; color: var(--ink-2);
  font-size: 13.8px; font-weight: 480; line-height: 1.45;
}
.nav-link:hover { color: var(--ink); background: var(--bg-inset); text-decoration: none; }
.nav-link.active {
  color: var(--accent); background: var(--accent-soft); font-weight: 620;
}

.sidebar-backdrop { display: none; }

/* ---------- Content ---------- */

.content {
  padding: 40px 52px 90px;
  min-width: 0;
}
.content-inner { max-width: 760px; margin: 0 auto; }

.loading { color: var(--ink-3); padding: 60px 0; text-align: center; }

.breadcrumb {
  font-size: 12.5px; font-weight: 650; color: var(--accent);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px;
}

.content h1 {
  font-size: 32px; font-weight: 720; letter-spacing: -.02em;
  line-height: 1.2; margin: 0 0 10px;
}
.page-lead { font-size: 17px; color: var(--ink-2); margin: 0 0 30px; line-height: 1.6; }

.content h2 {
  font-size: 22px; font-weight: 680; letter-spacing: -.015em;
  margin: 44px 0 12px; padding-top: 18px;
  border-top: 1px solid var(--border);
  scroll-margin-top: calc(var(--topbar-h) + 20px);
}
.content h3 {
  font-size: 17px; font-weight: 650; margin: 30px 0 8px;
  scroll-margin-top: calc(var(--topbar-h) + 20px);
}
.content h2:first-of-type { border-top: none; padding-top: 0; margin-top: 30px; }

.content p { margin: 0 0 14px; }
.content ul, .content ol { margin: 0 0 14px; padding-left: 24px; }
.content li { margin: 4px 0; }

.anchor-link { color: var(--ink-3); opacity: 0; margin-left: 8px; font-weight: 400; }
h2:hover .anchor-link, h3:hover .anchor-link { opacity: 1; }

code {
  font-family: var(--font-mono); font-size: .86em;
  background: var(--bg-inset); border: 1px solid var(--border);
  border-radius: 5px; padding: .1em .35em;
  color: var(--ink);
}

/* ---------- Code blocks ---------- */

.codeblock {
  position: relative;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius);
  margin: 6px 0 20px;
  overflow: hidden;
}
.codeblock-head {
  display: flex; align-items: center;
  padding: 7px 14px;
  font-size: 12px; font-weight: 600; color: var(--ink-3);
  border-bottom: 1px solid var(--code-border);
  background: color-mix(in srgb, var(--code-bg) 60%, var(--bg));
}
.codeblock pre {
  margin: 0; padding: 14px 16px; overflow-x: auto;
  font-family: var(--font-mono); font-size: 13px; line-height: 1.6;
  scrollbar-width: thin;
}
.codeblock code { background: none; border: none; padding: 0; font-size: inherit; }

.copy-btn {
  position: absolute; top: 6px; right: 8px;
  background: var(--bg); border: 1px solid var(--border); color: var(--ink-3);
  font: inherit; font-size: 11.5px; font-weight: 600;
  border-radius: 6px; padding: 3px 9px; cursor: pointer;
  opacity: 0; transition: opacity .15s;
}
.codeblock:hover .copy-btn { opacity: 1; }
.copy-btn:hover { color: var(--ink); }
.copy-btn.copied { color: var(--good); border-color: var(--good); opacity: 1; }
.codeblock-head ~ .copy-btn { top: 40px; }

/* syntax tokens */
.tok-k  { color: #a626a4; }            /* keyword */
.tok-t  { color: #c18401; }            /* type */
.tok-s  { color: #50a14f; }            /* string */
.tok-n  { color: #986801; }            /* number */
.tok-c  { color: var(--ink-3); font-style: italic; } /* comment */
.tok-f  { color: #4078f2; }            /* function/macro call */
.tok-pp { color: #ca4780; }            /* preprocessor / UMACRO */
[data-theme="dark"] .tok-k  { color: #c678dd; }
[data-theme="dark"] .tok-t  { color: #e5c07b; }
[data-theme="dark"] .tok-s  { color: #98c379; }
[data-theme="dark"] .tok-n  { color: #d19a66; }
[data-theme="dark"] .tok-f  { color: #61afef; }
[data-theme="dark"] .tok-pp { color: #e06c9f; }

/* ---------- Callouts ---------- */

.callout {
  display: flex; gap: 12px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  background: var(--bg-soft);
  border-radius: 8px; padding: 13px 16px; margin: 6px 0 20px;
  font-size: 14.5px;
}
.callout p:last-child { margin-bottom: 0; }
.callout-icon { flex: none; margin-top: 2px; }
.callout-title { font-weight: 680; margin-bottom: 2px; }
.callout.info    { border-left-color: var(--accent); }
.callout.info    .callout-icon { color: var(--accent); }
.callout.success { border-left-color: var(--good); background: var(--good-soft); }
.callout.success .callout-icon { color: var(--good); }
.callout.warning { border-left-color: var(--warn); background: var(--warn-soft); }
.callout.warning .callout-icon { color: var(--warn); }
.callout.danger  { border-left-color: var(--danger); background: var(--danger-soft); }
.callout.danger  .callout-icon { color: var(--danger); }

/* ---------- Tables ---------- */

.doc-figure { margin: 6px 0 22px; }
.doc-figure img {
  max-width: 100%; display: block;
  border: 1px solid var(--border); border-radius: var(--radius);
}
.doc-figure figcaption { margin-top: 8px; font-size: .85rem; color: var(--ink-3); }
.doc-figure.missing::before {
  content: attr(data-desc);
  display: block; padding: 16px 18px;
  border: 2px dashed var(--border); border-radius: var(--radius);
  color: var(--ink-3); font-size: .85rem; line-height: 1.55;
  white-space: pre-wrap; background: color-mix(in srgb, var(--border) 12%, transparent);
}

.table-wrap { overflow-x: auto; margin: 6px 0 20px; border: 1px solid var(--border); border-radius: var(--radius); }
table.doc-table { border-collapse: collapse; width: 100%; font-size: 14px; }
.doc-table th {
  text-align: left; font-weight: 650; font-size: 12.5px;
  text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3);
  background: var(--bg-soft);
  padding: 9px 14px; border-bottom: 1px solid var(--border);
}
.doc-table td { padding: 9px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.doc-table tr:last-child td { border-bottom: none; }

/* ---------- API cards ---------- */

.api-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  margin: 6px 0 18px; overflow: hidden;
}
.api-card-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 11px 16px; background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
}
.api-name { font-family: var(--font-mono); font-size: 14px; font-weight: 650; }
.api-kind {
  font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  border-radius: 99px; padding: 2px 9px;
  background: var(--accent-soft); color: var(--accent);
}
.api-kind.event { background: var(--warn-soft); color: var(--warn); }
.api-kind.node  { background: var(--good-soft); color: var(--good); }
.api-card-body { padding: 13px 16px; font-size: 14.5px; }
.api-card-body > p { margin-bottom: 10px; }
.api-params { margin: 8px 0 2px; display: grid; gap: 6px; }
.api-param { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 10px; font-size: 13.5px; }
.api-param-name { font-family: var(--font-mono); color: var(--ink); white-space: nowrap; }
.api-param-name .api-type { color: var(--ink-3); font-size: 12px; display: block; }
.api-param-desc { color: var(--ink-2); }

/* ---------- Cards grid (landing) ---------- */

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 14px; margin: 6px 0 24px; }
.card {
  display: block; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; color: var(--ink); background: var(--bg);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.card:hover { text-decoration: none; border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-1px); }
.card-icon { font-size: 20px; margin-bottom: 8px; }
.card-title { font-weight: 650; font-size: 15px; margin-bottom: 3px; }
.card-desc { font-size: 13.2px; color: var(--ink-2); line-height: 1.5; }

/* ---------- Steps ---------- */

.steps { counter-reset: step; margin: 6px 0 20px; padding: 0; list-style: none; }
.step {
  position: relative; padding: 0 0 20px 44px; counter-increment: step;
}
.step::before {
  content: counter(step);
  position: absolute; left: 0; top: 0;
  width: 27px; height: 27px; border-radius: 99px;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}
.step::after {
  content: ""; position: absolute; left: 13px; top: 31px; bottom: 4px;
  width: 1px; background: var(--border);
}
.step:last-child::after { display: none; }
.step-title { font-weight: 650; margin-bottom: 4px; padding-top: 3px; }
.step p:last-child { margin-bottom: 0; }

/* ---------- Hero (landing page) ---------- */

.hero { padding: 26px 0 8px; }
.hero h1 { font-size: 40px; margin-bottom: 14px; }
.hero .page-lead { font-size: 18.5px; max-width: 620px; }
.hero-actions { display: flex; gap: 10px; margin: 22px 0 34px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 620; font-size: 14.5px;
  border-radius: 9px; padding: 9px 18px;
  border: 1px solid transparent;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); }
[data-theme="dark"] .btn-primary:hover { background: #256abf; }
.btn-ghost { border-color: var(--border-strong); color: var(--ink); }
.btn-ghost:hover { background: var(--bg-inset); }

.badges { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.badge {
  font-size: 12px; font-weight: 650; color: var(--ink-2);
  border: 1px solid var(--border); border-radius: 99px; padding: 3px 11px;
  background: var(--bg-soft);
}

/* ---------- Prev / Next ---------- */

.pager { display: flex; gap: 14px; margin-top: 56px; }
.pager a {
  flex: 1; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 13px 16px; color: var(--ink);
}
.pager a:hover { text-decoration: none; border-color: var(--accent); }
.pager .dir { font-size: 12px; color: var(--ink-3); font-weight: 600; }
.pager .ttl { font-weight: 640; color: var(--accent); font-size: 14.5px; }
.pager .next { text-align: right; }

/* ---------- TOC ---------- */

.toc {
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 30px 20px 40px 6px;
  font-size: 13px;
  scrollbar-width: thin;
}
.toc-title { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); margin-bottom: 8px; }
.toc a {
  display: block; color: var(--ink-3); padding: 3px 0 3px 12px;
  border-left: 2px solid var(--border); line-height: 1.5;
}
.toc a:hover { color: var(--ink); text-decoration: none; }
.toc a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.toc a.lvl3 { padding-left: 24px; }

/* ---------- Search overlay ---------- */

.search-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: color-mix(in srgb, var(--bg) 40%, rgba(9, 14, 20, .5));
  backdrop-filter: blur(3px);
  padding: 12vh 20px 0;
}
.search-panel {
  max-width: 620px; margin: 0 auto;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.search-input-row {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  color: var(--ink-3);
}
#searchInput {
  flex: 1; border: none; outline: none; background: none;
  font: inherit; font-size: 16px; color: var(--ink);
}
.search-results { max-height: 55vh; overflow-y: auto; padding: 8px; }
.search-hint { padding: 26px 16px; text-align: center; color: var(--ink-3); font-size: 14px; }
.search-result {
  display: block; padding: 10px 12px; border-radius: 8px; color: var(--ink);
  cursor: pointer;
}
.search-result:hover, .search-result.selected { background: var(--accent-soft); text-decoration: none; }
.search-result .sr-page { font-size: 11.5px; font-weight: 650; color: var(--accent); text-transform: uppercase; letter-spacing: .05em; }
.search-result .sr-title { font-weight: 620; font-size: 14.5px; }
.search-result .sr-snippet { font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-result mark { background: none; color: var(--accent); font-weight: 700; }

/* ---------- Responsive ---------- */

@media (max-width: 1180px) {
  .layout { grid-template-columns: 268px minmax(0, 1fr); }
  .toc { display: none; }
}

@media (max-width: 880px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: grid; place-items: center; }
  .sidebar {
    position: fixed; left: 0; top: var(--topbar-h); bottom: 0;
    width: 290px; background: var(--bg); z-index: 60;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: none;
  }
  body.nav-open .sidebar { transform: translateX(0); box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar-backdrop {
    display: block; position: fixed; inset: var(--topbar-h) 0 0 0;
    background: rgba(9,14,20,.45); z-index: 55;
  }
  .content { padding: 28px 22px 70px; }
  .search-btn span { display: none; }
  .search-btn { width: auto; }
  .search-btn kbd { display: none; }
  .top-link { display: none; }
  .hero h1 { font-size: 31px; }
}

::selection { background: color-mix(in srgb, var(--accent) 25%, transparent); }
