/*
 * Bottom sheets, drawn the way the phone's Compose code draws Material 3's ModalBottomSheet, at every
 * screen width (a wide window gets the same sheet, centred and capped at 640 px, like the phone's
 * code on a tablet). web-app-bottom-sheets.js adds dragging and the slide down when one closes.
 *
 * .wa-sheet-backdrop            the scrim over the page; the sheet sits on its bottom edge
 * .wa-sheet                     the sheet (28 px top corners, the phone's DrawBottomSheetAlert)
 * .wa-sheet--custom-content     24 px top corners (the phone's DrawBottomSheetWithCustomContent)
 * .wa-sheet--full-height        the phone's fillScreenHeight sheets; on the web as tall as their content
 *                               (the post composer's "Who can see this?" sheet stays full height, web-app-feed.css)
 * .wa-sheet-handle              Material's drag handle
 * .wa-sheet-scroll              the part that scrolls when the content is taller than the window
 * data-web-sheet-is-not-draggable (on the backdrop): the phone's allowSheetGestures = false
 */

.wa-sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    /* Material's scrim: the phone's scrim colour (black) at 32% */
    background: rgba(0, 0, 0, 0.32);
    /* a finger on the scrim or the sheet never scrolls the page behind it */
    touch-action: none;
    overscroll-behavior: contain;
    animation: wa-sheet-scrim-in 270ms ease-out;
}
.wa-sheet {
    position: relative;
    box-sizing: border-box;
    width: 100%;
    /* Material's BottomSheetDefaults.SheetMaxWidth */
    max-width: 640px;
    max-height: 100vh;
    max-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--md-background);
    color: var(--md-on-surface);
    border-radius: 28px 28px 0 0;
    padding-bottom: var(--wa-bottom-inset);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    /* Material's opening spring (stiffness 700, damping 0.9) sampled every 22 ms; browsers without linear() get the curve before it */
    animation: wa-sheet-slide-up 240ms cubic-bezier(0.2, 0.9, 0.3, 1);
    animation-timing-function: linear(0, 0.123, 0.341, 0.553, 0.719, 0.832, 0.906, 0.952, 0.977, 0.991, 0.997, 1);
}
.wa-sheet--custom-content { border-radius: 24px 24px 0 0; }
/* the phone's fillScreenHeight sheets: on the web every sheet is as tall as its content, never taller than the
   window (Anudeep, 2026-10-28: "no need to be full height, wrap content, apply to all bottom sheets") */
.wa-sheet--full-height { height: auto; max-height: 100vh; max-height: 100dvh; }
.wa-sheet-backdrop[hidden] { display: none; }
@keyframes wa-sheet-slide-up { from { transform: translateY(100%); } }
@keyframes wa-sheet-scrim-in { from { background-color: transparent; } }

/* Material's drag handle: a 32 x 4 px pill in on-surface-variant, 22 px above and below */
.wa-sheet-handle {
    display: flex;
    flex: none;
    justify-content: center;
    padding: 22px 0;
    cursor: grab;
    touch-action: none;
}
.wa-sheet-handle::before {
    content: "";
    width: 32px;
    height: 4px;
    border-radius: 999px;
    background: var(--md-on-surface-variant);
}
/* a handle on a sheet the phone never lets you pull down is only a look */
[data-web-sheet-is-not-draggable] .wa-sheet-handle { cursor: default; }
.wa-sheet-close { position: absolute; top: 12px; right: 12px; }
/* the cross every sheet gets. A sheet that already draws its own stays with that one. */
.wa-sheet-shell-close { z-index: 3; }
.wa-sheet:has(.wa-icon-button[data-web-close-dialog]:not(.wa-sheet-shell-close), .wa-magic-close-button, .wa-sheet-close:not(.wa-sheet-shell-close), .wa-cast-sheet-close) > .wa-sheet-shell-close {
    display: none;
}
.wa-sheet-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 24px 24px; }

/* while a finger or the mouse pulls it, and while it slides away */
.wa-sheet.is-being-dragged { cursor: grabbing; user-select: none; -webkit-user-select: none; }
.wa-sheet-backdrop.is-closing,
.wa-profile-sheet-backdrop.is-closing { background-color: transparent; transition: background-color 150ms ease-out; pointer-events: none; }
/* a sheet that replaced one with the same id (a form turning into its "thanks") doesn't slide up again */
.is-shown-in-place,
.is-shown-in-place > .wa-sheet { animation: none; }

@media (prefers-reduced-motion: reduce) {
    .wa-sheet-backdrop, .wa-sheet { animation: none; }
}

/* computers keep the scrollbar's room even when there is no scrollbar (web-app.css): while a sheet is open,
   that strip gets the same dimmed colour as the scrim so no bright edge shows beside it */
@media (min-width: 900px) {
    html:has(.wa-sheet-backdrop:not([hidden])) { background: color-mix(in srgb, var(--md-background) 68%, #000000); }
}
