/* ============================================================
   Environmental Synergy System - CSS Animations
   Double emoji stack, gate highlights, incinerator effects
   ============================================================ */

/* ========== Synergy Overlay (Double Emoji Stack) ========== */
.synergy-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5);
  opacity: 0;
  z-index: 10000;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.synergy-overlay.synergy-active {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

.emoji-stack {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: -20px;
}

.emoji-primary {
  font-size: 64px;
  animation: emoji-bounce 0.6s ease-out;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.emoji-secondary {
  font-size: 64px;
  animation: emoji-bounce 0.6s ease-out 0.1s;
  animation-fill-mode: backwards;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.unlock-emoji {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 32px;
  animation: unlock-pulse 1s ease-in-out 0.3s;
  animation-fill-mode: backwards;
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.8));
}

@keyframes emoji-bounce {
  0% {
    transform: translateY(-100px) scale(0);
    opacity: 0;
  }
  50% {
    transform: translateY(10px) scale(1.1);
    opacity: 1;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes unlock-pulse {
  0% {
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
  }
  20% {
    transform: translate(-50%, -50%) scale(1.5);
    opacity: 1;
  }
  50% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(2);
    opacity: 0;
  }
}

/* ========== Gate Highlight ========== */
.gate-highlight {
  position: relative;
  animation: gate-pulse 1s ease-in-out infinite;
}

.gate-highlight::after {
  content: '⭐';
  position: absolute;
  top: -5px;
  right: -5px;
  font-size: 12px;
  animation: star-twinkle 1.5s ease-in-out infinite;
}

@keyframes gate-pulse {
  0%, 100% {
    background-color: rgba(255, 215, 0, 0.1);
    box-shadow: 0 0 5px rgba(255, 215, 0, 0.3);
  }
  50% {
    background-color: rgba(255, 215, 0, 0.3);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
  }
}

@keyframes star-twinkle {
  0%, 100% {
    opacity: 0.5;
    transform: rotate(0deg) scale(1);
  }
  50% {
    opacity: 1;
    transform: rotate(180deg) scale(1.2);
  }
}

/* ========== Synergy Available/Incompatible States ========== */
.synergy-available {
  border: 2px solid rgba(0, 255, 0, 0.5);
  box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
  cursor: pointer;
}

.synergy-incompatible {
  border: 2px solid rgba(255, 0, 0, 0.5);
  box-shadow: 0 0 10px rgba(255, 0, 0, 0.3);
  cursor: not-allowed;
}

.synergy-failed {
  animation: shake 0.4s ease-in-out;
}

@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-10px);
  }
  75% {
    transform: translateX(10px);
  }
}

/* ========== Destruction Zone (Debrief Feed) ========== */
.destruction-zone-active {
  position: relative;
  border: 3px dashed rgba(255, 100, 100, 0.8) !important;
  background-color: rgba(255, 0, 0, 0.1) !important;
}

.destruction-zone-active::before {
  content: '🗑️ DROP TO DESTROY';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 16px;
  font-weight: bold;
  color: #ff6666;
  text-shadow: 0 0 10px rgba(255, 0, 0, 0.5);
  animation: pulse-warning 1s ease-in-out infinite;
  z-index: 100;
  pointer-events: none;
}

@keyframes pulse-warning {
  0%, 100% {
    opacity: 0.7;
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
  }
}

/* ========== Incinerator Animation ========== */
.incinerator-active {
  position: relative;
  animation: incinerator-burn 0.8s ease-out;
  overflow: hidden;
}

.incinerator-active::after {
  content: '🔥';
  position: absolute;
  top: 50%;
  left: 50%;
  font-size: 80px;
  transform: translate(-50%, -50%);
  animation: fire-burst 0.8s ease-out;
  z-index: 100;
  pointer-events: none;
}

@keyframes incinerator-burn {
  0% {
    background-color: rgba(255, 100, 0, 0);
  }
  30% {
    background-color: rgba(255, 100, 0, 0.5);
  }
  100% {
    background-color: rgba(50, 50, 50, 0.3);
  }
}

@keyframes fire-burst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0) rotate(0deg);
  }
  30% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.5) rotate(180deg);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5) rotate(360deg);
  }
}

