/* Docs portal styles.
 *
 * Everything above the "implementation additions" fence is the imported design
 * verbatim (Claude Design project "API-as-Product Platform Design", docs.html).
 * Keep it that way -- TestDocsDesignCSSIsReproducedVerbatim fails on drift, so a
 * re-import stays a one-file update.
 *
 * NOTE: docs pages load ds/styles.css and this file, but NOT site.css. Both page
 * stylesheets define :root tokens with different values (--leading is 26px here,
 * 28px on the landing page), so loading both would let one silently override the
 * other depending on link order. The design keeps them separate too: each
 * prototype carries its own <style> block.
 */

:root {
  --leading: 26px;
  --edge: clamp(16px, 3vw, 36px);
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
}
body { margin: 0; text-wrap: pretty; }
a { color: var(--color-accent-700); }
a:hover { color: var(--color-accent-800); }
.nav { padding-inline: var(--edge); position: sticky; top: 0; z-index: 20; background: var(--color-bg); }
.nav .docsearch { flex: 1; max-width: 420px; margin-inline: var(--space-6); }
.nav .input { min-height: 36px; width: 100%; }
@media (max-width: 760px) { .nav .docsearch { display: none; } }

.shell { display: grid; grid-template-columns: 268px minmax(0, 1fr) 232px;
  gap: 0 clamp(24px, 3.5vw, 56px); max-width: 1440px; margin: 0 auto; padding: 0 var(--edge); align-items: start; }
@media (max-width: 1180px) { .shell { grid-template-columns: 248px minmax(0, 1fr); } .toc { display: none; } }
@media (max-width: 820px) { .shell { grid-template-columns: 1fr; } .side { position: static; height: auto; } }

/* — left rail: dataset switcher + per-service tree — */
.side { position: sticky; top: 76px; height: calc(100vh - 96px); overflow-y: auto;
  padding: var(--leading) 0 calc(2 * var(--leading)); }
.switch { background: var(--color-surface); border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4); display: flex; align-items: center; gap: var(--space-3);
  cursor: pointer; box-shadow: var(--shadow-sm); }
.switch .lbl { font-size: 11.5px; letter-spacing: .07em; text-transform: uppercase; font-weight: 700;
  color: color-mix(in srgb, var(--color-text) 58%, transparent); display: block; }
.switch .val { font-family: var(--font-heading); font-size: 17px; line-height: 22px; }
.switch .caret { margin-left: auto; color: var(--color-accent-700); font-size: 13px; }
.tree { margin: var(--leading) 0 0; }
.tree h4 { font-size: 11.5px; letter-spacing: .07em; text-transform: uppercase; font-weight: 700;
  color: color-mix(in srgb, var(--color-text) 58%, transparent); margin: var(--leading) 0 var(--space-2); }
.tree h4:first-child { margin-top: 0; }
.tree ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.tree a { display: flex; align-items: center; gap: var(--space-2); text-decoration: none;
  font-size: 14.5px; line-height: 20px; padding: 6px 12px; border-radius: 999px;
  color: color-mix(in srgb, var(--color-text) 82%, transparent); }
.tree a:hover { background: var(--color-accent-100); color: var(--color-accent-800); }
.tree a[aria-current="page"] { background: var(--color-accent-200); color: var(--color-accent-800); font-weight: 600; }
.tree .m { font-family: var(--mono); font-size: 10.5px; font-weight: 700; letter-spacing: .04em;
  color: var(--color-accent-2-700); min-width: 2.6em; }

/* — center column — */
main { padding: var(--leading) 0 calc(3 * var(--leading)); min-width: 0; }
.crumbs { font-size: 12.5px; line-height: 20px; letter-spacing: .02em;
  color: color-mix(in srgb, var(--color-text) 58%, transparent); }
h1.doc { font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  font-size: 40px; line-height: 46px; margin: var(--space-3) 0 0; margin-left: -0.028em;
  text-box: trim-both cap alphabetic; }
.lede { font-size: 16.5px; line-height: var(--leading); max-width: 62ch;
  margin: var(--space-4) 0 0; color: color-mix(in srgb, var(--color-text) 82%, transparent); }
h2.doc { font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  font-size: 26px; line-height: 32px; margin: calc(2 * var(--leading)) 0 var(--space-3);
  text-box: trim-both cap alphabetic; }
