/* === PLACED PLANTS — plants the player puts in the ground === */

/* ============================================================ */
/*  SHARED SHADOW LAYER                                          */
/*  Shadows are SEPARATE elements rendered with low z-index so   */
/*  they always sit BEHIND every plant body.                     */
/* ============================================================ */
.placed-plant-shadow {
  position: absolute;
  bottom: calc(21vh - 4px);
  z-index: 5; /* below all plants (which are z-index 10+) */
  pointer-events: none;
  width: 36px;
  height: 6px;
  margin-left: -18px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center,
    rgba(0, 0, 0, 0.55) 0%,
    rgba(0, 0, 0, 0.35) 60%,
    transparent 100%);
  transform: scale(var(--rarity-scale, 1));
  transform-origin: center center;
  --rarity-scale: 1;
}
.placed-plant-shadow[data-rarity="comum"]    { --rarity-scale: 1;    }
.placed-plant-shadow[data-rarity="incomum"]  { --rarity-scale: 1.15; }
.placed-plant-shadow[data-rarity="raro"]     { --rarity-scale: 1.4;  }
.placed-plant-shadow[data-rarity="epico"]    { --rarity-scale: 1.7;  }
.placed-plant-shadow[data-rarity="lendario"] { --rarity-scale: 2.1;  }
.placed-plant-shadow[data-rarity="mitico"]   { --rarity-scale: 2.6;  }
.placed-plant-shadow[data-rarity="cosmico"]  { --rarity-scale: 3.2;  }
.placed-plant-shadow[data-rarity="desconhecido"] { --rarity-scale: 4; }

.placed-plant-shadow.just-planted {
  animation: shadowBirth 0.8s cubic-bezier(0.2, 1.6, 0.4, 1);
}
@keyframes shadowBirth {
  0%   { transform: scale(0); opacity: 0; }
  60%  { transform: scale(calc(var(--rarity-scale, 1) * 1.25)); opacity: 1; }
  100% { transform: scale(var(--rarity-scale, 1)); opacity: 1; }
}

/* Hide the OLD shadow ellipse that's still inside the plant SVGs */
.placed-plant-inner svg > ellipse:first-of-type {
  display: none;
}

.placed-plant {
  position: absolute;
  /* The SVG no longer renders its first ellipse (shadow), so we anchor
     the plant body bottom to the visible ground line directly. */
  bottom: calc(21vh - 4px);
  z-index: 10;
  pointer-events: none;
  transform-origin: bottom center;
  --rarity-glow: rgba(154, 154, 154, 0.4);
  --rarity-scale: 1;
}

.placed-plant-inner {
  display: inline-block;
  filter: drop-shadow(1px 2px 0 rgba(0, 0, 0, 0.55));
  transform-origin: bottom center;
}

/* --- Birth animation: pop in (RESPECTS rarity scale) --- */
.placed-plant.just-planted .placed-plant-inner {
  animation: plantBirth 0.8s cubic-bezier(0.2, 1.6, 0.4, 1);
}
@keyframes plantBirth {
  0%   { transform: scale(0)                                        translateY(6px); opacity: 0; }
  60%  { transform: scale(calc(var(--rarity-scale, 1) * 1.25))      translateY(-2px); opacity: 1; }
  100% { transform: scale(var(--rarity-scale, 1))                   translateY(0);   opacity: 1; }
}

/* --- Ancestral stage glow filter --- */
.placed-plant.ancestral .placed-plant-inner {
  filter:
    drop-shadow(1px 2px 0 rgba(0, 0, 0, 0.55))
    drop-shadow(0 0 10px var(--rarity-glow))
    drop-shadow(0 0 16px var(--rarity-glow));
}

/* --- Particles around ancestral plants --- */
.placed-plant.ancestral::before,
.placed-plant.ancestral::after {
  content: '';
  position: absolute;
  bottom: 30%;
  left: 50%;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--rarity-glow);
  box-shadow: 0 0 6px var(--rarity-glow);
  pointer-events: none;
  opacity: 0;
  animation: plantSpark 3.5s ease-in-out infinite;
}
.placed-plant.ancestral::after {
  animation-delay: 1.7s;
  left: 40%;
}
@keyframes plantSpark {
  0%   { opacity: 0; transform: translate(0, 0) scale(0.5); }
  20%  { opacity: 1; }
  100% { opacity: 0; transform: translate(8px, -30px) scale(1.2); }
}

/* ============================================================ */
/*  Rarity scale + z-index (bigger plants in FRONT of smaller)   */
/* ============================================================ */
.placed-plant[data-rarity="comum"]    { --rarity-glow: rgba(154,154,154,0.4);  --rarity-scale: 1;    z-index: 10; }
.placed-plant[data-rarity="incomum"]  { --rarity-glow: rgba(93,208,106,0.55);  --rarity-scale: 1.15; z-index: 11; }
.placed-plant[data-rarity="raro"]     { --rarity-glow: rgba(74,163,255,0.6);   --rarity-scale: 1.4;  z-index: 12; }
.placed-plant[data-rarity="epico"]    { --rarity-glow: rgba(162,93,255,0.65);  --rarity-scale: 1.7;  z-index: 13; }
.placed-plant[data-rarity="lendario"] { --rarity-glow: rgba(255,138,42,0.75);  --rarity-scale: 2.1;  z-index: 14; }
.placed-plant[data-rarity="mitico"]   { --rarity-glow: rgba(255,58,58,0.8);    --rarity-scale: 2.6;  z-index: 15; }
.placed-plant[data-rarity="cosmico"]  { --rarity-glow: rgba(61,240,255,0.9);   --rarity-scale: 3.2;  z-index: 16; }
.placed-plant[data-rarity="desconhecido"] { --rarity-glow: rgba(255,255,255,1); --rarity-scale: 4;   z-index: 17; }

/* ============================================================ */
/*  Default idle animation — composes with rarity scale          */
/*  (just-planted overrides via animation cascade)               */
/* ============================================================ */
.placed-plant .placed-plant-inner {
  animation: plantIdleScaled 4s ease-in-out infinite;
}
@keyframes plantIdleScaled {
  0%, 100% { transform: scale(var(--rarity-scale, 1))                       rotate(0deg);  }
  50%      { transform: scale(calc(var(--rarity-scale, 1) * 1.02))           rotate(-1deg); }
}

/* Ancestral plants get a bigger breathing animation */
.placed-plant.ancestral .placed-plant-inner {
  animation: plantBreatheScaled 5s ease-in-out infinite;
}
@keyframes plantBreatheScaled {
  0%, 100% { transform: scale(var(--rarity-scale, 1))                       rotate(0deg);  }
  50%      { transform: scale(calc(var(--rarity-scale, 1) * 1.045))          rotate(-1deg); }
}
