/* ============================================================================
   Documentation family — /methodology/, /guide/, /api/, /embed/
   ============================================================================

   The four routes that are *documentation* rather than data surfaces. They are
   one layout: a PageHeader, then a sticky contents column beside a reading
   column, sections with an h2/h3 rhythm, tables as `.am-table`, code in a
   quiet mono block, callouts as `.am-panel--quiet`. No KPI row, no dashboard
   grid, no card per paragraph — a reference page's job is to be read and
   checked against, and the 2026 language for that is the editorial one the
   reports family already uses.

   Cascade. This sheet is linked from `{% block extra_css %}`, which is
   *before* `bundle-shell.css` (brand → app-shell → canvas-2026 →
   theme-foundation → page-unification → … → am-system → shell-2026) and
   before `bundle-bridge.css` (canvas-bridge, workspaces). So at equal
   specificity those sheets win, and every rule below that answers one of them
   says which.

   What this sheet owns and what it composes:

   | Owns                                        | Composes from am-system.css |
   |---------------------------------------------|-----------------------------|
   | `.dp-*` — the developer portal's own parts  | `.am-doc*` the document frame |
   | `.method-*` — /methodology/'s own parts     | `.am-toc*` the contents column |
   | `.eg-*` — /embed/'s own parts               | `.am-page-head` `.am-report` |
   |                                             | `.am-section-head` `.am-table` |
   |                                             | `.am-panel` `.am-chip` `.am-btn` |
   |                                             | `.am-seg` `.am-search` `.c-disclosure` |

   2026-09-18: `.am-doc*` and `.am-toc*` were written here for these four
   routes and were never about any of them, so they are in am-system.css now,
   beside `.am-report` — which is also what let the reports family retire its
   own copy of the contents column (`.rr-toc`, 110 lines). What is left in
   this file is the four routes' own parts and the answers to the site-wide
   blankets that reach them.

   Two rules still drive the layout, unchanged since the family shipped:

   1. Nothing scrolls the page sideways. A reference page is mostly code
      samples and parameter tables, both of which are wider than a phone, so
      every wide thing scrolls inside its own box and every grid child that
      could be stretched by its content carries `min-width: 0`.

   2. Code is left-to-right in both locales. Arabic prose reads right-to-left;
      a cURL invocation does not, and mirroring one produces a command that
      looks right and cannot be run.
   ============================================================================ */


/* ===========================================================================
   The four routes' own containment
   ===========================================================================
   The document frame (`.am-doc*`) and the contents column (`.am-toc*`) live
   in am-system.css. What stays here is the one thing about them that is not
   generic: the ancestors these four routes have to stop being scroll
   containers, without which the promoted sticky column is inert.
   =========================================================================== */

/* The shell clips horizontal overflow on every page with
   `.main-content { overflow-x: hidden }`, and `hidden` makes that element a
   scroll container -- which silently disables `position: sticky` for
   everything inside it. The contents column was sticky in the stylesheet and
   stationary on screen, with nothing to show why. `clip` does the same
   clipping without creating a scroll container.

   Both of them: the shell sets `overflow-x: hidden` on the body as well, and
   one axis being `hidden` coerces the other from `visible` to `auto`, so the
   body becomes a scroll container that never scrolls -- and a sticky element
   anywhere inside it is inert. Scoped to these four routes, because the rest
   of the site has not been checked against the change. */
html body.page-api_docs,
html body.page-methodology,
html body.page-embed_generator,
html body.page-guide,
body.page-api_docs main.main-content,
body.page-methodology main.main-content,
body.page-embed_generator main.main-content,
body.page-guide main.main-content {
  overflow-x: clip;
  overflow-y: visible;
}



/* ===========================================================================
   PROMOTE to am-system as `.am-code`: the code block
   ===========================================================================
   The class names stay `dp-code*` for now: two tests pin them by string --
   `markets/tests/test_developer_portal.py` asserts
   `<span class="dp-code__label">cURL</span>` for every endpoint, and
   `test_accessibility.py` selects `div.dp-code pre` to prove each block is
   focusable. Renaming the component means moving those with it, which is a
   separate change from restyling it.

   A quiet mono block on the inset ground: a labelled head carrying the copy
   button, the code below it. Nothing tinted, nothing framed in the accent
   colour -- a sample is content, not a claim.
   =========================================================================== */
