/* OAIT Design System 2.1.0 · reference/css/overlay.css
   Overlays: the scrim, dialogs, bottom sheets, the responsive modal, side sheets, menus, popovers,
   and plain tooltips. Load after tokens/oait.css and base.css.

   Implements
   - Floating surfaces: surface-raised, shadow-elevation-3, and a transparent 1px edge for forced
     colors; rounded-sheet when modal, rounded-box when anchored (D-ARC-09, D-SEM-08, D-SEM-10,
     D-ARC-14, D-ARC-15, canonical §6.1, §10.0).
   - Dialog: up to 560px, 24px padding, the body scrolling between a fixed header and action row,
     headline-sm title, body-md description, a 48px close button 8px from the top and inline end,
     actions at the inline end 8px apart; sticky action row with a hairline for long forms
     (D-CSN-21, D-LAY-06, D-ARC-25, canonical §10.19).
   - Bottom sheet: top corners only, up to 560px, 90dvh, the decorative 32×4px handle, padding
     16 / 24 / 24 + the bottom inset, buttons sharing the width (D-CSN-22, D-LAY-17).
   - Responsive modal: a bottom sheet below 768px and a dialog from 768px (D-CSN-22, D-LAY-02).
   - Side sheet: 85vw up to 384px, full height, the two free corners rounded, from the inline end
     (phone menu) or start (admin drawer), safe areas padded (D-CSN-12, D-CSN-13, D-ARC-24).
   - Scrim: black 32% in both themes on the modal layer; dialog::backdrop for native dialogs; the
     page does not scroll while a native modal is open (D-CSN-21, D-ARC-26).
   - Menu: 200–320px, 8px block padding, 48px items with 16px inline padding and 12px gaps,
     body-lg, a 20px primary-ink check on the current or checked item, 8% / 12% state layers,
     38% disabled, outline-variant dividers; under its trigger at the inline end, 4px apart, or
     above it (D-CSN-23, D-ARC-24, D-ARC-20, D-COL-05).
   - Popover: the menu container with 16px padding, a label-md title, body-md text, and an optional
     close button (D-CSN-23, D-ARC-20).
   - Plain tooltip: inverse-surface in both themes, 4px corners, 4px 8px padding, 24px tall at
     least, up to 240px, body-sm, above its trigger and centered, on the tooltip layer
     (D-CSN-24, D-ARC-08, D-ARC-24, D-ARC-26).
   - Motion: fades at short-3; sheets slide at short-4; entrances emphasized; exits short-3
     emphasized-accelerate; nothing moves under reduced motion (base.css) (D-SEM-16, canonical §7.3).

   Tokens read: --color-surface-raised, --color-on-surface, --color-on-surface-variant,
   --color-primary-ink, --color-outline, --color-outline-variant, --color-scrim,
   --color-inverse-surface, --color-inverse-on-surface; --shadow-elevation-3;
   --radius-sheet, --radius-box, --radius-4px, --radius-full; --space-1, --space-2, --space-3,
   --space-4, --space-6, --space-10, --space-16, --space-card-medium, --space-row-inset,
   --space-stack-tight, --space-stack-loose, --space-fields; --container-dialog,
   --container-side-sheet, --container-menu, --container-tooltip; --size-menu-min,
   --size-menu-item, --size-icon-md, --size-focus-inset; --text-headline-sm, --text-title-lg,
   --text-body-lg, --text-body-md, --text-body-sm, --text-label-md (each with its --line-height,
   --letter-spacing, and --font-weight); --opacity-state-hover, --opacity-state-pressed,
   --opacity-state-disabled-content; --duration-short-3, --duration-short-4; --ease-standard,
   --ease-emphasized, --ease-emphasized-accelerate; --z-behind, --z-dropdown, --z-modal,
   --z-tooltip. Context property: --oa-state (CONTRIBUTING.md, reference CSS rules).

   Classes: .oa-scrim · .oa-dialog (__header __title __desc __close __body __actions
   __actions--sticky) · .oa-sheet (__handle) · .oa-modal · .oa-side-sheet (--start --end) ·
   .oa-menu (__item __icon __label __check __divider __anchor) · .oa-popover (__title __body
   __close __anchor) · .oa-tooltip (__anchor). The .oa-dialog__* parts are shared by every modal
   surface: dialog, bottom sheet, responsive modal, and side sheet.
   States and placement: [open], :modal, [hidden], [popover], :disabled, [aria-disabled="true"],
   [aria-current], [aria-checked="true"], [data-side="top" | "bottom"], [data-align="start" | "end"]
   (the attributes Radix also sets).
   Documentation only, never in a product: .oa-scrim--demo, .oa-menu__anchor--demo,
   .oa-popover__anchor--demo, .oa-tooltip__anchor--demo, and the open attribute written in HTML. */


