/* Every gallery index page (sphinx-gallery's "nested_sections" mode, the
 * current default) carries its own `.. toctree:: :hidden: :includehidden:`
 * pointing at each of its own subsections -- deliberately so the sidebar can
 * walk into it, but with no way to tell "Example gallery" (a real page in
 * docs/index.rst's own toctree) apart from "Pairwise data" (one of its
 * subsections, injected as a sidebar-level sibling, not a child) once
 * rendered: both become a plain `<li class="toctree-l1">`. The one thing
 * that *is* structurally different is the link itself -- a subsection's
 * points at an in-page anchor on its parent index (`...index.html#pairwise-
 * data`), where every real top-level page link has none. `:includehidden:`
 * is a per-directive override baked into the doctree at parse time (see
 * sphinx-gallery's own generated index.rst), so neither `collapse_navigation`
 * nor `html_theme_options["includehidden"]` -- both theme-level, applied
 * later -- can undo it; hiding by that link shape is the reliable lever
 * left. A gallery's own subsections stay one click away, from its index
 * page's in-page thumbnails -- just not permanently occupying sidebar space
 * on every other page too.
 *
 * :not([href="#"]) matters: whichever page is actually open renders ITS OWN
 * sidebar entry as a bare `href="#"` self-link (Sphinx's usual shorthand for
 * "this is where you already are"), which also contains "#" -- the naive
 * selector hid the very page you were standing on the instant you navigated
 * to it. A real subsection anchor is always `something#fragment`, never a
 * bare `#` alone, so excluding that exact value keeps the fix scoped to
 * sphinx-gallery's injected entries only.
 */
.wy-menu-vertical li.toctree-l1:has(> a[href*="#"]:not([href="#"])) {
    display: none;
}

/* A second, independent symptom of the same `:includehidden:` toctree above,
 * one level deeper: whichever subsection happens to be *last* in a gallery's
 * own `:includehidden:` list (see e.g. docs/auto_applications/index.rst's own
 * generated toctree) gets EVERY sibling subsection re-attached underneath it
 * a second time, as if they were its own children -- confirmed directly in
 * the built HTML across every multi-subsection gallery (applications'
 * "Finance, economics and risk", the example gallery's "Limitations", scale's
 * "Where it runs out", live streaming's "Lab instrument examples", ...), each
 * showing the *entire* sibling list nested a second time underneath. This is
 * a Sphinx toctree-resolution artifact, not anything in this project's own
 * gallery structure -- there is nothing in any subsection's own index.rst
 * that lists its siblings.
 *
 * The rule above already hides a subsection anchor entirely when it surfaces
 * at the top sidebar level, but here the anchor entry itself (e.g. "Finance,
 * economics and risk") is a wanted link one level in -- only its bogus
 * nested list needs to go. The reliable discriminator: a subsection anchor's
 * OWN real children (if it legitimately had any) would be further anchors on
 * that same shared index page, exactly like a genuine multi-section
 * reference page's sidebar entries (see api.html's own "Figure" ->
 * "Figure()"/"subplots()" nesting, which must NOT be touched by this) --
 * never a *real, separate page* link. A nested list actually made of real
 * page hrefs, sitting under an anchor parent, is never legitimate content;
 * it is always this duplication artifact.
 *
 * !important: the theme's own `li.current > ul` rule is what actually
 * *reveals* a nested list once a reader clicks a heading open (adding
 * `.current`), and it outranks a plain `display: none` here on specificity
 * -- checked directly, this fires on page load only from happening to match
 * the theme's own default *collapsed* state, and the bogus list snaps right
 * back open the moment the reader actually expands the entry, which is
 * exactly when it would be seen. Only `!important` reliably wins against a
 * class the theme itself is actively toggling on.
 */
.wy-menu-vertical li:has(> a[href*="#"]:not([href="#"])):has(> ul > li > a:not([href*="#"])) > ul {
    display: none !important;
}