.dp-code { margin-block-start: var(--c-space-3); }
.dp-code__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--c-space-3);
  background: var(--c-inset);
  border: 1px solid var(--c-line);
  border-block-end: 0;
  border-start-start-radius: var(--c-r-control);
  border-start-end-radius: var(--c-r-control);
  padding: var(--c-space-2) var(--c-space-3);
}
/* No uppercase: the label is the sample's own language name, and
   `text-transform` turned "cURL" into "CURL" on every card. */
.dp-code__label {
  color: var(--c-text-muted);
  font-size: var(--c-t-meta);
  font-weight: var(--c-w-medium);
}
.dp-code pre {
  margin: 0;
  background: var(--c-inset);
  border: 1px solid var(--c-line);
  border-end-start-radius: var(--c-r-control);
  border-end-end-radius: var(--c-r-control);
  padding: var(--c-space-4);
  overflow-x: auto;
  max-block-size: 30rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  direction: ltr;
  text-align: left;
}
.dp-code pre:focus-visible {
  outline: 2px solid var(--c-evidence);
  outline-offset: -2px;
}
/* theme-foundation.css gives every <code> a tinted pill, which is right for
   an identifier in a sentence and wrong inside a code block: the tint paints
   a rectangle behind each line's indentation and turns a JSON sample into a
   striped one. Reset here rather than there -- the pill is correct everywhere
   else on the page. */
.dp-code pre code {
  font-family: var(--c-mono);
  font-size: var(--c-t-meta);
  line-height: 1.6;
  color: var(--c-text-secondary);
  white-space: pre;
  background: none;
  border: 0;
  border-radius: 0;
  padding: 0;
}

/* The copy control. `.am-btn--ghost` carries the geometry, the hover and the
   44px floor; this is only the copied state, which is a colour *and* a label
   change (dev-portal.js swaps the text) because a colour alone is not a
   state. */
.dp-copy[data-dp-copied] { color: var(--c-up-ink); }


/* ===========================================================================
   Tables
   ===========================================================================
   The table itself is `.am-table` from am-system.css. What is here is the
   focusable scroller around it and the two places a documentation table needs
   something the component does not decide.

   PROMOTE: `.dp-scroll` is `.am-table-wrap` with a name of its own. Same
   reason as `.dp-code`: `test_accessibility.py` selects `div.dp-scroll` to
   prove every scroll box is focusable and named, so the rename moves with the
   test, not with the restyle.
   =========================================================================== */
.dp-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-inline: contain;
  min-width: 0;
}
/* The wrapper is the focusable scroller (tabindex=0, role=group); a table
   that scrolled on its own was an unreachable scrollable region for the
   keyboard. */
.dp-scroll > table { overflow: visible; display: table; }
.dp-scroll:focus-visible { outline: 2px solid var(--c-evidence); outline-offset: 2px; }

/* A reference table's cells are prose, not figures: they read from the top,
   not from the middle of a three-line description. */
.am-doc .am-table tbody th,
.am-doc .am-table td { vertical-align: top; }
/* Code inside a documentation table or sentence stays left-to-right and stays
   on its own bidi island; without the isolate an Arabic sentence reorders the
   punctuation of a JSON body around the identifier it belongs to. */
.am-doc code {
  direction: ltr;
  unicode-bidi: isolate;
}
/* An identifier is the row's name: it wraps between words and never inside
   one. `evaluation_pipeline_status` came apart as "evaluation_pipeline_ /
   status", which is not a name any more. */
.am-doc .am-table code { white-space: normal; overflow-wrap: break-word; }
.am-doc .am-table th code,
.am-doc .am-table td:first-child code { white-space: nowrap; }
/* `overflow-wrap: anywhere` counted every cell's min-content as one letter, so
   an auto-layout table was squeezed to the card width ("stri / ng") instead
   of scrolling inside its `.dp-scroll`. `break-word` only breaks a word that
   cannot fit on a line of its own. */
