/**
 * WDS Popups - Lightweight Modal System
 * Zero-dependency, performant popup styling
 */

:root {
  --wds-popup-overlay-bg: rgba(0, 0, 0, 0.75); /* Neutral pure black, no blue hue */
  --wds-popup-radius: 12px;
  --wds-popup-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  --wds-popup-transition-duration: 0.25s;
}

/* Scroll lock on body */
body.wds-popup-locked {
  overflow: hidden !important;
  touch-action: none;
}

/* Root modal wrapper */
.wds-popup {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  visibility: hidden;
  opacity: 0;
  transition: opacity var(--wds-popup-transition-duration) cubic-bezier(0.16, 1, 0.3, 1),
              visibility var(--wds-popup-transition-duration) cubic-bezier(0.16, 1, 0.3, 1);
  padding: 1.25rem;
  box-sizing: border-box;
}

.wds-popup.is-open {
  visibility: visible;
  opacity: 1;
}

/* Backdrop / Overlay */
.wds-popup-overlay {
  position: absolute;
  inset: 0;
  background-color: var(--wds-popup-overlay-bg);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  cursor: pointer;
}

/* Modal Dialog Window */
.wds-popup-dialog {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-radius: var(--wds-popup-radius);
  box-shadow: var(--wds-popup-shadow);
  box-sizing: border-box;
  overflow: hidden;
  transition: transform var(--wds-popup-transition-duration) cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- ANIMATION PRESETS --- */

/* 1. Scale (Default) */
.wds-popup-dialog.anim-scale {
  transform: scale(0.95);
}
.wds-popup.is-open .wds-popup-dialog.anim-scale {
  transform: scale(1);
}

/* 2. Pure Fade (No movement) */
.wds-popup-dialog.anim-fade {
  transform: none;
}
.wds-popup.is-open .wds-popup-dialog.anim-fade {
  transform: none;
}

/* 3. Slide Up */
.wds-popup-dialog.anim-slide-up {
  transform: translateY(35px);
}
.wds-popup.is-open .wds-popup-dialog.anim-slide-up {
  transform: translateY(0);
}

/* 4. Slide Down */
.wds-popup-dialog.anim-slide-down {
  transform: translateY(-35px);
}
.wds-popup.is-open .wds-popup-dialog.anim-slide-down {
  transform: translateY(0);
}

/* Inner content area with auto-scroll */
.wds-popup-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 2rem;
  color: #1e293b;
  font-size: 1rem;
  line-height: 1.6;
}

/* Reset margins inside popup body */
.wds-popup-body > :first-child {
  margin-top: 0;
}
.wds-popup-body > :last-child {
  margin-bottom: 0;
}

/* When padding is set to 0 (e.g. for Elementor templates) */
.wds-popup-dialog.no-padding .wds-popup-body {
  padding: 0;
}

/* Close button */
.wds-popup-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 10;
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 50%;
  cursor: pointer;
  color: #475569;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
  outline: none;
}

.wds-popup-close:hover {
  background: #ffffff;
  color: #0f172a;
  transform: scale(1.06);
}

.wds-popup-close:focus-visible {
  box-shadow: 0 0 0 2px #3b82f6;
}

/* Dark mode / Light icon variant for dark backgrounds */
.wds-popup-close.close-light {
  background: rgba(15, 23, 42, 0.6);
  border-color: rgba(255, 255, 255, 0.15);
  color: #e2e8f0;
}

.wds-popup-close.close-light:hover {
  background: rgba(15, 23, 42, 0.9);
  color: #ffffff;
}

.wds-popup-close svg {
  display: block;
  width: 18px;
  height: 18px;
  stroke-width: 2.25;
}

/* Mobile responsiveness - strictly centered vertically and horizontally */
@media (max-width: 640px) {
  .wds-popup {
    padding: 1rem;
    align-items: center; /* Centered on mobile */
    justify-content: center;
  }

  .wds-popup-dialog {
    max-height: 90vh;
    border-radius: var(--wds-popup-radius);
  }

  .wds-popup-body {
    padding: 1.5rem 1.25rem;
  }

  .wds-popup-close {
    top: 0.75rem;
    right: 0.75rem;
    width: 32px;
    height: 32px;
  }

  .wds-popup-close svg {
    width: 16px;
    height: 16px;
  }
}