h3.doc { font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  font-size: 19px; line-height: 26px; margin: calc(1.5 * var(--leading)) 0 var(--space-2); }
p.doc, li.doc { font-size: 15.5px; line-height: var(--leading); max-width: 68ch;
  color: color-mix(in srgb, var(--color-text) 82%, transparent); }
code { font-family: var(--mono); font-size: 0.88em; background: var(--color-neutral-200);
  border-radius: 6px; padding: 1px 5px; }

.endpoint { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3);
  background: var(--color-surface); border-radius: 999px; padding: var(--space-3) var(--space-4);
  margin: var(--space-4) 0 0; }
.endpoint .verb { font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: .06em;
  background: var(--color-accent-2-700); color: var(--color-accent-2-100);
  border-radius: 999px; padding: 4px 12px; }
.endpoint .path { font-family: var(--mono); font-size: 14.5px; }
.endpoint .copy { margin-left: auto; }

.table { width: 100%; }
.table code { background: var(--color-accent-100); }
.tbl-wrap { overflow-x: auto; margin-top: var(--space-4); }

.code { background: var(--color-neutral-900); border-radius: var(--radius-md);
  overflow: hidden; box-shadow: var(--shadow-sm); margin-top: var(--space-4); }
.code-tabs { display: flex; gap: var(--space-2); padding: var(--space-3) var(--space-3) 0; flex-wrap: wrap; }
.code-tab { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  border: 0; cursor: pointer; border-radius: 999px; padding: 6px 13px;
  background: transparent; color: var(--color-neutral-400); font-family: var(--font-body); }
.code-tab[aria-selected="true"] { background: var(--color-accent-2-800); color: var(--color-accent-2-100); }
.code-tab:hover { color: var(--color-neutral-200); }
.code-tab:focus-visible { outline: 2px solid var(--color-accent-400); outline-offset: 2px; }
.code pre { margin: 0; padding: var(--space-4) var(--space-4) var(--space-6);
  font-family: var(--mono); font-size: 12.5px; line-height: 21px; color: var(--color-neutral-200); overflow-x: auto; }
.code .c { color: var(--color-neutral-500); }
.code .k { color: var(--color-accent-300); }
.code .s { color: var(--color-accent-2-300); }

/* — try-it panel (HTMX) — */
.tryit { background: var(--color-accent-2-100); border-radius: var(--radius-lg);
  padding: var(--space-6); margin-top: var(--leading); }
.tryit h3 { font-family: var(--font-heading); font-size: 19px; line-height: 26px; margin: 0 0 var(--space-3); }
.tryit .row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.tryit .input { min-height: 36px; }
.tryit .out { background: var(--color-neutral-900); color: var(--color-neutral-200);
  border-radius: var(--radius-md); font-family: var(--mono); font-size: 12.5px; line-height: 21px;
  padding: var(--space-4); margin: var(--space-4) 0 0; overflow-x: auto; }
.tryit .status { font-family: var(--mono); font-size: 12px; color: var(--color-accent-2-700); }

/* — annotation callout — */
.anno { border-left: 0; background: var(--color-accent-100); border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-6); margin-top: var(--leading); max-width: 74ch; }
.anno b { display: block; font-family: var(--font-heading); font-weight: 400; font-size: 15px;
  color: var(--color-accent-800); margin-bottom: 4px; }
.anno p { font-size: 14.5px; line-height: 23px; margin: 0;
  color: color-mix(in srgb, var(--color-text) 82%, transparent); }
.anno ul { margin: var(--space-2) 0 0; padding-left: 1.1em; font-size: 14.5px; line-height: 23px;
  color: color-mix(in srgb, var(--color-text) 82%, transparent); }

/* — right rail — */
.toc { position: sticky; top: 76px; padding: calc(3 * var(--leading)) 0 var(--leading); }
.toc h4 { font-size: 11.5px; letter-spacing: .07em; text-transform: uppercase; font-weight: 700;
  color: color-mix(in srgb, var(--color-text) 58%, transparent); margin: 0 0 var(--space-3); }
.toc ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.toc a { font-size: 13.5px; line-height: 20px; text-decoration: none;
  color: color-mix(in srgb, var(--color-text) 70%, transparent); }
.toc a:hover, .toc a[aria-current="true"] { color: var(--color-accent-800); }
.pager { display: flex; justify-content: space-between; gap: var(--space-4);
  margin-top: calc(2 * var(--leading)); flex-wrap: wrap; }

