/* Docs layout + content styling. Uses the site's design tokens from shared.css. */
body { margin: 0; background: var(--bg); color: var(--text); }

.docs-shell {
  max-width: 1360px;
  margin: 0 auto;
  padding: 92px 32px 96px;
  display: grid;
  grid-template-columns: 344px minmax(0, 1fr) 180px;
  gap: 40px;
  align-items: start;
}

/* Right rail: "On this page" */
.docs-toc { position: sticky; top: 80px; max-height: calc(100vh - 100px); overflow-y: auto; padding-top: 2px; }
.docs-toc-label { font-family: 'Geist Mono', monospace; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px 12px; }
.docs-toc a { display: block; padding: 4px 12px; font-size: 13.5px; line-height: 1.45; color: var(--muted2); text-decoration: none; border-left: 1.5px solid var(--border); transition: color .12s, border-color .12s; }
.docs-toc a:hover { color: var(--text); border-left-color: var(--border2); text-decoration: none; }
.docs-toc a.active { color: var(--accent); border-left-color: var(--accent); }

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

/* ── Sidebar ─────────────────────────────────────────── */
.docs-side {
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding-right: 6px;
}
.docs-side::-webkit-scrollbar { width: 6px; }
.docs-side::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.docs-search {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  margin-bottom: 18px;
  outline: none;
  transition: border-color .15s;
}
.docs-search:focus { border-color: var(--accent); }
.docs-search::placeholder { color: var(--muted); }

/* Top-left section tabs (Guides / API Reference) — an underline-active row that
   switches the whole sidebar tree. Sits at the top of the sidebar on desktop and
   at the top of the drawer on mobile. */
.docs-tabs { display: flex; gap: 2px; margin: 0 0 18px; border-bottom: 1px solid var(--border); }
.docs-tab {
  padding: 7px 11px 10px; font-size: 13.5px; font-weight: 600; color: var(--muted);
  text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
  white-space: nowrap; transition: color .12s, border-color .12s;
}
.docs-tab:hover { color: var(--text); }
.docs-tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* ── Inline content tabs (audience toggle + language switcher) ── */
.doc-tabs { margin: 22px 0 26px; }
.doc-tabbar { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.doc-tab-btn {
  padding: 8px 15px 11px; font-size: 14.5px; font-weight: 600; color: var(--muted);
  background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  cursor: pointer; font-family: inherit; white-space: nowrap;
}
.doc-tab-btn:hover { color: var(--text); }
.doc-tab-btn.active { color: var(--text); border-bottom-color: var(--accent); }
.doc-tabpane[hidden] { display: none; }
/* Compact pill variant for the language switcher */
.doc-tabs.compact { margin: 8px 0 18px; }
.doc-tabs.compact .doc-tabbar { border-bottom: 0; margin-bottom: 10px; gap: 6px; }
.doc-tabs.compact .doc-tab-btn {
  padding: 5px 13px; font-size: 13px; border: 1px solid var(--border);
  border-radius: 999px; margin-bottom: 0;
}
.doc-tabs.compact .doc-tab-btn.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }

/* Per-host connect accordions */
.doc-acc { border: 1px solid var(--border); border-radius: 12px; margin: 0 0 10px; background: var(--bg2); overflow: hidden; }
.doc-acc summary { padding: 14px 18px; font-size: 15px; font-weight: 600; color: var(--text); cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; }
.doc-acc summary::-webkit-details-marker { display: none; }
.doc-acc summary::after { content: "+"; margin-left: auto; font-family: 'Geist Mono', monospace; font-size: 18px; color: var(--muted); }
.doc-acc[open] summary::after { content: "\2212"; }
.doc-acc .acc-body { padding: 2px 18px 16px; }
.doc-acc .acc-body p { font-size: 14.5px; margin: 0 0 12px; }
.doc-acc .acc-body p:last-child { margin-bottom: 0; }

