/* ═══════════════════════════════════════════════════════════════════════════
   StoryNest — Freemium Paywall Styles  (paywall.css)
   Mobile-first. Tested at 360px (common Kenyan Android viewport).
   Loads alongside flipbook.css — no class names conflict.

   ENQUEUE in class-frontend.php:
     wp_enqueue_style('scai-paywall', SCAI_PLUGIN_URL . 'public/css/paywall.css',
       ['scai-flipbook'], SCAI_VERSION);
═══════════════════════════════════════════════════════════════════════════ */

/* ── Prevent body scroll when paywall is open ────────────────────────────── */
body.scai-no-scroll { overflow: hidden; }

/* ════════════════════════════════════════════════════════════════════════════
   1. PAYWALL OVERLAY (Full-viewport backdrop)
════════════════════════════════════════════════════════════════════════════ */
.scai-pw-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;                       /* Above everything, including nav bars  */
  background: rgba(10, 5, 25, 0.90);   /* Deep dark, respects low-light mobile  */
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: flex-start;             /* Top-align so modal is reachable on small screens */
  justify-content: center;
  padding: 16px 12px 32px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Modal box ────────────────────────────────────────────────────────────── */
.scai-pw-box {
  background: #fff;
  border-radius: 20px;
  width: 100%;
  max-width: 880px;
  padding: 28px 20px 24px;
  position: relative;
  box-shadow:
    0 32px 96px rgba(0, 0, 0, 0.55),
    0 0 0 1.5px rgba(108, 63, 197, 0.22);
  animation: scai-pw-in 0.38s cubic-bezier(0.34, 1.48, 0.64, 1) forwards;
}