.am-doc .am-table td { overflow-wrap: break-word; }

/* theme-foundation.css gives every <code> a tinted pill. Inside a chip or a
   button the pill is a second box around the first one, drawn in the one
   colour this system reserves for verification. The identifier keeps the mono
   face and takes the control's own ink. */
.am-doc :is(.am-chip, .am-btn) code {
  background: none;
  border: 0;
  border-radius: 0;
  padding: 0;
  color: inherit;
  font-family: var(--c-mono);
  font-size: inherit;
}

/* A quoted paragraph is prose, not a list item: no browser indent, and the
   panel it sits on supplies the inset. */
.am-doc blockquote { margin-inline: 0; }
.am-doc blockquote.am-panel--quiet { margin-block: 0; }


/* ===========================================================================
   /api/ — the developer portal
   =========================================================================== */

/* The body column. A div and not a second <main>: base.html already opens
   <main id="main-content"> around every page body. The class is what the
   layout uses; `test_accessibility.py` asserts both halves of that. */
.dp__main { min-width: 0; }

/* One endpoint. Not `.am-panel`, because `test_developer_portal.py` matches
   `<article class="dp-endpoint" id="…">` as a literal string -- so the panel's
   surface is restated here rather than composed. PROMOTE with the test. */
.dp-endpoint {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--c-r-panel);
  margin-block-end: var(--c-space-3);
  scroll-margin-block-start: 9.5rem;
}
.dp-endpoint,
.dp-endpoint > * { min-width: 0; }
/* Block padding one step tighter than the inline padding: a card is four
   short bands (identity, parameters, a row of disclosures) rather than four
   tall ones, and at 24px the whitespace between bands was taller than the
   disclosure row itself. */
.dp-endpoint > * { padding: var(--c-space-3) var(--c-space-5); }
.dp-endpoint > * + * { border-block-start: 1px solid var(--c-line); }

.dp-endpoint__head { display: grid; gap: var(--c-space-2); }
.dp-endpoint__head p { margin: 0; max-inline-size: 72ch; }
.dp-endpoint__summary {
  color: var(--c-text);
  font-size: var(--c-t-lead);
  line-height: 1.45;
}
.dp-endpoint__line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--c-space-2) var(--c-space-3);
}

/* The method and the path are one object: a mono label on the inset ground.
   It was a cyan pill on a cyan tint, which is the evidence colour spent on
   the word "GET" -- and every endpoint on this page is a GET. */
.dp-method {
  font-family: var(--c-mono);
  font-size: var(--c-t-label);
  font-weight: var(--c-w-bold);
  letter-spacing: 0.06em;
  color: var(--c-text-secondary);
  background: var(--c-inset);
  border: 1px solid var(--c-line);
  border-radius: var(--c-r-chip);
  padding: 0.15rem 0.45rem;
}
.dp-path {
  font-family: var(--c-mono);
  font-size: var(--c-t-body);
  color: var(--c-text);
  overflow-wrap: anywhere;
  direction: ltr;
  unicode-bidi: isolate;
}

/* A quiet label above a table or a list. 13px muted medium, no uppercase
   tracking -- the same register as `.am-table`'s header row, which is what
   this is a header for. */
.dp-subhead {
  margin: 0 0 var(--c-space-2);
  color: var(--c-text-muted);
  font-size: var(--c-t-meta);
  font-weight: var(--c-w-medium);
}

/* --- Disclosures on a card ------------------------------------------------ */
/* The example response and the four code samples of every endpoint, all
   expanded, made this the tallest page on the site by a factor of nine
   (42,807px at 1440 against a 4,552px baseline). They are behind a disclosure
   now. Two rules keep that from costing anything:

   1. The summary is a real target. `display: list-item` is kept -- turning a
      <summary> into a flex container removes the native marker in Chrome and
      leaves a disclosure with no disclosure triangle -- so the children are
      made inline instead, and the block is padded to clear 44px on a phone.
   2. Nothing inside a closed <details> is unreachable to the page's own
      search: the filter matches `data-dp-endpoint`, an attribute, so a
      collapsed sample is still findable, and a link to an id inside one opens
      its ancestors (dev-portal.js). */