/* ---------------------------------------------------------------------------------------------
   1. Scrim. Black at 32% in both themes, on the modal layer. Native dialogs draw it with
   ::backdrop; .oa-scrim is the element version (Radix Dialog.Overlay, framework-free sheets that
   are not <dialog>). A press on it closes what it holds (D-CSN-21, D-ARC-26).
   --------------------------------------------------------------------------------------------- */

.oa-scrim {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background-color: var(--color-scrim);
  transition:
    opacity var(--duration-short-3) var(--ease-standard),
    display var(--duration-short-3) allow-discrete;
}

/* The element scrim leaves like the backdrop: hidden fades it out over short-3. */
.oa-scrim[hidden] {
  opacity: 0;
  transition-timing-function: var(--ease-emphasized-accelerate);
}

dialog::backdrop {
  background-color: var(--color-scrim);
  transition:
    opacity var(--duration-short-3) var(--ease-standard),
    overlay var(--duration-short-3) allow-discrete,
    display var(--duration-short-3) allow-discrete;
}

dialog:not([open])::backdrop {
  opacity: 0;
  transition-timing-function: var(--ease-emphasized-accelerate);
}

/* The page behind a native modal does not scroll (D-CSN-21). */
:root:has(dialog:modal) {
  overflow: hidden;
}


/* ---------------------------------------------------------------------------------------------
   2. Modal surfaces: what dialog, bottom sheet, responsive modal, and side sheet share.
   surface-raised (#ffffff light, #322823 dark), elevation-3, a transparent 1px edge, a column of
   header, body, and actions 24px apart (D-ARC-09, D-SEM-08, D-SEM-10, D-ARC-25).
   --------------------------------------------------------------------------------------------- */

.oa-dialog,
.oa-sheet,
.oa-modal,
.oa-side-sheet {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: var(--space-stack-loose);
  border: 1px solid transparent;
  background-color: var(--color-surface-raised);
  color: var(--color-on-surface);
  box-shadow: var(--shadow-elevation-3);
  overflow: auto;
  overscroll-behavior: contain;
}

/* A closed native dialog stays hidden whatever display the class gives it. */
dialog:is(.oa-dialog, .oa-sheet, .oa-modal, .oa-side-sheet):not([open]) {
  display: none;
}

/* Documentation only: a native dialog opened without showModal() (the open attribute written in
   HTML) sits in the page flow, so pages can show it open and static. In a product this look is
   the sign of a dialog opened the wrong way: always call showModal(). */
dialog:is(.oa-dialog, .oa-sheet, .oa-modal, .oa-side-sheet)[open]:not(:modal) {
  position: relative;
  inset: auto;
  z-index: auto;
}


/* ---------------------------------------------------------------------------------------------
   3. Dialog. Centered, calc(100% - 2rem) wide up to 560px, at most calc(100dvh - 2rem) tall,
   24px padding, rounded-sheet (D-CSN-21, D-LAY-06, D-LAY-17, D-ARC-15).
   --------------------------------------------------------------------------------------------- */

.oa-dialog {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  margin: auto;
  inline-size: calc(100% - 2 * var(--space-4));
  max-inline-size: var(--container-dialog);
  block-size: fit-content;
  max-block-size: calc(100dvh - 2 * var(--space-4) - var(--oa-safe-top) - var(--oa-safe-bottom));
  padding: var(--space-card-medium);
  border-radius: var(--radius-sheet);
}

