/* =========================================================================
   ntgcalls-napi docs · "Engineered / Precise"
   IBM Plex Sans + Mono · signal-green accent · WCAG-AA verified contrast
   ========================================================================= */

:root {
  --max-content: 720px;
  --sidebar-w: 244px;
  --toc-w: 208px;
  --topbar-h: 52px;
  --radius: 7px;
  --font-sans: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---- Dark (default) ---- contrast verified AA on text-bearing pairs ---- */
[data-theme="dark"] {
  --bg: #111214;
  --bg-alt: #15171a;
  --bg-code: #0d0e10;
  --border: #26282c;
  --border-strong: #34373c;
  --text: #e8e8e4; /* 15.26 on bg */
  --text-muted: #a0a29c; /* lifted for AA */
  --text-faint: #82847f; /* 4.96 on bg — AA */
  --accent: #2bb673; /* 7.18 on bg — AA */
  --accent-dim: #1f8a57;
  --accent-soft: rgba(43, 182, 115, 0.1);
  --on-accent: #06140d; /* 7.22 on accent — AA */
  --syntax-kw: #c08cff;
  --syntax-str: #e0a96d;
  --syntax-com: #82847f;
}

/* ---- Light ---- warm paper ---- */
[data-theme="light"] {
  --bg: #fafaf8;
  --bg-alt: #f3f2ee;
  --bg-code: #f5f4f0;
  --border: #e4e2dc;
  --border-strong: #d4d2ca;
  --text: #16171a; /* 17.15 on bg */
  --text-muted: #5a5a55; /* AA */
  --text-faint: #6e6e67; /* 4.91 on bg — AA */
  --accent: #15794a; /* 5.20 on bg — AA */
  --accent-dim: #0f6840;
  --accent-soft: rgba(21, 121, 74, 0.08);
  --on-accent: #ffffff;
  --syntax-kw: #8250df;
  --syntax-str: #b35309;
  --syntax-com: #6e6e67;
}

* {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
}
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  height: var(--topbar-h);
  padding: 0 1.5rem;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  flex: 0 0 auto;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.82rem;
  letter-spacing: -0.01em;
  color: var(--text);
}
.brand:hover {
  text-decoration: none;
  color: var(--text);
}
.brand:hover .brand-mark {
  color: var(--accent-dim);
}
.brand-mark {
  width: 18px;
  height: 18px;
  color: var(--accent);
  flex: 0 0 auto;
}
.brand .at {
  color: var(--text-faint);
}
.topbar-spacer {
  flex: 1;
}
.topbar-meta {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  text-transform: uppercase;
}
.topbar-link {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  text-transform: uppercase;
}
.topbar-link:hover {
  color: var(--text);
  text-decoration: none;
}
.theme-toggle {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  border-radius: 6px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--text);
}
.nav-burger {
  display: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--text-muted);
}

/* ---------- Layout ---------- */
.layout {
  display: flex;
  align-items: flex-start;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky;
  top: var(--topbar-h);
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 1.75rem 1.25rem;
  border-right: 1px solid var(--border);
}
.nav-group-label {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 0.65rem 0.5rem;
}
.nav-group + .nav-group {
  margin-top: 1.5rem;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.34rem 0.5rem;
  border-radius: 5px;
  color: var(--text-muted);
  font-size: 0.87rem;
}
.nav-link .idx {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-faint);
}
.nav-link:hover {
  color: var(--text);
  background: var(--bg-alt);
  text-decoration: none;
}
.nav-link.active {
  color: var(--text);
  background: var(--bg-alt);
}
.nav-link.active .idx {
  color: var(--accent);
}

/* ---------- Content ---------- */
.content {
  flex: 1;
  min-width: 0;
  padding: 3.25rem 3rem 5rem;
}
.content article {
  max-width: var(--max-content);
  margin: 0 auto;
}

