/**
 * Forja do Mago — Smart Conversions
 * Fase 5 · Parte 4: Exit-Intent UI — Modal Premium + Golden Bundle
 *
 * Design Principles:
 *   – Parece um produto premium, não um pop-up de spam
 *   – Mobile-first: drawer que sobe de baixo (como o LoreSheet)
 *   – Desktop: modal centralizado com backdrop blur
 *   – Destaque visual no desconto dinâmico (badge dourado)
 *   – Produto âncora exibido como card de e-commerce real
 *
 * @version 5.4.0
 */

:root {
  --forja-exit-bg:           #ffffff;
  --forja-exit-overlay:      rgba(0, 0, 0, 0.60);
  --forja-exit-radius:       20px;
  --forja-exit-accent:       #7b2d8b;   /* sobrescrito por JS com cor do grupo */
  --forja-exit-gold:         #f0a500;
  --forja-exit-gold-light:   #fff8e1;
  --forja-exit-z-overlay:    9100;
  --forja-exit-z-modal:      9101;
  --forja-exit-transition:   0.38s cubic-bezier(0.32, 0.72, 0, 1);
}

/* ─── OVERLAY ─────────────────────────────────────────────────────────────── */

.forja-exit-overlay {
  position:   fixed;
  inset:      0;
  z-index:    var(--forja-exit-z-overlay);
  background: var(--forja-exit-overlay);
  opacity:    0;
  pointer-events: none;
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter:          blur(3px);
  transition: opacity var(--forja-exit-transition);
}

.forja-exit-overlay--visible {
  opacity:        1;
  pointer-events: all;
}

/* ─── MODAL WRAPPER ───────────────────────────────────────────────────────── */
/* Mobile: sobe de baixo (drawer). Desktop: centralizado. */

.forja-exit-modal {
  position:       fixed;
  z-index:        var(--forja-exit-z-modal);
  background:     var(--forja-exit-bg);
  border-radius:  var(--forja-exit-radius) var(--forja-exit-radius) 0 0;
  box-shadow:     0 -10px 50px rgba(0, 0, 0, 0.25);
  width:          100%;
  left:           0;
  bottom:         0;
  max-height:     90vh;
  overflow-y:     auto;
  overflow-x:     hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  /* Entrada: começa fora da tela */
  transform:      translateY(100%);
  opacity:        0;
  transition:     transform var(--forja-exit-transition),
                  opacity 0.25s ease;
  padding-bottom: env(safe-area-inset-bottom, 0);
  display:        flex;
  flex-direction: column;
}

.forja-exit-modal--visible {
  transform: translateY(0);
  opacity:   1;
}

/* ─── DRAG HANDLE ────────────────────────────────────────────────────────── */
.forja-exit-modal__handle {
  flex-shrink:    0;
  display:        flex;
  justify-content: center;
  padding:        14px 0 6px;
}
.forja-exit-modal__handle::before {
  content:       "";
  display:       block;
  width:         38px;
  height:        4px;
  background:    #d4d4d4;
  border-radius: 2px;
}

