/* ==========================================================================
   sticky-scarcity.css — Barra sticky no fim da viewport + toast de vendas
   Aparece após scroll de 800px. Liga via JS lots-watcher.js.
   data-urgency=low|medium|high|critical controla intensidade visual da chama.
   ========================================================================== */

/* ==========================================================================
   Anti-flicker: esconde elementos com data-* até o primeiro fetch popular
   ========================================================================== */
[data-scarcity-pct],
[data-scarcity-fill],
[data-current-lot],
[data-current-lot-lower],
[data-current-price],
[data-coupon-price] {
  opacity: 0;
  transition: opacity 0.35s ease, width 0.6s cubic-bezier(0.22, 1, 0.36, 1),
              background 0.4s ease, box-shadow 0.4s ease;
}
body.lots-data-loaded [data-scarcity-pct],
body.lots-data-loaded [data-scarcity-fill],
body.lots-data-loaded [data-current-lot],
body.lots-data-loaded [data-current-lot-lower],
body.lots-data-loaded [data-current-price],
body.lots-data-loaded [data-coupon-price] {
  opacity: 1;
}
/* Fallback: se JS não rodar em 4s, revela mesmo assim pra não esconder pra sempre */
body:not(.lots-data-loaded) [data-scarcity-pct],
body:not(.lots-data-loaded) [data-scarcity-fill],
body:not(.lots-data-loaded) [data-current-lot],
body:not(.lots-data-loaded) [data-current-lot-lower],
body:not(.lots-data-loaded) [data-current-price],
body:not(.lots-data-loaded) [data-coupon-price] {
  animation: lots-fallback-reveal 0s ease forwards 4s;
}
@keyframes lots-fallback-reveal { to { opacity: 1; } }

.sticky-scarcity {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 90;
  background: linear-gradient(180deg, rgba(20, 18, 16, 0.96) 0%, rgba(20, 18, 16, 1) 100%);
  border-top: 2px solid var(--color-accent, #e25e3e);
  color: #fff;
  padding: 0.7rem 1rem;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.25);
  transform: translateY(110%);
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}

.sticky-scarcity.is-visible {
  transform: translateY(0);
  pointer-events: auto;
}

/* Desktop: label+bar à esquerda, CTA à direita ocupando 2 linhas */
.sticky-scarcity__inner {
  max-width: 1080px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 0.45rem 1.1rem;
  align-items: center;
}

