/* ============================================================ */
/* agent-video-editor — public MCP tool reference (`/docs`)      */
/* ============================================================ */
/* ADDITIVE layer. docs.html loads landing.css FIRST and this     */
/* file second; landing.css owns the :root design tokens, the     */
/* page shell (.lp-header / .lp-main / .lp-section / .lp-footer), */
/* the buttons, the code block and the scroll-reveal. Everything  */
/* here is namespaced `.docs-*` (custom properties `--docs-*`)    */
/* and only ever *adds*.                                          */
/*                                                                */
/* There is deliberately NO :root token block in this file. The   */
/* palette already lives in exactly two hand-synced copies        */
/* (viewer.css and landing.css, both mirrored from                */
/* frontend/src/styles/tokens.css) and landing.css's own header   */
/* calls that fragility out by name. A third copy would be a      */
/* third thing to forget. If you need a colour here, use the      */
/* token — do not restate it.                                     */
/*                                                                */
/* Dark only, like the rest of the public site: `color-scheme:    */
/* dark` is set once in landing.css and there is no               */
/* prefers-color-scheme rule anywhere in this stylesheet.         */
/* ============================================================ */

/* Layout constants live on <body class="docs-page"> rather than :root, so
   this file never touches the shared token scope. */
.docs-page {
  /* Height of the sticky .lp-header. Used twice: to offset the sticky
     sidebar, and as the scroll-margin on every in-page anchor target so a
     jumped-to heading never lands underneath the header. */
  --docs-header-h: 4.2rem;
  --docs-anchor-gap: calc(var(--docs-header-h) + var(--sp-3));
  --docs-toc-w: 232px;

  /* Focus indicator. The landing page's convention is
     `0 0 0 3px rgba(79,143,247,0.2)`, but composited over our three surfaces
     that 20%-alpha blue only reaches ~1.1-1.3:1 — WCAG 2.2 SC 1.4.11 wants
     >= 3:1 for a focus indicator, and on this page the ring is the ONLY focus
     signal for the skip link, the filter, 50 TOC links, 40 self-links and the
     table scroll regions. So docs pages override it with a solid two-stop
     ring: an inner --bg-app halo separates the indicator from the component's
     own border, and the outer --accent stop carries the contrast (5.1-5.7:1
     against every surface we sit on). Scoped to .docs-page — landing.css is
     not touched. */
  --docs-focus-ring: 0 0 0 2px var(--bg-app), 0 0 0 4px var(--accent);
}

/* Every jump target on the page. Anchors are the primary navigation here, so
   this is load-bearing, not polish. */
.docs-page .lp-section[id],
.docs-step[id],
.docs-group[id],
.docs-tool[id] {
  scroll-margin-top: var(--docs-anchor-gap);
}

/* ============================================================ */
/* Skip link — first focusable element on the page               */
/* ============================================================ */
.docs-skip {
  position: absolute;
  left: var(--sp-2);
  top: var(--sp-2);
  z-index: 40;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  transform: translateY(-200%);
  transition: transform var(--dur-fast) var(--ease-sharp);
}
.docs-skip:focus {
  transform: translateY(0);
  outline: none;
  box-shadow: var(--docs-focus-ring);
}

/* The .lp-* controls this page borrows carry landing.css's own focus ring
   (rgba(79,143,247,0.2) / 0.35), which measures 1.3-1.9:1 against our surfaces
   and fails SC 1.4.11 just as the .docs-* one did. Re-point them at the strong
   ring here rather than leaving half the page's focusable elements on a ring
   you cannot see. Scoped to .docs-page, so landing.css and /ui are untouched
   and this file stays purely additive. */
.docs-page .lp-btn:focus-visible,
.docs-page .lp-copy:focus-visible,
.docs-page .lp-link:focus-visible,
.docs-page .lp-header__brand:focus-visible,
.docs-page .lp-header__nav a.lp-nav-link:focus-visible,
.docs-page .lp-footer a:focus-visible {
  outline: none;
  box-shadow: var(--docs-focus-ring);
}

/* ============================================================ */
/* 00 · Hero                                                     */
/* ============================================================ */
.docs-hero .lp-strip {
  max-width: 200px;
  margin-bottom: var(--sp-4);
}
.docs-hero__title {
  font-size: var(--fs-display);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin: 0 0 var(--sp-3);
}
.docs-hero__lead {
  font-size: var(--fs-lead);
  color: var(--fg-muted);
  max-width: 54ch;
  margin: 0 0 var(--sp-4);
}
/* The endpoint line is landing.css's .lp-prompt; it ships as a <div> there
   and a <p> here, so reset the paragraph margin. */
.docs-hero .lp-prompt {
  margin: 0;
  max-width: 100%;
}

