/* Screenshots are exported with an opaque white background, the draw.io
   SVGs with a transparent one. Give them a consistent card look so they sit
   well on furo's dark theme instead of floating as stark white rectangles. */
article figure img {
    background: #fff;
    border-radius: 6px;
}

/* Explicit dark theme selection */
body[data-theme="dark"] article figure img {
    border: 1px solid #404040;
    padding: 6px;
    box-sizing: border-box;
}

/* "auto" theme following a dark OS preference */
@media (prefers-color-scheme: dark) {
    body:not([data-theme="light"]):not([data-theme="dark"]) article figure img {
        border: 1px solid #404040;
        padding: 6px;
        box-sizing: border-box;
    }
}

/* furo leaves table cells at the browser default (vertically centred). */
article table.docutils td,
article table.docutils th {
    vertical-align: top;
}

/* Lightbox overlay opened by custom.js when a figure is clicked: the image
   keeps its aspect ratio (--aspect, set by custom.js once it has loaded) and
   is scaled to the largest size that fits 96 % of the window, but never past
   --cap, twice the figure's size in the app, so a small dialog is not blown
   up; the white card covers exactly the image. */
.figure-lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.82);
    cursor: zoom-out;
}

.figure-lightbox img {
    width: min(96vw, calc(96vh * var(--aspect, 1)), var(--cap, 96vw));
    height: auto;
    background: #fff;
    border-radius: 6px;
}

.figure-lightbox img.loading {
    visibility: hidden;
}

/* UI labels: furo's guilabel box is half transparent and hard to see, and it
   leaves :menuselection: unmarked. Both get an opaque box with a visible
   border, in the light and the dark theme. */
body {
    --color-guilabel-background: #ddeeff;
    --color-guilabel-border: #9fc3e9;
}

body[data-theme="dark"] {
    --color-guilabel-background: #1d3d63;
    --color-guilabel-border: #4a7bb5;
}

@media (prefers-color-scheme: dark) {
    body:not([data-theme="light"]) {
        --color-guilabel-background: #1d3d63;
        --color-guilabel-border: #4a7bb5;
    }
}

.menuselection {
    background-color: var(--color-guilabel-background);
    border: 1px solid var(--color-guilabel-border);
    border-radius: .5em;
    color: var(--color-guilabel-text);
    font-size: .9em;
    padding: 0 .3em;
}

/* Japanese labels are marked with brackets ([設定]) by tools/label_brackets.py,
   the Japanese convention; a box around them as well would mark them twice. */
html[lang="ja"] .guilabel,
html[lang="ja"] .menuselection {
    background: none;
    border: 0;
    font-size: inherit;
    padding: 0;
}

/* Japanese type has no italic: the browser would slant a quote (<em>, put in
   「」 by tools/emphasis_quotes.py) and a code comment artificially. !important
   outranks Pygments' code-comment rules, which are more specific than any
   selector worth writing here. */
html[lang="ja"] * {
    font-style: normal !important;
}

/* Japanese Windows draws the backslash (0x5C) as the yen sign, on the
   keyboard, in paths and in the app. The Japanese help asks for the Japanese
   Windows fonts first, which draw it that way, so the help shows what the
   app shows. The character stays 0x5C: copied into the app it still works. */
html[lang="ja"] body {
    --font-stack: "Yu Gothic UI", "Meiryo UI", "Meiryo", sans-serif;
    --font-stack--headings: var(--font-stack);
    --font-stack--monospace: "MS Gothic", "Osaka-Mono", monospace;
}
