/**
 * AdWell Ad Styles
 *
 * Unified CSS for both preview (AdPreview.tsx) and production (sdk.js)
 * This file is loaded by sdk.js for production and imported by globals.css for preview
 */

/* ==========================================================================
   Animation Keyframes
   ========================================================================== */

@keyframes adwell-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes adwell-slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes adwell-slideDown {
  from { opacity: 0; transform: translateY(-30px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes adwell-slideLeft {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes adwell-slideRight {
  from { opacity: 0; transform: translateX(-30px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes adwell-bounce {
  0% { opacity: 0; transform: scale(0.3); }
  50% { transform: scale(1.05); }
  70% { transform: scale(0.9); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes adwell-scale {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

/* ==========================================================================
   Animation Classes
   ========================================================================== */

.adwell-animate-fade { animation: adwell-fade 0.4s ease-out forwards; }
.adwell-animate-slideUp { animation: adwell-slideUp 0.4s ease-out forwards; }
.adwell-animate-slideDown { animation: adwell-slideDown 0.4s ease-out forwards; }
.adwell-animate-slideLeft { animation: adwell-slideLeft 0.4s ease-out forwards; }
.adwell-animate-slideRight { animation: adwell-slideRight 0.4s ease-out forwards; }
.adwell-animate-bounce { animation: adwell-bounce 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards; }
.adwell-animate-scale { animation: adwell-scale 0.3s ease-out forwards; }
.adwell-hidden { opacity: 0; visibility: hidden; }

/* ==========================================================================
   Minimized Button (Remind Later)
   ========================================================================== */

.adwell-minimized-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  padding: 12px 20px;
  border-radius: 50px;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
  cursor: pointer;
  z-index: 9998;
  font-family: system-ui, sans-serif;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.adwell-minimized-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
}

/* ==========================================================================
   Countdown Ad Styles
   ========================================================================== */

@keyframes adwell-countdown-rotate {
  0% { transform: rotate(0deg) scale(1); }
  100% { transform: rotate(360deg) scale(1.1); }
}

@keyframes adwell-countdown-drift {
  0%, 100% { transform: translate3d(-8%, -6%, 0); opacity: 0.45; }
  50% { transform: translate3d(8%, 6%, 0); opacity: 0.7; }
}

.adwell-countdown-bg {
  position: relative;
  overflow: hidden;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14),
    inset 0 -24px 40px rgba(0, 0, 0, 0.2);
}

.adwell-countdown-bg::before {
  content: "";
  position: absolute;
  inset: -60% -40%;
  background: conic-gradient(
    from 140deg,
    rgba(255, 255, 255, 0.35),
    transparent 30%,
    rgba(255, 255, 255, 0.18) 55%,
    transparent 75%,
    rgba(255, 255, 255, 0.28)
  );
  opacity: 0.85;
  filter: blur(12px);
  will-change: transform, opacity;
  animation: adwell-countdown-rotate 10s linear infinite;
  mix-blend-mode: screen;
  pointer-events: none;
}

.adwell-countdown-bg::after {
  content: "";
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.32), transparent 55%),
    radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.24), transparent 60%),
    linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.22), transparent);
  opacity: 0.7;
  filter: blur(4px);
  will-change: transform, opacity;
  animation: adwell-countdown-drift 6s ease-in-out infinite;
  mix-blend-mode: screen;
  pointer-events: none;
}

/* Light tone variant */
.adwell-countdown-bg[data-tone="light"] {
  text-shadow: 0 1px 2px rgba(15, 23, 42, 0.35);
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08),
    inset 0 -24px 40px rgba(15, 23, 42, 0.12);
}

.adwell-countdown-bg[data-tone="light"]::before {
  opacity: 0.45;
  mix-blend-mode: multiply;
}

.adwell-countdown-bg[data-tone="light"]::after {
  opacity: 0.45;
  mix-blend-mode: multiply;
}

/* Gold tone variant */
.adwell-countdown-bg[data-tone="gold"] {
  text-shadow: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3),
    inset 0 -24px 40px rgba(0, 0, 0, 0.08);
}

.adwell-countdown-bg[data-tone="gold"]::before {
  background: conic-gradient(
    from 140deg,
    rgba(255, 255, 255, 0.5),
    transparent 30%,
    rgba(255, 255, 255, 0.25) 55%,
    transparent 75%,
    rgba(255, 255, 255, 0.4)
  );
  opacity: 0.8;
  mix-blend-mode: overlay;
}

.adwell-countdown-bg[data-tone="gold"]::after {
  background:
    radial-gradient(circle at 25% 25%, rgba(255, 255, 255, 0.4), transparent 55%),
    radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.3), transparent 60%),
    linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  opacity: 0.7;
  mix-blend-mode: overlay;
}

.adwell-countdown-bg > * {
  position: relative;
  z-index: 1;
}

.adwell-countdown-bg div,
.adwell-countdown-bg span {
  position: relative;
}