.docs-group { margin-bottom: 6px; }
.docs-group-h {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: 0;
  padding: 7px 8px;
  font-family: 'Switzer', sans-serif;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  cursor: pointer;
  border-radius: 6px;
}
.docs-group-h:hover { color: var(--text); }
.docs-group-h .chev { transition: transform .18s; flex-shrink: 0; opacity: .7; }
.docs-group.open .docs-group-h .chev { transform: rotate(90deg); }

.docs-group-items { display: none; padding: 2px 0 6px; }
.docs-group.open .docs-group-items { display: block; }

.docs-link {
  display: block;
  padding: 6px 10px 6px 14px;
  margin-left: 6px;
  border-left: 1.5px solid var(--border);
  font-size: 13.5px;
  color: var(--muted2);
  text-decoration: none;
  transition: color .12s, border-color .12s;
}
.docs-link:hover { color: var(--text); border-left-color: var(--border2); }
.docs-link.active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.docs-link .ext { opacity: .5; font-size: 11px; }

.docs-nav-toggle { display: none; }

/* ── Main content ────────────────────────────────────── */
.docs-main { min-width: 0; position: relative; }
/* Copy-for-AI button — top-right of the content, above the fold. */
.docs-ai-copy {
  position: absolute; top: 2px; right: 0; z-index: 2;
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-size: 12.5px; font-weight: 600; color: var(--muted);
  background: var(--bg2); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 11px; cursor: pointer; transition: color .12s, border-color .12s;
}
.docs-ai-copy:hover { color: var(--text); border-color: var(--border2); }
.docs-ai-copy.ok { color: var(--accent); border-color: var(--accent); }
.docs-ai-copy svg { flex-shrink: 0; }
@media (max-width: 700px) { .docs-ai-copy { position: static; margin: 0 0 16px; } }
.docs-eyebrow { font-family: var(--font-sans, 'Switzer', system-ui, sans-serif); font-size: 12px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin: 0 0 12px; }
.docs-main h1 { font-family: var(--font-display, 'Instrument Serif', Georgia, serif); font-weight: 400; font-size: 44px; line-height: 1.08; letter-spacing: -.01em; margin: 0 0 16px; text-wrap: balance; }
.docs-main h1 em { color: var(--accent); font-style: italic; }
.docs-main h2 { font-family: var(--font-display, 'Instrument Serif', Georgia, serif); font-weight: 400; font-size: 28px; letter-spacing: -.01em; margin: 48px 0 14px; scroll-margin-top: 90px; }
.docs-main h3 { font-family: var(--font-sans, 'Switzer', system-ui, sans-serif); font-weight: 600; font-size: 17px; letter-spacing: -.015em; margin: 30px 0 10px; }
.docs-lede { font-size: 18px; color: var(--muted2); line-height: 1.6; max-width: 66ch; margin: 0 0 8px; }
.docs-main p { font-size: 15.5px; color: var(--muted2); line-height: 1.7; max-width: 68ch; margin: 0 0 16px; }
.docs-main p b, .docs-main li b { color: var(--text); font-weight: 600; }
.docs-main a { color: var(--accent); text-decoration: none; }
.docs-main a:hover { text-decoration: underline; }
.docs-main ul, .docs-main ol { font-size: 15.5px; color: var(--muted2); line-height: 1.7; max-width: 68ch; padding-left: 22px; margin: 0 0 16px; }
.docs-main li { margin-bottom: 7px; }
/* Numbered walkthrough steps — circular badges, so a guide reads like instructions */
.docs-main ol.steps { list-style: none; counter-reset: step; padding-left: 0; margin: 0 0 20px; max-width: 68ch; }
.docs-main ol.steps > li { counter-increment: step; position: relative; padding: 3px 0 3px 44px; margin-bottom: 14px; color: var(--text); }
.docs-main ol.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft, var(--bg3)); color: var(--accent);
  border: 1px solid var(--border); font-family: 'Geist Mono', monospace;
  font-size: 13px; font-weight: 600;
}
.docs-main code { font-family: 'Geist Mono', monospace; font-size: .88em; background: var(--bg3); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; color: var(--text); }

