/* ===========================================
   SectionPop — Popup & Slideout Styles
   =========================================== */

/* -------------------------
 * Body Lock (prevent scroll)
 * ------------------------- */

.sp-body--locked {
  overflow: hidden !important;
}

/* -------------------------
 * Overlay (backdrop)
 * ------------------------- */

.sp-overlay {
  position: fixed;
  inset: 0;
  z-index: 99998;
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  transition:
    background 0.4s ease,
    backdrop-filter 0.4s ease,
    visibility 0s linear 0.4s;
  cursor: pointer;
  pointer-events: none;
  visibility: hidden;
}

.sp-overlay--visible {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  pointer-events: auto;
  visibility: visible;
  transition:
    background 0.4s ease,
    backdrop-filter 0.4s ease,
    visibility 0s linear 0s;
}

/* -------------------------
 * Dialog (shared)
 * ------------------------- */

.sp-dialog {
  position: fixed;
  z-index: 99999;
  background: var(--sp-dialog-bg, #fff);
  outline: none;
  display: flex;
  flex-direction: column;
  pointer-events: none;
  visibility: hidden;
}

.sp-dialog.sp-dialog--visible {
  pointer-events: auto;
  visibility: visible;
}

.sp-dialog:focus-visible {
  outline: 2px solid var(--sp-focus-color, #2563eb);
  outline-offset: -2px;
}

/* -------------------------
 * Close Button
 * ------------------------- */

.sp-dialog__close {
  position: absolute;
  z-index: 10;
  top: 1rem;
  right: 1rem;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: var(--sp-close-bg, rgba(0, 0, 0, 0.06));
  color: var(--sp-close-color, #333);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.sp-dialog__close:hover {
  background: var(--sp-close-bg-hover, rgba(0, 0, 0, 0.12));
  transform: scale(1.05);
}

.sp-dialog__close:focus-visible {
  outline: 2px solid var(--sp-focus-color, #2563eb);
  outline-offset: 2px;
}

/* -------------------------
 * Content Container
 * ------------------------- */

.sp-dialog__content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* -------------------------
 * POPUP Variant
 * ------------------------- */

.sp-dialog--popup {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.96);
  width: min(90vw, 1200px);
  max-height: 90vh;
  border-radius: var(--sp-popup-radius, 12px);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.2);
  opacity: 0;
}

.sp-dialog--popup.sp-dialog--ready {
  transition:
    opacity 0.3s cubic-bezier(0.4, 0, 1, 1),
    transform 0.3s cubic-bezier(0.4, 0, 1, 1),
    visibility 0s linear 0.3s;
}

.sp-dialog--popup.sp-dialog--visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  transition:
    opacity 0.35s cubic-bezier(0, 0, 0.2, 1),
    transform 0.35s cubic-bezier(0, 0, 0.2, 1),
    visibility 0s linear 0s;
}

/* -------------------------
 * SLIDEOUT Variant
 * ------------------------- */

.sp-dialog--slide {
  top: 0;
  right: 0;
  bottom: 0;
  width: min(90vw, 720px);
  transform: translateX(100%);
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.15);
}

.sp-dialog--slide.sp-dialog--ready {
  transition:
    transform 0.35s cubic-bezier(0.4, 0, 1, 1),
    visibility 0s linear 0.35s;
}

.sp-dialog--slide.sp-dialog--visible {
  transform: translateX(0);
  transition:
    transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s linear 0s;
}

/* -------------------------
 * Responsive
 * ------------------------- */

@media (max-width: 767px) {
  /* Popup becomes near-fullscreen on mobile */
  .sp-dialog--popup {
    width: 95vw;
    max-height: 92vh;
    border-radius: var(--sp-popup-radius-mobile, 10px);
  }

  /* Slideout becomes full-width on mobile */
  .sp-dialog--slide {
    width: 100vw;
  }

  .sp-dialog__close {
    top: 0.75rem;
    right: 0.75rem;
  }
}

/* -------------------------
 * Reduce Motion
 * ------------------------- */

@media (prefers-reduced-motion: reduce) {
  .sp-overlay,
  .sp-dialog--popup,
  .sp-dialog--slide {
    transition-duration: 0.01ms !important;
  }
}

/* -------------------------
 * Hide sections before first open
 * ------------------------- */

body:not(.sqs-edit-mode-active) .sp-section--target:not(.sp-section--active) {
  display: none !important;
}

.sp-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* -------------------------
 * Squarespace Overrides
 * Keep cloned sections behaving properly
 * ------------------------- */

.sp-dialog__content > [data-section-id],
.sp-dialog__content > section {
  min-height: unset !important;
  position: relative !important;
}

/* Fix Squarespace section padding inside dialog */
.sp-dialog__content .page-section {
  min-height: unset !important;
}

/* Ensure media fills properly */
.sp-dialog__content img,
.sp-dialog__content video {
  max-width: 100%;
  height: auto;
}

/* -------------------------
 * Custom Properties Reference
 * 
 * Override these in your site CSS:
 *
 * --sp-dialog-bg            Dialog background (default: #fff)
 * --sp-close-bg             Close button background
 * --sp-close-bg-hover       Close button hover background
 * --sp-close-color           Close button icon color
 * --sp-focus-color           Focus ring color
 * --sp-popup-radius          Popup border radius
 * --sp-popup-radius-mobile   Popup border radius on mobile
 *
 * Example:
 *   :root {
 *     --sp-dialog-bg: #1a1a1a;
 *     --sp-close-color: #fff;
 *     --sp-close-bg: rgba(255, 255, 255, 0.1);
 *   }
 * ------------------------- */
