/* The bottom sheet (the same on every platform page): a panel that slides up from the bottom of a phone screen for a
   menu, settings or a choice. js/app-sheet.js lets it be dragged: the handle at the top pulls it up to nearly the full
   screen or down to bring it back or close it, a quick swipe down closes it, and so does dragging the content down once
   it is scrolled to the top. Tapping the dimmed page around it (app-sheet-scrim, which the page renders and closes the
   sheet on) or pressing Escape closes it too, so the sheet has no visible close button: its close button
   (app-sheet-close with data-app-close) is only there for screen readers and keyboards, and the script clicks it when
   the sheet is dragged away. Markup:
     <div class="app-sheet-scrim" @onclick="Close"></div>
     <div class="app-sheet" role="dialog" aria-label="...">
         <div class="app-sheet-grab" aria-hidden="true"></div>
         <button type="button" class="app-sheet-close" data-app-close @onclick="Close">Close</button>
         ...content...
     </div> */

.app-sheet-scrim {
    position: fixed;
    inset: 0;
    z-index: 1045;
    background: var(--app-scrim);
    animation: app-sheet-fade 0.2s ease backwards;
    transition: opacity 0.26s ease;
}

.app-sheet {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1047;
    display: flex;
    flex-direction: column;
    max-height: 70vh;
    max-height: 70dvh;
    /* The same 18px at the bottom as at the sides, so the content sits evenly in the sheet */
    padding: 0 18px calc(18px + env(safe-area-inset-bottom, 0px));
    border-radius: 22px 22px 0 0;
    /* The rounded top is also cut by a clip path: Chrome does not always clip a scrolling sheet's content and its
       sticky handle by the sheet's own corners (on some screens a sheet pulled up to its full height showed square top
       corners), while a clip path cuts whatever is drawn. It cuts a shadow too, so the sheet has none: the dimmed page
       around it sets it apart (R31). */
    clip-path: inset(0 round 22px 22px 0 0);
    background: var(--app-surface);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
    will-change: transform;
    /* Only before it starts (backwards), so the script's inline transform takes over once it is in place */
    /* It slides up whole and opaque from the screen's bottom edge, as the confirm dialog's phone sheet does: a sheet
       fading in would let what is under it show through while it rises */
    animation: app-sheet-up 0.34s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}

.app-sheet-full {
    max-height: 94vh;
    max-height: 94dvh;
}

/* The handle: a short bar in a 44px tall strip that takes the finger. It stays at the top while the sheet scrolls, on
   the sheet's own colour, so the content scrolls away under it instead of showing through around the bar (a sheet
   whose handle lies over a coloured head sets --app-sheet-grab-bg: transparent) */
.app-sheet-grab {
    position: sticky;
    top: 0;
    z-index: 2;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    margin: 0 -18px;
    padding-top: 10px;
    background: var(--app-sheet-grab-bg, var(--app-surface));
    touch-action: none;
    cursor: grab;
}

.app-sheet-grab::before {
    content: "";
    width: 40px;
    height: 5px;
    border-radius: 99px;
    background: var(--app-line);
}

/* A larger area takes the finger than the bar shows (44px tall in all) */
.app-sheet-grab::after {
    content: "";
    position: absolute;
    inset: 0 0 -16px;
}

/* While the finger moves it, the sheet follows at once. Its entrance is not stopped here with animation: none: taking
   that away again at the end of the drag would play the entrance from the start, so the sheet would flash out and slide
   in once more (R30). js/app-sheet.js finishes the entrance instead when a drag starts. */
.app-sheet-dragging {
    transition: none !important;
}

/* After a drag the sheet slides back into place (its height already follows the finger while it is pulled up, so only
   the slide is animated) */
.app-sheet-settle {
    transition: transform 0.28s var(--app-ease-out);
}

/* Only for screen readers and keyboards (Tab reaches it, Enter closes) */
.app-sheet-close {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    border: 0;
    white-space: nowrap;
}

/* The page behind an open sheet does not scroll. A menu's sheet (app-menu.css .app-menu-sheet) is in the page on
   computers too, hidden, so app-menu.css holds the page still only where that sheet shows. */
html:has(.app-sheet:not(.app-menu-sheet)) {
    overflow: hidden;
}

@keyframes app-sheet-fade {
    from {
        opacity: 0;
    }
}

@keyframes app-sheet-up {
    from {
        transform: translateY(100%);
    }
}

@media (prefers-reduced-motion: reduce) {
    .app-sheet {
        animation-name: app-sheet-fade;
    }

    .app-sheet-settle {
        transition: none;
    }
}
