/* Delete-agent modal — playful "destruction" + "rest in peace" scenes.
 * Pure CSS (no canvas, no images). Two scenes share a centred 200×140 stage.
 *
 *   .da-stage          — fixed-size container, both scenes mount inside
 *   .da-bot            — 8-bit-style robot built from divs
 *   .da-tomb           — grey tombstone shown after destruction
 *   .da-particle       — soap/dust particles floating around the bot
 *   .da-status         — single-line status text that swaps every few seconds
 *
 * Honours prefers-reduced-motion: keeps colours and characters but freezes
 * the looping animations so motion-sensitive users see a static scene
 * instead of nothing.
 */

.da-stage {
  position: relative;
  width: 100%;
  height: 160px;
  margin: .35rem 0 .85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* ---- Scene 1: bot getting swept away ---------------------------------- */

.da-bot {
  position: relative;
  width: 56px;
  height: 64px;
  animation: da-bot-shake 1.6s ease-in-out infinite;
  transform-origin: 50% 100%;
}
.da-bot.dying {
  animation:
    da-bot-shake .35s ease-in-out infinite,
    da-bot-fade 30s linear forwards;
}

/* Antenna with a blinking LED on top */
.da-bot-antenna {
  position: absolute;
  left: 50%;
  top: -8px;
  width: 2px;
  height: 10px;
  background: var(--muted, #888);
  transform: translateX(-50%);
}
.da-bot-antenna::after {
  content: '';
  position: absolute;
  top: -5px;
  left: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ff5e5e;
  transform: translateX(-50%);
  box-shadow: 0 0 6px #ff5e5e;
  animation: da-led-blink .9s ease-in-out infinite;
}

/* Head — square with rounded corners, two pixel eyes */
.da-bot-head {
  position: relative;
  width: 56px;
  height: 40px;
  border-radius: 9px;
  background: linear-gradient(180deg, #cfd3d8 0%, #9aa0a6 100%);
  border: 1.5px solid rgba(0,0,0,.25);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.4),
    0 2px 6px rgba(0,0,0,.4);
}
.da-bot-eye {
  position: absolute;
  top: 12px;
  width: 8px;
  height: 10px;
  background: #1a1a1a;
  border-radius: 2px;
  animation: da-bot-blink 3.2s steps(1, end) infinite;
}
.da-bot-eye.left  { left: 12px }
.da-bot-eye.right { right: 12px }

/* Body — chunky chest with a glowing power core */
.da-bot-body {
  position: relative;
  margin: 2px auto 0;
  width: 44px;
  height: 22px;
  border-radius: 4px 4px 6px 6px;
  background: linear-gradient(180deg, #b9bec3 0%, #82888d 100%);
  border: 1.5px solid rgba(0,0,0,.25);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.35),
    0 2px 4px rgba(0,0,0,.35);
}
.da-bot-core {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #17dc94;
  box-shadow: 0 0 8px #17dc94;
  transform: translate(-50%, -50%);
  animation: da-core-pulse 1.4s ease-in-out infinite;
}
.da-bot.dying .da-bot-core {
  animation: da-core-pulse .55s ease-in-out infinite;
}

/* Floating dust/soap particles */
.da-particle {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(23, 220, 148, .55);
  box-shadow: 0 0 4px rgba(23, 220, 148, .6);
  pointer-events: none;
  bottom: 30px;
  opacity: 0;
  animation: da-particle-rise 2.8s linear infinite;
}
.da-particle.p1 { left: 22%; animation-delay: 0.0s; background: rgba(245, 158, 11, .55); box-shadow: 0 0 4px rgba(245, 158, 11, .6) }
.da-particle.p2 { left: 36%; animation-delay: 0.4s }
.da-particle.p3 { left: 50%; animation-delay: 0.8s; background: rgba(200, 155, 255, .55); box-shadow: 0 0 4px rgba(200, 155, 255, .6) }
.da-particle.p4 { left: 64%; animation-delay: 1.2s }
.da-particle.p5 { left: 78%; animation-delay: 1.6s; background: rgba(245, 158, 11, .55); box-shadow: 0 0 4px rgba(245, 158, 11, .6) }
.da-particle.p6 { left: 30%; animation-delay: 2.0s; background: rgba(200, 155, 255, .55); box-shadow: 0 0 4px rgba(200, 155, 255, .6) }
.da-particle.p7 { left: 70%; animation-delay: 2.4s }

/* Broom that sweeps across, low and slow */
.da-broom {
  position: absolute;
  bottom: 22px;
  left: -40px;
  font-size: 26px;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.4));
  animation: da-broom-sweep 5s ease-in-out infinite;
  transform-origin: 50% 80%;
}

/* Rotating one-line status under the bot */
.da-status {
  text-align: center;
  font-size: .82rem;
  color: var(--muted);
  min-height: 1.2em;
  margin: .2rem 0 .8rem;
  font-style: italic;
  opacity: .9;
  transition: opacity .35s ease;
}
.da-status.swapping { opacity: 0 }

