/* Presentation for the generated frontend (TypeScript) API reference.
 *
 * TypeDoc's Markdown nests further than the theme's prose styles assume and its
 * type expressions arrive as runs of inline code, so a few of the theme's
 * defaults work against it. Every rule below is confined to pages carrying the
 * `.ts-api` marker that scripts/generate_frontend_api_docs.py writes at the top
 * of each generated page, so hand-written pages and the Python API reference
 * keep the theme's styling untouched.
 */

/* Headings ---------------------------------------------------------------- */

/* The theme sets `text-transform: uppercase` on h5. Member names of nested type
 * declarations land there, so `resultsCount` rendered as RESULTSCOUNT and the
 * reader could not recover the real casing of a TypeScript identifier. */
.md-typeset:has(.ts-api) h5 {
  text-transform: none;
}

/* The theme renders h6 as small grey text, which is meant for a trailing label
 * rather than for the identifiers that reach that depth here. Match h5 so the
 * two deepest levels stay legible. */
.md-typeset:has(.ts-api) h6 {
  color: var(--md-default-fg-color);
  letter-spacing: normal;
  text-transform: none;
}

/* Tables ------------------------------------------------------------------ */

/* The theme makes tables `display: inline-block` at 0.64rem, which shrink-wraps
 * the two-column parameter tables into a narrow strip and leaves the rest of the
 * content column empty. These tables are part of a signature, so they should
 * line up with the code block above them and use the body text size. */
.md-typeset:has(.ts-api) table:not([class]) {
  display: table;
  width: 100%;
  font-size: 0.72rem;
}

/* The theme wraps every table at runtime in `.md-typeset__table`, which is
 * `inline-block` and therefore shrink-wraps around the table no matter how wide
 * the table asks to be. Without this the parameter tables sit in a narrow strip
 * on the left with the rest of the content column empty. */
.md-typeset:has(.ts-api) .md-typeset__table {
  display: block;
}

/* The type column carries the long expressions; let it take the slack. */
.md-typeset:has(.ts-api) table:not([class]) th:first-child,
.md-typeset:has(.ts-api) table:not([class]) td:first-child {
  width: 1%;
  white-space: nowrap;
}

/* Inline code ------------------------------------------------------------- */

/* TypeDoc renders a type expression as one inline-code span per token, so the
 * theme's pill styling broke `Record<string, { bg: string }>` into a row of
 * disconnected chips. Dropping the pill lets the tokens read as a single
 * monospace expression. Fenced code blocks keep the theme's styling. */
.md-typeset:has(.ts-api) :not(pre) > code {
  background-color: transparent;
  padding: 0;
  border-radius: 0;
  color: var(--md-code-fg-color);
  word-break: normal;
}

/* Cross-references inside a type expression stay recognisable as links. */
.md-typeset:has(.ts-api) a > code {
  color: var(--md-typeset-a-color);
}

.md-typeset:has(.ts-api) a:hover > code {
  color: var(--md-accent-fg-color);
}