/* Code blocks */
.codewrap { position: relative; margin: 0 0 18px; }
.codewrap pre { background: #17140e; border: 1px solid #2b2620; border-radius: 12px; padding: 16px 18px; overflow-x: auto; margin: 0; }
.codewrap pre code { font-family: 'Geist Mono', monospace; font-size: 13px; line-height: 1.65; background: none; border: 0; padding: 0; color: #e6e6ea; white-space: pre; }
.codewrap .copy { position: absolute; top: 9px; right: 9px; appearance: none; border: 1px solid var(--border2); background: var(--bg3); color: var(--muted2); font-family: 'Geist Mono', monospace; font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; padding: 4px 9px; border-radius: 7px; cursor: pointer; opacity: 0; transition: opacity .15s, color .12s; }
.codewrap:hover .copy { opacity: 1; }
.codewrap .copy:hover { color: var(--text); border-color: var(--accent); }
.codewrap .copy.ok { color: #4ade80; border-color: #4ade80; opacity: 1; }
.codewrap pre code .c { color: #6b7280; }
.codewrap pre code .k { color: #8ab4f8; }
.codewrap pre code .s { color: #86efac; }

/* Callout */
.callout { display: flex; gap: 12px; background: var(--bg2); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 12px; padding: 15px 18px; margin: 0 0 18px; font-size: 14.5px; color: var(--muted2); line-height: 1.6; max-width: 68ch; }
.callout b { color: var(--text); }

/* Tables */
.docs-table-wrap { overflow-x: auto; margin: 0 0 18px; border: 1px solid var(--border); border-radius: 12px; }
table.docs-tbl { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 480px; }
table.docs-tbl th, table.docs-tbl td { text-align: left; padding: 11px 15px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.docs-tbl thead th { font-family: 'Switzer', sans-serif; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
table.docs-tbl tr:last-child td { border-bottom: 0; }
table.docs-tbl td b { color: var(--text); }

/* Cards (e.g. on the intro page) */
.docs-cards { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; margin: 4px 0 20px; }
a.docs-card { display: block; text-decoration: none; background: var(--bg2); border: 1px solid var(--border); border-radius: 13px; padding: 18px 20px; transition: border-color .15s, transform .1s; }
a.docs-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.docs-card h3 { margin: 0 0 5px; font-size: 16px; color: var(--text); }
.docs-card p { margin: 0; font-size: 13.5px; }

/* Prev / next */
.docs-pager { display: flex; justify-content: space-between; gap: 12px; margin: 56px 0 0; padding-top: 24px; border-top: 1px solid var(--border); }
.docs-pager a { display: flex; flex-direction: column; gap: 3px; border: 1px solid var(--border); border-radius: 12px; padding: 14px 18px; text-decoration: none; min-width: 0; max-width: 48%; transition: border-color .15s; }
.docs-pager a:hover { border-color: var(--accent); text-decoration: none; }
.docs-pager a.next { text-align: right; margin-left: auto; }
.docs-pager .dir { font-family: 'Geist Mono', monospace; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.docs-pager .lbl { font-size: 15px; font-weight: 600; color: var(--text); }

@media (max-width: 960px) {
  .docs-shell { grid-template-columns: minmax(0, 1fr); padding: 84px 20px 64px; gap: 0; }
  .docs-side { position: relative; top: 0; max-height: none; overflow: visible; margin-bottom: 24px; padding-right: 0; }
  /* Breadcrumb bar: hamburger + where you are. Tapping opens the drawer. */
  .docs-nav-toggle {
    display: flex; align-items: center; gap: 11px; width: 100%;
    box-sizing: border-box; padding: 11px 15px; background: var(--bg2);
    border: 1px solid var(--border); border-radius: 11px; color: var(--text);
    font: inherit; font-size: 14px; cursor: pointer; text-align: left;
  }
  .docs-nav-toggle .dnt-burger { flex-shrink: 0; color: var(--text); }
  .dnt-crumb { display: flex; align-items: center; gap: 8px; min-width: 0; }
  .dnt-group { color: var(--muted); white-space: nowrap; }
  .dnt-sep { color: var(--muted); opacity: .6; }
  .dnt-page { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* The nav body becomes a left slide-in drawer over a backdrop. */
  .docs-nav-body {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 200;
    width: 84vw; max-width: 340px; margin: 0;
    background: var(--bg); border-right: 1px solid var(--border);
    box-shadow: 2px 0 44px rgba(0, 0, 0, .18);
    padding: 22px 18px calc(env(safe-area-inset-bottom) + 22px);
    overflow-y: auto; -webkit-overflow-scrolling: touch;
    transform: translateX(-102%); transition: transform .24s ease; display: block;
  }
  .docs-side.open .docs-nav-body { transform: translateX(0); }
  .docs-nav-backdrop {
    position: fixed; inset: 0; z-index: 190; background: rgba(0, 0, 0, .42);
    opacity: 0; transition: opacity .24s ease;
  }
  .docs-side.open .docs-nav-backdrop { opacity: 1; }
  .docs-nav-backdrop[hidden] { display: none; }

  .docs-main h1 { font-size: 36px; }
  .docs-cards { grid-template-columns: 1fr; }
  .docs-pager a { max-width: 100%; }
}
/* Lock the page behind the mobile drawer so only the drawer scrolls. */
body.docs-drawer-open { overflow: hidden; }

/* API reference (rendered by docs-api.js) */
.api-op { border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; margin: 0 0 16px; background: var(--bg2); }
.api-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.api-m { font-family: 'Geist Mono', monospace; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 6px; text-transform: uppercase; letter-spacing: .03em; }
.api-path { font-family: 'Geist Mono', monospace; font-size: 13.5px; background: none; border: 0; padding: 0; color: var(--text); }
.api-sum { margin: 0 0 4px; font-size: 14.5px; }
.api-op h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 0 8px; }
.m-get { color: #075985; background: rgba(2,132,199,0.14); }
.m-post { color: #14532d; background: rgba(22,163,74,0.16); }
.m-patch { color: #78350f; background: rgba(217,119,6,0.18); }
.m-delete { color: #7f1d1d; background: rgba(220,38,38,0.16); }
.m-put { color: #581c87; background: rgba(147,51,234,0.16); }
:root[data-theme='dark'] .m-get { color: #7dd3fc; background: rgba(56,189,248,0.14); }
:root[data-theme='dark'] .m-post { color: #86efac; background: rgba(74,222,128,0.14); }
:root[data-theme='dark'] .m-patch { color: #fcd34d; background: rgba(251,191,36,0.16); }
:root[data-theme='dark'] .m-delete { color: #fca5a5; background: rgba(248,113,113,0.16); }
:root[data-theme='dark'] .m-put { color: #d8b4fe; background: rgba(192,132,252,0.16); }

/* ── API reference: resource sections + deep endpoint pages ── */
.api-res { margin: 0 0 8px; }
.api-res-h { font-family: var(--font-display, 'Instrument Serif', Georgia, serif); font-weight: 400; font-size: 30px; letter-spacing: -.01em; margin: 44px 0 6px; scroll-margin-top: 90px; }
.api-op { border: 1px solid var(--border); border-radius: 14px; padding: 20px 22px; margin: 18px 0 0; background: var(--bg2); scroll-margin-top: 84px; }
.api-op h4 { font-family: 'Switzer', sans-serif; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 9px; }
.api-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.api-m { font-family: 'Geist Mono', monospace; font-size: 11.5px; font-weight: 600; padding: 4px 10px; border-radius: 6px; text-transform: uppercase; letter-spacing: .03em; }
.api-path { font-family: 'Geist Mono', monospace; font-size: 14px; background: none; border: 0; padding: 0; color: var(--text); }
.api-sum { margin: 0 0 4px; font-size: 15px; color: var(--text); font-weight: 500; }

/* field tables */
table.api-fields td { vertical-align: top; }
.api-req { font-family: 'Geist Mono', monospace; font-size: 9.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); background: var(--accent-soft, rgba(234,88,12,.1)); padding: 1px 6px; border-radius: 5px; margin-left: 4px; vertical-align: middle; }
.api-type { font-family: 'Geist Mono', monospace; font-size: 12px; color: var(--muted); }
.api-enum { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.api-enum code { font-size: 11px; padding: 0 5px; }

/* responses */
.api-ex-label { font-size: 12px; color: var(--muted); margin: 0 0 6px; }
.api-resp { margin: 0 0 12px; }
.api-resp-h { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; font-size: 14px; color: var(--muted2); }
.api-code { font-family: 'Geist Mono', monospace; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 6px; }
.api-code.ok { color: #14532d; background: rgba(22,163,74,.16); }
.api-code.warn { color: #78350f; background: rgba(217,119,6,.18); }
.api-code.err { color: #7f1d1d; background: rgba(220,38,38,.16); }
:root[data-theme='dark'] .api-code.ok { color: #86efac; background: rgba(74,222,128,.14); }
:root[data-theme='dark'] .api-code.warn { color: #fcd34d; background: rgba(251,191,36,.16); }
:root[data-theme='dark'] .api-code.err { color: #fca5a5; background: rgba(248,113,113,.16); }

/* curl/JS tabs */
.api-tabs { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.api-tabbar { display: flex; gap: 2px; background: var(--bg3); padding: 5px 6px 0; border-bottom: 1px solid var(--border); }
.api-tab { appearance: none; border: 0; background: none; font-family: 'Geist Mono', monospace; font-size: 12px; color: var(--muted); padding: 7px 13px; border-radius: 8px 8px 0 0; cursor: pointer; }
.api-tab.active { color: var(--text); background: var(--bg2); }
.api-tabpane .codewrap { margin: 0; }
.api-tabpane .codewrap pre { border: 0; border-radius: 0; }

/* method chips (page + sidebar) */
.m-get { color: #075985; background: rgba(2,132,199,0.14); }
.m-post { color: #14532d; background: rgba(22,163,74,0.16); }
.m-patch { color: #78350f; background: rgba(217,119,6,0.18); }
.m-delete { color: #7f1d1d; background: rgba(220,38,38,0.16); }
.m-put { color: #581c87; background: rgba(147,51,234,0.16); }
:root[data-theme='dark'] .m-get { color: #7dd3fc; background: rgba(56,189,248,0.14); }
:root[data-theme='dark'] .m-post { color: #86efac; background: rgba(74,222,128,0.14); }
:root[data-theme='dark'] .m-patch { color: #fcd34d; background: rgba(251,191,36,0.16); }
:root[data-theme='dark'] .m-delete { color: #fca5a5; background: rgba(248,113,113,0.16); }
:root[data-theme='dark'] .m-put { color: #d8b4fe; background: rgba(192,132,252,0.16); }

/* sidebar: endpoint list under API reference */
.api-navgroup { margin: 2px 0 8px; }
.api-navlabel { font-family: 'Geist Mono', monospace; font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--faint, var(--muted)); padding: 6px 10px 3px 14px; }
.docs-link.api { display: flex; align-items: center; gap: 9px; padding: 5px 8px 5px 14px; font-family: 'Geist Mono', monospace; font-size: 12.5px; white-space: nowrap; }
.api-mini { font-size: 10px; font-weight: 600; letter-spacing: .02em; padding: 2px 6px; border-radius: 5px; flex-shrink: 0; width: 36px; text-align: center; text-transform: uppercase; }
