/* SidebarShell — organism. Spec: component-specs/sidebar-shell.md */

.sidebar {
    position: sticky;
    top: 64px;
    align-self: start;
    max-height: calc(100vh - 64px);
    /* Floor so the right divider runs full height even on short menus. */
    min-height: calc(100vh - 64px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px 20px 40px;
    border-right: var(--border-hairline) solid var(--border-default);
    scrollbar-width: none;
}

.sidebar::-webkit-scrollbar {
    display: none;
}

.sidebar-list {
    display: flex;
    flex-direction: column;
    /* Accordion growth goes downward; the clicked trigger never re-centers. */
    justify-content: flex-start;
}

/* Fixed overlay footer (<1000px): Contact, then GitHub + theme row. */
.sidebar-overlay-footer {
    display: none;
    flex-direction: column;
    align-items: flex-start;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    gap: 8px;
    padding: 16px 20px calc(16px + env(safe-area-inset-bottom));
    background: var(--surface-canvas);
}

.sidebar-overlay-footer::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 100%;
    height: 28px;
    background: linear-gradient(to top, var(--surface-canvas), transparent);
    pointer-events: none;
}

.sidebar-overlay-footer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    align-self: stretch;
    margin-top: 4px;
}

/* Fixed overlay search bar (<1000px), fade below. */
.sidebar-overlay-top {
    display: none;
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    z-index: 1;
    padding: 12px 20px;
    background: var(--surface-canvas);
}

.sidebar-overlay-top::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    height: 28px;
    background: linear-gradient(to bottom, var(--surface-canvas), transparent);
    pointer-events: none;
}

.sidebar-overlay-search {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 6px;
    height: 44px;
    padding-inline: 14px;
    border: var(--border-hairline) solid var(--border-default);
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--text-tertiary);
    font-size: var(--text-mini-size);
    font-weight: var(--font-weight-medium);
    cursor: pointer;
}

.sidebar-overlay-search [stroke-width] {
    stroke-width: 2.25;
}

/* <1000px: full-screen overlay toggled by the TopNav hamburger. */
@media (width <= 999px) {
    .sidebar {
        position: static;
        padding: 0;
        /* A surviving 100vh floor pushes content a viewport down. */
        min-height: 0;
        max-height: none;
        overflow-y: visible;
        border-right: none;
    }

    .sidebar-list {
        display: none;
        position: fixed;
        top: 64px;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: var(--z-settings-modal);
        background: var(--surface-canvas);
        /* Top clears the fixed search bar; bottom must fully clear the fixed
         * footer or the last item is unreachable. */
        padding: 84px 20px calc(132px + env(safe-area-inset-bottom));
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .sidebar-list[data-mobile-open='true'] {
        display: flex;
    }

    .sidebar-overlay-top {
        display: block;
    }

    .sidebar-overlay-footer {
        display: flex;
    }
}

/* ---------- Nav groups ---------- */
.sidebar-group-trigger {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 8px;
    padding: 12px 8px 6px;
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: var(--text-mini-size);
    font-weight: var(--font-weight-semibold);
    text-align: left;
    cursor: pointer;
}

.sidebar-chevron {
    margin-left: auto;
    flex-shrink: 0;
    color: var(--text-quaternary);
    transform: rotate(0deg);
    transition: transform 0.12s cubic-bezier(0.455, 0.03, 0.515, 0.955);
}

.sidebar-chevron [stroke-width] {
    stroke-width: 2.5;
}

.sidebar-group[data-state='closed'] .sidebar-chevron {
    transform: rotate(-90deg);
}

.sidebar-group-content[data-state='open'] {
    animation-duration: 0.15s;
    animation-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.sidebar-group-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
    list-style: none;
    margin: 0;
    padding: 0.5rem 0 12px;
}

.sidebar-group-list li {
    margin: 0;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 32px;
    padding-inline: 8px;
    border-radius: 8px;
    color: var(--text-tertiary);
    font-size: var(--text-mini-size);
    font-weight: var(--font-weight-medium);
    text-decoration: none;
}

.sidebar-top-level-list {
    padding-top: 4px;
    margin-bottom: 8px;
}

.sidebar-nav-icon {
    flex-shrink: 0;
    color: var(--text-quaternary);
}

.sidebar-nav-item[aria-current='page'] .sidebar-nav-icon {
    color: var(--color-accent);
}

@media (any-hover: hover) {
    .sidebar-nav-item:hover {
        color: var(--text-secondary);
    }
}

.sidebar-nav-item[aria-current='page'] {
    color: var(--text-primary);
}
