/* Dialog / Modal
 * Native <dialog> element styling with backdrop.
 * Pairs with modal_controller.js, turbo_confirm_controller.js,
 * and confirmation_controller.js.
 * Entry/exit animation via @starting-style (no JavaScript).
 */

@layer components {
  dialog {
    --dialog-max-width: min(90vw, 32rem);

    max-width: var(--dialog-max-width);
    padding: var(--block-space-l) var(--inline-space-l);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-canvas);
    color: var(--color-ink);
    box-shadow: 0 8px 32px oklch(0% 0 0 / 0.15);

    /* Entry animation */
    opacity: 1;
    scale: 1;
    transition:
      opacity 150ms ease,
      scale 150ms ease,
      overlay 150ms ease allow-discrete,
      display 150ms ease allow-discrete;

    @starting-style {
      opacity: 0;
      scale: 0.95;
    }

    /* Exit animation (when closing) */
    &:not([open]) {
      opacity: 0;
      scale: 0.95;
    }
  }

  dialog::backdrop {
    background: oklch(0% 0 0 / 0.4);
    transition:
      background 150ms ease,
      overlay 150ms ease allow-discrete,
      display 150ms ease allow-discrete;

    @starting-style {
      background: oklch(0% 0 0 / 0);
    }
  }

  /* Dialog header */
  dialog header,
  dialog .dialog__header {
    margin-block-end: var(--block-space);
    font-weight: 600;
  }

  /* Dialog footer (action buttons) */
  dialog footer,
  dialog .dialog__footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--inline-space);
    margin-block-start: var(--block-space-l);
  }
}
