/* ==========================================================================
   App sidebar (#620)

   The menu drawer behind the avatar in the top bar. It slides in over a dimmed
   backdrop and holds the manager's own quick links plus the entries that have
   no tab of their own: search, profile, settings, wiki.

   It comes in from the edge its avatar sits on: the left in the app, the
   corner the avatar moved to (#659), and the right in the browser, where the
   avatar is the last thing in the navbar (#714). Everything below is written
   for the left; `--right` turns it around.
   ========================================================================== */

.app-sidebar-backdrop {
    position: fixed;
    inset: 0;
    /* Same rung as every other body-level layer, so DOM order decides what sits
       on top: tapping "Settings" closes this panel and appends the account
       overlay after it, which is what puts the overlay in front. */
    z-index: 200;
    background-color: rgba(var(--app-black-rgb), 0.5);
    backdrop-filter: blur(2px);
    display: flex;
    justify-content: flex-start;
    animation: app-sidebar-backdrop-in 0.25s ease-out;
}

.app-sidebar-backdrop.closing {
    animation: app-sidebar-backdrop-out 0.25s ease-in forwards;
}

/* The browser's drawer, hinged on the other side: the panel parks at the right
   edge, its shadow falls the other way and it slides out to the right. */
.app-sidebar-backdrop--right {
    justify-content: flex-end;
}

.app-sidebar-backdrop--right .app-sidebar {
    box-shadow: -2px 0 12px var(--app-sidebar-shadow);
    animation-name: app-sidebar-in-right;
}

.app-sidebar-backdrop--right.closing .app-sidebar {
    animation-name: app-sidebar-out-right;
}

.app-sidebar {
    width: min(78vw, 320px);
    height: 100vh;
    height: 100dvh;
    background: var(--app-ground);
    /* Named once, because the right-hand drawer casts the same shadow the
       other way — und dieselbe Linie trennt oben wie unten. */
    --app-sidebar-shadow: rgba(var(--app-black-rgb), 0.4);
    --app-sidebar-line: rgba(var(--app-white-rgb), 0.12);
    box-shadow: 2px 0 12px var(--app-sidebar-shadow);
    display: flex;
    flex-direction: column;
    padding: calc(1rem + env(safe-area-inset-top, 0px)) 0 calc(1rem + env(safe-area-inset-bottom, 0px));
    animation: app-sidebar-in 0.25s ease-out;
}

.app-sidebar-backdrop.closing .app-sidebar {
    animation: app-sidebar-out 0.25s ease-in forwards;
}

/* Die Eintraege sind eine Bootstrap-Listengruppe (#706, Stufe 7) — Zeile,
   Hover und Tastaturfokus kommen von dort. Die Schublade sagt nur, dass ihr
   eigener Grund durchscheint und wo die Zeile ihre Trennlinie nimmt: der
   dunkle Modus setzt sie auf `--app-ink`, was hier eine helle Linie waere. */
.app-sidebar .app-sidebar__items {
    --bs-list-group-bg: transparent;
    --bs-list-group-border-color: transparent;
    --bs-list-group-action-hover-bg: rgba(var(--app-white-rgb), 0.08);
    --bs-list-group-action-active-bg: rgba(var(--app-white-rgb), 0.12);

    /* Gegen `[data-bs-theme=dark] .list-group` in base.css, das der Gruppe
       eine eigene Flaeche gibt — gleiche Spezifitaet, spaeteres Stylesheet,
       und der Schluesselselektor ist unsere eigene Klasse. */
    background-color: transparent;
    border-color: transparent;
}

/* Invite, admin and logout are pushed to the bottom of the drawer — the
   `margin-top: auto` takes the place of the panel's former `space-between`,
   which would have parked this group in the middle now that a third child
   (the version) follows it. */
.app-sidebar .app-sidebar__items--account {
    margin-top: auto;
    padding-top: 0.5rem;
    /* Die Trennlinie steht hier und nicht eine Regel hoeher: das
       `border-color: transparent` dort gilt fuer die ganze Gruppe und haette
       sie sonst mitgeloescht. */
    border-top: 1px solid var(--app-sidebar-line);
}

/* Die Zeile selbst: `list-group-item list-group-item-action` mit
   `d-flex align-items-center gap-3`. Eigen bleibt ihr der breitere
   Innenabstand — eine Schublade wird mit dem Daumen bedient — und die
   Schriftgroesse. */
.app-sidebar__item {
    padding: 0.9rem 1.25rem;
    font-size: 1.05rem;
    text-align: left;
    cursor: pointer;
}

.app-sidebar__item i {
    width: 1.25rem;
    text-align: center;
}

.app-sidebar__version {
    padding: 0 1.25rem;
    margin-top: 0.75rem;
    font-size: 0.75rem;
}

@keyframes app-sidebar-backdrop-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes app-sidebar-backdrop-out {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* Transforms are exempt from the dvh rule: sliding the panel a full viewport
   width out is meant to clear the edge either way. */
@keyframes app-sidebar-in {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes app-sidebar-out {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(-100%);
    }
}

@keyframes app-sidebar-in-right {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes app-sidebar-out-right {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(100%);
    }
}

/* --------------------------------------------------------------------------
   Quick links (#659)

   The manager's own shortcuts, above everything else because they are the
   reason most people open the drawer at all.
   -------------------------------------------------------------------------- */

.app-sidebar .app-sidebar__items--quick {
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--app-sidebar-line);
    margin-bottom: 0.5rem;
}

/* No heading while the list is empty — there would be nothing under it. */
.app-sidebar__heading {
    padding: 0 1.25rem 0.35rem;
    color: var(--bs-secondary-color);
    font-size: 0.7rem;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* The row is the shortcut plus its own remove button; the shortcut takes
   whatever width is left so the whole label stays tappable. */
.app-sidebar__quick {
    display: flex;
    align-items: center;
}

.app-sidebar__quick .app-sidebar__item {
    flex: 1 1 auto;
    min-width: 0;
}

.app-sidebar__quick .app-sidebar__item span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Dimmed until it is touched: removing is not what this row is for. */
/* A `CloseButton` since #706. The padding it carried was its tap target; the
   button brings its own, so what is left is the inset from the panel edge. */
.app-sidebar__quick-remove {
    flex: 0 0 auto;
    align-self: center;
    margin-right: 1.25rem;
}

/* Einen Merker anlegen ist nicht, wofuer die Schublade da ist — die Zeile
   steht deshalb leiser als die darueber. */
.app-sidebar__item--add {
    --bs-list-group-action-color: var(--bs-secondary-color);

    font-size: 0.95rem;
}