/* The window the dialog centers in stops at the top and bottom insets, so a tall dialog keeps its
   title and Close button out of the notch and its actions above the home indicator (canonical §4.10). */
.oa-dialog:modal {
  inset-block: var(--oa-safe-top) var(--oa-safe-bottom);
}


/* ---------------------------------------------------------------------------------------------
   4. Bottom sheet, and the responsive modal below 768px. Fixed to the bottom, the window's width
   up to 560px and centered, at most 90dvh tall, the top corners rounded and the bottom square;
   a 32×4px handle 16px from the top; content 16px under the handle, 24px at the sides, 24px plus
   the bottom safe area at the end (D-CSN-22, D-LAY-17, D-SEM-05).
   --------------------------------------------------------------------------------------------- */

.oa-sheet,
.oa-modal {
  --oa-sheet-handle-inline: 32px; /* component constant (D-ARC-24) */
  --oa-sheet-handle-block: 4px;   /* component constant (D-ARC-24) */
  position: fixed;
  inset-block: auto var(--oa-keyboard-inset);
  inset-inline: 0;
  z-index: var(--z-modal);
  margin-block: 0;
  margin-inline: auto;
  inline-size: 100%;
  max-inline-size: var(--container-dialog);
  block-size: fit-content;
  max-block-size: calc(90dvh - var(--oa-keyboard-inset));
  padding-block: calc(2 * var(--space-4) + var(--oa-sheet-handle-block)) calc(var(--space-card-medium) + var(--oa-safe-bottom));
  padding-inline: var(--space-card-medium);
  border-block-end-width: 0;
  border-start-start-radius: var(--radius-sheet);
  border-start-end-radius: var(--radius-sheet);
  border-end-start-radius: 0;
  border-end-end-radius: 0;
}

/* Decorative: aria-hidden. It does not mean the sheet can be swiped unless the product builds it,
   and even then Cancel or Close stays the way out (WCAG 2.5.7). */
.oa-sheet__handle {
  position: absolute;
  inset-block-start: var(--space-4);
  inset-inline: 0;
  margin-inline: auto;
  inline-size: var(--oa-sheet-handle-inline);
  block-size: var(--oa-sheet-handle-block);
  border-radius: var(--radius-full);
  background-color: color-mix(in srgb, var(--color-outline) 40%, transparent); /* outline at 40%, canonical §10.19 */
}

/* The responsive modal from 768px: the dialog geometry, no handle (D-CSN-22). */
@media (min-width: 48rem) {
  .oa-modal {
    inset-block: var(--oa-safe-top) calc(var(--oa-safe-bottom) + var(--oa-keyboard-inset));
    inset-inline: 0;
    margin: auto;
    inline-size: calc(100% - 2 * var(--space-4));
    max-block-size: calc(100dvh - 2 * var(--space-4) - var(--oa-safe-top) - var(--oa-safe-bottom) - var(--oa-keyboard-inset));
    padding: var(--space-card-medium);
    border-block-end-width: 1px;
    border-radius: var(--radius-sheet);
  }

  .oa-modal .oa-sheet__handle {
    display: none;
  }
}


/* ---------------------------------------------------------------------------------------------
   5. Side sheet. Modal, full height, 85vw up to 384px, attached to the inline end (the phone menu
   of a site header) or the inline start (the admin drawer below 768px); the two corners that face
   the page are rounded, the attached side is square; 24px padding plus the safe areas
   (D-CSN-12, D-CSN-13, D-ARC-24, D-SEM-05, D-LAY-17).
   --------------------------------------------------------------------------------------------- */

.oa-side-sheet {
  --oa-side-sheet-from: 100%;
  position: fixed;
  inset-block: 0;
  inset-inline: auto 0;
  z-index: var(--z-modal);
  margin: 0;
  inline-size: 85vw;
  max-inline-size: var(--container-side-sheet);
  block-size: 100dvh;
  max-block-size: none;
  padding-block: calc(var(--space-6) + var(--oa-safe-top)) calc(var(--space-6) + var(--oa-safe-bottom));
  padding-inline: var(--space-6) calc(var(--space-6) + var(--oa-safe-end)); /* the attached side takes its inset */
  border-start-start-radius: var(--radius-sheet);
  border-end-start-radius: var(--radius-sheet);
  border-start-end-radius: 0;
  border-end-end-radius: 0;
}

