/* ---------- Reading width switch ---------- */
.reading-width-switch {
    position: sticky;
    top: 80px; /* Fixed below the navbar */
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    padding: 7px 14px;
    background: #fff;
    border: 1px solid rgba(37, 99, 235, 0.15);
    border-radius: 999px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    width: fit-content;
    font-size: 0.82rem;
}
/* Hidden on mobile */
@media (max-width: 991.98px) {
    .reading-width-switch { display: none !important; }
}
.rw-label {
    display: inline-flex;
    align-items: center;
    color: #2563eb;
    font-weight: 600;
    padding-right: 4px;
    border-right: 1px solid rgba(37, 99, 235, 0.25);
    line-height: 1;
    font-size: 0.78rem;
}
.rw-label i { font-size: 0.92rem; }
.rw-btn {
    display: inline-flex;
    align-items: center;
    gap: 2px; /* Keep the double arrows close */
    padding: 4px 10px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: transparent;
    color: #666;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.18s, color 0.18s, border-color 0.18s, transform 0.12s;
    line-height: 1;
}
.rw-btn:hover {
    background: rgba(37, 99, 235, 0.1);
    color: #2563eb;
}
.rw-btn.rw-active {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}
.rw-btn i { font-size: 0.82rem; transform: rotate(90deg); }
@media (max-width: 576px) {
    .reading-width-switch { margin-bottom: 10px; padding: 4px 8px; font-size: 0.76rem; }
    .rw-btn { padding: 4px 8px; font-size: 0.76rem; }
}

/* ---------- Reading width CSS variable switch ---------- */
/* Default: wide layout (col-lg-7 / col-lg-3) */
.handbook-parents-layout {
    --rg-main: 58.3333%;
    --rg-toc: 25%;
    --rg-side: 16.6667%;
}
/* Comfortable reading: body 50%, TOC 33%, sidebar stays 16.7% */
.handbook-parents-layout.reading-narrow {
    --rg-main: 50%;
    --rg-toc: 33.3333%;
}

/* Override Bootstrap grid via CSS variables at lg+ breakpoints */
@media (min-width: 992px) {
    .handbook-parents-layout > .about-page-main {
        flex: 0 0 var(--rg-main) !important;
        max-width: var(--rg-main) !important;
        transition: flex-basis 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                    max-width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .handbook-parents-layout > .handbook-chapter-toc-col {
        flex: 0 0 var(--rg-toc) !important;
        max-width: var(--rg-toc) !important;
        transition: flex-basis 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                    max-width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .handbook-parents-layout > .about-sidebar-col {
        flex: 0 0 var(--rg-side) !important;
        max-width: var(--rg-side) !important;
    }
    /* Transition the body as well for smoother padding changes */
    .handbook-parents-layout > .about-page-main .article-frame,
    .handbook-parents-layout > .about-page-main .handbook-content {
        transition: padding 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    }
}
/* Chapter TOC sidebar: wider in narrow mode without horizontal scroll; fits in wide mode */
.handbook-parents-layout.reading-narrow .handbook-chapter-toc-col .handbook-toc-shell {
    max-height: calc(100vh - 200px);
}

/* Chapter TOC hint dots: unified blue to match the site palette */
.handbook-chapter-toc-col .handbook-toc-shell .sidebar > .toc-link::before {
    background: #dbeafe;
}
.handbook-chapter-toc-col .handbook-toc-shell .sidebar > .toc-link:hover::before {
    background: #3b82f6;
}
.handbook-chapter-toc-col .handbook-toc-shell .sidebar > .toc-link.active::before {
    background: #2563eb;
}