/* eyebrow (mono section number, spec-sheet tell) */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 1.4rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.eyebrow .seg {
  color: var(--accent);
}
.eyebrow .bar {
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ---------- Typography ---------- */
h1,
h2,
h3,
h4,
h5 {
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.015em;
  scroll-margin-top: calc(var(--topbar-h) + 1rem);
}
h1 {
  font-size: 2rem;
  margin: 0 0 1rem;
  text-wrap: balance;
}
h2 {
  font-size: 1.4rem;
  margin: 3rem 0 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}
h3 {
  font-size: 1.1rem;
  margin: 2rem 0 0.7rem;
}
h4,
h5 {
  font-size: 0.98rem;
  margin: 1.6rem 0 0.5rem;
  font-family: var(--font-mono);
  font-weight: 500;
  letter-spacing: -0.01em;
}
/* API-reference method signatures (h4/h5 authored as inline code) */
h4 code,
h5 code {
  font-size: 0.92em;
  background: var(--bg-code);
  border: 1px solid var(--border);
  padding: 0.2em 0.5em;
  color: var(--text);
}
p,
ul,
ol {
  margin: 0 0 1rem;
}
ul,
ol {
  padding-left: 1.4rem;
}
li {
  margin: 0.3rem 0;
}
li::marker {
  color: var(--text-faint);
}
strong {
  font-weight: 600;
}
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

/* ---------- Code ---------- */
code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--accent-soft);
  color: var(--text);
  padding: 0.14em 0.4em;
  border-radius: 4px;
}
pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  overflow-x: auto;
  margin: 0 0 1.25rem;
  font-size: 0.82rem;
  line-height: 1.65;
}
pre code {
  background: transparent;
  padding: 0;
  font-size: inherit;
  color: var(--text);
}

/* Prism token tints, mapped to the palette */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: var(--syntax-com);
}
.token.keyword,
.token.boolean,
.token.atrule,
.token.important {
  color: var(--syntax-kw);
}
.token.string,
.token.char,
.token.attr-value,
.token.regex {
  color: var(--syntax-str);
}
.token.function,
.token.class-name {
  color: var(--accent);
}
.token.number,
.token.constant,
.token.symbol {
  color: var(--syntax-str);
}
.token.punctuation,
.token.operator {
  color: var(--text-muted);
}

/* ---------- Tables (spec-sheet ruled) ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.4rem;
  font-size: 0.86rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
th,
td {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 0.55rem 0.8rem;
  text-align: left;
  vertical-align: top;
}
th:last-child,
td:last-child {
  border-right: none;
}
tr:last-child td {
  border-bottom: none;
}
th {
  background: var(--bg-alt);
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}
td code {
  background: transparent;
  padding: 0;
  color: var(--text);
}

/* ---------- Callouts (GitHub-style alerts) ---------- */
blockquote {
  margin: 0 0 1.4rem;
  padding: 0.85rem 1.1rem;
  border: 1px solid var(--border);
  border-left: 2px solid var(--text-faint);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--bg-alt);
  color: var(--text);
}
blockquote p:last-child {
  margin-bottom: 0;
}
.callout {
  --callout: var(--accent);
  border-left-color: var(--callout);
}
.callout-title {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0 0 0.45rem;
  color: var(--callout);
}
.callout-note {
  --callout: #4596e6;
}
.callout-tip {
  --callout: var(--accent);
}
.callout-important {
  --callout: #a371f7;
}
.callout-warning {
  --callout: #d2922a;
}
.callout-caution {
  --callout: #e5564b;
}

/* ---------- Right-hand on-page TOC ---------- */
.toc {
  position: sticky;
  top: var(--topbar-h);
  flex: 0 0 var(--toc-w);
  width: var(--toc-w);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 3.25rem 1.25rem;
  border-left: 1px solid var(--border);
}
.toc-label {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 0.85rem;
}
.toc nav {
  display: flex;
  flex-direction: column;
}
.toc a {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0.24rem 0 0.24rem 0.85rem;
  border-left: 1px solid var(--border);
  line-height: 1.35;
}
.toc a:hover {
  color: var(--text);
  text-decoration: none;
}
.toc a.h3 {
  padding-left: 1.6rem;
  font-size: 0.76rem;
}
.toc a.active {
  color: var(--text);
  border-left-color: var(--accent);
}

/* ---------- Home hero ---------- */
.hero h1 {
  font-size: 2.7rem;
  line-height: 1.08;
  letter-spacing: -0.025em;
  margin: 0 0 1.1rem;
}
.hero h1 em {
  font-style: normal;
  color: var(--accent);
}
.hero .lede {
  font-size: 1.12rem;
  color: var(--text-muted);
  max-width: 34rem;
  margin: 0 0 2rem;
  text-wrap: pretty;
}
.hero-actions {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 2.5rem;
}
.btn {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.01em;
  padding: 0.6rem 1.1rem;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
}
.btn:hover {
  text-decoration: none;
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}
.btn-primary:hover {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
}
.btn-ghost:hover {
  border-color: var(--text-faint);
}