/* The end sheet is the default; the modifier names it in markup. */
.oa-side-sheet--end {
  inset-inline: auto 0;
}

.oa-side-sheet--start {
  --oa-side-sheet-from: -100%;
  inset-inline: 0 auto;
  padding-inline: calc(var(--space-6) + var(--oa-safe-start)) var(--space-6);
  border-start-start-radius: 0;
  border-end-start-radius: 0;
  border-start-end-radius: var(--radius-sheet);
  border-end-end-radius: var(--radius-sheet);
}

/* Everything mirrors with the direction: an end sheet is attached to the left in Arabic and slides
   in from there; its padding needs no override, because --oa-safe-end is the left inset in
   right-to-left (base.css, canonical §4.10). */
.oa-side-sheet:dir(rtl) {
  --oa-side-sheet-from: -100%;
}

.oa-side-sheet--start:dir(rtl) {
  --oa-side-sheet-from: 100%;
}

dialog.oa-side-sheet[open]:not(:modal) {
  block-size: auto;
}

/* Side sheet header: the title and its close button on one row. */
.oa-side-sheet .oa-dialog__header {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding-inline-end: 0;
}

.oa-side-sheet .oa-dialog__title {
  font-size: var(--text-title-lg);
  line-height: var(--text-title-lg--line-height);
  letter-spacing: var(--text-title-lg--letter-spacing);
  font-weight: var(--text-title-lg--font-weight);
}

/* The 48px button's icon lines up with the 24px padding. */
.oa-side-sheet .oa-dialog__close {
  margin-inline-end: calc(-1 * var(--space-3));
}


/* ---------------------------------------------------------------------------------------------
   6. Parts every modal surface shares: header (title, description, close), body, and actions
   (D-CSN-21, D-ARC-20, D-ARC-21).
   --------------------------------------------------------------------------------------------- */

.oa-dialog__header {
  display: flex;
  flex: none;
  flex-direction: column;
  gap: var(--space-stack-tight);
  padding-inline-end: var(--space-10); /* the title keeps 40px clear of the close button */
}

.oa-dialog__title {
  margin: 0;
  color: var(--color-on-surface);
  font-size: var(--text-headline-sm);
  line-height: var(--text-headline-sm--line-height);
  letter-spacing: var(--text-headline-sm--letter-spacing);
  font-weight: var(--text-headline-sm--font-weight);
}

.oa-dialog__desc {
  margin: 0;
  color: var(--color-on-surface-variant);
  font-size: var(--text-body-md);
  line-height: var(--text-body-md--line-height);
  letter-spacing: var(--text-body-md--letter-spacing);
  font-weight: var(--text-body-md--font-weight);
}

/* A 48px close icon button 8px from the top and inline end of dialogs and bottom sheets. */
:is(.oa-dialog, .oa-sheet, .oa-modal) .oa-dialog__close {
  position: absolute;
  inset-block-start: var(--space-2);
  inset-inline-end: var(--space-2);
}

/* The body scrolls while the header and the actions stay. It bleeds 8px into the padding so the
   focus ring of a full-width field is never clipped by the scroll box. */
.oa-dialog__body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: var(--space-fields);
  min-block-size: 0;
  margin: calc(-1 * var(--space-2));
  padding: var(--space-2);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* The action row slot. The row itself is button.css's .oa-actions on the same element: the dialog
   footer by default (Cancel first, the main button last at the inline end, 8px apart), --sheet in
   bottom sheets (both lg, sharing the width), --modal in the responsive modal (D-CAI-04). */
.oa-dialog__actions {
  flex: none;
}

/* Long forms: the action row keeps a 1px outline-variant top edge across the full width. */
.oa-dialog__actions--sticky {
  margin-block-start: calc(-1 * var(--space-2));
  margin-inline: calc(-1 * var(--space-card-medium));
  padding-block-start: var(--space-4);
  padding-inline: var(--space-card-medium);
  border-block-start: 1px solid var(--color-outline-variant);
}


