/* Override Furo theme color variables */
body {
    --color-brand-visited: var(--color-brand-content);
    --color-api-name: #39bd9d;
    --color-link--visited: var(--color-link);
    --color-link-underline--visited: var(--color-link-underline);
}

/* Hide the module prefix in API signatures */
.sig-prename {
    display: none;
}

/* Make sidebar and table of contents fill available space */
.sidebar-container, .toc-drawer {
    flex: 1;
    max-width: 30em;
}

.bottom-of-page,
.bottom-of-page .left-details,
.bottom-of-page .right-details {
    display: none !important;
}

/* Add bottom padding for previous/next navigation buttons */
.related-pages {
    margin-bottom: 2rem !important;
}

/* Add bottom padding to main content area */
article[role="main"] {
    padding-bottom: 2rem !important;
}

/* Fade out yellow highlight on anchor link targets after 3 seconds */
/* Target only the heading elements that Furo highlights, not the entire section */
:target > h1:first-of-type,
:target > h2:first-of-type,
:target > h3:first-of-type,
:target > h4:first-of-type,
:target > h5:first-of-type,
:target > h6:first-of-type,
span:target ~ h1:first-of-type,
span:target ~ h2:first-of-type,
span:target ~ h3:first-of-type,
span:target ~ h4:first-of-type,
span:target ~ h5:first-of-type,
span:target ~ h6:first-of-type {
    animation: heading-highlight-fade 3s ease-out forwards;
}

