/*
 * Modal — confirmation, form-in-modal, detail view.
 */

@import url('../tokens.css');

.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
  opacity: 0;
  transition: opacity var(--transition-slow);
  padding: var(--space-4);
}

.modal-overlay.is-open {
  opacity: 1;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  background-color: var(--color-surface-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - var(--space-10));
  display: flex;
  flex-direction: column;
  transform: translateY(-4px);
  transition: transform var(--transition-slow);
}

.modal-overlay.is-open .modal {
  transform: translateY(0);
}

.modal-lg {
  max-width: 720px;
}

/* ---------------------------------------------------------------
 * Drawer variant — slides in from the right edge.
 *
 * Used by the reminder dialog (and any future side-panel form).
 *
 * Implementation notes:
 *  - Native <dialog> elements have a built-in centered positioning
 *    (`position: absolute; inset: 0; margin: auto`) that fights any
 *    flex alignment we set on them. We sidestep it by positioning the
 *    inner .modal article with `position: fixed` to the viewport's
 *    right edge, and turning the surrounding overlay into a
 *    pass-through layer.
 *  - No dark backdrop, no opacity fade — only a transform slide so the
 *    motion is decisive, not soft.
 *  - The rest of the page stays interactive (pointer-events: none on
 *    the overlay). The user closes via the X button or Escape.
 * ------------------------------------------------------------- */
.modal-overlay-drawer-right {
  position: fixed;
  inset: 0;
  /* Light grey wash — dims the page enough to feel like the drawer is
     in front and the page is on pause. The neutral mid-grey base
     (instead of pure black with low alpha) keeps it from looking
     muddy on dark UI elements. No backdrop-filter (blur reads as a
     fade animation, which the spec explicitly rules out here). */
  background-color: rgba(31, 41, 55, 0.35);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  display: block;
  padding: 0;
  /* pointer-events: auto so clicks on the dim area are caught — the
     page behind cannot be interacted with while the drawer is open.
     The overlay click handler in reminders.js closes the drawer on
     such clicks. */
  pointer-events: auto;
  opacity: 1;
  transition: none;
  border: none;
}

.modal.modal-drawer-right {
  position: fixed;
  top: 0;
  right: 0;
  width: 100%;
  max-width: 440px;
  height: 100vh;
  max-height: 100vh;
  border: none;
  border-radius: 0;
  box-shadow: -8px 0 24px -8px rgba(0, 0, 0, 0.12);
  transform: translateX(100%);
  transition: transform 250ms ease-out;
  pointer-events: auto;
}

.modal-overlay-drawer-right.is-open .modal.modal-drawer-right {
  transform: translateX(0);
}

@media (max-width: 640px) {
  .modal.modal-drawer-right {
    max-width: 100%;
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-6);
  border-bottom: 1px solid var(--color-border);
}

.modal-title {
  font-size: var(--text-h2);
  font-weight: var(--text-h2-weight);
  line-height: var(--text-h2-leading);
  color: var(--color-text-primary);
}

.modal-close {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-pill);
  color: var(--color-text-secondary);
  transition:
    background-color var(--transition),
    color var(--transition);
}

.modal-close:hover {
  background-color: var(--color-surface-muted);
  color: var(--color-text-primary);
}

.modal-close:focus-visible {
  outline: var(--focus-outline);
  outline-offset: var(--focus-outline-offset);
}

.modal-close svg {
  width: var(--icon);
  height: var(--icon);
}

.modal-body {
  padding: var(--space-6);
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border);
}
