/* Shared section navigation shell for chapter pages */
.guide-menu-toggle {
    display: none;
    position: fixed;
    top: 0.75rem;
    right: 0.75rem;
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--background-alt);
    color: var(--primary-color);
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
    z-index: 220;
    box-shadow: var(--shadow);
}

.guide-nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 190;
}

.guide-side-nav {
    position: sticky;
    top: 1rem;
    float: left;
    width: 250px;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    background: var(--background-alt);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: var(--spacing-sm);
    margin: 1rem 0 0 1rem;
    z-index: 180;
}

.guide-side-nav__title {
    font-family: var(--font-heading);
    color: var(--primary-color);
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: var(--spacing-xs);
}

.guide-side-nav__title--link {
    display: inline-block;
    margin-bottom: 0.35rem;
    border-bottom: 1px solid transparent;
}

.guide-side-nav__title--link:hover {
    border-bottom-color: var(--primary-color);
}

.guide-side-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: block !important;
}

.guide-side-nav li {
    margin: 0;
    display: block !important;
}

.guide-side-nav a {
    display: block;
    padding: 0.5rem 0.65rem;
    color: var(--text-color);
    border: none;
    font-size: 0.84rem;
    text-align: left;
    justify-content: flex-start;
    transition: background 0.3s, color 0.3s;
    border-radius: 6px;
}

.guide-side-nav a:hover {
    background: var(--primary-color);
    color: white;
}

.guide-main {
    width: min(var(--max-width), calc(100% - 2rem));
    margin-left: auto;
    margin-right: auto;
    padding-top: 1rem;
}

@media (max-width: 768px) {
    .guide-menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .guide-nav-overlay.is-open {
        display: block;
    }

    .guide-side-nav {
        position: fixed;
        top: 0;
        left: 0;
        float: none;
        margin: 0;
        width: min(82vw, 320px);
        height: 100vh;
        max-height: none;
        border-radius: 0;
        border-left-width: 0;
        border-top: 4px solid var(--primary-color);
        transform: translateX(-105%);
        transition: transform 0.25s ease;
        z-index: 200;
    }

    .guide-side-nav.is-open {
        transform: translateX(0);
    }

    .guide-main {
        margin-left: 0;
        padding-top: 0;
    }
}

@media print {
    .guide-side-nav,
    .guide-menu-toggle,
    .guide-nav-overlay {
        display: none !important;
    }

    .guide-main {
        margin-left: 0;
    }
}

/* Shared back-to-top control */
.back-to-top {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    width: 2.6rem;
    height: 2.6rem;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: var(--background-alt);
    color: var(--primary-color);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: var(--shadow);
    z-index: 240;
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.back-to-top.is-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}
