/* web/docs.css - the API docs (/docs, rendered by lib/docs.ts): a top bar, the sections
   in a rail on the left, the reference in a readable column. The console's Docs page
   mounts the same .docs-layout and uses these same rules; it only moves the sticky
   offsets below, which default to this page's top bar. Colours and fonts are
   style.css's tokens. */

:root {
  --docs-sticky-top: 76px;   /* the rail, under the top bar */
  --docs-strip-top: 57px;    /* the phone's section strip, under the top bar */
  --docs-strip-height: 56px;
}

/* style.css sets body to height: 100%, which would let the sticky top bar stick for only
   one screen; the docs page grows with its content. */
.docs-page { height: auto; min-height: 100vh; }

/* ── Top bar ────────────────────────────────────────────────────────────────── */
.docs-top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px clamp(16px, 3vw, 32px);
  background: color-mix(in srgb, var(--ink) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.docs-brand { color: var(--text); text-decoration: none; font-family: var(--serif); font-size: 19px; display: flex; align-items: baseline; gap: 10px; }
.docs-brand .eyebrow { margin: 0; }
.docs-top-links { display: flex; align-items: center; gap: 18px; font-size: 14px; }
.docs-top-links a { color: var(--muted); text-decoration: none; }
.docs-top-links a:hover { color: var(--text); }
.docs-top-links .docs-top-cta { color: var(--accent-ink); background: var(--accent); padding: 6px 14px; border-radius: 999px; font-weight: 600; }
.docs-top-links .docs-top-cta:hover { color: var(--accent-ink); filter: brightness(1.08); }

/* ── Layout: rail + reading column ──────────────────────────────────────────── */
.docs-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 760px);
  gap: clamp(24px, 4vw, 64px);
  max-width: 1160px;
  margin: 0 auto;
  padding: 32px clamp(16px, 3vw, 32px) 120px;
}
.docs-rail {
  position: sticky; top: var(--docs-sticky-top); align-self: start;
  max-height: calc(100vh - var(--docs-sticky-top) - 20px); overflow-y: auto;
  display: grid; gap: 1px; font-size: 13.5px;
}
.docs-rail a {
  display: flex; align-items: center; gap: 8px;
  color: var(--muted); text-decoration: none;
  padding: 6px 10px; border-radius: 8px; line-height: 1.3;
}
.docs-rail a:hover { color: var(--text); background: var(--panel); }
.docs-rail a.active { color: var(--text); background: var(--panel-2); }
.rail-path { font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; }

