/* ==========================================================================
   Apogee — code blocks as an editor surface.

   Served to all 30 instances from theme.custom_dir (overrides-shared/), so
   there is one copy instead of thirty. Depends on two pymdownx.highlight
   options being set in mkdocs.yml:

     pygments_lang_class: true   -> .language-* on the wrapper (badge, select)
     line_spans: __span          -> per-line spans (content.code.select)
     linenums_style: pymdownx-inline -> [data-linenos] gutter, not a <table>

   Without those, the selectors below match nothing and the blocks fall back
   to stock Material. lint_build.py fails the build if they regress.
   ========================================================================== */

/* 1 ── Dark code surface in BOTH colour schemes.
      Material declares these on :root per scheme; redeclaring them on the
      code container flips the block alone, leaving the page as it was. */
.md-typeset .highlight,
.md-typeset .highlighttable,
.md-typeset pre > code,
.md-typeset .md-code__content {
  --md-code-bg-color: #11131a;
  --md-code-fg-color: #d6dae4;
  --md-code-hl-color: #ffd54f26;
  --md-code-hl-color--light: #ffd54f14;
  --md-code-hl-comment-color: #6b7385;
  --md-code-hl-keyword-color: #c792ea;
  --md-code-hl-operator-color: #89ddff;
  --md-code-hl-punctuation-color: #8b93a7;
  --md-code-hl-name-color: #d6dae4;
  --md-code-hl-function-color: #82aaff;
  --md-code-hl-constant-color: #f78c6c;
  --md-code-hl-string-color: #c3e88d;
  --md-code-hl-number-color: #f78c6c;
  --md-code-hl-special-color: #ff5370;
  --md-code-hl-variable-color: #eeffff;
  --md-code-hl-generic-color: #9aa2b5;
  --md-default-fg-color--lightest: #2a2f3d;
}

/* 2 ── The frame. */
.md-typeset .highlight {
  border: 1px solid #262b38;
  border-radius: 0.45rem;
  overflow: hidden;
  box-shadow:
    0 1px 2px #0000001f,
    0 4px 14px #00000014;
  margin: 1.1em 0;
}

.md-typeset .highlight > pre,
.md-typeset .highlight > pre > code {
  border-radius: 0;
  margin: 0;
}

.md-typeset .highlight pre > code {
  padding: 0.78rem 1rem;
  scrollbar-width: thin;
  scrollbar-color: #3a4153 transparent;
}

.md-typeset .highlight pre > code::-webkit-scrollbar {
  height: 0.4rem;
}

.md-typeset .highlight pre > code::-webkit-scrollbar-thumb {
  background: #3a4153;
  border-radius: 0.2rem;
}

/* 3 ── Title bar: the filename from title="…", or the language name that
      pymdownx auto_title injects when no title was given. Material emits
      both as `.highlight > span.filename`. */
.md-typeset .highlight > span.filename {
  background: #171a23;
  color: #9aa2b5;
  border-bottom: 1px solid #262b38;
  border-radius: 0.45rem 0.45rem 0 0;
  font:
    500 0.72rem/1 "JetBrains Mono",
    "Fira Code",
    Consolas,
    monospace;
  letter-spacing: 0.02em;
  margin: 0;
  padding: 0.6rem 1rem 0.6rem 2.4rem;
  position: relative;
  text-transform: none;
}

/* Three dots, purely decorative — reads as "this is a file". */
.md-typeset .highlight > span.filename::before {
  content: "";
  position: absolute;
  left: 1rem;
  top: 50%;
  width: 0.42rem;
  height: 0.42rem;
  margin-top: -0.21rem;
  border-radius: 50%;
  background: var(--md-accent-fg-color, #00d4ff);
  box-shadow:
    0.62rem 0 0 #3a4153,
    1.24rem 0 0 #262b38;
}

/* 4 ── Line-number gutter (linenums_style: pymdownx-inline). */
.md-typeset .highlight [data-linenos]::before {
  content: attr(data-linenos);
  display: inline-block;
  width: 2.6ch;
  margin-right: 1rem;
  padding-right: 0.7rem;
  border-right: 1px solid #262b38;
  color: #4d5567;
  text-align: right;
  user-select: none;
  -webkit-user-select: none;
}

.md-typeset .highlight a[id^="__codelineno"]:target::before,
.md-typeset .highlight a[id^="__codelineno"]:hover::before {
  color: var(--md-accent-fg-color);
}

/* 5 ── hl_lines="3 8" gets a left rail rather than only a tint. */
.md-typeset .highlight .hll,
.md-typeset .highlight mark {
  background: var(--md-code-hl-color);
  box-shadow: inset 0.18rem 0 0 var(--md-accent-fg-color);
  display: block;
  margin: 0 -1rem;
  padding: 0 1rem;
}

/* 6 ── Copy / select buttons must clear the title bar. */
.md-typeset .md-code__nav {
  top: 0.45rem;
  right: 0.45rem;
}

.md-typeset .highlight > span.filename ~ pre .md-code__nav {
  top: 2.6rem;
}

/* 7 ── Tabbed variants sit flush against the block they introduce. */
.md-typeset .tabbed-set > .tabbed-labels {
  box-shadow: none;
}

.md-typeset .tabbed-set .tabbed-content .highlight {
  margin-top: 0.3em;
}

/* 8 ── Inline code follows the page scheme; only blocks go dark. */
.md-typeset :not(pre) > code {
  font-size: 0.84em;
  border-radius: 0.2rem;
}

/* 9 ── mkdocstrings signatures are long; wrap instead of scrolling away. */
.md-typeset .doc-signature > pre > code {
  white-space: pre-wrap;
  word-break: break-word;
}
