/* BugCapsule developer docs. Values come from tokens.css (copied from the identity build). */
@import url("tokens.css");

:root {
  --bg: var(--color-background-primary);
  --bg-2: var(--color-background-secondary);
  --surface: var(--color-surface-primary);
  --surface-2: var(--color-surface-elevated);
  --text: var(--color-text-primary);
  --text-2: var(--color-text-secondary);
  --text-3: var(--color-text-tertiary);
  --accent: var(--color-brand-orange);
  --accent-text: var(--color-brand-orange);
  --accent-soft: #ff730017;
  --success: var(--color-success);
  --warning: var(--color-warning);
  --info: var(--color-info);
  --border: var(--color-border-subtle);
  --border-2: var(--color-border-default);
  --code-bg: #111113;
  --code-text: #e6e6e1;
  --tok-comment: #7c7c86;
  --tok-string: #6bd49b;
  --tok-keyword: #ff9a4d;
  --tok-number: #f2c66d;
  --tok-type: #8ab4f8;
  --header-h: 60px;
  --sidebar-w: 264px;
  --toc-w: 220px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: var(--color-light-background);
  --bg-2: #ecece8;
  --surface: var(--color-light-surface);
  --surface-2: #f0f0ec;
  --text: var(--color-light-text);
  --text-2: var(--color-light-muted);
  --text-3: #6f6f76;
  --accent-text: var(--color-light-accentText);
  --accent-soft: #ff730014;
  --success: var(--color-light-success);
  --warning: var(--color-light-warning);
  --info: var(--color-light-info);
  --border: #dcdcd6;
  --border-2: #c4c4bd;
  --code-bg: #1a1a1d;
  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: var(--color-light-background);
    --bg-2: #ecece8;
    --surface: var(--color-light-surface);
    --surface-2: #f0f0ec;
    --text: var(--color-light-text);
    --text-2: var(--color-light-muted);
    --text-3: #6f6f76;
    --accent-text: var(--color-light-accentText);
    --accent-soft: #ff730014;
    --success: var(--color-light-success);
    --warning: var(--color-light-warning);
    --info: var(--color-light-info);
    --border: #dcdcd6;
    --border-2: #c4c4bd;
    --code-bg: #1a1a1d;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--header-h) + 16px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.65 var(--font-family-sans);
  font-feature-settings: "cv11", "ss01";
}
a { color: var(--accent-text); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: var(--border-focus) solid var(--accent); outline-offset: var(--border-focusOffset); border-radius: 2px; }
img, svg { max-width: 100%; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 30;
  height: var(--header-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 600; }
.brand img { height: 26px; width: auto; display: block; }
.brand .logo-light { display: none; }
:root[data-theme="light"] .brand .logo-dark { display: none; }
:root[data-theme="light"] .brand .logo-light { display: block; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .brand .logo-dark { display: none; }
  :root:not([data-theme="dark"]) .brand .logo-light { display: block; }
}
.brand-tag {
  font: 500 12px/1 var(--font-family-mono); letter-spacing: .04em;
  color: var(--text-2); border: 1px solid var(--border-2); padding: 4px 7px; border-radius: var(--radius-pill);
}
.header-spacer { flex: 1; }
.search { position: relative; width: min(340px, 40vw); }
.search input {
  width: 100%; height: 36px; padding: 0 36px 0 12px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-2); border-radius: var(--radius-md);
  font: inherit; font-size: 14px;
}
.search input::placeholder { color: var(--text-3); }
.search kbd { position: absolute; right: 8px; top: 8px; }
.search-results {
  position: absolute; top: 42px; left: 0; right: 0; max-height: 60vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius-md);
  box-shadow: var(--shadow-panel); padding: 6px; display: none;
}
.search-results.open { display: block; }
.search-results a { display: block; padding: 8px 10px; border-radius: 6px; color: var(--text); text-decoration: none; font-size: 14px; }
.search-results a small { display: block; color: var(--text-3); font-size: 12px; }
.search-results a[aria-selected="true"], .search-results a:hover { background: var(--accent-soft); }
.search-results .empty { padding: 10px; color: var(--text-3); font-size: 14px; }
.icon-btn {
  height: 36px; min-width: 36px; display: inline-grid; place-items: center;
  background: transparent; color: var(--text-2); border: 1px solid var(--border-2); border-radius: var(--radius-md);
  cursor: pointer; font: inherit; font-size: 14px; padding: 0 8px;
}
.icon-btn:hover { color: var(--text); border-color: var(--text-3); }
.menu-btn { display: none; }
.site-link { color: var(--text-2); text-decoration: none; font-size: 14px; white-space: nowrap; padding: 0 4px; }
.site-link:hover { color: var(--text); }