/* ---------------------------------------------------------------------------------------------
   7. Motion (D-SEM-16, canonical §7.3). Enter with ease-emphasized; leave at short-3 with
   ease-emphasized-accelerate. Native dialogs animate open and close with @starting-style and
   allow-discrete display and overlay; elsewhere the exit runs where the browser supports it and
   is instant otherwise. base.css switches every transition off under reduced motion, so states
   change at once; never wait for transitionend.
   --------------------------------------------------------------------------------------------- */

.oa-dialog {
  transition-property: opacity, scale, display, overlay;
  transition-duration: var(--duration-short-3);
  transition-timing-function: var(--ease-emphasized);
  transition-behavior: allow-discrete;
}

.oa-sheet,
.oa-modal,
.oa-side-sheet {
  transition-property: translate, display, overlay;
  transition-duration: var(--duration-short-4);
  transition-timing-function: var(--ease-emphasized);
  transition-behavior: allow-discrete;
}

dialog.oa-dialog:not([open]) {
  opacity: 0;
  scale: 0.95;
  transition-timing-function: var(--ease-emphasized-accelerate);
}

dialog:is(.oa-sheet, .oa-modal):not([open]) {
  translate: 0 100%;
  transition-duration: var(--duration-short-3);
  transition-timing-function: var(--ease-emphasized-accelerate);
}

dialog.oa-side-sheet:not([open]) {
  translate: var(--oa-side-sheet-from) 0;
  transition-duration: var(--duration-short-3);
  transition-timing-function: var(--ease-emphasized-accelerate);
}

@media (min-width: 48rem) {
  .oa-modal {
    transition-property: opacity, scale, display, overlay;
    transition-duration: var(--duration-short-3);
  }

  dialog.oa-modal:not([open]) {
    translate: none;
    opacity: 0;
    scale: 0.95;
  }
}

@starting-style {
  .oa-scrim,
  dialog[open]::backdrop {
    opacity: 0;
  }

  .oa-dialog {
    opacity: 0;
    scale: 0.95;
  }

  .oa-sheet,
  .oa-modal {
    translate: 0 100%;
  }

  .oa-side-sheet {
    translate: var(--oa-side-sheet-from) 0;
  }
}

@media (min-width: 48rem) {
  @starting-style {
    .oa-modal {
      translate: none;
      opacity: 0;
      scale: 0.95;
    }
  }
}


/* ---------------------------------------------------------------------------------------------
   8. Menu. Anchored list of actions or links: surface-raised, rounded-box, elevation-3,
   200–320px, 8px block padding, on the dropdown layer (D-CSN-23, D-ARC-24, D-ARC-26).
   The class carries the look only; .oa-menu__anchor places it, or a library (Radix, Floating UI)
   places its wrapper. Show it by removing the hidden attribute.
   --------------------------------------------------------------------------------------------- */

.oa-menu {
  box-sizing: border-box;
  z-index: var(--z-dropdown);
  inline-size: max-content;
  min-inline-size: var(--size-menu-min);
  max-inline-size: min(var(--container-menu), calc(100vw - 2 * var(--space-gutter))); /* never wider than the page frame: 288px at 320 */
  margin: 0;
  padding-block: var(--space-2);
  padding-inline: 0;
  list-style: none;
  border: 1px solid transparent;
  border-radius: var(--radius-box);
  background-color: var(--color-surface-raised);
  color: var(--color-on-surface);
  box-shadow: var(--shadow-elevation-3);
  overflow: hidden auto;
  overscroll-behavior: contain;
}

/* One row: at least 48px, 16px inline padding, 12px between icon, label, and check, body-lg. */
.oa-menu__item {
  position: relative;
  isolation: isolate;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  inline-size: 100%;
  min-block-size: var(--size-menu-item);
  margin: 0;
  padding-block: 0; /* canonical §10.20: min-h-12 px-4 gap-3; the 48px minimum centers one line, so a row in another script (Arabic in an English menu) stays 48px */
  padding-inline: var(--space-row-inset);
  border: 0;
  background: none;
  color: var(--color-on-surface);
  font-family: inherit;
  font-size: var(--text-body-lg);
  line-height: var(--text-body-lg--line-height);
  letter-spacing: var(--text-body-lg--letter-spacing);
  font-weight: var(--text-body-lg--font-weight);
  text-align: start;
  text-decoration: none;
  cursor: pointer;
}