/* Stat tiles: a <dl>, so each fact keeps its label/value relationship. */
.docs-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--sp-3);
  margin: var(--sp-4) 0 0;
}
.docs-stat {
  min-width: 0;
  padding: var(--sp-3);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-top: 2px solid var(--el-clip-border);
}
/* The four-colour motif again, one tile each — same order as .lp-strip. */
.docs-stats > .docs-stat:nth-child(2) { border-top-color: var(--el-text-border); }
.docs-stats > .docs-stat:nth-child(3) { border-top-color: var(--el-audio-border); }
.docs-stats > .docs-stat:nth-child(4) { border-top-color: var(--el-overlay-border); }

.docs-stat__label {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--fs-mono-label);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--lp-faint-text);
}
.docs-stat__value {
  margin: var(--sp-1) 0 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--fg);
}
.docs-stat__value--mono {
  font-family: var(--font-mono);
  font-size: var(--fs-md);
  font-weight: 500;
  letter-spacing: 0;
  /* Long values ("streamable-http") must wrap inside the tile rather than
     widen the grid track and push the page sideways. */
  overflow-wrap: anywhere;
}

/* ============================================================ */
/* 01 · Quick start                                              */
/* ============================================================ */
.docs-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--sp-4);
}
/* Same trap as .lp-hero__copy and .lp-code in landing.css: a grid item defaults
   to `min-width: auto`, i.e. it refuses to shrink below its min-content width.
   The step's <pre> is one long non-wrapping mono line, so on a 375px phone the
   implicit `auto` track grew to 624px and dragged the whole PAGE into a
   horizontal scroll instead of scrolling inside the <pre>'s own
   `overflow-x: auto`. `min-width: 0` lets the item take the track's width and
   hands the overflow back to the <pre>, where it belongs. */
.docs-step {
  min-width: 0;
  position: relative;
  padding: var(--sp-4) var(--sp-4) var(--sp-4) calc(var(--sp-4) * 3.25);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.docs-step__num {
  position: absolute;
  left: var(--sp-4);
  top: var(--sp-4);
  font-family: var(--font-mono);
  font-size: var(--fs-mono-label);
  color: var(--accent);
  letter-spacing: 0.08em;
}
.docs-step__title {
  margin: 0 0 var(--sp-2);
  font-size: var(--fs-h3);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.docs-step__body {
  margin: 0;
  color: var(--fg-muted);
  max-width: 72ch;
}
.docs-step__code { margin-top: var(--sp-3); }

/* ============================================================ */
/* 02 · Reference — sidebar + content                            */
/* ============================================================ */
.docs-ref {
  display: grid;
  grid-template-columns: var(--docs-toc-w) minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 2.5rem);
  /* Deliberately NOT `align-items: start`: that would shrink the nav column to
     its own content height, and a sticky child can only travel inside its
     parent's box. The default `stretch` gives the sidebar the full height of
     the content column, which is what makes the TOC follow the reader. */
  margin-top: var(--sp-4);
}

.docs-toc { min-width: 0; }
.docs-toc__inner {
  position: sticky;
  top: var(--docs-anchor-gap);
  max-height: calc(100vh - var(--docs-anchor-gap) - var(--sp-4));
  overflow-y: auto;
  padding-right: var(--sp-1);
}

/* --- Filter --- */
.docs-filter { margin-bottom: var(--sp-3); }
.docs-filter__input {
  width: 100%;
  padding: 0.45rem 0.6rem;
  background: var(--bg-elevated);
  /* NOT --border (#262b33): at ~1.2:1 against --bg-elevated it is fine for a
     decorative divider but not for the visible boundary of an editable field,
     which SC 1.4.11 holds to >= 3:1. --lp-faint-text is an existing token
     (landing.css's AA-safe grey) and measures 4.8-5.5:1 on all three surfaces,
     so the field reads as a field without inventing a bespoke colour. */
  border: 1px solid var(--lp-faint-text);
  border-radius: var(--radius-sm);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  transition: border-color var(--dur-fast) var(--ease-sharp),
    box-shadow var(--dur-fast) var(--ease-sharp);
}
.docs-filter__input::placeholder { color: var(--lp-faint-text); }
.docs-filter__input:focus-visible,
.docs-filter__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--docs-focus-ring);
}
.docs-filter__status {
  margin: var(--sp-1) 0 0;
  min-height: 1.2em; /* reserve the row so filling it never shifts the list */
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--lp-faint-text);
}

/* --- The tree --- */
.docs-toc__list,
.docs-toc__tools {
  list-style: none;
  margin: 0;
  padding: 0;
}
.docs-toc__group + .docs-toc__group { margin-top: var(--sp-2); }

