/**
 * Exit-Intent Conversion Popup — Task #1529298
 *
 * Two A/B variants on /pricing, /books, /books/*, /toolkits/*, /bundles/*, /plans/*
 *   Variant A (Discount)  — 20% off Pro coupon, Stripe checkout CTA
 *   Variant B (Free Lead) — email capture → free chapter delivery
 *
 * Desktop: centered modal, dark overlay, white card, Fraunces heading
 * Mobile:  bottom-sheet (375px), full-width buttons
 * Owns: #sr-conv-overlay and .sr-conv-* selectors only
 */

/* ═══════════════════════════════════════════════════════════════
   Overlay backdrop
   ═══════════════════════════════════════════════════════════════ */

#sr-conv-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9995;
  background: rgba(5, 15, 30, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.28s ease;
  font-family: 'DM Sans', system-ui, sans-serif;
}

#sr-conv-overlay.sr-conv-visible {
  display: flex !important;
  opacity: 1;
}

/* ═══════════════════════════════════════════════════════════════
   Card shell
   ═══════════════════════════════════════════════════════════════ */

.sr-conv-card {
  position: relative;
  background: #ffffff;
  border-radius: 22px;
  box-shadow:
    0 28px 90px rgba(5, 15, 30, 0.38),
    0 0 0 1px rgba(0, 179, 125, 0.12);
  max-width: 520px;
  width: 92%;
  max-height: 92vh;
  overflow-y: auto;
  overflow-x: hidden;
  animation: sr-conv-pop-in 0.34s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Emerald top accent */
.sr-conv-card::before {
  content: '';
  position: absolute;
  top: 0; left: 20px; right: 20px;
  height: 3px;
  background: linear-gradient(90deg, #00B37D 0%, #005e42 100%);
  border-radius: 0 0 3px 3px;
}

@keyframes sr-conv-pop-in {
  from { transform: scale(0.90) translateY(16px); opacity: 0; }
  to   { transform: scale(1)    translateY(0);    opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════════
   Close button — 44px tap target
   ═══════════════════════════════════════════════════════════════ */

.sr-conv-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 9996;
  width: 44px;
  height: 44px;
  background: #f8fafc;
  border: 1.5px solid rgba(15, 23, 42, 0.14);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #374151 !important;
  transition: background 0.18s, transform 0.15s, box-shadow 0.18s;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.1);
  pointer-events: auto !important;
}

.sr-conv-close:hover {
  background: #f1f5f9;
  transform: scale(1.06);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.14);
}

.sr-conv-close:active { transform: scale(0.94); }

.sr-conv-close:focus {
  outline: 2px solid #00B37D;
  outline-offset: 2px;
}

.sr-conv-close svg line { stroke: currentColor; }

/* ═══════════════════════════════════════════════════════════════
   Content body
   ═══════════════════════════════════════════════════════════════ */

.sr-conv-body {
  padding: 48px 36px 36px;
}

/* Badge pill */
.sr-conv-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: #005e42;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  background: rgba(0, 179, 125, 0.1);
  border: 1px solid rgba(0, 179, 125, 0.28);
  padding: 5px 13px;
  border-radius: 20px;
  margin-bottom: 16px;
}

.sr-conv-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #00B37D;
  flex-shrink: 0;
}

/* Headline — Fraunces */
.sr-conv-headline {
  margin: 0 0 12px;
  font-family: 'Fraunces', Georgia, serif;
  font-size: 30px;
  font-weight: 800;
  line-height: 1.18;
  color: #060f1e;
  letter-spacing: -0.4px;
}

.sr-conv-headline em {
  color: #00875A;
  font-style: italic;
}

/* Sub copy */
.sr-conv-sub {
  margin: 0 0 28px;
  font-size: 15px;
  line-height: 1.65;
  color: #374151;
}

/* ═══════════════════════════════════════════════════════════════
   Variant A: Discount offer
   ═══════════════════════════════════════════════════════════════ */

.sr-conv-coupon-box {
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border: 1.5px dashed #86efac;
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 22px;
}

.sr-conv-coupon-icon {
  font-size: 32px;
  flex-shrink: 0;
}

.sr-conv-coupon-text {
  flex: 1;
  min-width: 0;
}

.sr-conv-coupon-label {
  font-size: 12px;
  font-weight: 600;
  color: #047857;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 4px;
}

.sr-conv-coupon-code {
  font-family: 'DM Mono', 'Courier New', monospace;
  font-size: 22px;
  font-weight: 800;
  color: #065F46;
  letter-spacing: 2px;
  line-height: 1;
}

.sr-conv-coupon-savings {
  font-size: 13px;
  color: #047857;
  margin-top: 3px;
}

/* ═══════════════════════════════════════════════════════════════
   Primary CTA button
   ═══════════════════════════════════════════════════════════════ */

.sr-conv-btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 17px 24px;
  font-size: 16px;
  font-weight: 700;
  font-family: 'DM Sans', system-ui, sans-serif;
  background: #00B37D;
  color: #ffffff !important;
  border: none;
  border-radius: 13px;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 6px 24px rgba(0, 179, 125, 0.38);
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  letter-spacing: 0.1px;
  line-height: 1.2;
  text-align: center;
}

.sr-conv-btn-primary:hover {
  background: #009a6a;
  box-shadow: 0 8px 36px rgba(0, 179, 125, 0.5);
  transform: translateY(-1px);
  color: #ffffff !important;
  text-decoration: none;
}

.sr-conv-btn-primary:active {
  transform: scale(0.98) translateY(0);
}

.sr-conv-btn-primary:focus {
  outline: 2px solid #00B37D;
  outline-offset: 3px;
}

