/* Dark-mode figure inversion.
   Book figures are white-background, black-line textbook PNG/JPG crops that glare
   in dark mode. In the slate scheme, render them as a photographic "negative"
   (luminance flipped) while hue-rotate(180deg) restores any coloured strokes so
   red/blue diagram lines keep their meaning. SVGs are theme-aware and excluded. */
[data-md-color-scheme="slate"] .md-typeset img[src$=".png" i]:not(.no-invert),
[data-md-color-scheme="slate"] .md-typeset img[src$=".jpg" i]:not(.no-invert),
[data-md-color-scheme="slate"] .md-typeset img[src$=".jpeg" i]:not(.no-invert),
[data-md-color-scheme="slate"] .md-typeset img[src$=".gif" i]:not(.no-invert),
[data-md-color-scheme="slate"] .md-typeset img[src$=".webp" i]:not(.no-invert) {
    filter: invert(1) hue-rotate(180deg);
}

/* Never invert when printing — paper is light, so keep the original figure. */
@media print {
    .md-typeset img {
        filter: none !important;
    }
}

/* Compiled TikZ figures are transparent, responsive SVGs with explicit light
   and dark variants. The theme script swaps variants when Material's palette
   changes; stable sizing prevents a swap from shifting the notes layout. */
.md-typeset figure.tikz-figure {
    display: block;
    width: 100%;
    max-width: 62rem;
    margin-inline: auto;
}

.md-typeset figure.tikz-figure img[src*="/tikz/"],
.md-typeset figure.tikz-figure img[src*="img/tikz/"] {
    width: 100%;
    height: auto;
    margin-inline: auto;
    background: transparent;
}

@media print {

    .md-typeset figure img[src*="/tikz/"],
    .md-typeset figure img[src*="img/tikz/"] {
        max-height: 19cm;
        object-fit: contain;
    }
}