/**
 * PopupPro — Frontend Styles
 * Premium popup / modal stylesheet for 3 layout types.
 *
 * All styles are scoped to .ppo-wrapper to prevent collisions with any theme.
 * Uses CSS custom properties injected by PHP for per-popup theming.
 */

/* ── CSS Variables (defaults, overridden by PHP inline styles) ──────────────── */
.ppo-wrapper {
  --ppo-max-width:   640px;
  --ppo-bg:          #ffffff;
  --ppo-text-color:  #1e293b;
  --ppo-btn-bg:      #6366f1;
  --ppo-btn-color:   #ffffff;
  --ppo-overlay-bg:  rgba(0,0,0,.6);
  --ppo-radius:      20px;
  --ppo-shadow:      0 25px 60px rgba(0,0,0,.35), 0 8px 24px rgba(0,0,0,.2);
  --ppo-transition:  350ms cubic-bezier(.4,0,.2,1);
  --ppo-font:        'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Base Wrapper ───────────────────────────────────────────────────────────── */
.ppo-wrapper {
  position: fixed;
  inset: 0;
  z-index: 999998;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}

.ppo-wrapper.ppo-active {
  display: flex;
}

/* ── Overlay ────────────────────────────────────────────────────────────────── */
.ppo-overlay {
  position: absolute;
  inset: 0;
  background: var(--ppo-overlay-bg);
  backdrop-filter: blur(4px) saturate(1.2);
  -webkit-backdrop-filter: blur(4px) saturate(1.2);
  opacity: 0;
  transition: opacity var(--ppo-transition);
  cursor: pointer;
}

.ppo-overlay--visible {
  opacity: 1;
}

/* ── Modal Container ────────────────────────────────────────────────────────── */
.ppo-modal {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: var(--ppo-max-width);
  background: var(--ppo-bg);
  border-radius: var(--ppo-radius);
  box-shadow: var(--ppo-shadow);
  overflow: hidden;
  font-family: var(--ppo-font);
  color: var(--ppo-text-color);
  -webkit-font-smoothing: antialiased;

  /* Hidden state — animated in via JS class toggle */
  opacity: 0;
  transition: opacity var(--ppo-transition), transform var(--ppo-transition);
}

.ppo-modal--visible {
  opacity: 1;
}

/* ── Close Button ───────────────────────────────────────────────────────────── */
.ppo-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 10;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  transition: background 200ms ease, transform 200ms ease, box-shadow 200ms ease;
}

.ppo-close:hover {
  background: #fff;
  transform: scale(1.1) rotate(90deg);
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
}

.ppo-close:focus-visible {
  outline: 2px solid var(--ppo-btn-bg);
  outline-offset: 2px;
}

/* ── Shared Content Elements ────────────────────────────────────────────────── */
.ppo-title {
  font-size: clamp(18px, 3.5vw, 24px);
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 10px;
  color: var(--ppo-text-color);
}

.ppo-text {
  font-size: clamp(14px, 2.5vw, 15.5px);
  line-height: 1.65;
  color: var(--ppo-text-color);
  opacity: .8;
  margin: 0 0 24px;
}

/* ── CTA Button ─────────────────────────────────────────────────────────────── */
.ppo-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 26px;
  border-radius: 12px;
  background: var(--ppo-btn-bg);
  color: var(--ppo-btn-color);
  font-family: var(--ppo-font);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  line-height: 1;
  letter-spacing: -.01em;
  transition: filter 200ms ease, transform 200ms ease, box-shadow 200ms ease;
  box-shadow: 0 4px 14px rgba(0,0,0,.2);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

/* Hover glow */
.ppo-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,.15) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 200ms ease;
}

.ppo-btn:hover::before {
  opacity: 1;
}

.ppo-btn:hover {
  filter: brightness(1.06);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}

.ppo-btn:active {
  transform: translateY(0);
}

/* Show only the right-arrow SVG, hide the first one by default */
.ppo-btn svg:first-child { display: none; }
.ppo-btn:hover svg:first-child { display: block; }
.ppo-btn:hover svg:last-child  { display: none; }

/* ══════════════════════════════════════════════════════════════════════════════
   TYPE 1: IMAGE URL
   Full-image popup that opens a link on click.
══════════════════════════════════════════════════════════════════════════════ */
.ppo-content--image-url {
  display: block;
}

.ppo-image-link {
  display: block;
  position: relative;
  line-height: 0;
  text-decoration: none;
}

.ppo-image-link picture,
.ppo-classic-image picture {
  display: block;
  width: 100%;
}

.ppo-split-image picture {
  display: block;
  width: 100%;
  height: 100%;
}

.ppo-image {
  width: 100%;
  max-height: 520px;
  object-fit: cover;
  display: block;
  transition: transform 600ms cubic-bezier(.4,0,.2,1);
}

.ppo-image-link:hover .ppo-image {
  transform: scale(1.03);
}

/* Hover overlay */
.ppo-image-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.7) 0%, rgba(0,0,0,0) 60%);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 28px;
  opacity: 0;
  transition: opacity 300ms ease;
}

.ppo-image-link:hover .ppo-image-overlay {
  opacity: 1;
}