.docs-toc__link {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: 0.25rem 0.4rem;
  border-left: 2px solid transparent;
  border-radius: var(--radius-sm);
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--fg-muted);
  transition: color var(--dur-fast) var(--ease-sharp),
    border-color var(--dur-fast) var(--ease-sharp);
}
.docs-toc__link:hover { color: var(--fg); }
.docs-toc__link:focus-visible {
  outline: none;
  box-shadow: var(--docs-focus-ring);
}
/* Scrollspy target. The attribute is both the a11y signal and the style hook,
   so the two can never drift apart. `location` is the token ARIA defines for
   "the current item within a set" — "page" belongs to the header's /docs link,
   and "true" is the unspecific fallback. */
.docs-toc__link[aria-current="location"] {
  color: var(--fg);
  border-left-color: var(--accent);
  background: rgba(79, 143, 247, 0.08);
}
.docs-toc__count {
  flex: none;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 400;
  color: var(--lp-faint-text);
}

.docs-toc__tools {
  margin: var(--sp-1) 0 0;
  padding-left: var(--sp-3);
  border-left: 1px solid var(--border);
}
/* SC 2.5.8 (Target Size, Minimum) wants 24x24 CSS px. These 40 links sit flush
   against each other, so the "spacing" exception does not apply and the target
   really is the box — hence min-height rather than extra margin. */
.docs-toc__tool a {
  display: flex;
  align-items: center;
  min-height: 24px;
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--lp-faint-text);
  overflow-wrap: anywhere;
  transition: color var(--dur-fast) var(--ease-sharp);
}
.docs-toc__tool a:hover { color: var(--accent); }
.docs-toc__tool a:focus-visible {
  outline: none;
  color: var(--fg);
  box-shadow: var(--docs-focus-ring);
}

/* ============================================================ */
/* Groups + tool cards                                           */
/* ============================================================ */
.docs-content { min-width: 0; }

.docs-group + .docs-group {
  margin-top: calc(var(--sp-4) * 2.5);
  padding-top: calc(var(--sp-4) * 1.5);
  border-top: 1px solid var(--border);
}
.docs-group__title {
  /* An <h2> for heading order; sized as a sub-head because it sits inside the
     reference section, not above it. */
  margin: 0 0 var(--sp-2);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.docs-group__desc {
  margin: 0 0 var(--sp-4);
  color: var(--fg-muted);
  max-width: 72ch;
}

.docs-tool {
  padding: var(--sp-4);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--dur-fast) var(--ease-sharp);
}
.docs-tool + .docs-tool { margin-top: var(--sp-3); }
.docs-tool:target { border-color: var(--accent); }

.docs-tool__head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}
.docs-tool__name {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--fs-h3);
  font-weight: 600;
  color: var(--fg);
  overflow-wrap: anywhere;
}
/* Self-link. Always in the DOM and always keyboard-reachable — it only fades
   in on hover/focus, it is never display:none. */
.docs-tool__anchor {
  font-family: var(--font-mono);
  font-size: var(--fs-md);
  line-height: 1;
  padding: 0.15rem 0.3rem;
  border-radius: var(--radius-sm);
  color: var(--lp-faint-text);
  opacity: 0.45;
  transition: opacity var(--dur-fast) var(--ease-sharp),
    color var(--dur-fast) var(--ease-sharp);
}
.docs-tool:hover .docs-tool__anchor { opacity: 1; }
.docs-tool__anchor:hover { color: var(--accent); opacity: 1; }
.docs-tool__anchor:focus-visible {
  outline: none;
  opacity: 1;
  color: var(--accent);
  box-shadow: var(--docs-focus-ring);
}

/* --- Tier badge --- */
/* The word is the label; colour only echoes it, so nothing here depends on
   hue alone. */
.docs-tier {
  margin-left: auto;
  flex: none;
  padding: 0.1rem 0.5rem;
  border: 1px solid;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.04em;
  cursor: help;
}
/* --ok (#46a758) is only ~3.4:1 on --bg-panel and fails AA for this size.
   --el-audio-border (#34d399) is the same green already in the palette at a
   brightness that clears it — the same trade .lp-btn--solid makes when it
   borrows --el-clip instead of --accent. */
.docs-tier--public {
  color: var(--el-audio-border);
  border-color: rgba(52, 211, 153, 0.35);
  background: rgba(52, 211, 153, 0.08);
}
.docs-tier--operator {
  color: var(--warn);
  border-color: rgba(240, 161, 59, 0.4);
  background: rgba(240, 161, 59, 0.1);
}

.docs-tool__summary {
  margin: 0 0 var(--sp-3);
  color: var(--fg-muted);
  max-width: 72ch;
}
.docs-tool__label {
  margin: 0 0 var(--sp-2);
  font-family: var(--font-mono);
  font-size: var(--fs-mono-label);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--lp-faint-text);
}

/* --- Parameter table --- */
/* The wrapper scrolls, never the page. It is focusable (tabindex="0" in the
   markup) so a keyboard user can reach the scroll region without a mouse. */
