/* Content list spacing - scoped to .content to avoid affecting sidebar TOC */
.content li:not(:last-of-type) {
    margin-block-end: 0.5em;
}

.content :is(ul, ol) + :is(ul, ol),
.content li :is(ul, ol) {
    margin-block-start: 0.5em;
}

/* Reduces the top margin of an H2 that directly follows an H1 */
h1 + h2 {
    margin-top: -2.0rem;
}

/* Version Switcher Styles */
.version-selector-container {
    display: inline-flex;
    align-items: center;
    margin-left: 10px;
}

.version-selector {
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid var(--theme-popup-border);
    background-color: var(--theme-popup-bg);
    color: var(--fg);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.15s ease;
    max-width: 180px;
}

.version-selector:hover {
    border-color: var(--theme-hover);
    background-color: var(--theme-hover);
}

.version-selector:focus {
    outline: 2px solid var(--links);
    outline-offset: 2px;
}

/* Version Badge */
.version-badge {
    display: inline-block;
    margin-left: 0.75rem;
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 4px;
    background-color: var(--theme-popup-bg);
    border: 1px solid var(--theme-popup-border);
    vertical-align: middle;
}

.version-badge-snapshot {
    background-color: #fbbf24;
    color: #78350f;
    border-color: #f59e0b;
}

.version-badge-stable {
    background-color: #22c55e;
    color: #14532d;
    border-color: #16a34a;
}

/* Outdated Version Warning Banner */
.version-warning {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 2px solid #f59e0b;
    border-radius: 8px;
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.version-warning-content {
    color: #78350f;
}

.version-warning-content strong {
    color: #92400e;
}

.version-warning-content p {
    margin: 0.5rem 0 0 0;
    line-height: 1.6;
}

.version-warning-content a {
    color: #c2410c;
    text-decoration: underline;
    font-weight: 600;
}

.version-warning-content a:hover {
    color: #9a3412;
}

/* Responsive adjustments */
@media screen and (max-width: 1080px) {
    .version-selector-container {
        margin-left: 5px;
    }

    .version-selector {
        max-width: 120px;
        font-size: 0.8rem;
        padding: 3px 6px;
    }

    .version-badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.5rem;
        margin-left: 0.5rem;
    }
}

@media screen and (max-width: 768px) {
    .version-selector-container {
        display: none; /* Hide on very small screens to save space */
    }

    .version-badge {
        display: none;
    }

    .version-warning {
        padding: 0.75rem 1rem;
        margin: 1rem 0;
    }
}

/* Navigation Sidebar Link */
.nav-show-sidebar {
    color: var(--links);
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.15s ease;
}

.nav-show-sidebar:hover {
    color: var(--links-hover);
    text-decoration: underline;
}

.nav-show-sidebar-separator {
    color: var(--fg);
    opacity: 0.5;
}

/* ===== Sidebar TOC Spacing Adjustments ===== */

/* Style main chapter headings (1, 2, 3...) - slightly bigger with darker background */
.sidebar .chapter > li.chapter-item > a {
    font-size: 1.05em !important;
    font-weight: 600 !important;
    background-color: rgba(0, 0, 0, 0.08) !important;
    padding: 0.25em 0.5em !important;
    margin-left: -0.5em !important;
    border-radius: 4px !important;
    display: inline-block !important;
}

/* Increase space BEFORE main chapter headings only (li.chapter-item)
   This creates visual separation between chapters (e.g., between 5 and 6) */
.sidebar .chapter > li.chapter-item {
    margin-top: 1.2em !important;
}

/* Remove space before the first chapter */
.sidebar .chapter > li.chapter-item:first-child {
    margin-top: 0 !important;
}

/* Remove space before section wrapper li (keeps sub-chapters tight to parent)
   The section wrapper is a plain <li> without .chapter-item class */
.sidebar .chapter > li:not(.chapter-item) {
    margin-top: 0 !important;
    padding: 0 !important;
}

/* Hide section wrapper when chapter is collapsed (no expanded class) */
.sidebar .chapter > li.chapter-item:not(.expanded) + li:not(.chapter-item) {
    display: none !important;
}

/* Tighten spacing between sub-chapter items */
.sidebar .chapter .section > li {
    margin-bottom: 0.15em !important;
    margin-top: 0 !important;
}

/* ===== Heading Colors by Theme ===== */

