/* Modal dialogs (the native <dialog>): a blurred backdrop, a centred panel that scrolls its body while the title and the
   buttons stay put. Sizes: --sm, --md, --lg (nearly full window). See partials/modal.html and js/modal.js. */
.ez_modal {
  margin: auto;
  padding: 0;
  max-inline-size: none;
  max-block-size: none;
  background: transparent;
  border: 0;
  color: var(--ez-color-text-primary);
  overflow: visible;
}

.ez_modal::backdrop {
  background: var(--ez-scrim);
  backdrop-filter: blur(6px);
}

.ez_modal__panel {
  display: flex;
  flex-direction: column;
  max-block-size: calc(100dvh - 2rem);
  background: var(--ez-color-surface);
  border: 1px solid var(--ez-color-border);
  border-radius: var(--ez-radius-lg);
  box-shadow: var(--ez-shadow-lg);
  overflow: hidden;
}

.ez_modal--sm .ez_modal__panel { inline-size: min(26rem, calc(100vw - 2rem)); }
.ez_modal--md .ez_modal__panel { inline-size: min(42rem, calc(100vw - 2rem)); }
.ez_modal--lg .ez_modal__panel {
  inline-size: min(90rem, calc(100vw - 4rem));
  block-size: calc(100dvh - 4rem);
}

.ez_modal__head,
.ez_modal__foot {
  display: flex;
  flex: none;
  align-items: center;
  gap: var(--ez-space-3);
  padding: var(--ez-space-3) var(--ez-space-5);
  background: var(--ez-color-surface-container);
}

.ez_modal__head { justify-content: space-between; }
.ez_modal__foot { justify-content: flex-end; }

.ez_modal__title {
  margin: 0;
  font-size: var(--ez-font-size-lg);
}

.ez_modal__body {
  flex: 1;
  min-block-size: 0;
  padding: var(--ez-space-5);
  overflow: auto;
  overscroll-behavior: contain;
}

.ez_modal[open] .ez_modal__panel { animation: ez-modal-in 220ms cubic-bezier(0.2, 0.8, 0.2, 1); }
.ez_modal[open]::backdrop { animation: ez-modal-fade 220ms ease-out; }
.ez_modal--closing .ez_modal__panel { animation: ez-modal-out 160ms ease-in forwards; }
.ez_modal--closing::backdrop { animation: ez-modal-fade 160ms ease-in reverse forwards; }
.ez_modal--shake .ez_modal__panel { animation: ez-modal-shake 320ms ease-in-out; }

/* Fields in a modal sit in at most two columns, however wide the window is, so the eye reads straight down. */
.ez_modal .ez_form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ez_modal .ez_stack {
  gap: var(--ez-space-6);
}


.ez_form-section__title {
  margin: 0;
  color: var(--ez-color-text-muted);
  font-size: var(--ez-font-size-sm);
  font-weight: var(--ez-font-weight-medium);
}

.ez_modal .ez_check {
  font-size: var(--ez-font-size-md, 1rem);
}

html.ez_scroll-lock { overflow: hidden; }

@keyframes ez-modal-in {
  from { opacity: 0; transform: translateY(1rem) scale(0.97); }
}
@keyframes ez-modal-out {
  to { opacity: 0; transform: translateY(0.5rem) scale(0.98); }
}
@keyframes ez-modal-fade {
  from { opacity: 0; }
}
@keyframes ez-modal-shake {
  20% { transform: translateX(-0.375rem); }
  45% { transform: translateX(0.375rem); }
  70% { transform: translateX(-0.25rem); }
  90% { transform: translateX(0.125rem); }
}

@media (prefers-reduced-motion: reduce) {
  .ez_modal[open] .ez_modal__panel,
  .ez_modal[open]::backdrop,
  .ez_modal--closing .ez_modal__panel,
  .ez_modal--closing::backdrop,
  .ez_modal--shake .ez_modal__panel { animation-duration: 1ms; }
}

@media (max-width: 40rem) {
  .ez_modal .ez_form-grid { grid-template-columns: minmax(0, 1fr); }
}

@media print { .ez_modal { display: none; } }