/* ── Method badges (rail and headings) ──────────────────────────────────────── */
.method {
  flex: none;
  font-family: var(--mono); font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em;
  padding: 2px 6px; border-radius: 5px; line-height: 1.4;
  background: var(--panel-2); color: var(--muted);
}
.method-get { background: #1d3a2c; color: #7fe0a8; }
.method-post { background: #1f2f4a; color: #8cb8ff; }
.method-ws { background: #3a2a14; color: #f4bd6a; }
.method-delete { background: #44222a; color: var(--danger); }

/* ── Title row ──────────────────────────────────────────────────────────────── */
.docs-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.docs-head h1 { font-family: var(--serif); font-weight: 500; font-size: clamp(30px, 4vw, 40px); line-height: 1.15; margin: 0 0 12px; }

.copy-page { position: relative; flex: none; display: flex; margin-top: 6px; }
.copy-page > button {
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  font-size: 13px; padding: 6px 12px; cursor: pointer;
}
.copy-page > button:hover { background: var(--panel-2); }
.copy-page-main { border-radius: 10px 0 0 10px; }
.copy-page-more { border-radius: 0 10px 10px 0; border-left: 0 !important; padding: 6px 9px !important; }
.copy-page-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20;
  width: 280px; padding: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.45);
  display: grid; gap: 2px;
}
.copy-page-menu[hidden] { display: none; }
.copy-page-menu > * {
  display: grid; gap: 2px; text-align: left;
  padding: 8px 10px; border-radius: 8px; border: 0; background: none; cursor: pointer;
  color: var(--text); text-decoration: none; font: inherit; font-size: 13.5px;
}
.copy-page-menu > *:hover, .copy-page-menu > *:focus-visible { background: var(--panel-2); outline: none; }
.copy-page-menu span { color: var(--muted); font-size: 12.5px; }

/* ── The reference ──────────────────────────────────────────────────────────── */
.docs-body { font-size: 16px; line-height: 1.7; color: #d9d4e4; }
.docs-body .lead { font-size: 18px; color: var(--muted); margin: 0 0 8px; line-height: 1.55; }
.docs-body h2, .docs-body h3 { color: var(--text); scroll-margin-top: calc(var(--docs-sticky-top) + 8px); position: relative; }
.docs-body h2 {
  font-family: var(--serif); font-weight: 500; font-size: 27px; line-height: 1.25;
  margin: 64px 0 12px; padding-top: 28px; border-top: 1px solid var(--line);
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
}
.docs-body h2 .method { font-size: 12px; padding: 3px 8px; }
.docs-body h2 .path { font-family: var(--mono); font-size: 22px; background: none; padding: 0; }
.docs-body .lead + h2 { margin-top: 32px; }
.docs-body h3 .path { background: none; padding: 0; font-size: 16px; }
.docs-body h3 .method { margin-right: 8px; vertical-align: 2px; }
.docs-body h3 { font-size: 17px; font-weight: 600; margin: 32px 0 8px; }
.docs-body p { margin: 0 0 16px; }
.docs-body ul, .docs-body ol { padding-left: 22px; margin: 0 0 16px; }
.docs-body li { margin: 6px 0; }
.docs-body li::marker { color: var(--muted); }
.docs-body strong { color: var(--text); }
.docs-body a { color: var(--accent); text-underline-offset: 3px; }
.docs-body code { font-family: var(--mono); font-size: 0.85em; background: var(--panel-2); border-radius: 5px; padding: 1px 5px; color: var(--text); overflow-wrap: anywhere; }

.docs-body .anchor { position: absolute; left: -22px; color: var(--muted); text-decoration: none; font-weight: 400; opacity: 0; }
.docs-body h2 .anchor { top: 28px; }
.docs-body h2:hover .anchor, .docs-body h3:hover .anchor { opacity: 0.6; }

/* Code blocks: a language label and a copy button (web/docs.js) in the corner. */
.docs-body .code { position: relative; margin: 0 0 20px; }
.docs-body pre {
  margin: 0 0 20px; background: #110e16; border: 1px solid var(--line); border-radius: 12px;
  padding: 16px 18px; overflow-x: auto; font-size: 13px; line-height: 1.6;
}
.docs-body .code pre { margin: 0; padding-top: 30px; }
.docs-body pre code { background: none; padding: 0; font-size: inherit; overflow-wrap: normal; color: #e6e1ef; }
.docs-body .code-bar {
  position: absolute; top: 6px; left: 19px; right: 8px;
  display: flex; align-items: center; justify-content: space-between; pointer-events: none;
}
.docs-body .code-lang { font-family: var(--mono); font-size: 11px; color: var(--muted); text-transform: lowercase; }
.docs-body .code-copy {
  pointer-events: auto;
  font-size: 12px; color: var(--muted); background: var(--panel); border: 1px solid var(--line);
  border-radius: 7px; padding: 2px 9px; cursor: pointer; opacity: 0; transition: opacity 0.15s;
}
.docs-body .code:hover .code-copy, .docs-body .code-copy:focus-visible { opacity: 1; }
.docs-body .code-copy:hover { color: var(--text); }
@media (hover: none) { .docs-body .code-copy { opacity: 1; } }

/* Tables: parameters, errors, events. */
.docs-body .table-wrap { overflow-x: auto; margin: 0 0 20px; border: 1px solid var(--line); border-radius: 12px; }
.docs-body table { border-collapse: collapse; width: 100%; font-size: 14.5px; line-height: 1.55; }
.docs-body th { text-align: left; font-weight: 600; color: var(--text); background: var(--panel); padding: 9px 14px; border-bottom: 1px solid var(--line); }
.docs-body td { padding: 9px 14px; border-top: 1px solid var(--line); vertical-align: top; }
.docs-body tr:first-child td { border-top: 0; }
.docs-body td:first-child { white-space: nowrap; }
.docs-body td:first-child code { overflow-wrap: normal; }

/* Callouts: `> **Note:** …`. */
.docs-body .callout { margin: 0 0 20px; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line); border-left: 3px solid var(--accent); background: var(--panel); }
.docs-body .callout p { margin: 0; }
.docs-body .callout-warning, .docs-body .callout-important { border-left-color: #f4bd6a; }
.docs-body .callout-tip { border-left-color: #7fe0a8; }

.docs-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  padding: 8px 16px; border-radius: 999px; font-size: 13.5px; z-index: 30;
}

/* ── Narrow screens: the rail becomes a scrollable strip under the top bar ──── */
@media (max-width: 900px) {
  .docs-layout { grid-template-columns: minmax(0, 1fr); padding-top: 0; }
  .docs-rail {
    position: sticky; top: var(--docs-strip-top); z-index: 5; max-height: none;
    display: flex; overflow-x: auto; gap: 4px; padding: 10px 0;
    margin: 0 calc(-1 * clamp(16px, 3vw, 32px)); padding-inline: clamp(16px, 3vw, 32px);
    background: var(--ink); border-bottom: 1px solid var(--line);
  }
  .docs-rail a { white-space: nowrap; flex: none; }
  .docs-body h2, .docs-body h3 { scroll-margin-top: calc(var(--docs-strip-top) + var(--docs-strip-height) + 16px); }
  .docs-head { flex-direction: column; gap: 0; margin-top: 24px; }
  .docs-body .anchor { display: none; }
}
@media (max-width: 560px) {
  .docs-top-links a:not(.docs-top-cta) { display: none; }
  .docs-body { font-size: 15.5px; }
  .docs-body h2 { font-size: 23px; }
  .docs-body h2 .path { font-size: 18px; }
}