.dp-endpoint > .dp-endpoint__more { padding-block: var(--c-space-2); }
.dp-endpoint__more {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--c-space-2) var(--c-space-3);
}
.dp-endpoint__more > .dp-details { min-width: 0; }
/* An opened disclosure takes the whole width under the row, so its content is
   never squeezed into a chip's share of it. */
.dp-endpoint__more > .dp-details[open] { flex: 1 0 100%; }

.dp-details__summary {
  cursor: pointer;
  display: list-item;
  min-block-size: 32px;
  padding: var(--c-space-2) var(--c-space-3);
  border: 1px solid var(--c-line);
  border-radius: var(--c-r-pill);
  background: var(--c-inset);
  list-style-position: inside;
}
.dp-details__summary:hover { border-color: var(--c-line-strong); }
.dp-details__summary::marker { color: var(--c-text-faint); }
.dp-details__summary:hover .dp-subhead { color: var(--c-text); }
.dp-details__summary:focus-visible {
  outline: 2px solid var(--c-evidence);
  outline-offset: 2px;
}
/* A heading is legal inside <summary> and is what keeps the card's outline
   intact; it has to be inline, or it pushes itself off the marker's line. */
.dp-details__summary > .dp-subhead {
  display: inline;
  margin: 0;
}
.dp-details__meta {
  margin-inline-start: var(--c-space-2);
  font-family: var(--c-mono);
  font-size: var(--c-t-label);
  color: var(--c-text-muted);
  overflow-wrap: anywhere;
}
.dp-details[open] > .dp-details__summary { margin-block-end: var(--c-space-3); }

/* --- Lists on the portal -------------------------------------------------- */
.dp-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--c-space-3); }
/* `justify-items: start` because a <code> stretched to the width of a grid
   column reads as a filled bar rather than as an identifier. */
.dp-list li { display: grid; gap: 0.15rem; justify-items: start; }
.dp-list code { font-family: var(--c-mono); font-size: var(--c-t-meta); color: var(--c-text); }
.dp-list span { font-size: var(--c-t-meta); color: var(--c-text-secondary); line-height: 1.6; }
/* These two lists live inside `.am-report`, which draws a bullet before every
   `li` and indents it. A row of chips and a definition list are neither. Two
   classes and a child combinator, because am-system.css loads after this one
   and `.am-report ul > li::before` would otherwise win on order. */
.am-doc .dp-list > li,
.am-doc .dp-states > li {
  margin-block-end: 0;
  padding-inline-start: 0;
}
.am-doc .dp-list > li::before,
.am-doc .dp-states > li::before { content: none; }

