/* ============================================================
   BLOB – D&D Slime Mascot
   Blauer Schleim-Blob, unten rechts, mit Sprechblase
   ============================================================ */

/* Container */
#blob-container {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: var(--z-blob);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}

/* Sprechblase */
#blob-speech {
  pointer-events: auto;
  max-width: 280px;
  background: #1a2230;
  color: #e7eaf0;
  border: 1.5px solid #2a3a55;
  border-radius: 14px 14px 4px 14px;
  padding: 12px 16px;
  font-size: 0.88em;
  line-height: 1.55;
  box-shadow: 0 4px 20px rgba(0,80,200,0.15), 0 0 30px rgba(60,140,255,0.08);
  opacity: 0;
  transform: translateY(10px) scale(0.95);
  transition: opacity 0.35s ease, transform 0.35s ease;
  cursor: pointer;
  position: relative;
}
#blob-speech.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}
#blob-speech::after {
  content: '';
  position: absolute;
  bottom: -8px;
  right: 20px;
  width: 0; height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid #1a2230;
  filter: drop-shadow(0 1px 2px rgba(0,80,200,0.2));
}
#blob-speech .blob-close {
  position: absolute;
  top: 4px;
  right: 8px;
  background: none;
  border: none;
  color: #5a6a7a;
  font-size: 1.1em;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
}
#blob-speech .blob-close:hover { color: #e7eaf0; }
#blob-speech-text { padding-right: 16px; }

/* Blob Avatar (klickbar) */
#blob-avatar {
  pointer-events: auto;
  width: 72px;
  height: 72px;
  cursor: pointer;
  position: relative;
  transition: transform 0.2s ease;
}
#blob-avatar:hover {
  transform: scale(1.08);
}
#blob-avatar:active {
  transform: scale(0.95);
}

/* Blob SVG */
#blob-avatar svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 4px 12px rgba(40,120,255,0.35));
}

/* Schwabbel-Animation */
@keyframes blobWobble {
  0%   { d: path("M36 62 C16 62 6 52 6 38 C6 18 18 6 36 6 C54 6 66 18 66 38 C66 52 56 62 36 62Z"); }
  25%  { d: path("M36 63 C14 61 4 50 5 37 C7 17 20 5 36 5 C52 5 65 17 67 37 C68 50 58 61 36 63Z"); }
  50%  { d: path("M36 64 C18 63 8 53 7 39 C5 19 17 4 36 4 C55 4 67 19 65 39 C64 53 54 63 36 64Z"); }
  75%  { d: path("M36 63 C14 62 5 51 4 38 C6 16 19 7 36 7 C53 7 66 16 68 38 C67 51 58 62 36 63Z"); }
  100% { d: path("M36 62 C16 62 6 52 6 38 C6 18 18 6 36 6 C54 6 66 18 66 38 C66 52 56 62 36 62Z"); }
}

#blob-body {
  animation: blobWobble 3s ease-in-out infinite;
}

/* Augen-Blinzeln */
@keyframes blobBlink {
  0%, 90%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.1); }
}

#blob-eyes {
  animation: blobBlink 4s ease-in-out infinite;
  transform-origin: center;
}

/* Leichtes Schweben */
@keyframes blobFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

#blob-avatar {
  animation: blobFloat 2.5s ease-in-out infinite;
}

/* Aufmerksamkeits-Pulse wenn Blob was zu sagen hat */
@keyframes blobPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(60,140,255,0.4); }
  50% { box-shadow: 0 0 0 8px rgba(60,140,255,0); }
}
#blob-avatar.has-message {
  animation: blobFloat 2.5s ease-in-out infinite, blobPulse 2s ease-in-out infinite;
  border-radius: 50%;
}

/* Eingangs-Animation */
@keyframes blobEnter {
  0% { opacity: 0; transform: translateY(40px) scale(0.5); }
  60% { transform: translateY(-6px) scale(1.05); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
#blob-container.entering #blob-avatar {
  animation: blobEnter 0.7s ease-out forwards;
}

/* Spezial: Blob freut sich */
@keyframes blobBounce {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-12px) rotate(-5deg); }
  50% { transform: translateY(0) rotate(0deg); }
  75% { transform: translateY(-8px) rotate(5deg); }
}
#blob-avatar.happy {
  animation: blobBounce 0.6s ease-in-out;
}

/* ============================================================
   IDLE-ANIMATIONEN (zufällig)
   ============================================================ */

/* 1. Aufblähen */
@keyframes blobInflate {
  0%, 100% { transform: scale(1); }
  30% { transform: scale(1.35, 1.2); }
  50% { transform: scale(1.4, 1.15); }
  70% { transform: scale(0.9, 1.1); }
}
#blob-avatar.anim-inflate {
  animation: blobInflate 2s ease-in-out;
}

/* 2. Blasen (Container für JS-generierte Bubble-Elemente) */
@keyframes bubbleRise {
  0% { opacity: 0.8; transform: translateY(0) scale(0.5); }
  50% { opacity: 0.6; transform: translateY(-30px) scale(1); }
  100% { opacity: 0; transform: translateY(-60px) scale(0.3); }
}
.blob-bubble {
  position: absolute;
  width: 8px; height: 8px;
  background: radial-gradient(circle at 30% 30%, rgba(150,210,255,0.8), rgba(60,140,255,0.3));
  border-radius: 50%;
  pointer-events: none;
  animation: bubbleRise 1.5s ease-out forwards;
}

