/* ==========================================================================
   Onix drawer — the one shape of everything that opens over a page
   (Components/Shared/Drawer.razor; js/onix-definition.js and js/onix-mayla.js
   draw the same classes by hand): a panel at the right edge of the window,
   the page still in view at its left, over everything — the phone's tab bar
   included. The invoice's partner drawer (PartnerDrawer) is the model; the
   send dialogs, the document viewer, the bank dialogs, the Properties app's
   dialogs, the print designer's questions, the BI chat history and Mayla's
   panel are the same drawer. Never a centred box.

     .drawer-backdrop   the scrim over the page, the drawer at its right edge
     .drawer            the panel: a head, a scrolling body, an optional foot
     .drawer--narrow    a question, a note, a chat (480px); .drawer--wide a
                        page in a frame or a document (1180px); 820px else;
                        .drawer--full the whole window (a document's page screen)
     .drawer--floating  a drawer with no scrim (Mayla): the page stays usable

   Over everything, wherever the page draws it: the scrim is a popover
   (popover="manual" — Drawer.razor, js/onix-definition.js) that js/onix-drawer.js
   shows in the browser's top layer, so no ancestor's frame or stacking order
   reaches it (a form section is a container, a pane is sticky, a bar is blurred:
   each would cut the drawer to its box or leave it under the shell's bar, the ✕
   covered). The z-index below is what a browser without popovers is left with.
   What must stay over a drawer (the toasts, the connection-lost notice, the
   app's page viewer) is raised into the same layer by that script.

   Tokens only (css/onix-theme.css, css/onix-glass.css), so both themes come
   for free; the glass theme blurs the scrim as it does the command palette's.
   ========================================================================== */

/* In the top layer each keeps its own box, not the browser's popover box (a centred, bordered, padded canvas):
   no specificity, so every rule of theirs still has the last word. */
:where(.drawer-backdrop[popover], .toast-host[popover], .onix-viewer[popover], #components-reconnect-modal[popover]) {
    inset: auto; width: auto; height: auto; margin: 0; padding: 0; border: 0;
    overflow: visible; color: inherit; background: none;
}

.drawer-backdrop {
    position: fixed; inset: 0; z-index: 1300;
    display: flex; align-items: stretch; justify-content: flex-end;
    background: rgba(10, 14, 25, 0.32);
    animation: fade-in 0.14s var(--ease);
}
.drawer {
    --drawer-w: 820px;
    display: flex; flex-direction: column;
    width: min(var(--drawer-w), 100%); height: 100%;
    min-height: 0;
    padding-top: env(safe-area-inset-top, 0px);
    background: var(--bg, var(--panel)); color: var(--ink);
    border-left: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
    animation: drawer-in 0.18s var(--ease);
}
.drawer--narrow { --drawer-w: 480px; }
.drawer--wide { --drawer-w: 1180px; }
/* ATP-004: a screen over the whole window (the page screen of a document) — no page left in view at its left. */
.drawer--full { --drawer-w: 100%; border-left: 0; }
.drawer--floating { position: fixed; top: 0; right: 0; bottom: 0; height: auto; }
.drawer:focus { outline: none; }

.drawer__head {
    display: flex; align-items: center; gap: 12px; flex: none;
    padding: 10px 12px 10px 18px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}
.drawer__title {
    flex: 1 1 auto; min-width: 0; margin: 0;
    font: 700 1.02rem/1.3 var(--font-display);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.drawer__actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }

.drawer__body {
    flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain;
    padding: 14px 16px calc(16px + var(--safe-bottom, 0px));
}
.drawer__body > :first-child { margin-top: 0; }
/* A body that is a .form-card for its field styles (app.css .form-card label / input): the card's own box
   (app.css, onix-glass.css) is the drawer's. */
.drawer__body.form-card {
    max-width: none; margin: 0;
    background: transparent; border: 0; border-radius: 0; box-shadow: none;
    -webkit-backdrop-filter: none; backdrop-filter: none; animation: none;
}
.drawer__body.form-card::before { display: none; }
/* A page in a frame, a document: the body is the content, edge to edge. */
.drawer__body--flush { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.drawer__frame { flex: 1 1 auto; width: 100%; min-height: 0; border: 0; background: var(--bg, var(--panel)); }

.drawer__foot {
    flex: none; margin: 0; padding: 12px 18px calc(12px + var(--safe-bottom, 0px));
    border-top: 1px solid var(--line); background: var(--panel);
}

/* A toast over the drawer, not under its scrim. */
body:has(.drawer-backdrop) .toast-host { z-index: 1400; }

@keyframes drawer-in { from { transform: translateX(32px); opacity: 0; } to { transform: none; opacity: 1; } }

/* The whole width on a phone. */
@media (max-width: 767.98px) {
    .drawer { width: 100%; border-left: 0; }
    .drawer__head { padding: 8px 10px 8px 14px; }
}
@media (prefers-reduced-motion: reduce) {
    .drawer, .drawer-backdrop { animation: none; }
}
@media print {
    .drawer-backdrop, .drawer--floating { display: none !important; }
}