/* ========== Victory Frame (Quest Key Turn-In) ========== */
.victory-frame-active {
  position: relative;
  overflow: hidden;
  animation: victory-gradient-rotate 1.8s ease-in-out;
}

/* Axial gradient glow — rotating happy colors */
.victory-frame-active::before {
  content: '';
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  z-index: 99;
  pointer-events: none;
  border-radius: inherit;
  background: conic-gradient(
    from 0deg,
    #ff6b9d,
    #ffd700,
    #00ffa6,
    #00d4ff,
    #da70d6,
    #ff6b9d
  );
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask-composite: exclude;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  padding: 4px;
  animation: victory-border-spin 1.8s linear, victory-pulse-glow 0.6s ease-in-out 3;
}

/* ✨ sparkle emoji burst from center — CSS-only version (JS handles ricochet) */
.victory-frame-active::after {
  content: '✨';
  position: absolute;
  top: 50%;
  left: 50%;
  font-size: 48px;
  transform: translate(-50%, -50%);
  animation: victory-sparkle-burst 0.8s ease-out;
  z-index: 200;
  pointer-events: none;
}

@keyframes victory-gradient-rotate {
  0% {
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.6), inset 0 0 10px rgba(255, 107, 157, 0.3);
  }
  33% {
    box-shadow: 0 0 30px rgba(0, 255, 166, 0.6), inset 0 0 15px rgba(0, 212, 255, 0.3);
  }
  66% {
    box-shadow: 0 0 30px rgba(218, 112, 214, 0.6), inset 0 0 15px rgba(255, 215, 0, 0.3);
  }
  100% {
    box-shadow: 0 0 0px rgba(255, 215, 0, 0), inset 0 0 0px rgba(0, 0, 0, 0);
  }
}

@keyframes victory-border-spin {
  0% { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(360deg); }
}

@keyframes victory-pulse-glow {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

@keyframes victory-sparkle-burst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0) rotate(0deg);
  }
  30% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.5) rotate(180deg);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5) rotate(360deg);
  }
}

/* ========== Hand Fan Minimized State ========== */
.hand-fan-minimized {
  transition: all 0.3s ease-out;
  transform: scale(0.3);
  opacity: 0.5;
  pointer-events: none;
}

.hand-fan-minimized .hand-card {
  filter: grayscale(0.8);
}

/* ========== Card Highlight Selection (Non-Combat) ========== */
.hand-card-contextual-selected {
  position: relative;
  border: 3px solid rgba(255, 215, 0, 1);
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
  transform: translateY(-10px) scale(1.05);
  transition: all 0.2s ease-out;
  z-index: 10;
}

.hand-card-contextual-selected::before {
  content: '▶';
  position: absolute;
  top: -15px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 20px;
  color: #ffd700;
  animation: selected-bounce 0.6s ease-in-out infinite;
}

@keyframes selected-bounce {
  0%, 100% {
    transform: translateX(-50%) translateY(0);
  }
  50% {
    transform: translateX(-50%) translateY(-5px);
  }
}

/* ========== Debrief Feed Synergy Message ========== */
.debrief-message-synergy {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 140, 0, 0.2));
  border-left: 4px solid #ffd700;
  padding: 8px 12px;
  margin: 4px 0;
  border-radius: 4px;
  font-weight: bold;
  animation: message-slide-in 0.3s ease-out;
}

@keyframes message-slide-in {
  0% {
    transform: translateX(-100%);
    opacity: 0;
  }
  100% {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ========== Mobile Portrait UI Optimizations ========== */
@media (max-width: 768px) and (orientation: portrait) {
  .synergy-overlay {
    max-width: 80vw;
  }

  .emoji-primary,
  .emoji-secondary {
    font-size: 48px;
  }

  .unlock-emoji {
    font-size: 24px;
  }

  .destruction-zone-active::before {
    font-size: 12px;
  }

  .gate-highlight::after {
    font-size: 10px;
  }
}

/* ========== Drop Zone Detection States ========== */
.drop-zone-map-active {
  outline: 3px solid rgba(100, 200, 255, 0.5);
  outline-offset: -3px;
}

.drop-zone-debrief-active {
  outline: 3px solid rgba(255, 100, 100, 0.5);
  outline-offset: -3px;
}