/* ══════════════════════════════════════════════════════════════════════════
   Implementation additions
   ──────────────────────────────────────────────────────────────────────────
   Not in the imported design, because a static mockup did not need them: the
   tree and TOC are real navigation here, the try-it panel is a real form, and
   several controls the mockup drew as <div>/<span> are now interactive.
   Nothing below changes a rendered pixel of the design.
   ══════════════════════════════════════════════════════════════════════ */

/* The dataset switcher is a <details> so it opens without JavaScript. The design
   draws it as a div with role="button"; a control that only works with JS would
   be the one piece of navigation that breaks with it off. */
.switch-wrap { position: relative; }
.switch-wrap > summary { list-style: none; }
.switch-wrap > summary::-webkit-details-marker { display: none; }
.switch-wrap[open] .caret { transform: rotate(180deg); }
.switch .caret { transition: transform .15s ease; }
.switch-menu { list-style: none; margin: var(--space-2) 0 0; padding: var(--space-2);
  background: var(--color-surface); border-radius: var(--radius-md);
  box-shadow: var(--shadow-md); display: flex; flex-direction: column; gap: 1px; }
.switch-menu a { display: block; padding: 6px 12px; border-radius: 999px;
  text-decoration: none; font-size: 14.5px; line-height: 20px;
  color: color-mix(in srgb, var(--color-text) 82%, transparent); }
.switch-menu a:hover { background: var(--color-accent-100); color: var(--color-accent-800); }
.switch-menu [aria-selected="true"] a { background: var(--color-accent-200);
  color: var(--color-accent-800); font-weight: 600; }

/* Tree and TOC entries with no page behind them yet. Rendered as text rather than
   as href="#", because a link that goes nowhere is worse than an honest label. */
.tree .soon, .toc .soon {
  display: block; padding: 6px 12px; font-size: 14.5px; line-height: 20px;
  color: color-mix(in srgb, var(--color-text) 42%, transparent); cursor: default;
}
.toc .soon { padding: 0; font-size: 13.5px; }

/* The design's nav search is a bare input; here it is a real form. */
.nav form.docsearch { display: flex; }

/* Required-parameter marker in the params table. */
.table .req { font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase;
  font-weight: 700; color: var(--color-accent-700); }

/* Right rail: space the second group's heading, which the design does inline. */
.toc h4.toc-actions { margin-top: 26px; }

/* Dataset overview reuses .endpoint as a status bar. */
.endpoint .status-note { margin-left: auto; font-family: var(--mono); font-size: 12px;
  color: color-mix(in srgb, var(--color-text) 58%, transparent); }

/* Try-it output. The design shows one <pre>; these two lines label what came back,
   which matters because it is a documented example rather than a live call. */
.tryit .try-meta, .tryit .try-note {
  display: block; font-family: var(--mono); font-size: 11.5px; line-height: 18px;
}
.tryit .try-meta { color: var(--color-accent-2-300); }
.tryit .try-note { color: var(--color-neutral-500); margin-bottom: var(--space-2); }
.tryit form { margin: 0; }
.tryit .try-query { flex: 1 1 260px; }
/* hx-indicator target: dim while the request is in flight. */
#try-out.htmx-request { opacity: .55; transition: opacity .12s ease; }
@media (prefers-reduced-motion: reduce) { #try-out.htmx-request { transition: none; } }

/* The copy control is an <a> so it works without JS (it jumps to the request
   section); app.js upgrades it to a clipboard write. */
.endpoint a.copy { text-decoration: none; }

/* Narrow screens: content first, navigation after.
 *
 * The design collapses .shell to one column at 820px and makes .side static, which
 * is faithfully reproduced above. The consequence it did not anticipate is that the
 * full tree -- four groups, ~15 links -- then sits ABOVE the article, so a reader on
 * a phone scrolls past roughly a screen and a half of navigation to reach the first
 * sentence.
 *
 * Reordering the grid fixes that without touching the design's rules or its
 * appearance on any wider viewport: the article comes first, the tree and the TOC
 * follow it. Pure CSS on a grid that is already single-column here, so DOM order
 * (and therefore tab order and reading order for assistive tech) stays
 * navigation-first, which is where it belongs.
 */
@media (max-width: 820px) {
  .shell > main { order: 1; }
  .shell > .side { order: 2; padding-top: 0; border-top: 1px solid var(--color-divider); }
  .shell > .toc { order: 3; }
  /* The switcher is the one bit of the rail worth keeping reachable up top, so it
     stays a compact control rather than a full-width card. */
  .side .switch { max-width: 320px; }
}
