/* 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-normal);   /* 590 -> 400 (Ivan 2026-09-09) */
    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 {
    /* The Althea app's menu (Ivan, 2026-09-09): 32px rows, 10px inline padding,
     * 12px radius, 8px gap; labels in the primary text colour; the current
     * page on a soft rounded fill; every glyph teal. */
    display: flex;
    align-items: center;
    gap: 8px;
    height: 32px;
    padding-inline: 10px;
    border-radius: 12px;
    color: var(--text-primary);
    font-size: var(--text-mini-size);
    font-weight: var(--font-weight-normal);   /* 400 (design, 2026-09-09); the size is the 13px mini token already */
    text-decoration: none;
}

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

.sidebar-nav-icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    color: var(--color-accent);   /* teal on every row, as the app (teal-400 in dark) */
}

.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);
    background: rgba(255, 255, 255, 0.09);   /* the app's current-row fill, dark */
}
[data-theme='light'] .sidebar-nav-item[aria-current='page'] {
    background: var(--stone-200);   /* #edede9, the app's current-row fill, light */
}

/* The nav's line glyphs render as the Althea app's: a 14px glyph in the 16px
 * container with stroke 2.4 on the 24 viewBox, 1.4px on screen (measured
 * against the app, 2026-09-09). */
.sidebar-nav-icon [stroke-width] {
    stroke-width: 2.4;
}