@keyframes heading-highlight-fade {
    0% { background-color: var(--color-highlight-on-target, #fff59d); }
    100% { background-color: transparent; }
}

/* Fade out yellow highlight on property/method anchors (dt elements) */
dt:target {
    background-color: transparent !important;  /* Override Furo's !important rule */
    animation: dt-highlight-fade 3s ease-out forwards;
}

@keyframes dt-highlight-fade {
    0% { box-shadow: inset 0 0 0 9999px var(--color-highlight-on-target, #fff59d); }
    100% { box-shadow: inset 0 0 0 9999px transparent; }
}

@media (prefers-reduced-motion: reduce) {
    :target > h1:first-of-type,
    :target > h2:first-of-type,
    :target > h3:first-of-type,
    :target > h4:first-of-type,
    :target > h5:first-of-type,
    :target > h6:first-of-type,
    span:target ~ h1:first-of-type,
    span:target ~ h2:first-of-type,
    span:target ~ h3:first-of-type,
    span:target ~ h4:first-of-type,
    span:target ~ h5:first-of-type,
    span:target ~ h6:first-of-type,
    dt:target {
        animation: none;
        background-color: transparent !important;
        box-shadow: none;
    }
    .permalink-toast {
        transition: none;
    }
}

/* ============================================
   Class/Function Visual Separators
   ============================================ */

/* Add visual separation for top-level class and function definitions */
section > dl.py.class,
section > dl.py.function {
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-background-border, #e0e0e0);
}

/* Add a Treble green left border accent to class/function signature lines */
section > dl.py.class > dt,
section > dl.py.function > dt {
    border-left: 4px solid #39bd9d;
}

/* ============================================
   Permalink icon: rendered via CSS ::after so the # never
   appears in the DOM text (Algolia crawler can't index it).
   html_permalinks_icon is set to "" in conf.py so the <a>
   anchor exists but contains no text. We add # visually
   via ::after and show it only on hover.
   ============================================ */

a.headerlink {
    opacity: 0;
    transition: opacity 0.15s ease;
}
a.headerlink::after {
    content: "#";
}
*:hover > a.headerlink {
    opacity: 1;
}
a.headerlink:focus,
a.headerlink:focus-visible {
    opacity: 1;
}

/* Toast notification shown after clicking a permalink */
.permalink-toast {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%) translateY(-1rem);
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #fff;
    background: #303030;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    pointer-events: none;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 10000;
}
.permalink-toast--visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ============================================
   DocSearch Overrides
   ============================================ */

/* Brand color overrides (matching docs.treble.tech) */
:root {
    --docsearch-primary-color: #39bd9d;
    --docsearch-highlight-color: #39bd9d;
    --docsearch-hit-highlight-color: rgba(57, 189, 157, 0.1);
    --docsearch-focus-color: #39bd9d;
    --docsearch-searchbox-background: #f5f6f7;
    --docsearch-searchbox-focus-background: #fff;
    --docsearch-hit-background: #fff;
    --docsearch-footer-background: #fff;
    --docsearch-modal-background: #f5f6f7;
    --docsearch-container-background: rgba(94, 100, 112, 0.7);
    --docsearch-key-gradient: linear-gradient(-225deg, #d5dbe4, #f8f8f8);
    --docsearch-key-shadow: inset 0 -2px 0 0 #cdcde6, inset 0 0 1px 1px #fff,
        0 1px 2px 1px rgba(30, 35, 90, 0.4);
    --docsearch-hit-color: #444950;
    --docsearch-muted-color: #969faf;
    --docsearch-text-color: #1c1e21;
    --docsearch-icon-color: #969faf;
}

/* --- Issue 1: Contain search bar within sidebar --- */
#docsearch {
    overflow-x: hidden;
    overflow-y: visible;
    width: 100%;
    box-sizing: border-box;
}

.sidebar-search-container .DocSearch-Button,
#docsearch .DocSearch-Button {
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
    overflow-y: visible;
}

/* Vertically center Ctrl/K keys in sidebar search button */
.DocSearch-Button .DocSearch-Button-Keys {
    display: flex;
    align-items: center;
}

/* Ensure sidebar button keys match docs.treble.tech styling.
   furo-docsearch-custom.css sets --docsearch-key-gradient: none in :root,
   and DocSearch v4 uses box-shadow: none!important on .DocSearch-Button-Key.
   We must use direct values with !important to override both. */
.DocSearch-Button .DocSearch-Button-Key {
    background: linear-gradient(-225deg, #d5dbe4, #f8f8f8) !important;
    box-shadow: inset 0 -2px 0 0 #cdcde6, inset 0 0 1px 1px #fff,
        0 1px 2px 1px rgba(30, 35, 90, 0.4) !important;
    border: 1px solid rgba(214, 214, 231, 0.2) !important;
    border-radius: 4px;
    color: #1c1e21;
    padding-bottom: 2px;
}

/* Dark mode sidebar button keys */
body[data-theme="dark"] .DocSearch-Button .DocSearch-Button-Key {
    background: linear-gradient(-26.5deg, #505050, #3a3a3a) !important;
    box-shadow: inset 0 -2px 0 0 #282828, inset 0 0 1px 1px #505050,
        0 1px 2px 1px rgba(0, 0, 0, 0.4) !important;
    border: 1px solid rgba(33, 33, 57, 0.2) !important;
    color: #e3e3e3;
}

/* --- Overlay styling to match docs.treble.tech --- */

/* Modal container */
.DocSearch-Modal {
    border-radius: 12px;
}

/* Search bar inside modal */
.DocSearch-SearchBar {
    padding: 12px 16px;
}

.DocSearch-Form {
    border-radius: 8px;
    background: var(--docsearch-searchbox-background);
}

.DocSearch-Form:focus-within {
    box-shadow: 0 0 0 2px #39bd9d !important;
}

/* Search icon color */
.DocSearch-Search-Icon {
    color: #39bd9d !important;
}

/* Result hit styling */
.DocSearch-Hit a {
    border-radius: 8px;
    background: var(--docsearch-hit-background);
}

/* Selected hit - green background */
.DocSearch-Hit[aria-selected="true"] a {
    background: #39bd9d !important;
}

/* Hit section headers - green */
.DocSearch-Hit-source {
    color: #39bd9d !important;
    font-weight: 600;
}

/* Hit icons - green */
.DocSearch-Hit-icon {
    color: #39bd9d !important;
}

.DocSearch-Hit[aria-selected="true"] .DocSearch-Hit-icon {
    color: #fff !important;
}

/* Hit action icons */
.DocSearch-Hit-action {
    color: var(--docsearch-muted-color);
}

.DocSearch-Hit[aria-selected="true"] .DocSearch-Hit-action {
    color: #fff !important;
}

/* Highlighted text in results - green */
.DocSearch-Hit mark {
    color: #39bd9d !important;
}

.DocSearch-Hit[aria-selected="true"] .DocSearch-Hit-title mark,
.DocSearch-Hit[aria-selected="true"] .DocSearch-Hit-path mark {
    color: #fff !important;
}

/* "See all results" link */
.DocSearch-HitsFooter a {
    color: #39bd9d !important;
}

.DocSearch-HitsFooter a:hover {
    color: #32a88a !important;
}

/* Reset/Cancel buttons */
.DocSearch-Reset {
    color: #39bd9d !important;
}

.DocSearch-Reset:hover {
    color: #32a88a !important;
}

/* Footer styling (matching docs.treble.tech) */
.DocSearch-Footer {
    border-top: 1px solid var(--color-background-border, #e0e0e0);
}

.DocSearch-Commands {
    color: #969faf !important;
}

.DocSearch-Label {
    color: #969faf !important;
}

.DocSearch-Commands-Key {
    background: var(--docsearch-key-gradient);
    box-shadow: var(--docsearch-key-shadow);
}

.DocSearch-Logo a {
    color: var(--docsearch-muted-color);
}

/* No results / Start screen */
.DocSearch-NoResults {
    color: var(--docsearch-muted-color);
}

.DocSearch-NoResults-Prefill-List .DocSearch-Prefill {
    color: #39bd9d !important;
}

.DocSearch-StartScreen {
    color: var(--docsearch-muted-color);
}

/* Input placeholder */
.DocSearch-Input::placeholder {
    color: #969faf !important;
}

/* --- Dark mode support for Furo's auto theme --- */
/* Furo sets body[data-theme=auto] and uses @media(prefers-color-scheme:dark)
   for auto dark mode. sphinx-docsearch only handles body[data-theme='dark'],
   so auto-dark is missed. We duplicate the dark variables for both selectors. */

/* Shared dark mode DocSearch variables */
body[data-theme="dark"],
body[data-theme="dark"] .DocSearch-Container {
    --docsearch-search-button-background: var(--color-sidebar-search-background);
    --docsearch-search-button-text-color: var(--color-foreground-muted);
    --docsearch-key-gradient: linear-gradient(-26.5deg, #505050, #3a3a3a);
    --docsearch-key-shadow: inset 0 -2px 0 0 #282828, inset 0 0 1px 1px #505050,
        0 1px 2px 1px rgba(0, 0, 0, 0.4);
    --docsearch-key-border-color: rgba(33, 33, 57, 0.2);
    --docsearch-key-text-color: #e3e3e3;
    --docsearch-primary-color: #39bd9d;
    --docsearch-highlight-color: #39bd9d;
    --docsearch-hit-highlight-color: rgba(57, 189, 157, 0.15);
    --docsearch-text-color: var(--color-foreground-primary);
    --docsearch-container-background: rgba(0, 0, 0, 0.8);
    --docsearch-modal-background: var(--color-background-secondary);
    --docsearch-modal-shadow: inset 1px 1px 0 0 var(--color-background-border),
        0 3px 8px 0 rgba(0, 0, 0, 0.3);
    --docsearch-searchbox-background: var(--color-background-primary);
    --docsearch-searchbox-focus-background: var(--color-background-primary);
    --docsearch-hit-color: var(--color-foreground-primary);
    --docsearch-hit-shadow: none;
    --docsearch-hit-background: var(--color-background-primary);
    --docsearch-footer-background: var(--color-background-primary);
    --docsearch-footer-shadow: inset 0 1px 0 0 rgba(58, 58, 58, 0.5),
        0 -4px 8px 0 rgba(0, 0, 0, 0.2);
    --docsearch-logo-color: #fff;
    --docsearch-muted-color: #7f8497;
    --docsearch-icon-color: #a8a8a8;
}

/* Dark mode element overrides */
body[data-theme="dark"] .DocSearch-Hit-source {
    color: #39bd9d !important;
}

body[data-theme="dark"] .DocSearch-Hit mark {
    color: #39bd9d !important;
}

body[data-theme="dark"] .DocSearch-Hit-icon {
    color: #39bd9d !important;
}

body[data-theme="dark"] .DocSearch-Hit[aria-selected="true"] a {
    background: #39bd9d !important;
}

body[data-theme="dark"] .DocSearch-Hit[aria-selected="true"] a,
body[data-theme="dark"] .DocSearch-Hit[aria-selected="true"] .DocSearch-Hit-title,
body[data-theme="dark"] .DocSearch-Hit[aria-selected="true"] .DocSearch-Hit-path,
body[data-theme="dark"] .DocSearch-Hit[aria-selected="true"] .DocSearch-Hit-title mark,
body[data-theme="dark"] .DocSearch-Hit[aria-selected="true"] .DocSearch-Hit-path mark,
body[data-theme="dark"] .DocSearch-Hit[aria-selected="true"] .DocSearch-Hit-icon,
body[data-theme="dark"] .DocSearch-Hit[aria-selected="true"] .DocSearch-Hit-action {
    color: var(--color-background-primary) !important;
}

body[data-theme="dark"] .DocSearch-Commands {
    color: #a8a8a8 !important;
}

body[data-theme="dark"] .DocSearch-Label {
    color: #a8a8a8 !important;
}

body[data-theme="dark"] .DocSearch-Form:focus-within {
    box-shadow: 0 0 0 2px #39bd9d !important;
}

/* Auto dark mode: Furo uses body[data-theme=auto] + prefers-color-scheme */
@media (prefers-color-scheme: dark) {
    body[data-theme="auto"],
    body[data-theme="auto"] .DocSearch-Container {
        --docsearch-search-button-background: var(--color-sidebar-search-background);
        --docsearch-search-button-text-color: var(--color-foreground-muted);
        --docsearch-key-gradient: linear-gradient(-26.5deg, #505050, #3a3a3a);
        --docsearch-key-shadow: inset 0 -2px 0 0 #282828, inset 0 0 1px 1px #505050,
            0 1px 2px 1px rgba(0, 0, 0, 0.4);
        --docsearch-key-border-color: rgba(33, 33, 57, 0.2);
        --docsearch-key-text-color: #e3e3e3;
        --docsearch-primary-color: #39bd9d;
        --docsearch-highlight-color: #39bd9d;
        --docsearch-hit-highlight-color: rgba(57, 189, 157, 0.15);
        --docsearch-text-color: var(--color-foreground-primary);
        --docsearch-container-background: rgba(0, 0, 0, 0.8);
        --docsearch-modal-background: var(--color-background-secondary);
        --docsearch-modal-shadow: inset 1px 1px 0 0 var(--color-background-border),
            0 3px 8px 0 rgba(0, 0, 0, 0.3);
        --docsearch-searchbox-background: var(--color-background-primary);
        --docsearch-searchbox-focus-background: var(--color-background-primary);
        --docsearch-hit-color: var(--color-foreground-primary);
        --docsearch-hit-shadow: none;
        --docsearch-hit-background: var(--color-background-primary);
        --docsearch-footer-background: var(--color-background-primary);
        --docsearch-footer-shadow: inset 0 1px 0 0 rgba(58, 58, 58, 0.5),
            0 -4px 8px 0 rgba(0, 0, 0, 0.2);
        --docsearch-logo-color: #fff;
        --docsearch-muted-color: #7f8497;
        --docsearch-icon-color: #a8a8a8;
    }

    body[data-theme="auto"] .DocSearch-Hit-source {
        color: #39bd9d !important;
    }

    body[data-theme="auto"] .DocSearch-Hit mark {
        color: #39bd9d !important;
    }

    body[data-theme="auto"] .DocSearch-Hit-icon {
        color: #39bd9d !important;
    }

    body[data-theme="auto"] .DocSearch-Hit[aria-selected="true"] a {
        background: #39bd9d !important;
    }

    body[data-theme="auto"] .DocSearch-Hit[aria-selected="true"] a,
    body[data-theme="auto"] .DocSearch-Hit[aria-selected="true"] .DocSearch-Hit-title,
    body[data-theme="auto"] .DocSearch-Hit[aria-selected="true"] .DocSearch-Hit-path,
    body[data-theme="auto"] .DocSearch-Hit[aria-selected="true"] .DocSearch-Hit-title mark,
    body[data-theme="auto"] .DocSearch-Hit[aria-selected="true"] .DocSearch-Hit-path mark,
    body[data-theme="auto"] .DocSearch-Hit[aria-selected="true"] .DocSearch-Hit-icon,
    body[data-theme="auto"] .DocSearch-Hit[aria-selected="true"] .DocSearch-Hit-action {
        color: var(--color-background-primary) !important;
    }

    body[data-theme="auto"] .DocSearch-Commands {
        color: #a8a8a8 !important;
    }

    body[data-theme="auto"] .DocSearch-Label {
        color: #a8a8a8 !important;
    }

    body[data-theme="auto"] .DocSearch-Form:focus-within {
        box-shadow: 0 0 0 2px #39bd9d !important;
    }

    /* Auto dark mode sidebar button keys */
    body[data-theme="auto"] .DocSearch-Button .DocSearch-Button-Key {
        background: linear-gradient(-26.5deg, #505050, #3a3a3a) !important;
        box-shadow: inset 0 -2px 0 0 #282828, inset 0 0 1px 1px #505050,
            0 1px 2px 1px rgba(0, 0, 0, 0.4) !important;
        border: 1px solid rgba(33, 33, 57, 0.2) !important;
        color: #e3e3e3;
    }
}