/* ---------- 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(--header-h); height: calc(100vh - var(--header-h));
  overflow-y: auto; padding: 24px 16px 48px 20px; border-right: 1px solid var(--border);
}
.sidebar h4 {
  margin: 22px 0 6px; padding-left: 10px;
  font: 500 12px/1.4 var(--font-family-sans); letter-spacing: .08em; text-transform: uppercase; color: var(--text-3);
}
.sidebar h4:first-child { margin-top: 0; }
.sidebar a {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 6px; color: var(--text-2); text-decoration: none; font-size: 14px; line-height: 1.4;
}
.sidebar a:hover { color: var(--text); background: var(--surface); }
.sidebar a[aria-current="page"] { color: var(--text); background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.sidebar .badge { margin-left: auto; }

main { min-width: 0; padding: 40px 56px 96px; }
.content { max-width: 800px; }
.toc {
  position: sticky; top: var(--header-h); height: calc(100vh - var(--header-h)); overflow-y: auto;
  padding: 40px 20px 40px 8px; font-size: 13px;
}
.toc p { margin: 0 0 8px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; font-size: 12px; color: var(--text-3); }
.toc a { display: block; padding: 4px 0 4px 10px; color: var(--text-3); text-decoration: none; border-left: 1px solid var(--border); line-height: 1.4; }
.toc a.depth-3 { padding-left: 22px; }
.toc a:hover { color: var(--text); }
.toc a.active { color: var(--accent-text); border-left-color: var(--accent); }

@media (max-width: 1200px) {
  .layout { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .toc { display: none; }
  main { padding: 36px 40px 80px; }
}
@media (max-width: 860px) {
  .layout { display: block; }
  .menu-btn { display: inline-grid; }
  .sidebar {
    position: fixed; z-index: 40; top: var(--header-h); left: 0; bottom: 0; height: auto; width: min(300px, 86vw);
    background: var(--bg); transform: translateX(-102%); transition: transform var(--duration-base) var(--easing-standard);
    box-shadow: var(--shadow-panel);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: var(--header-h) 0 0 0; background: #0008; z-index: 35; }
  main { padding: 28px 16px 72px; }
  .brand-tag, .search kbd, .site-link { display: none; }
  .search { width: auto; flex: 1; }
  .header-spacer { display: none; }
  .site-header { padding: 0 12px; gap: 10px; }
  .brand span.word { display: none; }
}

/* ---------- typography ---------- */
.eyebrow {
  margin: 0 0 10px; color: var(--accent-text);
  font: 500 12px/1.4 var(--font-family-mono); letter-spacing: .08em; text-transform: uppercase;
}
h1, h2, h3, h4 { color: var(--text); scroll-margin-top: calc(var(--header-h) + 16px); }
h1 { font-size: 40px; line-height: 1.1; font-weight: 500; letter-spacing: -0.035em; margin: 0 0 14px; }
h2 { font-size: 26px; line-height: 1.2; font-weight: 500; letter-spacing: -0.02em; margin: 56px 0 14px; padding-top: 8px; }
h3 { font-size: 19px; line-height: 1.3; font-weight: 600; letter-spacing: -0.01em; margin: 34px 0 10px; }
h4 { font-size: 15px; font-weight: 600; margin: 24px 0 8px; }
.content > h2:first-of-type { margin-top: 40px; }
.lede { font-size: 18px; color: var(--text-2); margin: 0 0 24px; max-width: 680px; }
p, ul, ol { margin: 0 0 16px; }
li { margin: 4px 0; }
li > ul, li > ol { margin: 4px 0 0; }
strong { font-weight: 600; color: var(--text); }
hr { border: 0; border-top: 1px solid var(--border); margin: 40px 0; }
.anchor { margin-left: 8px; color: var(--text-3); text-decoration: none; opacity: 0; font-weight: 400; }
h2:hover .anchor, h3:hover .anchor { opacity: 1; }
@media (max-width: 860px) { h1 { font-size: 32px; } h2 { font-size: 23px; } }

