/* PimsyCharacter.css */

.pimsy-character {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.5rem 1rem 0;
}

.pimsy-lottie-wrap {
  width: clamp(250px, 42vh, 520px);
  height: clamp(250px, 42vh, 520px);
  position: relative;
  transition: filter 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Premium Mood Aura */
.pimsy-lottie-wrap::after {
  content: "";
  position: absolute;
  inset: 15%;
  background: radial-gradient(circle, var(--aura-color, rgba(255, 96, 160, 0.2)) 0%, transparent 70%);
  z-index: -1;
  filter: blur(40px);
  opacity: 0.6;
  transition: background 0.8s ease;
  animation: auraPulse 4s ease-in-out infinite;
}

@keyframes auraPulse {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.15); opacity: 0.8; }
}

[data-state="idle"] { --aura-color: rgba(255, 96, 160, 0.2); }
[data-state="listening"] { --aura-color: rgba(71, 85, 105, 0.3); }
[data-state="thinking"] { --aura-color: rgba(255, 160, 0, 0.25); }
[data-state="speaking"] { --aura-color: rgba(255, 96, 160, 0.4); }
[data-state="dancing"] { --aura-color: rgba(139, 92, 246, 0.35); }
[data-state="mask"] { --aura-color: rgba(34, 197, 94, 0.3); }

/* All state animations live in stacked layers; only the active one is visible */
.lottie-layer {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.05s ease;
  pointer-events: none;
  will-change: opacity;
  transform: translateZ(0);
}
.lottie-layer-active {
  opacity: 1;
  pointer-events: auto;
}

.pimsy-lottie-wrap svg {
  overflow: visible !important;
}

.pimsy-label {
  font-size: 1rem;
  font-weight: 700;
  color: #E0407A;
  letter-spacing: 0.04em;
}

/* Speaking pulse glow */
@keyframes speak-glow {
  0%,100% { filter: drop-shadow(0 6px 18px rgba(240,112,152,0.30)); }
  50%     { filter: drop-shadow(0 8px 28px rgba(240,112,152,0.60)); }
}

/* Listening bounce */
@keyframes listen-bob {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-4px); }
}
[data-state="listening"] .pimsy-lottie-wrap {
  animation: listen-bob 1.4s ease-in-out infinite;
}

/* Thinking slow float */
@keyframes think-float {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-6px); }
}
[data-state="thinking"] .pimsy-lottie-wrap {
  animation: think-float 3.2s ease-in-out infinite;
}

/* Idle gentle float */
@keyframes idle-float {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-4px); }
}
[data-state="idle"] .pimsy-lottie-wrap {
  animation: idle-float 4s ease-in-out infinite;
}

/* Speaking head-bob — subtle nod in sync with talking energy */
@keyframes speak-bob {
  0%,100% { transform: translateY(0)    rotate(0deg);   }
  25%     { transform: translateY(-2px) rotate(-0.5deg); }
  75%     { transform: translateY(1px)  rotate(0.3deg);  }
}
[data-state="speaking"] .pimsy-lottie-wrap {
  animation: none;
}

/* ── Micro-expressions ───────────────────────────────────────────────────── */
.speaking-wrap { transition: transform 0.25s ease; }

.emotion-happy    { animation: expr-happy    0.9s ease-in-out; }
.emotion-sad      { animation: expr-sad      0.9s ease-in-out; }
.emotion-surprised{ animation: expr-surprised 0.8s ease-in-out; }
.emotion-thinking { animation: expr-thinking  1.1s ease-in-out; }

@keyframes expr-happy {
  0%,100% { transform: scale(1)      rotate(0deg);  }
  50%     { transform: scale(1.06)   rotate(1deg);  }
}
@keyframes expr-sad {
  0%,100% { transform: translateY(0) rotate(0deg);  }
  50%     { transform: translateY(3px) rotate(-1deg); }
}
@keyframes expr-surprised {
  0%,100% { transform: scale(1);    }
  30%     { transform: scale(1.08) translateY(-4px); }
}
@keyframes expr-thinking {
  0%,100% { transform: rotate(0deg);   }
  40%     { transform: rotate(-2deg) translateY(-2px); }
}

