/* ══════════════════════════════════════════════════
   EMBER DOZE CSS ANIMATIONS
   States: idle sleepy breathe, spike attack,
           thorn shoot, damaged flash
   Also: ground spike effect, DoT indicator on demon
══════════════════════════════════════════════════ */

/* ── Idle: slow drowsy breathing ────────────────── */
.plant-entity.ed-idle {
  animation:
    edBreathe 3s ease-in-out infinite,
    edGlow 4s ease-in-out infinite,
    plantPlace 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transform-origin: bottom center;
}

@keyframes edBreathe {
  0%   { transform: translate(-50%, -50%) scaleY(1)    scaleX(1)    translateY(0px)  rotate(0deg);    }
  20%  { transform: translate(-50%, -50%) scaleY(1.03) scaleX(0.98) translateY(-3px) rotate(-0.5deg); }
  50%  { transform: translate(-50%, -50%) scaleY(1.05) scaleX(0.97) translateY(-5px) rotate(0deg);    }
  80%  { transform: translate(-50%, -50%) scaleY(1.03) scaleX(0.98) translateY(-2px) rotate(0.5deg);  }
  100% { transform: translate(-50%, -50%) scaleY(1)    scaleX(1)    translateY(0px)  rotate(0deg);    }
}

/* Soft green-gold glow — plain meadow energy */
@keyframes edGlow {
  0%, 100% {
    filter:
      drop-shadow(0 0 4px rgba(134, 239, 172, 0.4))
      drop-shadow(0 2px 6px rgba(0, 0, 0, 0.6));
  }
  50% {
    filter:
      drop-shadow(0 0 10px rgba(134, 239, 172, 0.7))
      drop-shadow(0 0 18px rgba(250, 204, 21, 0.3))
      drop-shadow(0 2px 6px rgba(0, 0, 0, 0.6));
  }
}

/* ── Spike attack: squish down then pop up ───────── */
.plant-entity.ed-spike {
  animation: edSpikeAnim 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  transform-origin: bottom center;
  filter:
    drop-shadow(0 0 14px rgba(134, 239, 172, 0.9))
    drop-shadow(0 0 28px rgba(250, 204, 21, 0.5))
    brightness(1.35);
}

@keyframes edSpikeAnim {
  0%   { transform: translate(-50%, -50%) scaleY(1)    scaleX(1)    translateY(0px);  }
  15%  { transform: translate(-50%, -50%) scaleY(0.82) scaleX(1.15) translateY(6px);  }
  40%  { transform: translate(-50%, -50%) scaleY(1.18) scaleX(0.88) translateY(-8px); }
  65%  { transform: translate(-50%, -50%) scaleY(0.95) scaleX(1.04) translateY(2px);  }
  100% { transform: translate(-50%, -50%) scaleY(1)    scaleX(1)    translateY(0px);  }
}

/* ── Thorn shoot: lean forward, snap back ────────── */
.plant-entity.ed-shoot {
  animation: edShootAnim 0.38s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  transform-origin: bottom center;
  filter:
    drop-shadow(0 0 10px rgba(134, 239, 172, 0.8))
    brightness(1.2);
}

@keyframes edShootAnim {
  0%   { transform: translate(-50%, -50%) scaleX(1)    scaleY(1)    translateX(0px);  }
  20%  { transform: translate(-50%, -50%) scaleX(0.82) scaleY(1.12) translateX(-6px); }
  50%  { transform: translate(-50%, -50%) scaleX(1.16) scaleY(0.9)  translateX(7px);  }
  75%  { transform: translate(-50%, -50%) scaleX(0.96) scaleY(1.03) translateX(-2px); }
  100% { transform: translate(-50%, -50%) scaleX(1)    scaleY(1)    translateX(0px);  }
}

/* ── Damaged: green shake flash ──────────────────── */
.plant-entity.ed-damaged {
  animation:
    plantShake 0.3s ease-in-out infinite,
    edDamageFlash 0.14s ease-out 4;
}

