/* Copies of input.css's @theme tokens, which own them; change those first.
   tests/unit_tests/test_docs_theme.py fails when the colours drift. */
:root {
  --color-ground: #0d1117;
  --color-surface-1: #10151d;
  --color-surface-2: #161c26;
  --color-surface-3: #1e2733;
  --color-border: #232b36;
  --color-text: #e6edf3;
  --color-text-strong: #ffffff;
  --color-text-muted: #9aa4b0;
  --color-text-faint: #878f9c;
  --color-brand: #8b5cf6;
  --color-accent: #2dd4bf;
  --color-accent-bright: #5fe6d4;
  --color-accent-ink: #04211d;
  --color-focus: var(--color-accent-bright);
  --color-status-clear: #3fb950;
  --color-status-found: #d6a036;
  --color-status-attn: #38bdf8;
  --color-status-fail: #f8564e;
  --shadow-overlay: 0 16px 40px -24px rgba(0, 0, 0, 0.85);

  --md-text-font: "Geist";
  --md-code-font: "Geist Mono";
}

@font-face {
  font-family: "Geist";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/geist-latin-wght-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Geist Mono";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/geist-mono-latin-wght-normal.woff2") format("woff2");
}

:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

/* Screen only: Material scopes slate to screen, so print keeps its light scheme. */
@media screen {
  :root {
    color-scheme: dark;
  }

  [data-md-color-scheme="slate"] {
    --md-default-bg-color: var(--color-ground);
    --md-default-fg-color: var(--color-text);
    --md-default-fg-color--light: var(--color-text-muted);
    --md-default-fg-color--lighter: var(--color-text-faint);
    --md-default-fg-color--lightest: var(--color-border);

    --md-primary-fg-color: var(--color-ground);
    --md-primary-fg-color--dark: var(--color-ground);
    --md-primary-bg-color: var(--color-text-strong);
    --md-primary-bg-color--light: var(--color-text-muted);
    --md-accent-fg-color: var(--color-accent-bright);
    --md-accent-fg-color--transparent: color-mix(in srgb, var(--color-accent) 10%, transparent);
    --md-accent-bg-color: var(--color-accent-ink);

    --md-typeset-a-color: var(--color-accent);
    --md-typeset-mark-color: var(--color-surface-3);
    --md-typeset-table-color: var(--color-border);
    --md-typeset-table-color--light: var(--color-surface-1);

    --md-code-bg-color: var(--color-surface-2);
    --md-code-bg-color--light: var(--color-surface-2);
    --md-code-bg-color--lighter: var(--color-surface-2);
    --md-code-fg-color: var(--color-text);

    --md-admonition-bg-color: var(--color-surface-2);

    --md-footer-bg-color: var(--color-ground);
    --md-footer-bg-color--dark: var(--color-surface-1);

    --md-mermaid-node-bg-color: var(--color-surface-3);
    --md-mermaid-node-fg-color: var(--color-text-muted);
    --md-mermaid-edge-color: var(--color-text-faint);
    --md-mermaid-label-bg-color: var(--color-surface-2);

    --md-shadow-z1: none;
    --md-shadow-z2: var(--shadow-overlay);
    --md-shadow-z3: var(--shadow-overlay);
  }

  /* Header — the blur sits on a pseudo-element: backdrop-filter on .md-header itself would
     trap the phone search panel, which is position: fixed, inside the 48px bar. */
  .md-header {
    background-color: transparent;
    border-bottom: 1px solid var(--color-border);
  }

  .md-header::before {
    position: absolute;
    inset: 0;
    z-index: -1;
    content: "";
    background-color: color-mix(in srgb, var(--color-ground) 80%, transparent);
    backdrop-filter: blur(12px);
  }

  .md-header--shadow {
    box-shadow: none;
  }

  .md-header__topic:first-child {
    font-size: 17px;
    letter-spacing: -0.025em;
  }

  .md-search__inner,
  .md-version__list,
  .md-tooltip,
  .md-tooltip2 {
    --md-default-bg-color: var(--color-surface-2);
  }

  /* Material paints this toast in inverted colours, so the pair is swapped back. */
  .md-dialog {
    --md-default-fg-color: var(--color-surface-2);
    --md-default-bg-color: var(--color-text);
  }

  @media (min-width: 60em) {
    .md-search__form {
      background-color: var(--color-surface-2);
      border: 1px solid var(--color-border);
      border-radius: 8px;
    }

    [data-md-toggle="search"]:checked ~ .md-header .md-search__form {
      border-radius: 8px 8px 0 0;
      box-shadow: none;
    }

    [data-md-toggle="search"]:checked ~ .md-header .md-search__output {
      border: 1px solid var(--color-border);
      border-top: none;
      border-radius: 0 0 8px 8px;
    }
  }

  .md-version__list {
    border: 1px solid var(--color-border);
    border-radius: 8px;
  }

  .md-tooltip,
  .md-tooltip2__inner,
  .md-dialog {
    border: 1px solid var(--color-border);
    border-radius: 12px;
  }

  .md-nav__link {
    color: var(--color-text-muted);
  }

  .md-nav__link:is([for], [href]):is(:hover, :focus) {
    color: var(--color-text);
  }

  .md-nav--primary .md-nav__item--active > .md-nav__link {
    color: var(--color-text);
  }

  .md-nav .md-nav__item .md-nav__link--active {
    color: var(--color-text-strong);
  }

  .md-nav--primary .md-nav__link--active {
    box-shadow: inset 3px 0 0 var(--color-brand);
  }

  @media (min-width: 76.25em) {
    .md-nav--primary .md-nav__link--active {
      padding-left: 0.5rem;
      margin-left: -0.5rem;
    }
  }

  .md-nav--primary .md-nav--secondary .md-nav__link--active {
    box-shadow: none;
  }

  @media (max-width: 76.234375em) {
    .md-sidebar--primary {
      --md-default-bg-color: var(--color-surface-1);
      --md-primary-fg-color: var(--color-surface-1);
    }

    .md-nav--primary .md-nav__title {
      background-color: var(--color-surface-1);
    }
  }

  .md-typeset {
    line-height: 1.75;
  }

  .md-typeset :is(h1, h2, h3) {
    color: var(--color-text-strong);
    letter-spacing: -0.025em;
  }

  .md-typeset :is(h1, h2) {
    font-weight: 700;
  }

  .md-typeset h3 {
    font-weight: 600;
  }

  .md-typeset a:not(.headerlink, .md-content__button):hover {
    text-decoration: underline;
    text-underline-offset: 2px;
  }

  .md-typeset :not(pre) > code {
    --md-code-fg-color: var(--color-text-strong);
    --md-code-bg-color: var(--color-surface-3);
    border-radius: 4px;
  }

  /* The surface is painted here, not on the pieces inside: their square corners would poke past
     the radius, and clipping them with overflow would cut off code annotation tooltips. */
  .md-typeset div.highlight {
    --md-code-bg-color: transparent;
    margin-block: 1em;
    background-color: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: 12px;
  }

  .md-typeset div.highlight :is(pre, .highlighttable, span.filename) {
    margin-block: 0;
  }

  .md-typeset .highlight span.filename {
    color: var(--color-text-muted);
  }

  .md-typeset table:not([class]) {
    border-radius: 12px;
  }

  .md-typeset table:not([class]) th {
    color: var(--color-text-strong);
    background-color: var(--color-surface-2);
  }

  .md-typeset mark {
    color: var(--color-text-strong);
    text-decoration: underline;
    text-underline-offset: 2px;
  }

  .md-typeset a mark {
    color: inherit;
  }

  /* Admonitions — status colour only on the rail and the icon, never as a fill behind text. */
  .md-typeset :is(.admonition, details) {
    --daiv-tone: var(--color-status-attn);
  }

  .md-typeset :is(.admonition, details).warning {
    --daiv-tone: var(--color-status-found);
  }

  .md-typeset :is(.admonition, details):is(.tip, .success, .example) {
    --daiv-tone: var(--color-status-clear);
  }

  .md-typeset :is(.admonition, details):is(.failure, .danger, .bug) {
    --daiv-tone: var(--color-status-fail);
  }

  .md-typeset :is(.admonition, details)[class] {
    font-size: 0.7rem;
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--daiv-tone);
    border-radius: 12px;
  }

  .md-typeset :is(.admonition, details)[class] > :is(.admonition-title, summary) {
    color: var(--color-text-strong);
    background-color: transparent;
  }

  .md-typeset :is(.admonition, details)[class] > :is(.admonition-title, summary)::before {
    background-color: var(--daiv-tone);
  }

  .md-typeset :is(.admonition, details)[class] > summary::after {
    color: var(--color-text-muted);
  }

  /* Grid cards are static: only the link inside one is clickable, so the card keeps no hover. */
  .md-typeset .grid.cards > ul > li,
  .md-typeset .grid.cards > ul > li:is(:hover, :focus-within) {
    padding: 1.2rem;
    background-color: var(--color-surface-2);
    border-color: var(--color-border);
    border-radius: 16px;
    box-shadow: none;
  }
}