@media (max-width: 640px) {
  /* Character stays prominent on mobile — chat is capped above */
  .pimsy-lottie-wrap { width: clamp(240px, 64vw, 340px); height: clamp(240px, 64vw, 340px); }
}

/* ══════════════════════════════════════════════════════════════════════════════
   EASTER EGG 1 — The Spin (click Pimsy to spin 360°)
══════════════════════════════════════════════════════════════════════════════ */
.pimsy-lottie-wrap {
  cursor: pointer;
}
.pimsy-lottie-wrap:hover {
  filter: drop-shadow(0 6px 24px rgba(240, 112, 152, 0.50));
}
.pimsy-lottie-wrap:active {
  transform: scale(0.96);
}

@keyframes pimsy-spin-once {
  0%   { transform: rotate(0deg)   scale(1);    }
  40%  { transform: rotate(200deg) scale(1.08); }
  100% { transform: rotate(360deg) scale(1);    }
}
.pimsy-spinning {
  animation: pimsy-spin-once 0.95s cubic-bezier(0.36, 0.07, 0.19, 0.97) !important;
}

/* ══════════════════════════════════════════════════════════════════════════════
   EASTER EGG 3 — Nightcap (ZZZ overlay after 10 PM)
══════════════════════════════════════════════════════════════════════════════ */
.pimsy-nighttime .pimsy-lottie-wrap {
  filter: drop-shadow(0 6px 18px rgba(148, 163, 184, 0.35)) brightness(0.90) sepia(0.12);
}

.zzz-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
}

@keyframes zzz-rise {
  0%   { transform: translateY(0px)  scale(0.7) rotate(-5deg); opacity: 0;   }
  15%  { opacity: 1; }
  80%  { opacity: 0.85; }
  100% { transform: translateY(-72px) scale(1.3) rotate(5deg);  opacity: 0; }
}

.zzz-bubble {
  position: absolute;
  font-weight: 800;
  font-family: 'Inter', sans-serif;
  color: #94a3b8;
  animation: zzz-rise 3.6s ease-out infinite;
  text-shadow: 0 1px 6px rgba(148, 163, 184, 0.45);
  user-select: none;
  letter-spacing: -0.02em;
}

.pimsy-sleeping {
  filter: grayscale(0.4) brightness(0.7) sepia(0.1);
  animation: pimsy-breathing 3.5s ease-in-out infinite !important;
}

@media (max-width: 640px) {
  .pimsy-sleeping {
    filter: grayscale(0.5) brightness(0.65) sepia(0.15);
  }
}

@keyframes pimsy-breathing {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.025); }
}

/* Ensure ZZZ bubbles show up nicely during sleep */
.pimsy-sleeping .zzz-overlay {
  opacity: 1;
  display: block;
}

/* Three ZZZ bubbles staggered in size and position */
.zzz-bubble:nth-child(1) {
  font-size: 1.2rem;
  left: 58%;
  top: 22%;
  animation-delay: 0s;
}
.zzz-bubble:nth-child(2) {
  font-size: 0.95rem;
  left: 67%;
  top: 12%;
  animation-delay: 1.2s;
}
.zzz-bubble:nth-child(3) {
  font-size: 0.70rem;
  left: 74%;
  top: 5%;
  animation-delay: 2.4s;
}

/* ══════════════════════════════════════════════════════════════════════════════
   EASTER EGG 4 — Enemies (Double-click Pimsy to spawn 3 Zany Faces)
   ══════════════════════════════════════════════════════════════════════════════ */
.pimsy-enemy {
  position: absolute;
  width: 140px;
  height: 140px;
  z-index: 50;
  pointer-events: none;
  animation: enemy-pop 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  filter: drop-shadow(0 8px 16px rgba(0,0,0,0.15));
}

@keyframes enemy-pop {
  0% { transform: scale(0) rotate(-20deg); opacity: 0; }
  60% { transform: scale(1.15) rotate(10deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

@media (max-width: 640px) {
  .pimsy-enemy {
    width: 90px;
    height: 90px;
  }
}