.oa-menu__item::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: var(--z-behind);
  border-radius: inherit;
  background-color: currentColor;
  opacity: var(--oa-state, 0);
  pointer-events: none;
  transition: opacity var(--duration-short-3) var(--ease-standard);
}

@media (hover: hover) {
  .oa-menu__item:hover {
    --oa-state: var(--opacity-state-hover);
  }
}

.oa-menu__item:active {
  --oa-state: var(--opacity-state-pressed);
}

.oa-menu__item:active::before {
  transition-duration: 0ms; /* lint-ok: a press shows at once, the release fades (canonical §2.7) */
}

/* Rows inside a clipping container take the inset ring (canonical §6.3). */
.oa-menu__item:focus-visible,
.oa-menu__item[data-demo-focus] {
  outline-offset: var(--size-focus-inset);
}

.oa-menu__item:is(:disabled, [aria-disabled="true"]) {
  color: color-mix(in srgb, var(--color-on-surface) calc(var(--opacity-state-disabled-content) * 100%), transparent);
  cursor: default;
}

.oa-menu__item:is(:disabled, [aria-disabled="true"])::before {
  opacity: 0;
}

/* Icons and the check are 20px whatever icon class they carry (D-ARC-22). */
.oa-menu__item :is(.oa-menu__icon, .oa-menu__check) {
  flex: none;
  font-size: var(--size-icon-md);
}

.oa-menu__icon {
  color: var(--color-on-surface-variant);
}

.oa-menu__label {
  flex: 1 1 auto;
  min-inline-size: 0;
  overflow-wrap: anywhere;
}

/* The check marks the current item of a disclosure list (aria-current) or a checked item of an
   action menu (aria-checked); it is the non-color cue (D-CAI-14). */
.oa-menu__check {
  color: var(--color-primary-ink);
  visibility: hidden;
}

.oa-menu__item:is([aria-current]:not([aria-current="false"]), [aria-checked="true"]) .oa-menu__check {
  visibility: visible;
}

.oa-menu__item:is(:disabled, [aria-disabled="true"]) :is(.oa-menu__icon, .oa-menu__check) {
  color: inherit;
}

.oa-menu__divider {
  display: block;
  block-size: 0;
  margin-block: var(--space-2);
  margin-inline: 0;
  border: 0;
  border-block-start: 1px solid var(--color-outline-variant);
  color: inherit; /* an <hr> keeps the browser's gray text color otherwise */
}


/* ---------------------------------------------------------------------------------------------
   9. Popover. A non-modal anchored panel for help or details: the menu container with 16px
   padding, a label-md title, body-md text, and an optional close button. Below 640px the same
   content opens as a bottom sheet (D-CSN-23, D-ARC-20).
   --------------------------------------------------------------------------------------------- */

.oa-popover {
  box-sizing: border-box;
  position: relative;
  z-index: var(--z-dropdown);
  display: flex;
  flex-direction: column;
  gap: var(--space-stack-tight);
  inline-size: max-content;
  min-inline-size: var(--size-menu-min);
  max-inline-size: min(var(--container-menu), calc(100vw - 2 * var(--space-gutter))); /* never wider than the page frame: 288px at 320 */
  margin: 0;
  padding: var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-box);
  background-color: var(--color-surface-raised);
  color: var(--color-on-surface);
  box-shadow: var(--shadow-elevation-3);
}

.oa-popover__title {
  margin: 0;
  color: var(--color-on-surface);
  font-size: var(--text-label-md);
  line-height: var(--text-label-md--line-height);
  letter-spacing: var(--text-label-md--letter-spacing);
  font-weight: var(--text-label-md--font-weight);
}

.oa-popover:has(> .oa-popover__close) .oa-popover__title {
  padding-inline-end: var(--space-10);
}

.oa-popover__body {
  margin: 0;
  color: var(--color-on-surface-variant);
  font-size: var(--text-body-md);
  line-height: var(--text-body-md--line-height);
  letter-spacing: var(--text-body-md--letter-spacing);
  font-weight: var(--text-body-md--font-weight);
}