/* ─── CLOSE BUTTON ───────────────────────────────────────────────────────── */
.forja-exit-modal__close {
  position:       absolute;
  top:            14px;
  right:          16px;
  width:          40px;
  height:         40px;
  border:         none;
  background:     #f5f5f5;
  border-radius:  50%;
  font-size:      18px;
  color:          #666;
  cursor:         pointer;
  display:        flex;
  align-items:    center;
  justify-content: center;
  transition:     background 0.15s, transform 0.12s;
  z-index:        1;
  -webkit-tap-highlight-color: transparent;
  padding:        0;
}
.forja-exit-modal__close:hover  { background: #e8e8e8; color: #111; }
.forja-exit-modal__close:active { transform: scale(0.9); }
.forja-exit-modal__close:focus-visible {
  outline: 2px solid var(--forja-exit-accent);
  outline-offset: 2px;
}

/* ─── CORPO DO MODAL ─────────────────────────────────────────────────────── */
.forja-exit-modal__inner {
  padding: 0 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ─── HEADER (Headline + Sub) ────────────────────────────────────────────── */
.forja-exit-modal__header {
  text-align: center;
  padding-top: 6px;
}

.forja-exit-modal__headline {
  font-size:      22px;
  font-weight:    800;
  color:          #111;
  line-height:    1.25;
  margin:         0 0 8px;
  letter-spacing: -0.3px;
}

.forja-exit-modal__sub {
  font-size:   14px;
  color:       #666;
  line-height: 1.55;
  margin:      0;
}

/* ─── BADGE DE DESCONTO ──────────────────────────────────────────────────── */
.forja-exit-badge {
  display:         flex;
  align-items:     center;
  justify-content: center;
  gap:             10px;
  background:      linear-gradient(135deg, var(--forja-exit-gold), #e6960f);
  border-radius:   14px;
  padding:         14px 20px;
  box-shadow:      0 4px 20px rgba(240, 165, 0, 0.35);
  animation:       forja-exit-badge-glow 2s ease-in-out infinite;
}

@keyframes forja-exit-badge-glow {
  0%, 100% { box-shadow: 0 4px 20px rgba(240, 165, 0, 0.35); }
  50%       { box-shadow: 0 6px 30px rgba(240, 165, 0, 0.55); }
}

.forja-exit-badge__pct {
  font-size:   40px;
  font-weight: 900;
  color:       #fff;
  line-height: 1;
  text-shadow: 0 2px 8px rgba(0,0,0,0.15);
  letter-spacing: -1px;
}

.forja-exit-badge__label {
  font-size:   14px;
  font-weight: 700;
  color:       rgba(255,255,255,0.9);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1.2;
}

/* ─── PRODUTO ÂNCORA (Golden Bundle) ─────────────────────────────────────── */
.forja-exit-anchor {
  display:       flex;
  gap:           14px;
  align-items:   center;
  background:    var(--forja-exit-gold-light);
  border:        2px solid rgba(240, 165, 0, 0.4);
  border-radius: 14px;
  padding:       14px;
  text-decoration: none;
  color:         inherit;
  transition:    background 0.15s, border-color 0.15s;
}

.forja-exit-anchor:hover {
  background:    #fff3cd;
  border-color:  rgba(240, 165, 0, 0.7);
}

.forja-exit-anchor__img {
  width:         80px;
  height:        80px;
  object-fit:    cover;
  border-radius: 10px;
  flex-shrink:   0;
  background:    #eee;
}

.forja-exit-anchor__info {
  flex:        1;
  min-width:   0;
}

.forja-exit-anchor__name {
  font-size:   14px;
  font-weight: 700;
  color:       #1a1a1a;
  line-height: 1.35;
  margin-bottom: 6px;
  /* trunca em 2 linhas */
  display:       -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow:      hidden;
}

.forja-exit-anchor__price {
  font-size:   16px;
  font-weight: 800;
  color:       var(--forja-exit-accent);
}
.forja-exit-anchor__price del {
  font-weight: 400;
  color:       #aaa;
  font-size:   13px;
  margin-right: 4px;
}

/* ─── CTA PRINCIPAL ──────────────────────────────────────────────────────── */
.forja-exit-modal__cta {
  display:         block;
  width:           100%;
  padding:         16px;
  background:      var(--forja-exit-accent);
  color:           #fff;
  border:          none;
  border-radius:   12px;
  font-size:       16px;
  font-weight:     700;
  text-align:      center;
  text-decoration: none;
  cursor:          pointer;
  transition:      filter 0.15s, transform 0.12s;
  -webkit-tap-highlight-color: transparent;
  letter-spacing:  0.2px;
}

.forja-exit-modal__cta:hover  { filter: brightness(1.1); color: #fff; }
.forja-exit-modal__cta:active { transform: scale(0.98); }
.forja-exit-modal__cta:focus-visible {
  outline: 3px solid var(--forja-exit-accent);
  outline-offset: 3px;
}

/* Estado de loading do CTA */
.forja-exit-modal__cta--loading {
  pointer-events: none;
  opacity: 0.7;
}
.forja-exit-modal__cta--loading::after {
  content:      " ⏳";
  display:      inline;
  font-size:    14px;
}

/* Estado de sucesso do CTA */
.forja-exit-modal__cta--success {
  background: #1d7a3a;
  pointer-events: none;
}

/* ─── LEGAL / RODAPÉ ─────────────────────────────────────────────────────── */
.forja-exit-modal__legal {
  text-align:  center;
  font-size:   11px;
  color:       #aaa;
  margin:      0;
  line-height: 1.5;
}

/* ─── COUNTDOWN ──────────────────────────────────────────────────────────── */
.forja-exit-modal__countdown {
  display:     flex;
  align-items: center;
  justify-content: center;
  gap:         6px;
  font-size:   13px;
  color:       #888;
}

.forja-exit-modal__countdown-timer {
  font-weight: 700;
  color:       var(--forja-exit-accent);
  font-variant-numeric: tabular-nums;
}

/* ─── LORE BONUS INDICATOR ───────────────────────────────────────────────── */
.forja-exit-lore-boost {
  display:     flex;
  align-items: center;
  gap:         8px;
  font-size:   12px;
  color:       #555;
  background:  #f8f4ff;
  border:      1px solid rgba(123, 45, 139, 0.2);
  border-radius: 8px;
  padding:     8px 12px;
}

.forja-exit-lore-boost__icon {
  font-size:  18px;
  flex-shrink: 0;
}

/* ─── RESPONSIVIDADE (Desktop) ───────────────────────────────────────────── */
@media (min-width: 600px) {
  .forja-exit-modal {
    left:           50%;
    width:          520px;
    transform:      translateX(-50%) translateY(60px) scale(0.96);
    opacity:        0;
    bottom:         auto;
    top:            50%;
    margin-top:     -280px;
    border-radius:  var(--forja-exit-radius);
    max-height:     90vh;
  }

  .forja-exit-modal--visible {
    transform: translateX(-50%) translateY(0) scale(1);
    opacity:   1;
  }
}

/* ─── ACESSIBILIDADE ─────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .forja-exit-modal,
  .forja-exit-overlay { transition: none; }
  .forja-exit-badge   { animation: none; }
}