.sticky-scarcity__label {
  font-size: 0.9rem;
  line-height: 1.25;
  color: rgba(255, 255, 255, 0.92);
  grid-column: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sticky-scarcity__label strong {
  color: var(--color-accent, #e25e3e);
  font-weight: 700;
}

.sticky-scarcity__bar {
  position: relative;
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  overflow: visible;
  grid-column: 1;
  transition: height 0.4s ease;
}

.sticky-scarcity__bar::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  z-index: 0;
}

.sticky-scarcity__fill {
  display: block;
  height: 100%;
  position: relative;
  background: linear-gradient(90deg, #fbbf24 0%, #fb923c 100%);
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1),
              background 0.4s ease,
              box-shadow 0.4s ease;
  z-index: 1;
}

.sticky-scarcity__cta {
  grid-column: 2;
  grid-row: 1 / span 2;
  background: var(--color-accent, #e25e3e);
  color: #fff;
  font-weight: 700;
  font-size: 0.92rem;
  padding: 0.75rem 1.2rem;
  border-radius: 8px;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.15s ease, background 0.15s ease;
  align-self: center;
}

.sticky-scarcity__cta:hover {
  background: #d54a2a;
  transform: translateY(-1px);
}

/* ==========================================================================
   Mobile (<600px): stack vertical full-width pra evitar quebra de linha
   ========================================================================== */
@media (max-width: 599px) {
  .sticky-scarcity {
    padding: 0.6rem 0.85rem 0.75rem;
  }
  .sticky-scarcity__inner {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    gap: 0.45rem;
  }
  .sticky-scarcity__label {
    grid-column: 1;
    grid-row: 1;
    font-size: 0.85rem;
    text-align: center;
  }
  .sticky-scarcity__bar {
    grid-column: 1;
    grid-row: 2;
  }
  .sticky-scarcity__cta {
    grid-column: 1;
    grid-row: 3;
    width: 100%;
    text-align: center;
    padding: 0.7rem 1rem;
    font-size: 0.9rem;
  }
}

/* ==========================================================================
   Animação de urgência progressiva — escala visual conforme % aumenta
   ========================================================================== */

/* Medium (50–74%): glow âmbar, ember pulse lento */
.sticky-scarcity[data-urgency="medium"] .sticky-scarcity__bar { height: 8px; }
.sticky-scarcity[data-urgency="medium"] .sticky-scarcity__fill {
  background: linear-gradient(90deg, #fb923c 0%, #ea580c 100%);
  box-shadow: 0 0 12px rgba(251, 146, 60, 0.5);
  animation: ember-pulse 4s ease-in-out infinite;
}

/* High (75–89%): vermelho-laranja, glow forte, chama começa a aparecer */
.sticky-scarcity[data-urgency="high"] .sticky-scarcity__bar { height: 10px; }
.sticky-scarcity[data-urgency="high"] .sticky-scarcity__fill {
  background: linear-gradient(90deg, #ea580c 0%, #dc2626 100%);
  box-shadow: 0 0 18px rgba(220, 38, 38, 0.7);
  animation: ember-pulse 2s ease-in-out infinite;
}

/* Critical (90–100%): vermelho intenso, chama plena, fire flow */
.sticky-scarcity[data-urgency="critical"] .sticky-scarcity__bar { height: 12px; }
.sticky-scarcity[data-urgency="critical"] .sticky-scarcity__fill {
  background: linear-gradient(90deg, #dc2626 0%, #f59e0b 50%, #dc2626 100%);
  background-size: 200% 100%;
  box-shadow: 0 0 24px rgba(220, 38, 38, 0.9), 0 0 40px rgba(245, 158, 11, 0.5);
  animation: ember-pulse 1.2s ease-in-out infinite, fire-flow 3s linear infinite;
}

@keyframes ember-pulse {
  0%, 100% { filter: brightness(1); transform: scaleY(1); }
  50%      { filter: brightness(1.3); transform: scaleY(1.18); }
}

@keyframes fire-flow {
  0%   { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

/* ==========================================================================
   Chama CSS na ponta da barra fill — pseudo-element ::after
   ========================================================================== */
.sticky-scarcity__fill::after {
  content: '';
  position: absolute;
  right: -7px;
  top: 50%;
  width: 14px;
  height: 22px;
  transform: translateY(-50%) scale(0);
  background: radial-gradient(ellipse at 50% 70%,
    #fef9c3 0%, #facc15 22%, #f97316 50%, #dc2626 78%, transparent 100%);
  filter: blur(1.5px);
  border-radius: 50% 50% 20% 20% / 60% 60% 40% 40%;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  mix-blend-mode: screen;
}

.sticky-scarcity[data-urgency="high"] .sticky-scarcity__fill::after {
  opacity: 0.75;
  transform: translateY(-50%) scale(0.85);
  animation: flame-flicker 0.18s ease-in-out infinite alternate;
}

.sticky-scarcity[data-urgency="critical"] .sticky-scarcity__fill::after {
  opacity: 1;
  transform: translateY(-50%) scale(1.15);
  animation: flame-flicker 0.13s ease-in-out infinite alternate,
             flame-grow 1s ease-in-out infinite;
}

@keyframes flame-flicker {
  0%   { transform: translateY(-50%) scale(1)    rotate(-4deg); filter: blur(1.5px) brightness(1); }
  100% { transform: translateY(-50%) scale(1.18) rotate(4deg);  filter: blur(2px)   brightness(1.35); }
}

@keyframes flame-grow {
  0%, 100% { width: 14px; height: 22px; }
  50%      { width: 19px; height: 30px; }
}

/* Fagulhas em critical — segundo pseudo-element acima da chama */
.sticky-scarcity__fill::before {
  content: '';
  position: absolute;
  right: -2px;
  top: -8px;
  width: 4px;
  height: 4px;
  background: radial-gradient(circle, #fef9c3 0%, #f97316 60%, transparent 100%);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}
.sticky-scarcity[data-urgency="critical"] .sticky-scarcity__fill::before {
  animation: spark-rise 1.4s ease-in infinite;
}
@keyframes spark-rise {
  0%   { opacity: 0; transform: translate(0, 0) scale(0.6); }
  20%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-6px, -22px) scale(0.2); }
}

/* ==========================================================================
   Label vibra em critical (puxa atenção sem ser irritante)
   ========================================================================== */
.sticky-scarcity[data-urgency="critical"] .sticky-scarcity__label {
  animation: urgent-shake 2.5s ease-in-out infinite;
}
.sticky-scarcity[data-urgency="critical"] .sticky-scarcity__label strong {
  color: #fca5a5;
  text-shadow: 0 0 8px rgba(252, 165, 165, 0.6);
}

@keyframes urgent-shake {
  0%, 92%, 100% { transform: translateX(0); }
  93% { transform: translateX(-2px); }
  95% { transform: translateX(2px); }
  97% { transform: translateX(-1.5px); }
  99% { transform: translateX(1.5px); }
}

/* ==========================================================================
   Pulse de venda nova (já existia, mantido — aciona via JS pulseFills())
   ========================================================================== */
.sticky-scarcity__fill.is-pulsing,
[data-scarcity-fill].is-pulsing {
  animation: scarcity-pulse 0.9s ease-out;
}
@keyframes scarcity-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(226, 94, 62, 0.65); }
  70%  { box-shadow: 0 0 0 8px rgba(226, 94, 62, 0); }
  100% { box-shadow: 0 0 0 0 rgba(226, 94, 62, 0); }
}

/* Esgotado */
body.is-sold-out .sticky-scarcity__cta {
  background: #555;
  pointer-events: none;
  opacity: 0.7;
}

/* ==========================================================================
   Empurra o WhatsApp FAB pra cima quando a sticky bar tá visível
   (Mobile usa stack vertical, então sticky fica mais alta — empurra mais)
   ========================================================================== */
body.has-sticky-scarcity .wa-brutal {
  bottom: 6rem;
  transition: bottom 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

@media (max-width: 599px) {
  body.has-sticky-scarcity .wa-brutal {
    bottom: 11rem;
  }
}

/* ==========================================================================
   Reduced motion: desliga animações intensas, mantém estado base
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .sticky-scarcity,
  .sticky-scarcity__fill,
  .sticky-scarcity__fill::after,
  .sticky-scarcity__fill::before,
  .sticky-scarcity__label,
  body.has-sticky-scarcity .wa-brutal {
    animation: none !important;
    transition: none !important;
  }
}

/* ==========================================================================
   Toast (notificações de "+1 vaga ocupada" / "lote virou")
   ========================================================================== */

.lots-toast-root {
  position: fixed;
  bottom: 90px;
  right: 1rem;
  z-index: 95;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
  max-width: 92vw;
}

.lots-toast {
  background: rgba(20, 18, 16, 0.96);
  color: #fff;
  padding: 0.85rem 1.1rem;
  border-radius: 10px;
  border-left: 4px solid var(--color-accent, #e25e3e);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32);
  font-size: 0.88rem;
  line-height: 1.45;
  max-width: 340px;
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: auto;
}

.lots-toast.is-visible {
  opacity: 1;
  transform: translateX(0);
}

.lots-toast--lot {
  border-left-color: #facc15;
  background: linear-gradient(135deg, #1a1612 0%, #2a1f15 100%);
}

.lots-toast strong {
  color: var(--color-accent, #e25e3e);
  font-weight: 700;
}

.lots-toast--lot strong {
  color: #facc15;
}

@media (max-width: 480px) {
  .lots-toast-root {
    right: 0.5rem;
    left: 0.5rem;
    bottom: 160px;
    max-width: none;
  }
  .lots-toast {
    max-width: 100%;
    font-size: 0.82rem;
  }
}