/* ==========================================================================
   Celebration Ad Styles
   ========================================================================== */

@keyframes confetti-fall {
  0% {
    opacity: 1;
    transform: translateY(-20px) rotate(0deg) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(300px) rotate(720deg) scale(0.5);
  }
}

@keyframes celebration-reveal {
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes celebration-bounce {
  0% { transform: scale(0); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.adwell-celebration {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
}

.adwell-confetti-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.adwell-confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  opacity: 0;
  animation: confetti-fall 3s ease-out forwards;
}

.adwell-celebration-content {
  animation: celebration-reveal 0.5s ease-out 1s forwards;
  opacity: 0;
  transform: scale(0.9);
}

.adwell-celebration-title {
  animation: celebration-bounce 0.6s ease-out forwards;
  font-size: 24px;
  font-weight: 800;
  text-align: center;
}

/* ==========================================================================
   Slot/Gacha Ad Styles
   ========================================================================== */

@keyframes slot-spin {
  0% { transform: translateY(0); }
  100% { transform: translateY(var(--slot-stop, -180px)); }
}

.adwell-slot {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
}

.adwell-slot-window {
  overflow: hidden;
  height: 60px;
  position: relative;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.1);
}

.adwell-slot-reel {
  display: flex;
  flex-direction: column;
  animation: slot-spin 2s cubic-bezier(0.15, 0.85, 0.35, 1) forwards;
}

.adwell-slot-item {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
}

/* ==========================================================================
   Scratch Card Ad Styles
   ========================================================================== */

.adwell-scratch {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  cursor: crosshair;
  user-select: none;
  -webkit-user-select: none;
}

.adwell-scratch-surface {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #c0c0c0 0%, #a8a8a8 50%, #c0c0c0 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #666;
  z-index: 5;
}

.adwell-scratch-surface::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 10px,
    rgba(255,255,255,0.1) 10px,
    rgba(255,255,255,0.1) 20px
  );
}

.adwell-scratch-reveal {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

/* ==========================================================================
   Roulette Ad Styles
   ========================================================================== */

@keyframes roulette-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(var(--roulette-rotation, 1800deg)); }
}

.adwell-roulette {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
}

.adwell-roulette-wheel {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  position: relative;
  margin: 0 auto;
  border: 4px solid #333;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.adwell-roulette-segment {
  position: absolute;
  width: 50%;
  height: 50%;
  left: 50%;
  top: 50%;
  transform-origin: 0 0;
  clip-path: polygon(0 0, 100% 0, 0 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.adwell-roulette-pointer {
  position: absolute;
  top: -15px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 15px solid transparent;
  border-right: 15px solid transparent;
  border-top: 25px solid #ef4444;
  z-index: 10;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

/* ==========================================================================
   Flash Sale Ad Styles
   ========================================================================== */

@keyframes flash-rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes flash-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.8; transform: scale(1.05); }
}

.adwell-flash-sale {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
}

.adwell-flash-sale::before {
  content: "";
  position: absolute;
  inset: -50%;
  background: conic-gradient(
    from 0deg,
    transparent 0deg,
    rgba(255,255,255,0.8) 10deg,
    transparent 20deg
  );
  animation: flash-rotate 3s linear infinite;
}

.adwell-flash-sale-content {
  position: relative;
  z-index: 1;
  padding: 20px;
}

.adwell-flash-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #ef4444;
  color: white;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  animation: flash-pulse 1s ease-in-out infinite;
}

/* ==========================================================================
   Modal Styles (for iframe embedding)
   ========================================================================== */

.adwell-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: adwell-fade 0.2s ease-out;
}

.adwell-modal-container {
  position: relative;
  width: auto;
  min-width: 300px;
  max-width: 95vw;
  max-height: 90vh;
  background: #fff !important;
  background-image: none !important;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
  animation: adwell-scale 0.2s ease-out;
}

.adwell-modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 10;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  line-height: 1;
}

.adwell-modal-close:hover {
  background: rgba(0, 0, 0, 0.7);
}

.adwell-modal-content {
  max-width: 95vw;
  max-height: 90vh;
  overflow: auto;
  background: #fff !important;
  background-image: none !important;
}

.adwell-modal-content img {
  max-width: 100%;
  height: auto;
  display: block;
}

.adwell-modal-iframe {
  width: 100%;
  min-width: 600px;
  height: 80vh;
  border: none;
}

/* ==========================================================================
   Conversation Ad Styles
   ========================================================================== */

/* Conversation node enter animation */
@keyframes adwell-conversation-slide {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.adwell-conversation-node-enter {
  animation: adwell-conversation-slide 0.3s ease-out;
}

/* Conversation container */
.adwell-conversation {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
}

/* Choice button hover effect */
.adwell-conversation-choice {
  transition: all 0.2s ease;
}

.adwell-conversation-choice:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* Choices container */
.adwell-conv-choices {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Reset button */
.adwell-conv-reset {
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.adwell-conv-reset:hover {
  opacity: 1;
}