code, kbd, pre { font-family: var(--font-family-mono); font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
:not(pre) > code {
  font-size: .86em; padding: .12em .38em; border-radius: 5px;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border); overflow-wrap: anywhere;
}
kbd {
  font-size: 11px; padding: 2px 6px; border-radius: 4px; color: var(--text-2);
  border: 1px solid var(--border-2); border-bottom-width: 2px; background: var(--surface);
}

/* ---------- code blocks ---------- */
.code {
  position: relative; margin: 0 0 20px;
  background: var(--code-bg); border: 1px solid #26272b; border-radius: var(--radius-lg); overflow: hidden;
}
.code-head {
  display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 8px 0 14px;
  border-bottom: 1px solid #26272b; color: #a9a9b2; font: 500 12px/1 var(--font-family-mono);
}
.code-head .file { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
pre {
  margin: 0; padding: 14px 16px; overflow-x: auto; color: var(--code-text);
  font-size: 13px; line-height: 1.65; tab-size: 2;
}
pre code { font: inherit; }
.copy-btn {
  background: transparent; border: 1px solid #3d3d44; color: #a9a9b2; border-radius: 6px;
  font: 500 11px/1 var(--font-family-sans); padding: 5px 8px; cursor: pointer;
}
.copy-btn:hover { color: #f4f4f1; border-color: #6e6e78; }
.code:not(:has(.code-head)) .copy-btn { position: absolute; top: 8px; right: 8px; opacity: 0; transition: opacity var(--duration-fast); }
.code:not(:has(.code-head)):hover .copy-btn, .code:not(:has(.code-head)) .copy-btn:focus-visible { opacity: 1; }
.tok-c { color: var(--tok-comment); font-style: italic; }
.tok-s { color: var(--tok-string); }
.tok-k { color: var(--tok-keyword); }
.tok-n { color: var(--tok-number); }
.tok-t { color: var(--tok-type); }
.tok-p { color: #a9a9b2; }

/* tabs (code and content) */
.tabs { margin: 0 0 20px; }
.tab-list { display: flex; gap: 2px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tab-list button {
  background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  color: var(--text-2); padding: 8px 12px; font: 500 14px/1.2 var(--font-family-sans); cursor: pointer;
}
.tab-list button:hover { color: var(--text); }
.tab-list button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tab-panel[hidden] { display: none; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 0 22px; border: 1px solid var(--border); border-radius: var(--radius-md); }
table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.5; }
th, td { text-align: left; vertical-align: top; padding: 9px 12px; border-bottom: 1px solid var(--border); }
th { font-weight: 600; color: var(--text); background: var(--bg-2); font-size: 13px; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td code { white-space: normal; overflow-wrap: anywhere; }
td:first-child code { overflow-wrap: normal; }
.flow-wrap pre, .code pre.flow { background: none; border: 0; border-radius: 0; margin: 0; padding: 14px 16px; }

/* ---------- callouts ---------- */
.callout {
  display: grid; grid-template-columns: 22px 1fr; gap: 10px;
  margin: 0 0 20px; padding: 14px 16px; border-radius: var(--radius-md);
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--info);
  font-size: 15px;
}
.callout > :last-child { margin-bottom: 0; }
.callout .ico { font: 600 14px/1.5 var(--font-family-mono); color: var(--info); }
.callout.warn { border-left-color: var(--warning); } .callout.warn .ico { color: var(--warning); }
.callout.danger { border-left-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--surface)); } .callout.danger .ico { color: var(--accent-text); }
.callout.tip { border-left-color: var(--success); } .callout.tip .ico { color: var(--success); }
.callout p { margin: 0 0 8px; } .callout p:last-child { margin: 0; }
.callout-body > :last-child { margin-bottom: 0; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px;
  border-radius: var(--radius-pill); font: 500 11px/1 var(--font-family-mono); letter-spacing: .02em;
  border: 1px solid var(--border-2); color: var(--text-2); white-space: nowrap; vertical-align: 2px;
}
.badge.ok { color: var(--success); border-color: color-mix(in srgb, var(--success) 45%, transparent); }
.badge.part { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 45%, transparent); }
.badge.no { color: var(--text-3); }
.badge.hot { color: var(--accent-text); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.badge.get { color: var(--success); } .badge.post { color: var(--info); } .badge.patch { color: var(--warning); } .badge.delete { color: var(--accent-text); }

/* ---------- cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin: 0 0 28px; }
.card {
  display: block; padding: 18px; border-radius: var(--radius-lg); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); text-decoration: none;
  transition: border-color var(--duration-fast), transform var(--duration-fast);
}
a.card:hover { border-color: var(--accent); transform: translateY(-1px); }
.card h3 { margin: 0 0 6px; font-size: 16px; }
.card p { margin: 0; color: var(--text-2); font-size: 14px; line-height: 1.5; }
.card .meta { margin-top: 12px; font: 500 12px/1.4 var(--font-family-mono); color: var(--text-3); }

/* ---------- steps ---------- */
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0 0 24px; }
.steps > li { position: relative; padding: 0 0 8px 46px; margin: 0; }
.steps > li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font: 600 13px/1 var(--font-family-mono);
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border-2);
}
.steps > li::after { content: ""; position: absolute; left: 14px; top: 34px; bottom: 6px; width: 1px; background: var(--border); }
.steps > li:last-child::after { display: none; }
.steps > li > h3, .steps > li > h4 { margin-top: 2px; }

