/* Collapsible side-rail groups for the wide rail (min-width: 1700px).
   Compact icon rail and phone drawer stay as they are: titles keep their
   existing .sr-group-title styles, lists stay visible, toggles are not tabbable.
   Without JS there are no .sr-group wrappers, so every group stays visible
   and the original sibling-list dividers still apply. */

.side-rail .sr-group { display: flex; flex-direction: column; }

/* Reset UA <button> chrome only. Do not set width, display, padding, font,
   color, or text-transform here — those beat the existing .sr-group-title
   typography and the compact visually-hidden clip. */
.side-rail button.sr-group-toggle {
    margin: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    appearance: none;
    -webkit-appearance: none;
    font-family: inherit;
    text-align: left;
    cursor: default;
}

/* After JS wraps each title+list, lists are no longer siblings, so restore
   the compact-rail group dividers on the list inside the following group. */
@media (min-width: 768px) and (min-height: 561px), (min-width: 1280px) {
    /* Restate the clipped 1px box so a <button> matches the original <p> title. */
    .side-rail button.sr-group-toggle { min-width: 0; width: 1px; height: 1px; }
    .side-rail .sr-groups[data-sr-collapsible="1"] .sr-group + .sr-group > .sr-list::before {
        content: "";
        display: block;
        height: 1px;
        margin: 5px 10px;
        background: var(--border);
    }
}
@media (min-width: 768px) and (min-height: 561px) and (max-height: 820px) {
    .side-rail .sr-groups[data-sr-collapsible="1"] .sr-group + .sr-group > .sr-list::before {
        margin: 2px 10px;
    }
}

@media (min-width: 1700px) {
    .side-rail button.sr-group-title.sr-group-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        width: 100%;
        height: auto;
        min-width: 0;
        cursor: pointer;
        border-radius: 8px;
        /* restate existing wide-rail title styles at this higher specificity */
        padding: 10px 12px 4px;
        font-size: 0.68rem;
        font-weight: 700;
        letter-spacing: 1.1px;
        text-transform: uppercase;
        color: var(--text-muted);
    }
    /* first group heading stays tight, matching the existing first-child title rule */
    .side-rail .sr-groups .sr-group:first-child button.sr-group-toggle { padding-top: 2px; }
    .side-rail button.sr-group-toggle:hover,
    .side-rail button.sr-group-toggle:focus-visible { color: var(--text); }
    .side-rail button.sr-group-toggle:focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: -2px;
    }
    .side-rail button.sr-group-toggle::after {
        content: "";
        flex: none;
        width: 6px;
        height: 6px;
        margin-top: -2px;
        border-right: 1.8px solid currentColor;
        border-bottom: 1.8px solid currentColor;
        transform: rotate(-45deg); /* chevron points right when collapsed */
        transition: transform 0.15s ease;
    }
    .side-rail button.sr-group-toggle[aria-expanded="true"]::after {
        margin-top: -4px;
        transform: rotate(45deg); /* chevron points down when open */
    }
    .side-rail .sr-group:not(.is-open) > .sr-list { display: none; }
    .side-rail .sr-groups[data-sr-collapsible="1"] .sr-group + .sr-group > .sr-list::before { display: none; }
}

/* Phone / short-screen drawer: a <button> is first-child of its wrap, which
   would make every heading match the old .sr-group-title:first-child rule.
   Restate the original padding so only the first group stays tight. */
@media (max-width: 767px), (max-width: 1279px) and (max-height: 560px) {
    .side-rail .sr-groups[data-sr-collapsible="1"] button.sr-group-toggle {
        display: block;
        width: 100%;
        padding: 12px 12px 4px;
    }
    .side-rail .sr-groups[data-sr-collapsible="1"] .sr-group:first-child button.sr-group-toggle {
        padding-top: 4px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .side-rail button.sr-group-toggle::after { transition: none; }
}
