/* The action menus of every platform list (a card's or row's ⋯, a list's "sort and show" menu, a viewer's ⋯): on a
   computer a card under its button, below 1024px (tablets and phones, touch) the same items in a bottom sheet over the
   dimmed page. Markup:
     <div class="app-menu-anchor">
         <button ... aria-expanded="true">⋯</button>
         <div class="app-menu" role="menu">
             <button class="app-menu-item" role="menuitem"><i class="bx bx-edit"></i>Edit<kbd class="app-key">E</kbd></button>
             <div class="app-menu-sep" role="separator"></div>
             <button class="app-menu-item app-menu-item-danger" role="menuitem">...</button>
         </div>
     </div>
     <div class="app-menu-away" @onclick="Close"></div>          (a click anywhere else closes the card)
     <div class="app-sheet-scrim app-menu-scrim" @onclick="Close"></div>
     <div class="app-sheet app-menu-sheet" role="menu">
         <div class="app-sheet-grab"></div><button class="app-sheet-close" data-app-close>...</button>
         <div class="app-menu-sheet-head">(picture)<span class="app-menu-sheet-name"><b>Name</b><small>Detail</small></span></div>
         ...the same items...
     </div>
   The page renders both forms while a menu is open; this file shows the card on a computer and the sheet below 1024px.
   The sheet is the shared bottom sheet (app-sheet.css, js/app-sheet.js: dragging, Escape, its box and entrance). Pages
   only place the card (which side, upwards, a wider list) and never restyle the items. */

.app-menu-anchor {
    position: relative;
    display: inline-flex;
}

/* ---------- the card under its button (computers) ---------- */
.app-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 20;
    width: 236px;
    padding: 6px;
    border: 1px solid var(--app-line);
    border-radius: 18px;
    background: var(--app-surface);
    box-shadow: var(--app-shadow-menu);
    cursor: default;
    transform-origin: top right;
    animation: app-menu-in 0.2s var(--app-ease-out) both;
}

/* A menu with two-way choices (sort, order, layout): wide enough for their labels */
.app-menu-wide {
    width: 288px;
}

/* A click outside the open card closes it: the page covers itself unseen, under the open card or row (which the page
   lifts above this layer with a z-index of 5 or more) */
.app-menu-away {
    position: fixed;
    inset: 0;
    z-index: 4;
}

/* ---------- the items ----------
   Every row of a menu (items, the two-way choices, the lines between groups) spans the same width inside the menu's
   6px padding, and the groups are 6px apart; the menu's corner (18px) is the items' corner (12px) plus that padding,
   the same as the shared drop-down list (app-ui.css .app-sel-list) */
.app-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 40px;
    padding: 0 12px;
    border: 0;
    border-radius: 12px;
    background: none;
    color: var(--app-text);
    font: inherit;
    font-size: 14px;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

/* The item's icon: a font icon, or a small picture such as Bina's star at the same size */
.app-menu-item > .bx:first-child {
    flex: none;
    color: var(--app-text-muted);
    font-size: 18px;
}

.app-menu-item > img:first-child {
    flex: none;
    width: 18px;
    height: 18px;
}

.app-menu-item .app-key,
.app-menu-check {
    margin-left: auto;
}

/* The tick beside the chosen option of a menu */
.app-menu-check {
    color: var(--app-accent);
    font-size: 18px;
}

/* The chosen option */
.app-menu-item-on,
.app-menu-item-on > .bx:first-child {
    color: var(--app-accent);
    font-weight: 600;
}

.app-menu-item-danger,
.app-menu-item-danger > .bx:first-child {
    color: var(--app-danger);
}

.app-menu-item-accent,
.app-menu-item-accent > .bx:first-child {
    color: var(--app-accent);
    font-weight: 600;
}

.app-menu-item:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* An item with a second line (app-menu-lines): its icon stays beside the first line */
.app-menu-item-two {
    align-items: flex-start;
}

.app-menu-item-two > .bx:first-child {
    margin-top: 10px;
}

.app-menu-lines {
    display: flex;
    flex-direction: column;
    padding: 8px 0;
    line-height: 1.3;
}

.app-menu-lines small {
    color: var(--app-text-muted);
    font-size: 12px;
}

@media (hover: hover) {
    .app-menu-item:not(:disabled):hover {
        background: var(--app-surface-soft);
    }

    .app-menu-item-danger:not(:disabled):hover {
        background: var(--app-danger-soft);
    }
}

.app-menu-sep {
    height: 1px;
    margin: 6px 0;
    background: var(--app-line);
}

/* A group's title (Sort by, Show as) */
.app-menu-label {
    margin: 0;
    padding: 8px 12px 4px;
    color: var(--app-text-muted);
    font-size: 12px;
    font-weight: 600;
}

.app-menu-hint {
    margin: 2px 12px 6px;
    color: var(--app-text-muted);
    font-size: 12px;
    line-height: 1.45;
}

/* A group of two-way choices in a menu: an app-segmented app-segmented-even */
.app-menu-segments {
    display: grid;
    margin: 6px 0 0;
}

/* A key on the keyboard: the shortcut beside a menu item, or in a list of shortcuts */
.app-key {
    display: inline-grid;
    place-items: center;
    flex: none;
    box-sizing: border-box;
    min-width: 24px;
    height: 24px;
    padding: 0 7px;
    border: 1px solid var(--app-line);
    border-bottom-width: 2px;
    border-radius: 7px;
    background: var(--app-surface-soft);
    color: var(--app-text-muted);
    font: 600 12px var(--app-font-family);
    white-space: nowrap;
}

/* ---------- which form shows ---------- */
@media (min-width: 1024px) {
    .app-menu-sheet,
    .app-menu-scrim {
        display: none;
    }
}

@media (max-width: 1023.98px) {
    .app-menu {
        display: none;
    }

    /* The sheet's dimmed scrim closes the menu now; the unseen layer stays only for other pop-ups of the page that are
       still cards at this width */
    html:has(.app-menu-sheet) .app-menu-away {
        display: none;
    }

    /* The page behind an open menu sheet does not scroll (app-sheet.css leaves the menu sheets out of its own rule, as
       they are in the page on computers too, hidden) */
    html:has(.app-menu-sheet) {
        overflow: hidden;
    }

    /* The name and detail of what the menu acts on, above the actions: as wide as the actions and 6px above them like
       a group line */
    .app-menu-sheet-head {
        display: flex;
        align-items: center;
        gap: 12px;
        margin-bottom: 6px;
        padding: 4px 12px 14px;
        border-bottom: 1px solid var(--app-line);
    }

    .app-menu-sheet-name {
        display: flex;
        flex-direction: column;
        min-width: 0;
    }

    .app-menu-sheet-name b {
        overflow: hidden;
        color: var(--app-text-strong);
        font-size: 15px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .app-menu-sheet-name small {
        color: var(--app-text-muted);
        font-size: 12.5px;
    }

    /* Finger-sized rows */
    .app-menu-sheet .app-menu-item {
        min-height: 52px;
        font-size: 15px;
    }

    .app-menu-sheet .app-menu-item > .bx:first-child {
        font-size: 20px;
    }

    .app-menu-sheet .app-menu-segments .app-segmented-option {
        height: 44px;
        font-size: 14px;
    }
}

@keyframes app-menu-in {
    from {
        opacity: 0;
        transform: translateY(-6px) scale(0.97);
    }
}

@media (prefers-reduced-motion: reduce) {
    .app-menu {
        animation: none;
    }
}
