/* github-flavored dark palette */
[data-bs-theme="dark"] {
  --bs-body-bg: #0d1117;
  --bs-body-color: #e6edf3;
  --bs-secondary-bg: #161b22;
  --bs-tertiary-bg: #161b22;
  --bs-border-color: #30363d;
  --bs-link-color: #4493f8;
  --bs-link-hover-color: #79b8ff;
}
[data-bs-theme="dark"] .navbar {
  background-color: #161b22 !important;
  border-bottom: 1px solid #30363d;
}
[data-bs-theme="dark"] pre,
[data-bs-theme="dark"] code {
  background-color: #161b22;
}
[data-bs-theme="dark"] .card,
[data-bs-theme="dark"] footer {
  background-color: #0d1117;
  border-color: #30363d;
}

/* ---- figures ---------------------------------------------------------- */

/* [1] Disable pkgdown's dark-mode auto-inversion.
   pkgdown 2.2.x ships
     [data-bs-theme="dark"] img.r-plt { filter: invert(100%) hue-rotate(180deg) }
   and its own opt-out class .no-invert-dark-mode is a no-op, because the SCSS
   re-applies the same mixin instead of clearing the filter. Override it here.
   extra.css is linked after bootstrap.min.css in <head>, so this wins on
   source order at equal specificity (0,2,1) and needs no !important.
   Nothing on this site currently carries .r-plt (the figures are hand-written
   HTML), so this is insurance against a future real plot chunk. */
[data-bs-theme="dark"] img.r-plt,
[data-bs-theme="dark"] .cell-output-display img,
[data-bs-theme="dark"] .fig-light,
[data-bs-theme="dark"] .fig-dark {
  filter: none;
}

/* [2] Figures that ship two renderings: show the file matching the current
   theme. Keyed on data-bs-theme, NOT on prefers-color-scheme, because
   lightswitch.js writes data-bs-theme onto <html> from localStorage and
   resolves "auto" itself. A media query would show the light image on a dark
   page the moment a reader clicks the toggle against their OS setting.
   On github.com neither rule applies; the #gh-light-mode-only and
   #gh-dark-mode-only fragments in README.md do that job there.
   display:block + margin-inline:auto keeps the README's <p align="center">
   centring working, which text-align alone would not do for a block image. */
.fig-light,
.fig-dark {
  display: block;
  max-width: 100%;
  height: auto;
  margin-inline: auto;
}
.fig-dark { display: none; }
[data-bs-theme="dark"] .fig-light { display: none; }
[data-bs-theme="dark"] .fig-dark  { display: block; }

/* [4] Captions of hand-written <figure> blocks, to match pkgdown's own
   .caption sizing. The card is on the <img>, not the <figure>, so captions
   stay on the page background in both themes and need no colour override. */
figure > figcaption {
  font-size: 0.9rem;
  opacity: 0.85;
  margin-top: 0.6rem;
}

/* number the "On this page" TOC entries with a hanging indent, so wrapped
   titles stay visually separate and the list is countable at a glance */
#toc ul.nav { counter-reset: toc-num; }
#toc ul.nav > li { counter-increment: toc-num; }
#toc ul.nav > li > a.nav-link {
  padding-left: 1.6em;
  text-indent: -1.6em;
}
#toc ul.nav > li > a.nav-link::before {
  content: counter(toc-num) ". ";
  font-variant-numeric: tabular-nums;
  opacity: 0.6;
}
