/* Redwood overlays — the dialog and the drawer panel.
 *
 * Values were read out of the JET 21.0.0 Redwood theme (oj-redwood-min.css:
 * --oj-dialog-*, .oj-dialog, the oj-drawer-popup surrogate; identical at
 * 19.0.0) and the core-pack theme beside it (oraclejet-preact
 * Theme-redwood/theme.css: --oj-c-dialog-*,
 * --oj-c-drawer-popup-overlay-drawer-background-color), and mapped onto the
 * --rw-* names. Where they disagree the core pack wins. The raw lengths are
 * Oracle's structural widths: the 600px dialog, the 320px drawer minimum and
 * the 90vw drawer maximum.
 *
 * Load after redwood-tokens.css (and redwood-dark.css if you use it).
 * Opening, closing, focus trapping, Escape and the modal backdrop are the
 * application's job; this file only draws the panels.
 *
 *   <section class="rw-dialog" role="dialog" aria-modal="true" aria-labelledby="t">
 *     <header class="rw-dialog-head"><h2 id="t">Void invoice</h2>…close…</header>
 *     <div class="rw-dialog-body">…</div>
 *     <footer class="rw-dialog-foot"><button class="rw-btn">Cancel</button>
 *       <button class="rw-btn rw-btn-danger">Void</button></footer>
 *   </section>
 *
 *   <aside class="rw-drawer" role="dialog" aria-label="Invoice INV-1042">
 *     <header class="rw-dialog-head">…</header>…
 *   </aside>
 *
 * Readings, and where each is rounded onto a token:
 *
 *   Dialog     600px wide, never closer than 1.5rem to the window edge
 *              (max 100vw and 100vh less 3rem); radius lg; 1px divider border;
 *              ground --rw-bg-content (the core pack's popup surface; the
 *              legacy theme used neutral-10) and shadow lg (legacy: xl).
 *   Header     2.75rem above the title, 2rem either side, .75rem below
 *              (11x / 8x / 3x); title heading-xs at 800. No band, no rule.
 *   Body       0 2rem 1rem (8x / 4x); it scrolls, the header and footer do
 *              not.
 *   Footer     1rem 2rem 2rem (4x / 8x); actions on the end edge, .5rem apart
 *              (the toolbar spacing).
 *   Drawer     full height on the end edge (or .rw-drawer-start), at least
 *              320px and at most 90vw; ground neutral-10 in both themes'
 *              readings, which is --rw-bg-subtle. Oracle's drawer shadow is a
 *              sideways 5% glow no token expresses; it is rounded to
 *              --rw-shadow-sm. The drawer's width is the application's to
 *              choose — Redwood's drawer page templates come in small, medium
 *              and large, and their widths were not verified.
 *
 * What people get wrong:
 *
 *   The dialog header is not a shaded band with a rule under it, and the
 *   footer is not a band either. Space separates them.
 *
 *   The backdrop. Oracle's scrim is neutral-190 at .4, and no token holds
 *   that alpha, so this file does not draw one. Draw it in the application
 *   and do not tint it with brand.
 *
 *   A dialog asks one question or edits one small thing. Detail that the user
 *   reads beside the page — a record, a preview, a long form — belongs in a
 *   drawer, which leaves the page visible.
 *
 *   Footer order: the primary action sits on the end edge, the dismissive one
 *   before it. A destructive primary is .rw-btn-danger and names the act
 *   ("Void invoice"), never "OK".
 *
 * (c) Oracle. Internal brand asset — see NOTICE. */

/* ── Dialog ───────────────────────────────────────────────────────────────── */

.rw-dialog {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  width: 600px;
  max-width: calc(100vw - var(--rw-space-12x));
  max-height: calc(100vh - var(--rw-space-12x));
  overflow: hidden;
  border: 1px solid var(--rw-divider);
  border-radius: var(--rw-radius-lg);
  background-color: var(--rw-bg-content);
  box-shadow: var(--rw-shadow-lg);
  color: var(--rw-text-primary);
  --rw-current-bg: var(--rw-bg-content);
}

.rw-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--rw-space-4x);
  padding: var(--rw-space-11x) var(--rw-space-8x) var(--rw-space-3x);
}

.rw-dialog-head > :is(h1, h2, h3, .rw-dialog-title) {
  margin: 0;
  color: var(--rw-text-primary);
  font-size: var(--rw-heading-xs-size);
  line-height: var(--rw-heading-xs-lh);
  font-weight: var(--rw-heading-weight);
}

.rw-dialog-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0 var(--rw-space-8x) var(--rw-space-4x);
}

.rw-dialog-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: var(--rw-space-2x);
  padding: var(--rw-space-4x) var(--rw-space-8x) var(--rw-space-8x);
}

/* ── Drawer ───────────────────────────────────────────────────────────────── */

.rw-drawer {
  box-sizing: border-box;
  position: fixed;
  inset-block: 0;
  inset-inline-end: 0;
  z-index: 1050; /* --oj-core-z-index-dialog */
  display: flex;
  flex-direction: column;
  min-width: min(320px, 100vw);
  max-width: 90vw;
  overflow-y: auto;
  background-color: var(--rw-bg-subtle);
  box-shadow: var(--rw-shadow-sm);
  color: var(--rw-text-primary);
  --rw-current-bg: var(--rw-bg-subtle);
}

.rw-drawer-start {
  inset-inline-end: auto;
  inset-inline-start: 0;
}

.rw-drawer > .rw-dialog-body { overflow-y: visible; }

@media (forced-colors: active) {
  .rw-dialog { border-color: CanvasText; }
  .rw-drawer { border-inline-start: 1px solid CanvasText; }
  .rw-drawer-start { border-inline-start: 0; border-inline-end: 1px solid CanvasText; }
}
