/* NRTK Custom Styles */

/* Font Imports */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap');

/* ============================================
 * NRTK Brand Color Theme Overrides
 * Brand colors: Dark green #00843f, Bright green #3caf49
 * Overrides PyData Sphinx Theme defaults to use NRTK brand palette.
 * ============================================ */

/* Light mode overrides */
html[data-theme="light"] {
    --pst-color-primary: #00843f;
    --pst-color-primary-text: #ffffff;
    --pst-color-primary-highlight: #007036;
    --pst-color-primary-highlight-text: #ffffff;
    --pst-color-primary-bg: #e6f3ec;

    /* Override secondary (used for link hover) to remove purple */
    --pst-color-secondary: #007036;
    --pst-color-secondary-text: #ffffff;
    --pst-color-secondary-highlight: #005c2c;
    --pst-color-secondary-highlight-text: #ffffff;
    --pst-color-secondary-bg: #edf5f0;

    /* Override purple table row hover */
    --pst-color-table-row-hover-bg: #d0e8d8;

    /* Override teal inline-code-links to use green brand */
    --pst-color-inline-code-links: #00843f;
}

/* Dark mode overrides */
html[data-theme="dark"] {
    --pst-color-primary: #3caf49;
    --pst-color-primary-text: #14181e;
    --pst-color-primary-highlight: #47b852;
    --pst-color-primary-highlight-text: #14181e;
    --pst-color-primary-bg: #1a2e1a;

    /* Override secondary (used for link hover) to remove purple */
    --pst-color-secondary: #47b852;
    --pst-color-secondary-text: #14181e;
    --pst-color-secondary-highlight: #3caf49;
    --pst-color-secondary-highlight-text: #14181e;
    --pst-color-secondary-bg: #1a3a1a;

    /* Override purple table row hover */
    --pst-color-table-row-hover-bg: #2a4d25;

    /* Improve admonition title contrast — defaults are too dark against card bg */
    --pst-color-info-bg: #1a3a6b;
    --pst-color-success-bg: #1e5c30;
    --pst-color-warning-bg: #5c3a10;
    --pst-color-danger-bg: #5a1a25;

    /* Override teal inline-code-links to use green brand */
    --pst-color-inline-code-links: #3caf49;
}

/* Admonition title — extend background to full card width.
 * The theme's ::before pseudo-element is repurposed to carry the
 * background color wider than the title's own box. The container's
 * overflow: hidden clips the excess. */
.admonition > .admonition-title::before,
div.admonition > .admonition-title::before {
    background-color: inherit;
    left: -1rem;
    width: calc(100% + 2rem);
}

/* Quickstart Page Styles */
.sd-card-title {
    font-size: 1.25rem !important;
    font-weight: 600 !important;
}

.sd-card {
    min-height: 100px !important;
    height: 100% !important;
}

.sd-col {
    display: flex !important;
    flex-direction: column !important;
}

.sd-col > .sd-card {
    flex: 1 !important;
}

/* Right-align buttons within card footers */
.sd-card-footer {
    text-align: right;
}

/* Back-to-top button — outline style matching card buttons */
#pst-back-to-top {
    background-color: transparent;
    border: 2px solid var(--pst-color-primary);
    color: var(--pst-color-primary);
    transition: background-color 0.2s ease, color 0.2s ease;
}

#pst-back-to-top:hover {
    background-color: var(--pst-color-primary);
    color: var(--pst-color-primary-text);
}

/* Explore More section */
.explore-more-grid .sd-card-title {
    font-size: 1.05rem !important;
}

.explore-more-grid .sd-card,
.explore-more-grid .sd-card-body {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.explore-more-grid .sd-card {
    height: 80px !important;
}

.explore-more-grid .sd-card-body {
    padding: 0.5rem !important;
}

/* QuickStart Button Styles */
.nrtk-quickstart-button-container {
    text-align: center;
    margin: 20px 0;
}

.nrtk-quickstart-button {
    background: #00843f;
    padding: 16px 32px;
    border-radius: 8px;
    display: inline-block;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    transition: background 0.3s ease;
    text-decoration: none;
}

.nrtk-quickstart-button:hover {
    background: #007036;
    text-decoration: none;
}

.nrtk-quickstart-button-text {
    font-size: 1.1em;
    color: white;
    font-weight: 500;
}

.severity-btn {
    border: 0.5px solid #333 !important;
    border-radius: 1px !important;
}

.severity-btn.active {
    background-color: #00843f !important;
    color: white !important; /* make text readable */
    box-shadow: 0 0 5px #000;
    border: none !important;
}

#custom-filters-wrapper label {
    display: flex;
    align-items: center;
    gap: 6px; /* Adjust this to increase or decrease spacing */
}

/* Table overrides */
table td,
table th {
    white-space: normal;
}

/* Ensure images don't exceed paragraph width */
.bd-article img {
    max-width: 100%;
    height: auto;
}

/* Header anchor links - show only on hover */
.headerlink {
    opacity: 0;
    transition: opacity 0.2s ease;
}