/* Latte (light theme) - uses darker, more saturated colors */
html.latte h1, html.latte .content h1 { color: #1e66f5 !important; } /* Blue */
html.latte h2, html.latte .content h2 { color: #8839ef !important; } /* Mauve */
html.latte h3, html.latte .content h3 { color: #179299 !important; } /* Teal */
html.latte h4, html.latte .content h4 { color: #df8e1d !important; } /* Yellow */
html.latte h5, html.latte .content h5 { color: #40a02b !important; } /* Green */
html.latte h6, html.latte .content h6 { color: #e64553 !important; } /* Maroon */

/* Frappe (dark theme) */
html.frappe h1, html.frappe .content h1 { color: #8caaee !important; } /* Blue */
html.frappe h2, html.frappe .content h2 { color: #ca9ee6 !important; } /* Mauve */
html.frappe h3, html.frappe .content h3 { color: #81c8be !important; } /* Teal */
html.frappe h4, html.frappe .content h4 { color: #e5c890 !important; } /* Yellow */
html.frappe h5, html.frappe .content h5 { color: #a6d189 !important; } /* Green */
html.frappe h6, html.frappe .content h6 { color: #ea999c !important; } /* Maroon */

/* Macchiato (dark theme) */
html.macchiato h1, html.macchiato .content h1 { color: #8aadf4 !important; } /* Blue */
html.macchiato h2, html.macchiato .content h2 { color: #c6a0f6 !important; } /* Mauve */
html.macchiato h3, html.macchiato .content h3 { color: #8bd5ca !important; } /* Teal */
html.macchiato h4, html.macchiato .content h4 { color: #eed49f !important; } /* Yellow */
html.macchiato h5, html.macchiato .content h5 { color: #a6da95 !important; } /* Green */
html.macchiato h6, html.macchiato .content h6 { color: #ee99a0 !important; } /* Maroon */

/* Mocha (dark theme) */
html.mocha h1, html.mocha .content h1 { color: #89b4fa !important; } /* Blue */
html.mocha h2, html.mocha .content h2 { color: #cba6f7 !important; } /* Mauve */
html.mocha h3, html.mocha .content h3 { color: #94e2d5 !important; } /* Teal */
html.mocha h4, html.mocha .content h4 { color: #f9e2af !important; } /* Yellow */
html.mocha h5, html.mocha .content h5 { color: #a6e3a1 !important; } /* Green */
html.mocha h6, html.mocha .content h6 { color: #eba0ac !important; } /* Maroon */

/* Ensure heading links inherit their heading color */
html.latte :is(h1, h2, h3, h4, h5, h6) > a,
html.frappe :is(h1, h2, h3, h4, h5, h6) > a,
html.macchiato :is(h1, h2, h3, h4, h5, h6) > a,
html.mocha :is(h1, h2, h3, h4, h5, h6) > a {
    color: inherit !important;
}

/* ===== Sidebar TOC Level Colors (matching heading colors) ===== */

/* Latte theme - TOC colors */
html.latte .sidebar .chapter > li.chapter-item > a:not(.active) { color: #1e66f5 !important; } /* Blue - Level 1 */
html.latte .sidebar .chapter .section > li.chapter-item > a:not(.active) { color: #8839ef !important; } /* Mauve - Level 2 */
html.latte .sidebar .chapter .section .section > li.chapter-item > a:not(.active) { color: #179299 !important; } /* Teal - Level 3 */

/* Frappe theme - TOC colors */
html.frappe .sidebar .chapter > li.chapter-item > a:not(.active) { color: #8caaee !important; } /* Blue - Level 1 */
html.frappe .sidebar .chapter .section > li.chapter-item > a:not(.active) { color: #ca9ee6 !important; } /* Mauve - Level 2 */
html.frappe .sidebar .chapter .section .section > li.chapter-item > a:not(.active) { color: #81c8be !important; } /* Teal - Level 3 */

/* Macchiato theme - TOC colors */
html.macchiato .sidebar .chapter > li.chapter-item > a:not(.active) { color: #8aadf4 !important; } /* Blue - Level 1 */
html.macchiato .sidebar .chapter .section > li.chapter-item > a:not(.active) { color: #c6a0f6 !important; } /* Mauve - Level 2 */
html.macchiato .sidebar .chapter .section .section > li.chapter-item > a:not(.active) { color: #8bd5ca !important; } /* Teal - Level 3 */

/* Mocha theme - TOC colors */
html.mocha .sidebar .chapter > li.chapter-item > a:not(.active) { color: #89b4fa !important; } /* Blue - Level 1 */
html.mocha .sidebar .chapter .section > li.chapter-item > a:not(.active) { color: #cba6f7 !important; } /* Mauve - Level 2 */
html.mocha .sidebar .chapter .section .section > li.chapter-item > a:not(.active) { color: #94e2d5 !important; } /* Teal - Level 3 */