.docs-table__wrap {
  overflow-x: auto;
  /* Same reasoning as the filter field: this box is a keyboard-focusable
     scroll region, so its edge is a functional boundary held to >= 3:1, not a
     decorative rule. The card, step and divider borders stay on --border. */
  border: 1px solid var(--lp-faint-text);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
}
.docs-table__wrap:focus-visible {
  outline: none;
  box-shadow: var(--docs-focus-ring);
}
.docs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-md);
  /* Keeps the description column elastic while the three narrow columns stay
     legible instead of collapsing to one word per line. */
  min-width: 480px;
}
.docs-table th,
.docs-table td {
  padding: var(--sp-2) var(--sp-3);
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}
.docs-table tbody tr:last-child th,
.docs-table tbody tr:last-child td { border-bottom: none; }
.docs-table th {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--lp-faint-text);
  background: var(--bg-panel);
  white-space: nowrap;
}
.docs-table td { color: var(--fg-muted); }
.docs-td--name {
  font-family: var(--font-mono);
  color: var(--fg) !important;
  white-space: nowrap;
}
.docs-td--type {
  font-family: var(--font-mono);
  color: var(--lp-faint-text) !important;
  white-space: nowrap;
}
.docs-td--req { white-space: nowrap; }

.docs-req {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--lp-faint-text);
}
.docs-req--required { color: var(--accent); }
.docs-req code {
  font-family: var(--font-mono);
  color: var(--fg);
}

.docs-noparams {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--fs-md);
  color: var(--lp-faint-text);
}

/* --- Returns --- */
.docs-returns {
  margin: var(--sp-3) 0 0;
  color: var(--fg-muted);
  max-width: 72ch;
}
.docs-returns__label {
  margin-right: var(--sp-2);
  font-family: var(--font-mono);
  font-size: var(--fs-mono-label);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--lp-faint-text);
}

/* --- Constraints / notes --- */
.docs-notes {
  margin: var(--sp-3) 0 0;
  padding: var(--sp-2) 0 var(--sp-2) var(--sp-3);
  list-style: none;
  border-left: 2px solid var(--el-text-border);
  background: rgba(212, 167, 44, 0.05);
  color: var(--fg-muted);
  font-size: var(--fs-body);
  max-width: 72ch;
}
.docs-notes li + li { margin-top: var(--sp-1); }
.docs-notes code {
  font-family: var(--font-mono);
  color: var(--fg);
}

/* --- Filter states --- */
.docs-is-hidden { display: none !important; }

.docs-empty {
  margin: var(--sp-4) 0 0;
  padding: var(--sp-4);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--fg-muted);
  text-align: center;
}
.docs-kbd {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--fg);
}

/* ============================================================ */
/* Responsive — reusing landing.css's two breakpoints            */
/* ============================================================ */
@media (max-width: 860px) {
  .docs-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* Below tablet the 232px sidebar leaves the parameter tables too narrow to
     read, so the TOC stops being a column and becomes a header block. It also
     stops being sticky: a pinned nav costs more of a short viewport than it
     gives back. */
  .docs-ref { grid-template-columns: 1fr; }
  .docs-toc__inner {
    position: static;
    max-height: none;
    overflow-y: visible;
    padding: var(--sp-3);
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }
  /* Ten groups is a scannable list; ten groups plus forty nested tools is a
     wall between the reader and the content. Cards still filter and the count
     is still announced — only this nested list goes. */
  .docs-toc__tools { display: none; }
  .docs-toc__list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sp-1);
  }
  .docs-toc__group + .docs-toc__group { margin-top: 0; }
}

@media (max-width: 560px) {
  .docs-page {
    /* The header wraps onto a second row at this width, so every anchor
       target needs a deeper landing pad. */
    --docs-header-h: 7.4rem;
  }
  .docs-stats { grid-template-columns: 1fr; }
  .docs-toc__list { grid-template-columns: 1fr; }
  .docs-step {
    padding: var(--sp-4);
    padding-top: calc(var(--sp-4) * 2.25);
  }
  .docs-tool { padding: var(--sp-3); }
  /* The badge drops under the name rather than squeezing it. */
  .docs-tier { margin-left: 0; }
}

/* ============================================================ */
/* prefers-reduced-motion — mandatory, mirrors landing.css       */
/* ============================================================ */
/* landing.css already zeroes every transition/animation and turns off
   `scroll-behavior: smooth` under this query; these rules only cover the
   pieces that must stay *visible* rather than merely still. */
@media (prefers-reduced-motion: reduce) {
  .docs-skip { transition: none !important; }
  /* Without the fade, the self-link would sit at 45% opacity forever — pin it
     to fully legible instead. */
  .docs-tool__anchor {
    opacity: 1;
    transition: none !important;
  }
}