.sr-conv-btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* ═══════════════════════════════════════════════════════════════
   Variant B: Email capture form
   ═══════════════════════════════════════════════════════════════ */

.sr-conv-book-preview {
  display: flex;
  gap: 16px;
  align-items: center;
  background: #f8fafc;
  border: 1px solid rgba(15, 23, 42, 0.09);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 24px;
}

.sr-conv-book-cover {
  width: 56px;
  height: 74px;
  background: linear-gradient(145deg, #0a2540 0%, #1a4a70 100%);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(10, 37, 64, 0.3);
}

.sr-conv-book-info {
  flex: 1;
  min-width: 0;
}

.sr-conv-book-eyebrow {
  font-size: 10px;
  font-weight: 700;
  color: #00875A;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 4px;
}

.sr-conv-book-title {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.35;
  margin-bottom: 4px;
}

.sr-conv-book-chapter {
  font-size: 12px;
  color: #64748b;
}

.sr-conv-form {
  margin-bottom: 14px;
}

.sr-conv-input {
  width: 100%;
  box-sizing: border-box;
  padding: 14px 16px;
  font-size: 15px;
  font-family: 'DM Sans', system-ui, sans-serif;
  border: 2px solid rgba(15, 23, 42, 0.13);
  border-radius: 12px;
  background: #ffffff;
  color: #0f172a;
  margin-bottom: 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.sr-conv-input:focus {
  outline: none;
  border-color: #00B37D;
  box-shadow: 0 0 0 3px rgba(0, 179, 125, 0.12);
}

.sr-conv-input::placeholder { color: #9ca3af; }

.sr-conv-input.sr-conv-error-border {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.sr-conv-error {
  display: none;
  font-size: 13px;
  color: #dc2626;
  padding: 10px 14px;
  background: rgba(220, 38, 38, 0.06);
  border: 1px solid rgba(220, 38, 38, 0.2);
  border-radius: 8px;
  margin-bottom: 12px;
}

.sr-conv-error.sr-conv-error-visible {
  display: block;
}

/* ═══════════════════════════════════════════════════════════════
   Success state
   ═══════════════════════════════════════════════════════════════ */

.sr-conv-success {
  display: none;
  text-align: center;
  padding: 12px 0 8px;
}

.sr-conv-success-icon {
  font-size: 52px;
  display: block;
  margin-bottom: 12px;
}

.sr-conv-success-headline {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 22px;
  font-weight: 800;
  color: #060f1e;
  margin: 0 0 8px;
}

.sr-conv-success-sub {
  font-size: 14px;
  color: #475569;
  line-height: 1.6;
  margin: 0;
}

/* ═══════════════════════════════════════════════════════════════
   Dismiss link
   ═══════════════════════════════════════════════════════════════ */

.sr-conv-dismiss {
  display: block;
  width: 100%;
  background: none;
  border: none;
  padding: 12px 0 4px;
  font-size: 13px;
  font-family: 'DM Sans', system-ui, sans-serif;
  color: #9ca3af;
  cursor: pointer;
  text-align: center;
  transition: color 0.2s;
  min-height: 44px;
  line-height: 1.4;
}

.sr-conv-dismiss:hover {
  color: #374151;
  text-decoration: underline;
}

/* Trust row */
.sr-conv-trust {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 16px;
  font-size: 11.5px;
  font-weight: 600;
  color: #6b7280;
  letter-spacing: 0.1px;
}

.sr-conv-trust-dot {
  color: #00B37D;
  opacity: 0.7;
  font-size: 9px;
}

/* ═══════════════════════════════════════════════════════════════
   Mobile: bottom-sheet at 375px
   ═══════════════════════════════════════════════════════════════ */

.sr-conv-drag-handle {
  display: none;
  justify-content: center;
  padding: 14px 0 4px;
}

.sr-conv-drag-pill {
  width: 40px;
  height: 4px;
  background: rgba(15, 23, 42, 0.14);
  border-radius: 2px;
}

@media (max-width: 600px) {
  #sr-conv-overlay {
    align-items: flex-end;
  }

  #sr-conv-overlay.sr-conv-visible {
    align-items: flex-end;
  }

  .sr-conv-card {
    width: 100%;
    max-width: 100%;
    border-radius: 20px 20px 0 0;
    max-height: 90vh;
    animation: sr-conv-sheet-up 0.34s cubic-bezier(0.34, 1.2, 0.64, 1) forwards;
    box-shadow: 0 -8px 56px rgba(5, 15, 30, 0.28), 0 -1px 0 rgba(0, 179, 125, 0.12);
  }

  .sr-conv-card::before { display: none; }

  @keyframes sr-conv-sheet-up {
    from { transform: translateY(100%); opacity: 0.6; }
    to   { transform: translateY(0);    opacity: 1; }
  }

  .sr-conv-drag-handle { display: flex; }

  .sr-conv-body {
    padding: 20px 24px 40px;
    padding-bottom: max(40px, calc(32px + env(safe-area-inset-bottom, 0px)));
  }

  .sr-conv-headline { font-size: 24px; }

  .sr-conv-btn-primary {
    font-size: 15px;
    padding: 15px 20px;
  }

  .sr-conv-close {
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
  }
}

/* ═══════════════════════════════════════════════════════════════
   Swipe-dismiss: JS sets transform; suppress animation during drag
   ═══════════════════════════════════════════════════════════════ */

.sr-conv-card.sr-conv-dragging {
  transition: none !important;
  animation: none !important;
}

/* ═══════════════════════════════════════════════════════════════
   Print: hide
   ═══════════════════════════════════════════════════════════════ */

@media print {
  #sr-conv-overlay { display: none !important; }
}