/* 3. Einschlafen */
@keyframes blobSleep {
  0%, 100% { transform: translateY(0) scaleY(1); }
  20% { transform: translateY(4px) scaleY(0.85); }
  40%, 80% { transform: translateY(6px) scaleY(0.8); }
}
#blob-avatar.anim-sleep {
  animation: blobSleep 3s ease-in-out;
}
#blob-avatar.anim-sleep #blob-eyes {
  animation: none;
  transform: scaleY(0.05);
}
/* Z-Z-Z Partikel */
@keyframes zzFloat {
  0% { opacity: 0; transform: translate(0, 0) rotate(-10deg) scale(0.5); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: translate(15px, -35px) rotate(10deg) scale(1.2); }
}
.blob-zzz {
  position: absolute;
  top: 5px; right: -5px;
  font-size: 14px;
  font-weight: 800;
  color: #6ec6ff;
  pointer-events: none;
  animation: zzFloat 1.2s ease-out forwards;
  text-shadow: 0 0 6px rgba(60,140,255,0.5);
}

/* 4. Regenbogen-Farbwechsel */
@keyframes blobRainbow {
  0%   { filter: drop-shadow(0 4px 12px rgba(40,120,255,0.35)) hue-rotate(0deg); }
  25%  { filter: drop-shadow(0 4px 12px rgba(255,100,100,0.35)) hue-rotate(90deg); }
  50%  { filter: drop-shadow(0 4px 12px rgba(100,255,100,0.35)) hue-rotate(180deg); }
  75%  { filter: drop-shadow(0 4px 12px rgba(255,100,255,0.35)) hue-rotate(270deg); }
  100% { filter: drop-shadow(0 4px 12px rgba(40,120,255,0.35)) hue-rotate(360deg); }
}
#blob-avatar.anim-rainbow svg {
  animation: blobRainbow 2s ease-in-out;
}

/* 5. Hüpfen */
@keyframes blobHop {
  0%, 100% { transform: translateY(0); }
  15% { transform: translateY(-16px); }
  25% { transform: translateY(0); }
  40% { transform: translateY(-12px); }
  50% { transform: translateY(0); }
  62% { transform: translateY(-6px); }
  70% { transform: translateY(0); }
}
#blob-avatar.anim-hop {
  animation: blobHop 1.5s ease-in-out;
}

/* 6. Schütteln */
@keyframes blobShake {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  10% { transform: translateX(-4px) rotate(-4deg); }
  20% { transform: translateX(4px) rotate(4deg); }
  30% { transform: translateX(-3px) rotate(-3deg); }
  40% { transform: translateX(3px) rotate(3deg); }
  50% { transform: translateX(-2px) rotate(-2deg); }
  60% { transform: translateX(2px) rotate(2deg); }
  70% { transform: translateX(-1px) rotate(0deg); }
  80% { transform: translateX(1px) rotate(0deg); }
}
#blob-avatar.anim-shake {
  animation: blobShake 0.8s ease-in-out;
}

/* 7. Augen rollen */
@keyframes eyeRoll {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(2px, -2px); }
  50% { transform: translate(0, 2px); }
  75% { transform: translate(-2px, -1px); }
}
#blob-avatar.anim-eyeroll #blob-eyes {
  animation: eyeRoll 1.5s ease-in-out;
}

/* 8. Zerplatzen & reformieren */
@keyframes blobSplat {
  0% { transform: scale(1); opacity: 1; }
  20% { transform: scale(1.3, 0.7); opacity: 1; }
  35% { transform: scale(0.2); opacity: 0; }
  36%, 65% { transform: scale(0); opacity: 0; }
  80% { transform: scale(1.15); opacity: 1; }
  90% { transform: scale(0.95); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
#blob-avatar.anim-splat {
  animation: blobSplat 2.5s ease-in-out;
}
/* Splat-Tropfen */
@keyframes splatDrop {
  0% { opacity: 1; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.3); }
}
.blob-splat-drop {
  position: absolute;
  width: 10px; height: 10px;
  background: radial-gradient(circle, #6ec6ff, #1a5a9e);
  border-radius: 50%;
  pointer-events: none;
  animation: splatDrop 0.8s ease-out forwards;
}

/* ── Helden-Verwandlung ────────────────────────────────── */
.blob-hero-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 15%;
  opacity: 0;
  transition: opacity 0.5s ease;
  z-index: 1;
  box-shadow: 0 0 12px rgba(209,74,74,.5);
}
.blob-hero-img.visible {
  opacity: 1;
}
#blob-avatar.anim-hero svg {
  opacity: 0;
  transition: opacity 0.5s ease;
}
#blob-avatar.anim-hero {
  animation: heroGlow 2s ease-in-out infinite;
}
@keyframes heroGlow {
  0%, 100% { filter: drop-shadow(0 0 6px rgba(209,74,74,.4)); }
  50% { filter: drop-shadow(0 0 14px rgba(209,74,74,.7)); }
}

/* Responsive */
@media (max-width: 600px) {
  #blob-avatar { width: 56px; height: 56px; }
  #blob-speech { max-width: 220px; font-size: 0.82em; }
  #blob-container { bottom: 10px; right: 10px; }
}