h1:hover .headerlink,
h2:hover .headerlink,
h3:hover .headerlink,
h4:hover .headerlink,
h5:hover .headerlink,
h6:hover .headerlink {
    opacity: 1;
}

/* Rubric permalink anchors — custom class avoids Sphinx/theme CSS on
 * .headerlink (basic.css visibility:hidden, pydata theme sizing) that
 * causes layout issues inside sphinx-design dropdown cards.
 */
.rubric-permalink {
    color: var(--pst-color-secondary);
    font-size: 0.8em;
    margin-left: 0.2em;
    padding: 0 4px;
    text-decoration: none;
    user-select: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.rubric:hover .rubric-permalink {
    opacity: 1;
}

/* Dropdown whitespace fix - when collapsed, the pydata theme's box-shadow
 * and background on <details> creates a visible card area below the summary.
 * Fix: strip visual styling from the <details> wrapper and move it onto
 * the <summary> instead, so nothing renders below the clickable header.
 */
details.sd-dropdown:not([open]) {
    box-shadow: none !important;
    background: transparent !important;
    background-color: transparent !important;
}

details.sd-dropdown:not([open]) > summary.sd-card-header {
    box-shadow: 0 .2rem .5rem var(--pst-color-shadow), 0 0 .0625rem var(--pst-color-shadow);
    border-radius: .25rem;
}

/* Tighten spacing between risk-factor and perturber-dependency
 * category sections. Targets: heading top margin, dropdown bottom
 * margin, section gaps, and hidden toctree-wrapper divs.
 */
section[id$="-risk-factors"],
section[id$="-perturbers"] {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

section[id$="-risk-factors"] > h2,
section[id$="-perturbers"] > h3 {
    margin-top: 0.75rem !important;
    margin-bottom: 0.4rem !important;
}

section[id$="-risk-factors"] > .toctree-wrapper {
    margin: 0 !important;
    padding: 0 !important;
}

details.sd-dropdown.sd-mb-3 {
    margin-bottom: 0 !important;
    min-height: 3em !important;
}

/* Rubric headings inside dropdowns - style as sub-headings */
details.sd-dropdown .rubric {
    font-size: 1.15em;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 0.3rem;
}


/* Navbar logo size */
.navbar-brand img {
    max-height: 40px;
    width: auto;
}

/* Force hide any persistent search fields in navbar - only search button should be visible */
#pst-search-dialog:not([open]) {
    display: none !important;
}

/* Hide search field in navbar center */
.navbar-center .bd-search,
.navbar-center form[action="search.html"],
.navbar-header-items__center .bd-search,
.navbar-header-items__center form[action="search.html"],
header .bd-search:not(dialog .bd-search),
header form.bd-search:not(#pst-search-dialog form.bd-search) {
    display: none !important;
    visibility: hidden !important;
}

/* Hide the search button field variant (not the icon button) */
.search-button-field {
    display: none !important;
}

/* Mobile - work with theme's native drawer pattern */
@media (max-width: 991.98px) {
    /* Ensure article container has appropriate spacing */
    .bd-article-container {
        padding: 1rem;
        box-sizing: border-box;
    }

    /* Ensure search button remains visible */
    .search-button__button,
    button.search-button__button,
    .pst-navbar-icon.search-button {
        display: inline-block !important;
        visibility: visible !important;
    }
}

/* Desktop - resizable sidebar functionality */
@media (min-width: 1200px) {
    .bd-sidebar-primary {
        position: relative;
    }

    .sidebar-resize-handle {
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        width: 6px;
        cursor: col-resize;
        background: rgba(0, 132, 63, 0.2);
        z-index: 1100;
        transition: all 0.2s ease;
        pointer-events: auto;
    }

    .sidebar-resize-handle:hover,
    .sidebar-resize-handle.resizing {
        width: 8px;
        background: rgba(0, 132, 63, 0.5);
    }
}

/* Text wrapping for content elements */
.bd-article p,
.bd-article li,
.bd-article dd,
.bd-article td,
.bd-article th,
.bd-article a,
.bd-article h1,
.bd-article h2,
.bd-article h3,
.bd-article h4,
.bd-article h5,
.bd-article h6,
.bd-article code {
    overflow-wrap: break-word;
    max-width: 100%;
}

/* Code blocks use horizontal scroll */
.bd-article pre {
    overflow-x: auto;
    max-width: 100%;
}

/* Full sidebar navigation — all sections visible, only current expanded
 * pydata_sphinx_theme's collapse_navigation handles expand/collapse natively.
 * We just bold the active page link for visibility.
 */
nav.bd-links ul.bd-sidenav > li.toctree-l1 > a {
    font-weight: normal;
}

nav.bd-links ul.bd-sidenav > li.toctree-l1.current > a {
    font-weight: 700;
}

/* Sticky left sidebar - stays fixed while scrolling
 * Similar behavior to the right sidebar (table of contents)
 */
@media (min-width: 992px) {
    .bd-sidebar-primary {
        position: sticky !important;
        top: 4rem;  /* Account for navbar height */
        height: calc(100vh - 4rem);
        overflow-y: auto;
    }
}