/* The 48px close button sits 4px from the top and inline end, so its icon meets the padding. */
.oa-popover .oa-popover__close {
  position: absolute;
  inset-block-start: var(--space-1);
  inset-inline-end: var(--space-1);
}


/* ---------------------------------------------------------------------------------------------
   10. Plain tooltip. inverse-surface and inverse-on-surface in both themes, 4px corners,
   4px 8px padding, at least 24px tall, up to 240px wide, body-sm, on the tooltip layer. It adds
   to a control that already has a name; never the title attribute (D-CSN-24, D-ARC-08, D-ARC-24,
   D-ARC-26). Show it by removing the hidden attribute: after --duration-delay-tooltip on mouse
   rest, at once on keyboard focus (the script reads the token).
   --------------------------------------------------------------------------------------------- */

.oa-tooltip {
  box-sizing: border-box;
  display: block;
  z-index: var(--z-tooltip);
  inline-size: max-content;
  max-inline-size: var(--container-tooltip);
  min-block-size: var(--space-6);
  margin: 0;
  padding-block: var(--space-1);
  padding-inline: var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--radius-4px);
  background-color: var(--color-inverse-surface);
  color: var(--color-inverse-on-surface);
  font-size: var(--text-body-sm);
  line-height: var(--text-body-sm--line-height);
  letter-spacing: var(--text-body-sm--letter-spacing);
  font-weight: var(--text-body-sm--font-weight);
  text-align: start;
  overflow-wrap: break-word;
}


/* ---------------------------------------------------------------------------------------------
   11. Anchoring without a library. The trigger and its overlay share an anchor element:
   menus and popovers sit under the trigger, aligned to its inline end, 4px apart, or above it
   with data-side="top" (near the bottom of the window, in footers); data-align="start" aligns
   them to the trigger's inline start. Tooltips sit above the trigger, centered, 4px apart, or below
   with data-side="bottom" (triggers near the top of the window); data-align="start" or "end"
   keeps them inside the window at a row's edges (D-CSN-23, D-CSN-24).
   Inside a scrolling region (a table region) an absolute overlay would be clipped: render it in
   the top layer with the popover attribute and let the script or library place it. The anchor
   rules skip [popover] overlays: in the top layer their offsets would be read against the window.
   --------------------------------------------------------------------------------------------- */

.oa-menu__anchor,
.oa-popover__anchor,
.oa-tooltip__anchor {
  position: relative;
  display: inline-flex;
  vertical-align: middle;
}

.oa-menu__anchor:not(.oa-menu__anchor--demo) > .oa-menu:not([popover]),
.oa-popover__anchor:not(.oa-popover__anchor--demo) > .oa-popover:not([popover]) {
  position: absolute;
  inset-block: calc(100% + var(--space-1)) auto;
  inset-inline: auto 0;
}

.oa-menu__anchor:not(.oa-menu__anchor--demo) > .oa-menu:not([popover])[data-side="top"],
.oa-popover__anchor:not(.oa-popover__anchor--demo) > .oa-popover:not([popover])[data-side="top"] {
  inset-block: auto calc(100% + var(--space-1));
}

.oa-menu__anchor:not(.oa-menu__anchor--demo) > .oa-menu:not([popover])[data-align="start"],
.oa-popover__anchor:not(.oa-popover__anchor--demo) > .oa-popover:not([popover])[data-align="start"] {
  inset-inline: 0 auto;
}

.oa-tooltip__anchor:not(.oa-tooltip__anchor--demo) > .oa-tooltip:not([popover]) {
  position: absolute;
  inset-block: auto calc(100% + var(--space-1));
  inset-inline: 50% auto;
  translate: -50% 0;
}

.oa-tooltip__anchor:not(.oa-tooltip__anchor--demo) > .oa-tooltip:not([popover]):dir(rtl) {
  translate: 50% 0;
}

.oa-tooltip__anchor:not(.oa-tooltip__anchor--demo) > .oa-tooltip:not([popover])[data-side="bottom"] {
  inset-block: calc(100% + var(--space-1)) auto;
}

