/*
 * drawer.css
 *
 * <dialog class="app-drawer" aria-labelledby open>
 *   <header class="app-drawer-header">
 *     <h2 class="app-drawer-title" id>Filter</h2>
 *     <button class="app-icon-button" data-variant="ghost" data-size="compact" aria-label="Schließen">…</button>
 *   </header>
 *   <div class="app-drawer-body">…</div>
 *   <footer class="app-drawer-footer">[buttons]</footer>
 * </dialog>
 *
 * A modal panel at the end edge, for a side task about the page behind it (a filter, a row's
 * details). Header, body and footer share their rules with the dialog (dialog.css). On a phone
 * (a viewport up to 480) it is a sheet from the bottom, nearly as tall as the screen, as every
 * overlay on a phone rises from the bottom: what comes in from the side is a page. It clears
 * the notch and the home indicator.
 */
@layer components {
    .app-drawer {
        position: fixed;
        inset-block: 0;
        inset-inline: auto 0;
        z-index: var(--app-z-side-panel);
        inline-size: min(var(--app-drawer-width), 100%);
        max-inline-size: 100%;
        block-size: var(--app-page-height);
        max-block-size: var(--app-page-height);
        margin: 0;
        padding-block: calc(var(--app-space-dialog) + var(--app-space-safe-top)) calc(var(--app-space-dialog) + var(--app-space-safe-bottom));
        padding-inline: 0;
        border: 0;
        background: var(--app-color-surface-raised);
        color: var(--app-color-text);
        box-shadow: var(--app-shadow-drawer);
    }

    .app-drawer[open] {
        display: flex;
        flex-direction: column;
        gap: var(--app-space-dialog-gap);
    }

    /* Viewport, --app-breakpoint-480, as the dialog's sheet. The gap above it keeps the page
       in sight, so it reads as over the page, not as a page of its own. */
    @media (width <= 480px) {
        .app-drawer {
            inset-block: auto 0;
            inset-inline: 0;
            inline-size: 100%;
            block-size: calc(var(--app-page-height) - var(--app-space-section) - var(--app-space-safe-top));
            padding-block: var(--app-space-dialog) calc(var(--app-space-dialog) + var(--app-space-safe-bottom));
            border-start-start-radius: var(--app-radius-card);
            border-start-end-radius: var(--app-radius-card);
        }

        :root[data-keyboard] .app-drawer {
            inset-block-end: var(--app-space-keyboard);
            block-size: calc(var(--app-page-height) - var(--app-space-keyboard) - var(--app-space-section) - var(--app-space-safe-top));
            padding-block: var(--app-space-dialog);
        }
    }

    .app-drawer::backdrop {
        background: var(--app-color-scrim);
    }

    /* Forced colours (a Windows contrast theme): shadows and backgrounds are gone, so frames
       are outlines and a chosen state is the system highlight. */
    @media (forced-colors: active) {
        .app-drawer {
            outline: var(--app-border-width) solid var(--app-color-forced-line);
            outline-offset: calc(-1 * var(--app-border-width));
        }
    }
}
