/* ============================================
   Blue Note Logic — Side Navigation
   Jazz Noir theme. Namespaced .sidenav (no clash
   with the admin panel's .sidebar).
   ============================================ */

/* ---- Layout: Site Wrapper ---- */
.site-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: calc(100vh - var(--nav-height));
    position: relative;
}

.site-layout__main {
    min-width: 0; /* prevent grid blowout from wide children */
}

/* ---- Side Navigation ---- */
.sidenav {
    width: 260px;
    background: var(--bg-deep);
    border-right: 1px solid var(--border);
    position: sticky;
    top: var(--nav-height);
    height: calc(100vh - var(--nav-height));
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 50;
    scrollbar-width: thin;
    scrollbar-color: var(--border-hover) transparent;
    transition: left 0.35s var(--ease-out), box-shadow 0.35s var(--ease);
}

[data-theme="dark"] .sidenav {
    background: var(--bg-section);
    border-right-color: var(--border);
}

.sidenav::-webkit-scrollbar { width: 4px; }
.sidenav::-webkit-scrollbar-track { background: transparent; }
.sidenav::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 2px; }

.sidenav__inner {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    padding-bottom: 1rem;
}

.sidenav__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1rem 0.6rem;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 0.5rem;
}

.sidenav__title {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent);
}

.sidenav__close {
    display: none; /* mobile only */
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    font-size: 1rem;
    border-radius: var(--radius-sm);
    transition: color 0.2s, background 0.2s;
}
.sidenav__close:hover {
    color: var(--text);
    background: var(--accent-glow);
}

/* ---- Nav Groups ---- */
.sidenav__nav {
    flex: 1;
    padding: 0 0.5rem;
}

.sidenav__group { margin-bottom: 0.25rem; }

.sidenav__group-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    border-radius: var(--radius-sm);
    transition: color 0.2s, background 0.2s;
    text-align: left;
}
.sidenav__group-toggle:hover {
    color: var(--text);
    background: var(--accent-glow);
}

.sidenav__chevron {
    flex-shrink: 0;
    transition: transform 0.25s var(--ease);
    color: var(--text-dim);
}
.sidenav__group-toggle[aria-expanded="false"] .sidenav__chevron {
    transform: rotate(-90deg);
}

/* ---- Nav List ---- */
.sidenav__list {
    list-style: none;
    margin: 0;
    padding: 0 0 0.25rem 0.75rem;
    overflow: hidden;
    max-height: 1200px;
    opacity: 1;
    transition: max-height 0.3s var(--ease-out), opacity 0.25s var(--ease);
}
.sidenav__list--collapsed {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
}
.sidenav__list li { margin: 0; }

.sidenav__link {
    display: block;
    padding: 0.38rem 0.5rem;
    font-size: 0.82rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    border-left: 2px solid transparent;
    line-height: 1.4;
    transition: color 0.2s, background 0.2s, border-left-color 0.2s, padding-left 0.2s;
}
.sidenav__link:hover {
    color: var(--text);
    background: var(--accent-glow);
    border-left-color: var(--accent);
    padding-left: 0.75rem;
}
.sidenav__link--active {
    color: var(--accent);
    background: var(--accent-glow-strong);
    border-left-color: var(--accent);
    font-weight: 500;
}

/* TOC indent (h3) + scroll-spy active */
.sidenav__list--toc .sidenav__link--h3 {
    padding-left: 1.25rem;
    font-size: 0.76rem;
    color: var(--text-muted);
}
.sidenav__list--toc .sidenav__link--spy-active {
    color: var(--accent);
    border-left-color: var(--accent);
}

/* Hide TOC group when no headings */
#sidenavGroupToc[data-empty="true"] { display: none; }

/* ---- Mode Toggle ---- */
.sidenav__mode {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.75rem 0.75rem 0.5rem;
    margin-top: auto;
    border-top: 1px solid var(--border-subtle);
}
.sidenav__mode-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s, background 0.2s;
}
.sidenav__mode-btn:hover {
    color: var(--text);
    background: var(--accent-glow);
}
.sidenav__mode-btn--active {
    color: var(--accent);
    background: var(--accent-glow-strong);
    font-weight: 600;
}

/* ---- Overlay (mobile) ---- */
.sidenav__overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 190;
    opacity: 0;
    pointer-events: none; /* never intercept clicks while hidden */
    transition: opacity 0.3s var(--ease);
}
.sidenav__overlay.is-visible {
    opacity: 1;
    pointer-events: auto; /* only clickable (to close) when drawer is open */
}

/* ---- Mobile Toggle Button ---- */
.sidenav-toggle { display: none; } /* hidden on desktop */

/* ---- Footer Meta Row ---- */
.footer__meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    width: 100%;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.65rem;
    color: var(--text-dim);
}
.footer__confidentiality { letter-spacing: 0.01em; }
.footer__updated {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    opacity: 0.75;
}

/* ============================================
   MOBILE: < 1024px — Drawer mode
   ============================================ */
@media (max-width: 1023px) {
    .site-layout { grid-template-columns: 1fr; }

    .sidenav {
        position: fixed;
        top: 0;
        left: -260px;
        height: 100vh;
        padding-top: var(--nav-height); /* clear the fixed top nav so the close row is tappable */
        z-index: 200;
        box-shadow: none;
    }
    .sidenav.is-open {
        left: 0;
        box-shadow: 4px 0 40px rgba(0, 0, 0, 0.35);
    }

    .sidenav__close {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 28px;
        height: 28px;
    }

    .sidenav__overlay { display: block; }

    .sidenav-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        bottom: 1.5rem;
        left: 1rem;
        width: 44px;
        height: 44px;
        background: var(--accent);
        color: var(--bg);
        border: none;
        border-radius: 50%;
        cursor: pointer;
        z-index: 180;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
        transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
    }
    .sidenav-toggle:hover {
        transform: scale(1.05);
        box-shadow: 0 6px 28px rgba(0, 0, 0, 0.4);
    }

    .footer__meta-row {
        flex-direction: column;
        text-align: center;
    }
}

/* Raise the FAB so it clears the chat coming-soon button on phones */
@media (max-width: 767px) {
    .sidenav-toggle { bottom: 5rem; }
}