/* Layout tweaks over sphinx_rtd_theme, so tables fit instead of scrolling.
 *
 * Two theme defaults combine badly for this project. The content column is
 * pinned at 800px, and table cells are set to `white-space: nowrap`, so any
 * table wider than the column can never wrap -- it gets a horizontal
 * scrollbar instead. The performance page has a six-column table that needs
 * 756px inside a 696px column, and the gallery pages embed 800px-wide
 * interactive figures.
 */

/* Give the content column room. Not `none`: unbounded lines are hard to read
 * on a wide monitor, and prose is most of the page. 1100px fits the widest
 * table and the interactive iframes with margin to spare. */
.wy-nav-content {
    max-width: 1100px;
}

/* Let table cells wrap. This is the change that actually removes the
 * scrollbar -- widening the column alone only postpones it to the next table
 * that grows a column. */
.wy-table-responsive table td,
.wy-table-responsive table th {
    white-space: normal;
}

/* Tables then use the width available rather than sizing to their content,
 * so column widths honour the `:widths:` given in the directive. */
.wy-table-responsive > table,
.rst-content table.docutils {
    width: 100%;
}

/* Keep long identifiers -- example names, cross-references -- from forcing a
 * column wider than its share once wrapping is allowed. */
.rst-content table.docutils td code,
.rst-content table.docutils td a {
    overflow-wrap: anywhere;
}

/* Interactive gallery figures: never let one push the page sideways. */
.plotpress-interactive iframe {
    max-width: 100%;
}

/* A many-panel figure links to its full standalone page instead of embedding
 * (see docs/conf.py's _interactive_embed) -- style that link like a button so
 * it reads as the primary way to explore the figure, not an afterthought. */
.plotpress-interactive-large {
    padding: 12px 16px;
    background: #f0f6ff;
    border: 1px solid #b9c6ef;
    border-radius: 6px;
}
.plotpress-open-full {
    display: inline-block;
    padding: 8px 16px;
    background: #2b8cff;
    color: #fff !important;
    border-radius: 6px;
    font-weight: 600;
    text-decoration: none !important;
}
.plotpress-open-full:hover {
    background: #1a72e0;
}

/* The RTD theme sizes html_logo to fill the search-box column -- half that
 * width reads as a mark next to the project name instead of a dominant
 * banner at the top of the sidebar. !important: the theme's own selector
 * (`.wy-side-nav-search > a img.logo`) outweighs this one's specificity
 * otherwise, regardless of custom.css loading after theme.css. */
.wy-side-nav-search img.logo {
    width: 50% !important;
    height: auto !important;
}

/* Below the theme's tablet breakpoint the sidebar collapses and the content
 * spans the viewport, so drop the cap rather than fight it. */
@media screen and (max-width: 768px) {
    .wy-nav-content {
        max-width: none;
    }
}

/* The home page's two ASCII-art diagrams (box-drawing lines + arrowheads)
 * mix plain ASCII with Unicode Box Drawing/Geometric Shapes characters on
 * long lines. The theme's default stack (SFMono-Regular, Menlo, Monaco,
 * Consolas, ...) is a real monospace font on every platform, but a handful
 * of viewers still see the two character sets drift out of column alignment
 * a few characters apart on a long line -- some font's Box Drawing/Geometric
 * Shapes glyphs are metriced a hair off from its Latin ones, even though
 * both report the same advance width. Cascadia Mono/Code (ships with
 * Windows Terminal and VS Code, so common on the platform this was actually
 * reported from) and DejaVu Sans Mono (the Linux default) both keep every
 * character in this file at a truly identical width; putting them first
 * only changes anything for a viewer who already has one installed, so this
 * is strictly additive over the previous stack. */
.rst-content pre,
.rst-content .highlight pre {
    font-family: "Cascadia Mono", "Cascadia Code", "DejaVu Sans Mono", Consolas,
                 SFMono-Regular, Menlo, Monaco, "Liberation Mono", "Courier New",
                 Courier, monospace;
}