.dp-states {
  display: flex;
  flex-wrap: wrap;
  gap: var(--c-space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.dp-change { display: grid; gap: var(--c-space-2); margin-block-end: var(--c-space-5); }
.dp-change h3 { margin-block-start: 0; }
.dp-change ul { margin: 0; padding: 0; list-style: none; display: grid; gap: var(--c-space-2); }
.dp-change li { font-size: var(--c-t-body); color: var(--c-text-secondary); line-height: 1.6; }
.am-doc .dp-change li { padding-inline-start: 0; margin-block-end: 0; }
.am-doc .dp-change li::before { content: none; }
.dp-kind {
  margin-inline-end: 0.45rem;
  color: var(--c-text-muted);
  font-size: var(--c-t-label);
  font-weight: var(--c-w-semi);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
[dir="rtl"] .dp-kind { letter-spacing: 0; }
.dp-kind[data-kind="changed"] { color: var(--c-attention); }
.dp-kind[data-kind="deprecated"],
.dp-kind[data-kind="removed"] { color: var(--c-down-ink); }

.dp-empty {
  font-size: var(--c-t-body);
  color: var(--c-text-muted);
  padding: var(--c-space-5);
  border: 1px dashed var(--c-line-strong);
  border-radius: var(--c-r-panel);
}

.dp__search-status {
  display: block;
  min-block-size: 1.2em;
  color: var(--c-text-muted);
  font-size: var(--c-t-meta);
}

.dp-sr {
  position: absolute;
  inline-size: 1px; block-size: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}


/* ===========================================================================
   /methodology/
   =========================================================================== */

/* The one surface on the page: the definitions table, which is the part a
   reader opens this page to check a published number against. */
.method-defs { margin-block: var(--c-space-4) 0; }
.method-defs .dp-scroll { margin-block-start: var(--c-space-4); }
/* Four columns, and the one that matters is the definition. Left to its own
   devices the table gave the two short columns a third of the width each and
   squeezed the sentence that defines the number into what was left. */
.method-defs .am-table { table-layout: fixed; min-inline-size: 44rem; }
.method-defs .am-table th:nth-child(1),
.method-defs .am-table td:nth-child(1) { inline-size: 24%; }
.method-defs .am-table th:nth-child(2),
.method-defs .am-table td:nth-child(2) { inline-size: 20%; }
.method-defs .am-table th:nth-child(4),
.method-defs .am-table td:nth-child(4) { inline-size: 14%; }
.method-defs .am-table td:nth-child(1) { overflow-wrap: anywhere; }
/* Long values (ISO timestamps, a sentence for the pipeline reason) wrap inside
   their own column instead of running under the Definition. */
.method-defs .am-table td.method-value { overflow-wrap: anywhere; white-space: normal; }
.method-defs .am-table td.method-value bdi { white-space: normal; }

/* The metric key is the row's identity: mono, full ink, and not wrapped. */
.method-key { font-family: var(--c-mono); font-size: var(--c-t-label); color: var(--c-text-muted); overflow-wrap: anywhere; }
.method-defs .am-table th code.method-key { white-space: normal; }
.method-value { font-variant-numeric: tabular-nums; }

.method-note--accuracy {
  border-inline-start: 2px solid var(--c-evidence);
  padding-inline-start: var(--c-space-3);
}
.method-computed {
  margin: var(--c-space-4) 0 0;
  color: var(--c-text-muted);
  font-size: var(--c-t-meta);
  line-height: 1.7;
}
.method-computed__partial { color: var(--c-attention); }


/* ===========================================================================
   /embed/ — the generator
   =========================================================================== */

/* Settings and preview side by side above 860px, stacked below it. The
   preview is the same URL the snippet quotes, so what a visitor sees is what
   a visitor gets. */
.eg-builder {
  display: grid;
  gap: var(--c-space-4);
  align-items: start;
  margin-block-start: var(--c-space-4);
}
@media (min-width: 860px) {
  .eg-builder { grid-template-columns: minmax(0, 320px) minmax(0, 1fr); }
}
.eg-builder > * { min-width: 0; }

.eg-label {
  display: block;
  margin-block-end: var(--c-space-2);
  color: var(--c-text-muted);
  font-size: var(--c-t-meta);
  font-weight: var(--c-w-medium);
}
/* A symbol, so: mono, upper, and left-to-right in both locales. The site-wide
   input rule in brand.css / theme-foundation.css / page-unification.css owns
   the border, the radius and the 44px floor; what is set here is the type and
   the direction. */
.eg-input {
  inline-size: 100%;
  min-block-size: 44px;
  background: var(--c-inset);
  border: 1px solid var(--c-line-strong);
  border-radius: var(--c-r-control);
  color: var(--c-text);
  font-family: var(--c-mono);
  font-size: 1rem;
  font-weight: var(--c-w-semi);
  text-transform: uppercase;
  padding: 0.55rem var(--c-space-3);
  direction: ltr;
  text-align: start;
}
.eg-input:focus-visible { outline: 2px solid var(--c-evidence); outline-offset: 1px; }
.eg-hint {
  margin: var(--c-space-2) 0 0;
  color: var(--c-text-muted);
  font-size: var(--c-t-meta);
  line-height: 1.6;
}

/* The preview is a well, so the widget reads as the thing being previewed and
   the box around it does not compete with it. */
.eg-preview {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: var(--c-space-3);
}
/* The frame's own height. dashboard.css sets `iframe { height: auto }`,
   which beats the height="220" attribute (presentational hints lose to any
   author rule), so every frame collapsed to the 150px default and cropped
   the badge's footer line. */
.eg-preview iframe,
.embed-examples-grid iframe { block-size: 220px; inline-size: 320px; }
.eg-preview iframe {
  border: 0;
  border-radius: var(--c-r-control);
  max-inline-size: 100%;
  background: var(--c-surface);
}

/* The snippet block inherits the whole of `.dp-code pre` -- the same box
   /api/ shows every sample in -- and changes one thing: the lines wrap
   instead of scrolling sideways. Four source lines are 584px wide and a phone
   is 313px, and a box you must scroll to see the end of what you are about to
   copy is a box that gets copied wrong. */
.dp-code pre.eg-code code {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.embed-examples-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--c-space-4);
  justify-items: center;
  margin-block-start: var(--c-space-4);
}
.embed-examples-grid iframe {
  max-inline-size: 100%;
  border: 0;
  border-radius: var(--c-r-control);
  background: var(--c-inset);
}
/* The empty branch is one block, not a column of a grid that has no items. */
.embed-examples-grid > .am-state { grid-column: 1 / -1; }

/* The samples' language switch, inserted by dev-portal.js as the first child
   of the stack it controls. */
.dp-samples__seg { margin-block-end: var(--c-space-2); }


/* ===========================================================================
   Holding the declared colour against the site-wide safety nets
   ===========================================================================
   canvas-bridge.css is the last stylesheet in the document and paints, in the
   light theme, every `p`, `li`, `td` and `th` at `--c-text-secondary`, every
   `[class*="-label"]` and `[class*="__meta"]` at `--c-text-muted`, and every
   `h1`–`h4` at `--c-text`. Each of those exists because an older component
   hardcoded a colour and a whole theme failed silently, and each reaches a
   component here that has already decided for itself.

   So the intent is restated with one class more than the blanket has, and
   only for the declarations that blanket actually reaches. Every value below
   is the one already declared above; nothing new is decided in this block.
   =========================================================================== */
:root[data-theme="light"] .am-doc .dp-list span,
:root[data-theme="light"] .am-doc .dp-change li { color: var(--c-text-secondary); }

:root[data-theme="light"] .am-doc .dp-code__label,
:root[data-theme="light"] .am-doc .dp-subhead,
:root[data-theme="light"] .am-doc .eg-label,
:root[data-theme="light"] .am-doc .eg-hint,
:root[data-theme="light"] .am-doc .method-computed { color: var(--c-text-muted); }

:root[data-theme="light"] .am-doc .dp-endpoint__summary,
:root[data-theme="light"] .am-doc .dp-list code { color: var(--c-text); }


/* ===========================================================================
   Motion, narrow screens, print
   =========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .dp-details__summary,
  .dp-endpoint { transition: none; }
}

/* An endpoint card is an anchor target like a document section, and
   am-system.css relaxes the section offset at this width because the shell's
   header stops being pinned. The card has to move with it. */
@media (min-width: 1180px) {
  .dp-endpoint { scroll-margin-block-start: var(--c-space-5); }
}

@media (max-width: 767px) {
  .dp-endpoint > * { padding-inline: var(--c-space-4); }
  /* The samples' language switch is an `.am-seg`, which am-system.css already
     grows to 44px here. The disclosure chips are ours. */
  .dp-details__summary { min-block-size: 44px; padding-block: 0.6rem; }
  .dp-code pre { padding: var(--c-space-3); }
  .method-defs .am-table { min-inline-size: 38rem; }
}

@media print {
  .dp-copy { display: none; }
  .dp-scroll { overflow: visible; }
  .dp-code pre { max-block-size: none; overflow: visible; white-space: pre-wrap; }
  .dp-details__summary { list-style: none; }
  .dp-endpoint { break-inside: avoid; }
}