/* ---- Scene 2: tombstone (the "Done" view) ---------------------------- */

.da-tomb {
  position: relative;
  width: 110px;
  height: 130px;
  animation: da-tomb-rise .9s cubic-bezier(.22, 1.2, .36, 1) both;
}
.da-tomb-stone {
  position: absolute;
  inset: 0 0 14px 0;
  border-radius: 55px 55px 8px 8px;
  background: linear-gradient(180deg, #6b7077 0%, #41464d 100%);
  border: 1.5px solid rgba(0,0,0,.45);
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,.18),
    inset 0 -3px 6px rgba(0,0,0,.35),
    0 6px 14px rgba(0,0,0,.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #d8dde3;
  text-shadow: 0 1px 0 rgba(0,0,0,.5);
  font-family: var(--mono);
}
.da-tomb-rip {
  font-weight: 800;
  font-size: .72rem;
  letter-spacing: .12em;
  margin-top: 16px;
  padding-inline: 6px;
  max-width: 100%;
  white-space: nowrap;
  text-align: center;
}
.da-tomb-id {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .04em;
  opacity: .92;
}
.da-tomb-dates {
  font-size: .58rem;
  opacity: .7;
  letter-spacing: .04em;
}
.da-tomb-grass {
  position: absolute;
  bottom: 0;
  left: -8px;
  right: -8px;
  height: 14px;
  border-radius: 3px;
  background:
    radial-gradient(circle at 10% 100%, #2d8a4e 0 4px, transparent 5px),
    radial-gradient(circle at 30% 100%, #2d8a4e 0 5px, transparent 6px),
    radial-gradient(circle at 55% 100%, #2d8a4e 0 4px, transparent 5px),
    radial-gradient(circle at 80% 100%, #2d8a4e 0 5px, transparent 6px),
    linear-gradient(180deg, transparent 0%, #1f6b3a 60%, #16562d 100%);
}

/* Ghost waving goodbye, hovers next to the stone */
.da-ghost {
  position: absolute;
  top: 20px;
  right: -34px;
  font-size: 26px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.4));
  animation: da-ghost-float 2.4s ease-in-out infinite;
}

/* Confetti — simple coloured squares falling once on entry */
.da-confetti {
  position: absolute;
  top: -10px;
  width: 6px;
  height: 10px;
  opacity: 0;
  animation: da-confetti-fall 1.6s ease-in forwards;
}

/* ---- Keyframes -------------------------------------------------------- */

@keyframes da-bot-shake {
  0%, 100% { transform: translateY(0)    rotate(0deg) }
  25%      { transform: translateY(-1px) rotate(-2deg) }
  75%      { transform: translateY(0)    rotate(2deg) }
}
@keyframes da-bot-fade {
  0%   { opacity: 1; filter: blur(0)     grayscale(0)   }
  60%  { opacity: .85; filter: blur(0)   grayscale(.4)  }
  90%  { opacity: .25; filter: blur(2px) grayscale(.9)  }
  100% { opacity: 0;   filter: blur(4px) grayscale(1)   }
}
@keyframes da-bot-blink {
  0%, 92%, 100% { transform: scaleY(1) }
  94%, 98%      { transform: scaleY(.1) }
}
@keyframes da-led-blink {
  0%, 100% { opacity: 1;  box-shadow: 0 0 6px #ff5e5e }
  50%      { opacity: .35; box-shadow: 0 0 2px #ff5e5e }
}
@keyframes da-core-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1);   box-shadow: 0 0 8px #17dc94 }
  50%      { transform: translate(-50%, -50%) scale(1.2); box-shadow: 0 0 14px #17dc94 }
}
@keyframes da-particle-rise {
  0%   { transform: translateY(0)    scale(.4); opacity: 0 }
  20%  { opacity: .9 }
  100% { transform: translateY(-110px) scale(1.1); opacity: 0 }
}
@keyframes da-broom-sweep {
  0%   { transform: translateX(0)    rotate(-15deg) }
  50%  { transform: translateX(220px) rotate(15deg) }
  100% { transform: translateX(0)    rotate(-15deg) }
}
@keyframes da-tomb-rise {
  0%   { opacity: 0; transform: translateY(28px) scale(.8) }
  100% { opacity: 1; transform: translateY(0)    scale(1)  }
}
@keyframes da-ghost-float {
  0%, 100% { transform: translateY(0)    rotate(-4deg) }
  50%      { transform: translateY(-7px) rotate(4deg)  }
}
@keyframes da-confetti-fall {
  0%   { opacity: 0; transform: translateY(0)    rotate(0deg)   }
  10%  { opacity: 1 }
  100% { opacity: 0; transform: translateY(150px) rotate(540deg) }
}

@media (prefers-reduced-motion: reduce) {
  .da-bot,
  .da-bot.dying,
  .da-bot-eye,
  .da-bot-antenna::after,
  .da-bot-core,
  .da-particle,
  .da-broom,
  .da-ghost,
  .da-confetti,
  .da-tomb {
    animation: none !important;
  }
  .da-bot.dying { opacity: .55 }
}
