/* sheet-modal -bottom-sheet / centered-dialog chrome split into head /
 * body / footer rails. The legacy ``.pos-modal-header / -body / -footer``
 * classes (built for the POS customer-quick + split-bill modals) are
 * kept as aliases so prod templates don't need a sweep at the same time
 * as the recipe atlas adopts the canonical name.
 *
 * Composes inside any container that owns its own surface + position
 * (today: <dialog class="pos-customer-modal">, <dialog class="pos-split-bill-modal">).
 * The generic ``.sheet-modal`` wrapper below owns the outer <dialog>
 * (bottom-sheet position + scrim); feature dialogs (recipe-quick-create-modal,
 * pos-customer-modal, …) can migrate onto it to drop bespoke positioning.
 *
 * Drop the ``.pos-modal-*`` alias once every prod template has migrated
 * to ``.sheet-modal-*``.
 */

/* Outer wrapper -a native <dialog> rendered as a bottom sheet stuck to the
 * screen bottom. Open it with ``dialog.showModal()`` so it lives in the top
 * layer (escapes transformed ancestors -a plain position:fixed otherwise
 * lands in a corner) and its ``::backdrop`` becomes the scrim. The UA centers
 * a :modal dialog via ``inset: 0; margin: auto``; we reset all four inset
 * edges (top auto, others 0) so the sheet pins full-width to the bottom.
 * Author origin beats the UA rule at equal specificity, so plain [open]
 * wins without ``!important``. Compose the head / body / footer rails inside. */
.sheet-modal {
  border: 0;
  border-radius: var(--radius-lg, 20px) var(--radius-lg, 20px) 0 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-md);
  padding: var(--space-3);
  width: 100%;
  max-width: 100%;
  max-height: 85vh;
  overflow: auto;
  box-sizing: border-box;
}

.sheet-modal[open] {
  position: fixed;
  inset: auto 0 0 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.sheet-modal::backdrop {
  background: color-mix(in srgb, var(--text) 40%, transparent);
}

/* Entrance/exit animation - scoped to the real <dialog> element (not the
   static design-system-preview.html mockup, which fakes an "open" sheet
   with a plain always-visible <div class="sheet-modal">). */
dialog.sheet-modal {
  transform: translateY(100%);
  opacity: 0;
  transition:
    transform var(--duration-slow) var(--ease-emphasized),
    opacity var(--duration-slow) var(--ease-emphasized),
    overlay var(--duration-slow) var(--ease-emphasized) allow-discrete,
    display var(--duration-slow) var(--ease-emphasized) allow-discrete;
}

dialog.sheet-modal[open] {
  transform: translateY(0);
  opacity: 1;
}

/* Browsers without @starting-style support just skip the entrance
   animation and render open - no broken state either way. */
@starting-style {
  dialog.sheet-modal[open] {
    transform: translateY(100%);
    opacity: 0;
  }
}

dialog.sheet-modal::backdrop {
  opacity: 1;
  transition:
    opacity var(--duration-slow) var(--ease-emphasized),
    overlay var(--duration-slow) var(--ease-emphasized) allow-discrete,
    display var(--duration-slow) var(--ease-emphasized) allow-discrete;
}

@starting-style {
  dialog.sheet-modal[open]::backdrop {
    opacity: 0;
  }
}

.sheet-modal-header,
.pos-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--divider);
}

.sheet-modal-header-title,
.pos-modal-header-title {
  font-size: var(--font-size-prominent);
  font-weight: 800;
  color: var(--text);
}

/* Close button -32×32 bordered chip that mirrors the focused-topbar
   back button. Bordered so it reads as tappable on any surface tint
   (white settings-cards, soft-tinted alerts inside the modal body).
   Same shape as .shell-focused-topbar-back. */
.sheet-modal-header-close,
.pos-modal-header-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--divider);
  background: var(--surface);
  color: var(--muted);
  display: grid;
  place-items: center;
  padding: 0;
  font-size: var(--font-size-subheading);
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
}

.sheet-modal-header-close:hover,
.sheet-modal-header-close:focus-visible,
.pos-modal-header-close:hover,
.pos-modal-header-close:focus-visible {
  background: var(--surface-soft);
  border-color: var(--border);
  color: var(--text);
  outline: none;
}

.sheet-modal-body,
.pos-modal-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  max-height: 60vh;
  overflow-y: auto;
}

.sheet-modal-footer,
.pos-modal-footer {
  display: flex;
  gap: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--divider);
}

.sheet-modal-footer .btn,
.pos-modal-footer .btn {
  flex: 1;
}