@keyframes edDamageFlash {
  0%   { filter: drop-shadow(0 0 14px #fff) brightness(3.5) saturate(0); }
  50%  { filter: drop-shadow(0 0 6px rgba(134, 239, 172, 0.8)) brightness(1.6) saturate(0.5); }
  100% { filter: drop-shadow(0 0 14px #fff) brightness(3.5) saturate(0); }
}

/* ══════════════════════════════════════════════════
   GROUND SPIKE EFFECT
   Rendered as child divs inside .ed-spike-effect
══════════════════════════════════════════════════ */

/* Container placed at demon foot position */
.ed-spike-effect {
  position: absolute;
  pointer-events: none;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 6px;
  overflow: visible;
  transform: translateY(4px);
}

/* Each spike tooth */
.ed-spike-tooth {
  width: 10px;
  background: linear-gradient(to top, #f97316, #facc15, #fef08a);
  border-radius: 2px;
  box-shadow:
    0 0 12px rgba(249, 115, 22, 0.85),
    0 0 22px rgba(251, 191, 36, 0.45);
  transform-origin: bottom center;
  height: 0px;
  opacity: 0;
  animation: edToothPop 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  animation-fill-mode: forwards;
  --target-height: 32px;
  clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
}

@keyframes edToothPop {
  0%   { height: 0px;  opacity: 1;   transform: scaleX(1.3); }
  35%  { height: var(--target-height, 32px); opacity: 1;   transform: scaleX(0.9); }
  60%  { height: var(--target-height, 32px); opacity: 1;   transform: scaleX(1);   }
  100% { height: var(--target-height, 32px); opacity: 1;   transform: scaleX(0.95); }
}

/* Ground crack under spikes */
.ed-spike-effect::before {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 44px;
  height: 4px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(74, 222, 128, 0.6) 0%, transparent 70%);
  animation: edGroundGlow 0.5s ease-out forwards;
}

@keyframes edGroundGlow {
  0%   { opacity: 1; transform: translateX(-50%) scaleX(0.5); }
  50%  { opacity: 0.8; transform: translateX(-50%) scaleX(1.2); }
  100% { opacity: 0; transform: translateX(-50%) scaleX(1.5); }
}

/* ══════════════════════════════════════════════════
   DOT INDICATOR ON DEMON (sticky thorn)
   Added as class .ed-dotted on demon element
══════════════════════════════════════════════════ */
.ed-dotted {
  filter: sepia(0.3) hue-rotate(80deg) !important;
  outline: 2px solid rgba(74, 222, 128, 0.6) !important;
  outline-offset: 2px;
}

/* Small thorn stuck icon above demon */
.ed-dotted::after {
  content: "🌿";
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  animation: edDotBob 0.5s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 30;
}

/* Badges shown on plant when abilities unlocked */
.plant-entity.ed-has-dot::after {
  content: "🌱";
  position: absolute;
  top: -10px;
  right: -6px;
  font-size: 14px;
  background: rgba(0,0,0,0.35);
  padding: 2px 4px;
  border-radius: 8px;
  z-index: 60;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}

.plant-entity.ed-has-thorn::after {
  content: "🗡️";
  position: absolute;
  top: -10px;
  right: -26px;
  font-size: 14px;
  background: rgba(0,0,0,0.35);
  padding: 2px 4px;
  border-radius: 8px;
  z-index: 60;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}

/* Sticky spike variant styling */
.ed-spike-dot .ed-spike-tooth {
  background: linear-gradient(to top, #15803d, #4ade80, #bbf7d0);
  box-shadow: 0 0 10px rgba(34,197,94,0.9), 0 0 18px rgba(34,197,94,0.3);
}

@keyframes edDotBob {
  0%   { transform: translateX(-50%) translateY(0px);   opacity: 1; }
  100% { transform: translateX(-50%) translateY(-4px);  opacity: 0.6; }
}

/* ══════════════════════════════════════════════════
   THORN PROJECTILE
   Uses existing .projectile class from game.css
   Add .thorn type styling here
══════════════════════════════════════════════════ */
.projectile.thorn {
  width: 12px;
  height: 6px;
  background: linear-gradient(90deg, #15803d, #4ade80, #bbf7d0);
  border-radius: 0 50% 50% 0;
  box-shadow:
    0 0 5px rgba(74, 222, 128, 0.7),
    0 0 10px rgba(74, 222, 128, 0.3);
  transform: translateY(-1px);
}

/* Thorn spin while flying */
.projectile.thorn {
  animation: thornSpin 0.3s linear infinite;
}

@keyframes thornSpin {
  0%   { transform: translateY(-1px) rotate(0deg);   }
  100% { transform: translateY(-1px) rotate(360deg); }
}
