/* juicy-animations.css - Satisfying, tactile animations and visual polish for HexSettlers */

/* 1. Producing Hexes Golden Glow (2.2s pulse with smooth fade-out) */
@keyframes hexRollGlowPulse {
  0% {
    filter: drop-shadow(0 0 2px rgba(251, 191, 36, 0.4));
  }
  30% {
    filter: drop-shadow(0 0 12px rgba(251, 191, 36, 0.9)) drop-shadow(0 0 24px rgba(245, 158, 11, 0.5));
  }
  65% {
    filter: drop-shadow(0 0 6px rgba(251, 191, 36, 0.5));
  }
  100% {
    filter: drop-shadow(0 0 0 rgba(251, 191, 36, 0));
  }
}

.hex-producing-active polygon.hex-base {
  animation: hexRollGlowPulse 2.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  stroke: #fbbf24 !important;
  stroke-width: 3.5px !important;
}

@keyframes tokenGlowRingFade {
  0% {
    stroke: #fbbf24;
    filter: drop-shadow(0 0 4px #fbbf24);
  }
  40% {
    stroke: #f59e0b;
    filter: drop-shadow(0 0 8px #f59e0b);
  }
  100% {
    stroke: inherit;
    filter: none;
  }
}

.hex-producing-active .token-group circle:first-child {
  animation: tokenGlowRingFade 2.2s ease-out forwards;
}

/* 2. Flying Resource Particles */
.flying-resource-particle {
  position: fixed;
  top: 0;
  left: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  will-change: transform, opacity;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.55), 0 0 14px currentColor;
  border: 2px solid #ffffff;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: none;
}

.flying-resource-particle svg {
  width: 22px;
  height: 22px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.8));
}

.flying-resource-particle.res-wood {
  background: radial-gradient(circle at 35% 35%, #2d6a4f, #1b4332);
  border-color: #52b788;
  color: #74c69d;
}

.flying-resource-particle.res-brick {
  background: radial-gradient(circle at 35% 35%, #e63946, #9a031e);
  border-color: #f28482;
  color: #f28482;
}

.flying-resource-particle.res-wool {
  background: radial-gradient(circle at 35% 35%, #76c893, #34a0a4);
  border-color: #b5e48c;
  color: #b5e48c;
}

.flying-resource-particle.res-wheat {
  background: radial-gradient(circle at 35% 35%, #f59e0b, #b45309);
  border-color: #fde047;
  color: #fde047;
}

.flying-resource-particle.res-ore {
  background: radial-gradient(circle at 35% 35%, #64748b, #334155);
  border-color: #cbd5e1;
  color: #e2e8f0;
}

.flying-resource-particle.res-coin {
  background: radial-gradient(circle at 35% 35%, #fbbf24, #d97706);
  border-color: #fef08a;
  color: #fef08a;
}

.flying-resource-particle.res-cloth {
  background: radial-gradient(circle at 35% 35%, #3b82f6, #1d4ed8);
  border-color: #93c5fd;
  color: #93c5fd;
}

.flying-resource-particle.res-paper {
  background: radial-gradient(circle at 35% 35%, #10b981, #047857);
  border-color: #6ee7b7;
  color: #6ee7b7;
}

/* 3. Inventory Card Landing Bounce */
@keyframes inventoryCardBump {
  0% {
    transform: scale(1);
  }
  30% {
    transform: scale(1.22) translateY(-4px);
    filter: brightness(1.35) drop-shadow(0 0 14px rgba(251, 191, 36, 0.8));
    border-color: #fbbf24;
  }
  65% {
    transform: scale(0.96) translateY(1px);
  }
  100% {
    transform: scale(1) translateY(0);
    filter: none;
  }
}

.resource-card-bump {
  animation: inventoryCardBump 0.38s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards !important;
}

/* 4. Settlement -> City Upgrade Bloom */
@keyframes cityUpgradeBloomRing {
  0% {
    r: 6;
    opacity: 1;
    stroke-width: 6;
    stroke: #ffffff;
  }
  50% {
    stroke: #fbbf24;
    stroke-width: 4;
  }
  100% {
    r: 34;
    opacity: 0;
    stroke-width: 1;
    stroke: #f59e0b;
  }
}

.city-upgrade-pulse {
  animation: cityUpgradeBloomRing 0.65s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  pointer-events: none;
}

/* 5. Robber 7 Alert Vignette */
@keyframes robberVignetteAlertPulse {
  0% {
    opacity: 0;
  }
  25% {
    opacity: 1;
  }
  75% {
    opacity: 0.85;
  }
  100% {
    opacity: 0;
  }
}

.robber-alert-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 990;
  box-shadow: inset 0 0 90px 30px rgba(220, 38, 38, 0.45);
  animation: robberVignetteAlertPulse 0.75s ease-out forwards;
}

/* 6. Blocked Hex Desaturation & Smog Overlay */
.hex-tile.hex-robber-blocked > polygon:first-of-type {
  filter: grayscale(85%) brightness(0.68) contrast(1.15) !important;
  stroke: #450a0a !important;
  stroke-width: 3.5px !important;
  transition: filter 0.4s ease, stroke 0.4s ease;
}

.robber-smog-layer {
  pointer-events: none;
  animation: smogFloat 4s ease-in-out infinite alternate;
}

@keyframes smogFloat {
  0% {
    opacity: 0.42;
    transform: scale(0.96) rotate(0deg);
  }
  50% {
    opacity: 0.62;
    transform: scale(1.04) rotate(4deg);
  }
  100% {
    opacity: 0.42;
    transform: scale(0.98) rotate(-3deg);
  }
}

/* 7. Smart Ghost Preview & Magnetic Snap */
.ghost-preview-group {
  pointer-events: none;
  opacity: 0.82;
  transition: transform 0.12s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.15s ease;
  will-change: transform, opacity;
}

.ghost-preview-group.ghost-unfocused {
  opacity: 0.45;
}

.ghost-preview-group path,
.ghost-preview-group line,
.ghost-preview-group circle {
  stroke-dasharray: 4, 3;
  animation: ghostDashScroll 1s linear infinite;
  filter: drop-shadow(0 0 6px rgba(251, 191, 36, 0.8));
}

@keyframes ghostDashScroll {
  to {
    stroke-dashoffset: -14;
  }
}

/* Ensure existing buildings and roads are ALWAYS 100% fully opaque and crisp */
.vertex-group.has-building,
.edge-group.built-road {
  opacity: 1 !important;
}

/* 8. Cozy Shore Foam Movement */
@keyframes shoreFoamDrift {
  0% {
    stroke-dashoffset: 0;
    opacity: 0.55;
  }
  50% {
    opacity: 0.85;
  }
  100% {
    stroke-dashoffset: 24;
    opacity: 0.55;
  }
}

.shore-foam-wave {
  animation: shoreFoamDrift 6s linear infinite;
  pointer-events: none;
}

/* Reduced motion accessibility */
@media (prefers-reduced-motion: reduce) {
  .hex-producing-active polygon,
  .hex-producing-active .token-group circle,
  .resource-card-bump,
  .city-upgrade-pulse,
  .robber-alert-overlay,
  .robber-smog-layer,
  .ghost-preview-group path,
  .ghost-preview-group line,
  .shore-foam-wave {
    animation: none !important;
  }
  .flying-resource-particle {
    display: none !important;
  }
}