.oa-tooltip__anchor:not(.oa-tooltip__anchor--demo) > .oa-tooltip:not([popover])[data-align="start"] {
  inset-inline: 0 auto;
  translate: none;
}

.oa-tooltip__anchor:not(.oa-tooltip__anchor--demo) > .oa-tooltip:not([popover])[data-align="end"] {
  inset-inline: auto 0;
  translate: none;
}

/* The top layer (popover attribute): fixed, and the script or library sets the coordinates. */
:is(.oa-menu, .oa-popover, .oa-tooltip)[popover] {
  position: fixed;
  inset-block: auto;
  inset-inline: auto;
}


/* ---------------------------------------------------------------------------------------------
   12. Anchored motion: menus and popovers fade and rise 4px over short-3 emphasized; tooltips
   fade over short-3 standard; exits fade over short-3 emphasized-accelerate (D-SEM-16).
   --------------------------------------------------------------------------------------------- */

.oa-menu,
.oa-popover {
  transition:
    opacity var(--duration-short-3) var(--ease-emphasized),
    translate var(--duration-short-3) var(--ease-emphasized),
    display var(--duration-short-3) allow-discrete,
    overlay var(--duration-short-3) allow-discrete;
}

.oa-tooltip {
  transition:
    opacity var(--duration-short-3) var(--ease-standard),
    display var(--duration-short-3) allow-discrete,
    overlay var(--duration-short-3) allow-discrete;
}

:is(.oa-menu, .oa-popover, .oa-tooltip)[hidden] {
  opacity: 0;
  transition-timing-function: var(--ease-emphasized-accelerate);
}

@starting-style {
  .oa-menu,
  .oa-popover {
    opacity: 0;
    translate: 0 var(--space-1);
  }

  .oa-tooltip {
    opacity: 0;
  }
}


/* ---------------------------------------------------------------------------------------------
   13. Documentation only. Never in a product.
   .oa-scrim--demo turns the scrim into an in-flow frame that stands in for the window behind a
   modal surface; the surface inside is a native dialog with the open attribute (section 2).
   The __anchor--demo modifiers lay the trigger and its open overlay out in the page flow, in the
   places the anchoring of section 11 gives them, so nothing overlaps the content that follows.
   --------------------------------------------------------------------------------------------- */

.oa-scrim--demo {
  position: relative;
  inset: auto;
  z-index: auto;
  display: grid;
  place-items: center;
  inline-size: 100%;
  min-inline-size: 0;
  padding-block: var(--space-10);
  padding-inline: var(--space-4);
  overflow: hidden;
}

.oa-scrim--demo:has(> .oa-sheet) {
  padding-block: var(--space-16) 0;
  padding-inline: 0;
}

.oa-scrim--demo > .oa-sheet {
  align-self: end;
}

.oa-scrim--demo:has(> .oa-side-sheet) {
  padding: 0;
  place-items: stretch end;
}

.oa-scrim--demo > .oa-side-sheet--start {
  justify-self: start;
}

@media (width < 48rem) {
  .oa-scrim--demo:has(> .oa-modal) {
    padding-block: var(--space-16) 0;
    padding-inline: 0;
  }

  .oa-scrim--demo > .oa-modal {
    align-self: end;
  }
}

.oa-menu__anchor--demo,
.oa-popover__anchor--demo {
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-1);
}

.oa-tooltip__anchor--demo {
  flex-direction: column-reverse;
  align-items: center;
  gap: var(--space-1);
}

.oa-menu__anchor--demo:has(> [data-side="top"]),
.oa-popover__anchor--demo:has(> [data-side="top"]) {
  flex-direction: column-reverse;
}

.oa-tooltip__anchor--demo:has(> [data-side="bottom"]) {
  flex-direction: column;
}

.oa-menu__anchor--demo:has(> [data-align="start"]),
.oa-popover__anchor--demo:has(> [data-align="start"]),
.oa-tooltip__anchor--demo:has(> [data-align="start"]) {
  align-items: flex-start;
}

.oa-tooltip__anchor--demo:has(> [data-align="end"]) {
  align-items: flex-end;
}