/* Terminal block — the signature detail */
.terminal {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-code);
  margin: 0 0 1.25rem;
}
.terminal-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.9rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
}
.terminal-bar .dots {
  display: flex;
  gap: 0.32rem;
}
.terminal-bar .dots span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
}
.terminal-bar .fname {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-faint);
  margin-left: 0.2rem;
}
.terminal pre {
  border: none;
  border-radius: 0;
  margin: 0;
  background: transparent;
}
.terminal-body {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.7;
  padding: 1rem 1.1rem;
}
.terminal-body .tok-cmd {
  color: var(--text-faint);
}
.terminal-body .tok-com {
  color: var(--syntax-com);
}

/* Spec grid (feature cards) */
.specs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin: 0 0 2rem;
}
.spec {
  padding: 1.15rem 1.25rem;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.spec:nth-child(2n) {
  border-right: none;
}
.spec:nth-last-child(-n + 2) {
  border-bottom: none;
}
.spec .num {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 0.6rem;
}
.spec h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
}
.spec p {
  font-size: 0.83rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.55;
}

/* ---------- Home: next steps + credits ---------- */
.next-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.next-list li {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  margin: 0;
  border-bottom: 1px solid var(--border);
}
.next-list li:last-child {
  border-bottom: none;
}
.next-list li a {
  flex: 0 0 9.5rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 500;
}
.next-list li span {
  color: var(--text-muted);
  font-size: 0.88rem;
}
.credits-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}
.credits-list li {
  padding-left: 1rem;
  border-left: 2px solid var(--border);
  margin: 0 0 0.85rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.credits-list li a {
  font-weight: 500;
}
@media (max-width: 600px) {
  .next-list li {
    flex-direction: column;
    gap: 0.2rem;
  }
  .next-list li a {
    flex: none;
  }
}

/* ---------- Tabbed code blocks ---------- */
.tabs {
  margin: 0 0 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.tab-list {
  display: flex;
  gap: 0;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  overflow-y: hidden;
}
.tab-btn {
  appearance: none;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 0.55rem 0.95rem;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  letter-spacing: 0.02em;
  color: var(--text-faint);
  cursor: pointer;
  white-space: nowrap;
}
.tab-btn:hover {
  color: var(--text);
}
.tab-btn[aria-selected="true"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.tab-panel {
  padding: 0;
}
/* Code blocks sit flush inside the panel; drop their own chrome. */
.tab-panel pre {
  margin: 0;
  border: none;
  border-radius: 0;
}
.tab-panel > :not(pre) {
  padding: 0.9rem 1.1rem;
  margin: 0;
}

/* ---------- Per-page meta line ---------- */
.page-meta {
  max-width: var(--max-content);
  margin: 3.5rem auto 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.02em;
  display: flex;
  gap: 0.6rem;
  align-items: center;
}
.page-meta a {
  color: var(--text-muted);
}
.page-meta a:hover {
  color: var(--text);
}

/* ---------- Site-wide footer band (credit only) ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
  padding: 1.4rem 2rem;
}
.site-footer-credit {
  margin: 0;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  letter-spacing: 0.02em;
  color: var(--text-faint);
}
.site-footer-credit a {
  color: var(--text-muted);
  font-weight: 500;
}
.site-footer-credit a:hover {
  color: var(--accent);
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .toc {
    display: none;
  }
}
/* The Links group in the drawer is mobile-only; on desktop npm/GitHub live in
   the topbar. The backdrop only exists at mobile widths. */
.sidebar-links {
  display: none;
}
.nav-backdrop {
  display: none;
}

@media (max-width: 820px) {
  .nav-burger {
    display: block;
  }
  /* Declutter the topbar: shorten the brand, drop redundant meta/links
     (version lives in the per-page meta; npm/GitHub move into the drawer). */
  .brand .at {
    display: none;
  }
  .topbar-meta,
  .topbar-link {
    display: none;
  }
  .topbar {
    gap: 0.6rem;
    padding: 0 1rem;
  }
  .sidebar-links {
    display: block;
  }
  /* Click-outside-to-dismiss backdrop, shown only when the drawer is open. */
  .nav-toggle:checked ~ .nav-backdrop {
    display: block;
    position: fixed;
    inset: var(--topbar-h) 0 0 0;
    z-index: 24;
    background: rgba(0, 0, 0, 0.45);
  }
  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    z-index: 25;
    background: var(--bg);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .nav-toggle:checked ~ .layout .sidebar {
    transform: translateX(0);
  }
  .content {
    padding: 2rem 1.4rem 3.5rem;
  }
  .hero h1 {
    font-size: 2.1rem;
  }
  .specs {
    grid-template-columns: 1fr;
  }
  .spec {
    border-right: none;
  }
}