.ppo-image-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  background: rgba(255,255,255,.95);
  color: #1e293b;
  border-radius: 99px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--ppo-font);
  backdrop-filter: blur(4px);
  box-shadow: 0 4px 20px rgba(0,0,0,.2);
  transform: translateY(6px);
  transition: transform 300ms cubic-bezier(.34,1.56,.64,1);
}

.ppo-image-link:hover .ppo-image-cta {
  transform: translateY(0);
}

/* ══════════════════════════════════════════════════════════════════════════════
   TYPE 2: SPLIT (Image left + Content right)
══════════════════════════════════════════════════════════════════════════════ */
.ppo-content--split {
  display: grid;
  grid-template-columns: 5fr 7fr;
  min-height: 380px;
}

.ppo-split-image {
  position: relative;
  overflow: hidden;
  background: #e2e8f0;
}

.ppo-split-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 600ms cubic-bezier(.4,0,.2,1);
}

.ppo-split-image:hover img {
  transform: scale(1.04);
}

.ppo-split-image--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
  color: #6366f1;
}

/* Decorative divider line */
.ppo-split-image::after {
  content: '';
  position: absolute;
  right: 0;
  top: 10%;
  bottom: 10%;
  width: 3px;
  background: linear-gradient(to bottom, transparent, rgba(255,255,255,.4), transparent);
}

.ppo-split-body {
  padding: 40px 36px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0;
}

.ppo-split-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--ppo-btn-bg), color-mix(in srgb, var(--ppo-btn-bg) 70%, #fff));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  margin-bottom: 20px;
  box-shadow: 0 4px 14px rgba(99,102,241,.3);
}

.ppo-split-body .ppo-title {
  font-size: clamp(16px, 3vw, 22px);
}

.ppo-split-body .ppo-text {
  font-size: 14px;
}

/* ══════════════════════════════════════════════════════════════════════════════
   TYPE 3: CLASSIC (Image top + Content below)
══════════════════════════════════════════════════════════════════════════════ */
.ppo-content--classic {
  display: flex;
  flex-direction: column;
}

.ppo-classic-image {
  width: 100%;
  overflow: hidden;
  flex-shrink: 0;
}

.ppo-classic-image img {
  width: 100%;
  height: 240px;
  object-fit: cover;
  display: block;
  transition: transform 600ms cubic-bezier(.4,0,.2,1);
}

.ppo-classic-image:hover img {
  transform: scale(1.03);
}

.ppo-classic-body {
  padding: 32px 36px 36px;
  display: flex;
  flex-direction: column;
}

/* Decorative top border accent */
.ppo-classic-body::before {
  content: '';
  display: block;
  width: 48px;
  height: 4px;
  background: var(--ppo-btn-bg);
  border-radius: 999px;
  margin-bottom: 20px;
}

/* ══════════════════════════════════════════════════════════════════════════════
   ANIMATIONS
══════════════════════════════════════════════════════════════════════════════ */

/* Fade */
.ppo-anim--fade .ppo-modal          { opacity: 0; transform: none; }
.ppo-anim--fade .ppo-modal--visible { opacity: 1; transform: none; }

/* Slide Up */
.ppo-anim--slide .ppo-modal          { opacity: 0; transform: translateY(48px); }
.ppo-anim--slide .ppo-modal--visible { opacity: 1; transform: translateY(0); }

/* Zoom */
.ppo-anim--zoom .ppo-modal          { opacity: 0; transform: scale(.82); }
.ppo-anim--zoom .ppo-modal--visible { opacity: 1; transform: scale(1); }

/* Flip */
.ppo-anim--flip .ppo-modal {
  opacity: 0;
  transform: perspective(1000px) rotateX(14deg) translateY(20px);
  transform-origin: top center;
}
.ppo-anim--flip .ppo-modal--visible {
  opacity: 1;
  transform: perspective(1000px) rotateX(0) translateY(0);
}

/* ── Body Lock ──────────────────────────────────────────────────────────────── */
body.ppo-body-lock {
  overflow: hidden;
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .ppo-wrapper { padding: 12px; align-items: flex-end; }

  .ppo-modal {
    border-radius: 24px 24px 0 0;
    max-height: 90dvh;
    overflow-y: auto;
  }

  /* Split becomes vertical on mobile */
  .ppo-content--split {
    grid-template-columns: 1fr;
  }

  .ppo-split-image {
    height: 200px;
  }

  .ppo-split-image::after { display: none; }

  .ppo-split-body { padding: 24px 24px 32px; }
  .ppo-classic-body { padding: 24px; }

  /* Slide from bottom on mobile */
  .ppo-anim--fade .ppo-modal,
  .ppo-anim--zoom .ppo-modal,
  .ppo-anim--flip .ppo-modal {
    transform: translateY(40px);
  }

  .ppo-anim--fade .ppo-modal--visible,
  .ppo-anim--zoom .ppo-modal--visible,
  .ppo-anim--flip .ppo-modal--visible {
    transform: translateY(0);
  }
}

@media (max-width: 400px) {
  .ppo-split-body { padding: 20px 20px 28px; }
  .ppo-classic-image img { height: 180px; }
}

/* ── Reduce Motion ──────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .ppo-overlay,
  .ppo-modal,
  .ppo-image,
  .ppo-btn,
  .ppo-image-cta,
  .ppo-image-overlay,
  .ppo-close { transition: none !important; }
}
