/* Popup Manager – frontend */
.pm-popup {
  --pm-width: 600px;
  --pm-bg: #fff;
  --pm-color: #222;
  --pm-padding: 32px;
  --pm-radius: 12px;
  --pm-overlay: rgba(0, 0, 0, .6);
  --pm-duration: .3s;
  --pm-z: 99990;

  position: fixed;
  inset: 0;
  z-index: var(--pm-z);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  pointer-events: none;
}

.pm-popup[hidden] {
  display: none;
}

html.pm-lock,
html.pm-lock body {
  overflow: hidden;
}

/* Overlay */
.pm-popup__overlay {
  position: absolute;
  inset: 0;
  background: var(--pm-overlay);
  opacity: 0;
  transition: opacity var(--pm-duration) ease;
  pointer-events: auto;
}

.pm-popup.is-open .pm-popup__overlay {
  opacity: 1;
}

/* Dialog */
.pm-popup__dialog {
  position: relative;
  box-sizing: border-box;
  width: min(var(--pm-width), 100%);
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  overflow: auto;
  overscroll-behavior: contain;
  padding: var(--pm-padding);
  border-radius: var(--pm-radius);
  background: var(--pm-bg);
  color: var(--pm-color);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
  pointer-events: auto;
  outline: none;
  transition: opacity var(--pm-duration) ease, transform var(--pm-duration) ease;
}

.pm-popup__title {
  margin: 0 2rem 1rem 0;
  color: inherit;
}

.pm-popup__content > :first-child {
  margin-top: 0;
}

.pm-popup__content > :last-child {
  margin-bottom: 0;
}

.pm-popup__content img,
.pm-popup__content video,
.pm-popup__content iframe {
  max-width: 100%;
}

.pm-popup__content img {
  height: auto;
}

/* Close button */
.pm-popup__close {
  position: absolute;
  top: .5rem;
  right: .5rem;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  opacity: .7;
  transition: opacity .15s ease, background-color .15s ease;
}

.pm-popup__close:hover,
.pm-popup__close:focus-visible {
  opacity: 1;
  background: rgba(128, 128, 128, .15);
}

/* Positions */
.pm-pos-bottom-right {
  align-items: flex-end;
  justify-content: flex-end;
}

.pm-pos-bottom-left {
  align-items: flex-end;
  justify-content: flex-start;
}

.pm-pos-top,
.pm-pos-bottom {
  padding: 0;
}

.pm-pos-top {
  align-items: flex-start;
}

.pm-pos-bottom {
  align-items: flex-end;
}

.pm-pos-top .pm-popup__dialog,
.pm-pos-bottom .pm-popup__dialog {
  width: 100%;
  max-height: 50vh;
  border-radius: 0;
}

.pm-pos-fullscreen {
  padding: 0;
}

.pm-pos-fullscreen .pm-popup__dialog {
  width: 100%;
  height: 100%;
  max-height: none;
  border-radius: 0;
}

/* Animations (initial state → .is-open) */
.pm-anim-fade .pm-popup__dialog,
.pm-anim-zoom .pm-popup__dialog,
.pm-anim-slide .pm-popup__dialog {
  opacity: 0;
}

.pm-anim-zoom .pm-popup__dialog {
  transform: scale(.9);
}

.pm-anim-slide .pm-popup__dialog {
  transform: translateY(40px);
}

.pm-anim-slide.pm-pos-top .pm-popup__dialog {
  transform: translateY(-100%);
}

.pm-anim-slide.pm-pos-bottom .pm-popup__dialog {
  transform: translateY(100%);
}

.pm-popup.is-open .pm-popup__dialog {
  opacity: 1;
  transform: none;
}

.pm-anim-none {
  --pm-duration: 0s;
}

@media (prefers-reduced-motion: reduce) {
  .pm-popup {
    --pm-duration: 0s;
  }
}

/* Small screens: corner popups become full-width at the bottom */
@media (max-width: 575.98px) {
  .pm-pos-bottom-right,
  .pm-pos-bottom-left {
    justify-content: center;
    padding: .5rem;
  }

  .pm-popup__dialog {
    padding: min(24px, var(--pm-padding));
  }
}