/* ---------- misc ---------- */
.diagram {
  margin: 8px 0 28px; padding: 20px; border-radius: var(--radius-lg);
  border: 1px solid var(--border); background: var(--bg-2);
}
.diagram svg { display: block; width: 100%; height: auto; }
.diagram figcaption { margin-top: 12px; color: var(--text-3); font-size: 13px; }
.dg-box { fill: var(--surface); stroke: var(--border-2); }
.dg-box.hot { stroke: var(--accent); }
.dg-text { fill: var(--text); font: 600 13px var(--font-family-sans); }
.dg-sub { fill: var(--text-3); font: 400 11px var(--font-family-mono); }
.dg-line { stroke: var(--text-3); stroke-width: 1.5; fill: none; }
.dg-line.hot { stroke: var(--accent); }
.dg-label { fill: var(--text-2); font: 500 11px var(--font-family-mono); }
.dg-dot { fill: var(--accent); }

.hero { padding: 8px 0 8px; }
.hero h1 { font-size: 48px; max-width: 720px; }
@media (max-width: 860px) { .hero h1 { font-size: 34px; } }
.flow {
  font: 500 13px/1.7 var(--font-family-mono); color: var(--text-2);
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px 18px; margin: 0 0 28px; overflow-x: auto; white-space: pre;
}
.flow b { color: var(--accent-text); font-weight: 600; }
.flow i { color: var(--success); font-style: normal; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 20px; font-size: 14px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 64px; }
.pager a { display: block; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-md); text-decoration: none; color: var(--text); }
.pager a:hover { border-color: var(--accent); }
.pager small { display: block; color: var(--text-3); font-size: 12px; margin-bottom: 2px; }
.pager .next { text-align: right; grid-column: 2; }
.page-foot { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--border); color: var(--text-3); font-size: 13px; }

.endpoint { margin: 0 0 30px; padding: 0 0 8px; border-bottom: 1px solid var(--border); }
.endpoint h3 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font: 600 15px/1.4 var(--font-family-mono); margin-top: 28px; }
.endpoint h3 .badge { height: 22px; font-size: 12px; }
.endpoint .auth { font: 500 12px/1 var(--font-family-mono); color: var(--text-3); margin-left: auto; }

details { margin: 0 0 14px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
details summary { cursor: pointer; padding: 12px 14px; font-weight: 500; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: "+"; display: inline-block; width: 18px; color: var(--accent-text); font-family: var(--font-family-mono); }
details[open] summary::before { content: "−"; }
details > :not(summary) { margin-left: 14px; margin-right: 14px; }
details > :last-child { margin-bottom: 14px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
@media print { .site-header, .sidebar, .toc, .pager { display: none; } .layout { display: block; } main { padding: 0; } }
