/*
 * docs-factory override for the Sphinx `nature` theme.
 *
 * Owned by the factory (injected via html_static_path + html_css_files from
 * the generator) rather than the read-only delta/ submodule's conf.py.
 *
 * Goal: make the table-of-contents sidebar a flexible-width column sized to
 * its content, clamped between 15% and 30% of the page, that scrolls
 * horizontally when entries are wider than the panel — instead of the theme's
 * fixed 230px float layout that wrapped long API signatures.
 */

/* Switch the two-column area from float + negative-margin to flexbox so the
 * sidebar width can flex independently of a hardcoded body margin. */
div.document {
    display: flex;
    align-items: flex-start;
}

/* Body column: take the remaining space; min-width:0 lets it shrink so the
 * sidebar can grow toward its 30% cap. */
div.documentwrapper {
    float: none;
    width: auto;
    flex: 1 1 0%;
    min-width: 0;
    order: 2;
}

div.bodywrapper {
    margin-left: 0;
}

/* TOC column: flexible 15%-30% of the page width, horizontal scroll on
 * overflow. Overrides basic.css's `float: left; width: 230px;
 * margin-left: -100%`. */
div.sphinxsidebar {
    float: none;
    margin-left: 0;
    width: auto;
    flex: 0 1 auto;
    min-width: 15%;
    max-width: 30%;
    overflow-x: auto;
    order: 1;
}

/* Keep entries on a single line so long signatures trigger the horizontal
 * scrollbar instead of wrapping (overrides basic.css word-wrap: break-word). */
div.sphinxsidebar,
div.sphinxsidebarwrapper ul {
    word-wrap: normal;
    overflow-wrap: normal;
}

div.sphinxsidebarwrapper ul {
    white-space: nowrap;
}

/* sphinx-copybutton: nudge the hover-to-copy button to .5em from the top/right
 * of the code block (default is .3em). Higher specificity than copybutton.css's
 * `button.copybtn` so it wins regardless of stylesheet load order. */
div.highlight button.copybtn {
    top: 0.5em;
    right: 0.5em;
}
