/**
 * Popup Manager - front-end styles (builds on Bootstrap 5 .modal)
 *
 * .modal-dialog is a full-viewport flex wrapper used for positioning;
 * .modal-content is the visible popup box.
 */

/* ---------- Layout / positioning ---------- */
.pm-modal .modal-dialog {
  display: flex;
  align-items: var(--pm-align-y, center);
  justify-content: var(--pm-align-x, center);
  width: 100%;
  max-width: none;
  min-height: 100%;
  margin: 0;
  pointer-events: none;
}

.pm-modal .modal-content {
  position: relative;
  top: var(--pm-shift-y, 0);
  left: var(--pm-shift-x, 0);
  flex: 0 1 auto;
  width: var(--pm-width, auto);
  max-width: 100%;
  height: var(--pm-height, auto);
  pointer-events: auto;
}

.pm-modal.pm-w-full .modal-content {
  flex-grow: 1;
}

/* Inherit the configured text colour inside the content */
.pm-modal .modal-body {
  color: inherit;
  overflow-y: auto;
}

/* Explicit heights: the body scrolls inside the box */
.pm-modal:not(.pm-h-auto) .modal-content {
  overflow: hidden;
}

/* Automatic height: box fits content, no inner scrolling */
.pm-modal.pm-h-auto .modal-body {
  overflow: visible;
}

/* Whole popup clickable */
.pm-modal.pm-linked .modal-content {
  cursor: pointer;
}

.pm-modal.pm-linked .modal-content:focus-visible {
  outline: 2px solid var(--bs-primary, #0d6efd);
  outline-offset: 2px;
}

/* Close (X) button */
.pm-modal .pm-close {
  position: absolute;
  top: .5rem;
  right: .5rem;
  z-index: 2;
}

/* ---------- Free background style ----------
 * No backdrop; the page stays scrollable and clickable everywhere
 * outside the popup box. No scrollbar on the popup when height is automatic.
 */
.pm-modal.pm-free {
  pointer-events: none;
  overflow: hidden;
}

.pm-modal.pm-free.pm-h-auto .modal-dialog,
.pm-modal.pm-free.pm-h-auto .modal-content,
.pm-modal.pm-free.pm-h-auto .modal-body {
  max-height: none;
  overflow: visible;
}

/* ---------- Static background style ----------
 * The popup is part of the page: the .modal element is positioned in the
 * document (not the viewport) and stretched to the page height by popup.js,
 * so it doubles as a full-page backdrop and the page scrolls normally with
 * the popup on it. A popup taller than the screen can be scrolled to the
 * bottom. --pm-scroll-top (set by popup.js on open) drops the dialog area to
 * where the visitor currently is, and the dialog is one screen tall so the
 * vertical/horizontal position settings still work relative to that view.
 */
.pm-modal.pm-static {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: auto;
  overflow: visible;
}

.pm-modal.pm-static .modal-dialog {
  min-height: 100vh;
  margin: var(--pm-scroll-top, 0px) 0 0 0;
}

@media (prefers-reduced-motion: reduce) {
  .pm-modal.fade,
  .pm-modal.fade .modal-dialog {
    transition: none;
  }
}