@keyframes scai-pw-in {
  from { opacity: 0; transform: scale(0.88) translateY(24px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Close button ─────────────────────────────────────────────────────────── */
.scai-pw-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: #f3f4f6;
  color: #6b7280;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s, color 0.18s;
  padding: 0;
}
.scai-pw-close:hover { background: #e5e7eb; color: #111827; }

/* ════════════════════════════════════════════════════════════════════════════
   2. MODAL HEADER
════════════════════════════════════════════════════════════════════════════ */
.scai-pw-header { margin-bottom: 22px; }

/* "Preview Generated!" pill */
.scai-pw-preview-pill {
  display: inline-block;
  background: linear-gradient(135deg, #6c3fc5, #9b5de5);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 4px 14px;
  border-radius: 100px;
  margin-bottom: 10px;
}

.scai-pw-title {
  font-size: clamp(18px, 5vw, 26px);
  font-weight: 800;
  color: #1a1028;
  margin: 0 0 8px;
  line-height: 1.25;
}

.scai-pw-subtitle {
  font-size: 14px;
  line-height: 1.65;
  color: #555;
  margin: 0;
}

/* ════════════════════════════════════════════════════════════════════════════
   3. TIER CARDS GRID — Mobile-first stacked, then multi-column
════════════════════════════════════════════════════════════════════════════ */
.scai-pw-tiers {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-bottom: 18px;
}

/* 2-col at ≥580px (tablet / large phone landscape) */
@media (min-width: 580px) {
  .scai-pw-tiers { grid-template-columns: 1fr 1fr; }
}

/* 3-col at ≥800px (desktop) — featured card in the middle */
@media (min-width: 800px) {
  .scai-pw-tiers {
    grid-template-columns: repeat(3, 1fr);
    align-items: start;
  }
}

/* ── Individual tier card ─────────────────────────────────────────────────── */
.scai-tier-card {
  border: 2px solid #e5e7eb;
  border-radius: 16px;
  padding: 18px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  background: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
  cursor: pointer;
}
.scai-tier-card:hover {
  border-color: var(--scai-primary, #6c3fc5);
  box-shadow: 0 8px 28px rgba(108, 63, 197, 0.16);
  transform: translateY(-3px);
}

/* ── Featured (Teacher's Monthly) card ───────────────────────────────────── */
.scai-pw-card--featured {
  border-color: var(--scai-primary, #6c3fc5);
  background: linear-gradient(160deg, #f8f5ff 0%, #fff 100%);
  box-shadow: 0 10px 36px rgba(108, 63, 197, 0.2);
  /* Lift above sibling cards on desktop */
  transform: translateY(-6px);
}
.scai-pw-card--featured:hover { transform: translateY(-10px); }

/* "Most Popular" badge (positioned above card top edge) */
.scai-pw-best {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #6c3fc5, #f97316);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 14px;
  border-radius: 100px;
  white-space: nowrap;
  letter-spacing: 0.2px;
  pointer-events: none;
}

/* ── Card content elements ────────────────────────────────────────────────── */
.scai-tc-icon { font-size: 26px; line-height: 1; }

.scai-tc-name {
  font-size: 14px;
  font-weight: 700;
  color: #1a1028;
  line-height: 1.25;
}

.scai-tc-price {
  font-size: clamp(20px, 4vw, 26px);
  font-weight: 400;
  color: var(--scai-primary, #6c3fc5);
  line-height: 1;
}
.scai-tc-price strong { font-weight: 800; }

.scai-tc-period {
  font-size: 13px;
  font-weight: 400;
  color: #9ca3af;
  margin-left: 1px;
}

.scai-tc-features {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}
.scai-tc-features li {
  font-size: 12.5px;
  color: #374151;
  line-height: 1.45;
}

/* ── M-Pesa pill ─────────────────────────────────────────────────────────── */
.scai-mpesa-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: #059669;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 6px;
  padding: 4px 9px;
  line-height: 1.3;
  margin-top: 2px;
}

/* ── Tier CTA button ─────────────────────────────────────────────────────── */
.scai-tier-cta {
  width: 100%;
  padding: 12px 16px;
  border-radius: 10px;
  border: 2px solid var(--scai-primary, #6c3fc5);
  background: transparent;
  color: var(--scai-primary, #6c3fc5);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
  margin-top: auto;       /* Push to bottom of card */
  letter-spacing: 0.2px;
}
.scai-tier-cta:hover:not(:disabled) {
  background: var(--scai-primary, #6c3fc5);
  color: #fff;
  transform: translateY(-1px);
}
.scai-tier-cta:disabled {
  opacity: 0.55;
  cursor: wait;
}

/* Featured card CTA — filled gradient style */
.scai-pw-card--featured .scai-tier-cta,
.scai-pw-card--featured .scai-btn-primary {
  background: linear-gradient(135deg, #6c3fc5 0%, #9b5de5 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 16px rgba(108, 63, 197, 0.42);
}
.scai-pw-card--featured .scai-tier-cta:hover:not(:disabled) {
  background: linear-gradient(135deg, #5b34a5 0%, #8a4fd0 100%);
  box-shadow: 0 6px 22px rgba(108, 63, 197, 0.52);
  transform: translateY(-2px);
}

/* ════════════════════════════════════════════════════════════════════════════
   4. MODAL ERROR & TRUST FOOTER
════════════════════════════════════════════════════════════════════════════ */
.scai-pw-error {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  padding: 10px 14px;
  color: #b91c1c;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  margin-bottom: 12px;
}

.scai-pw-trust {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 11.5px;
  color: #9ca3af;
  border-top: 1px solid #f3f4f6;
  padding-top: 14px;
  margin-top: 4px;
  letter-spacing: 0.2px;
}

/* ════════════════════════════════════════════════════════════════════════════
   5. GHOST PAGES (Locked pages 2–N in the flipbook)
   These appear INSIDE the existing flipbook via Flipbook.renderStoryPage()
   The .scai-ghost-page class is applied dynamically by paywall.js.
════════════════════════════════════════════════════════════════════════════ */
.scai-ghost-page { position: relative; overflow: hidden; }

/* Blur the real page content beneath the lock overlay */
.scai-ghost-page .scai-fb-page-content {
  filter: blur(7px) grayscale(0.3);
  -webkit-filter: blur(7px) grayscale(0.3);
  user-select: none;
  pointer-events: none;
  transition: filter 0.3s ease;
}

/* Blurred gradient overlay */
.scai-ghost-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(248, 245, 255, 0.3) 0%,
    rgba(108, 63, 197, 0.08) 100%
  );
  z-index: 1;
  pointer-events: none;
}

/* Lock label overlay */
.scai-ghost-page::after {
  content: '🔒  Unlock Full Story';
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--scai-primary, #6c3fc5);
  letter-spacing: 0.3px;
  cursor: pointer;
  text-align: center;
  padding: 20px;
  /* Subtle frosted glass effect */
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  transition: background 0.2s ease;
}
.scai-ghost-page:hover::after {
  background: rgba(255, 255, 255, 0.62);
  content: '🔓  Click to Unlock';
}

/* ── Lock pulse animation — fires when user tries to turn to a ghost spread ── */
@keyframes scai-lock-pulse {
  0%, 100% { transform: scale(1);    border-color: #e5e7eb; box-shadow: none; }
  40%       { transform: scale(1.02); border-color: var(--scai-primary, #6c3fc5); box-shadow: 0 0 0 5px rgba(108,63,197,0.18); }
}
.scai-lock-pulse {
  animation: scai-lock-pulse 0.45s ease-in-out 2;
}

/* ════════════════════════════════════════════════════════════════════════════
   6. TEASER BANNER (Injected below the flipbook after preview loads)
════════════════════════════════════════════════════════════════════════════ */
.scai-teaser-banner {
  background: linear-gradient(135deg, #1a0d35 0%, #3d2066 100%);
  border-radius: 16px;
  padding: 18px 20px;
  margin: 14px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  animation: scai-pw-in 0.4s ease forwards;
}

.scai-teaser-text {
  color: rgba(255, 255, 255, 0.92);
  font-size: 14px;
  line-height: 1.65;
  flex: 1;
  min-width: 180px;
}

.scai-teaser-btn {
  background: linear-gradient(135deg, var(--scai-secondary, #f97316), #fb923c);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 11px 18px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: opacity 0.18s, transform 0.18s;
  letter-spacing: 0.2px;
}
.scai-teaser-btn:hover { opacity: 0.92; transform: translateY(-1px); }

/* ════════════════════════════════════════════════════════════════════════════
   7. SUCCESS BANNER (Shown after full story generation completes)
════════════════════════════════════════════════════════════════════════════ */
.scai-success-banner {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  color: #fff;
  border-radius: 10px;
  padding: 13px 18px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 14px;
  letter-spacing: 0.2px;
  animation: scai-pw-in 0.35s ease forwards;
}

/* ════════════════════════════════════════════════════════════════════════════
   8. GENERATING ERROR STATE
════════════════════════════════════════════════════════════════════════════ */
.scai-gen-error {
  text-align: center;
  padding: 40px 20px;
}
.scai-gen-error-icon { font-size: 48px; margin-bottom: 12px; }
.scai-gen-error h3 {
  color: #b91c1c;
  font-size: 18px;
  margin: 0 0 8px;
}
.scai-gen-error p {
  color: #555;
  font-size: 14px;
  line-height: 1.6;
  margin: 0 0 20px;
}

/* ════════════════════════════════════════════════════════════════════════════
   9. SPINNER (Used on the Generate button during preview loading)
════════════════════════════════════════════════════════════════════════════ */
.scai-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: scai-spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes scai-spin {
  to { transform: rotate(360deg); }
}

/* ════════════════════════════════════════════════════════════════════════════
   10. RESPONSIVE OVERRIDES — Small phones (≤400px)
════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 400px) {
  .scai-pw-box {
    padding: 22px 14px 20px;
    border-radius: 14px;
  }
  .scai-pw-title { font-size: 17px; }
  .scai-pw-subtitle { font-size: 13px; }
  .scai-pw-tiers { gap: 10px; }
  .scai-tier-card { padding: 14px 12px 12px; }
  .scai-tc-price { font-size: 20px; }
  .scai-pw-trust { flex-direction: column; align-items: center; gap: 6px; }
  .scai-teaser-banner { flex-direction: column; text-align: center; }
}

/* ════════════════════════════════════════════════════════════════════════════
   11. HIGH-CONTRAST / REDUCED-MOTION ACCESSIBILITY
════════════════════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  .scai-pw-box,
  .scai-teaser-banner,
  .scai-success-banner,
  .scai-lock-pulse          { animation: none !important; }
  .scai-tier-card,
  .scai-tier-cta,
  .scai-pw-close            { transition: none !important; }
  .scai-ghost-page .scai-fb-page-content { filter: blur(5px) !important; }
}

@media (forced-colors: active) {
  .scai-pw-best,
  .scai-pw-preview-pill,
  .scai-teaser-btn          { border: 2px solid ButtonText; }
}
