/* ============================================
   Walkie Mascot — Animations & Styling
   WalkieTalk French Games
   ============================================
   Body-level animations target .mascot-svg directly
   so they fire regardless of wrapper structure
   (getMascotSVG used without mascotHTML wrapper).

   Sub-element animations target named groups
   inside the SVG for independent layered motion.
   ============================================ */

/* ---- Base ---- */

.mascot-svg {
  display: block;
  overflow: visible; /* allow sparkles / arms that extend outside viewBox */
}

.mascot-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
}

.mascot-char-wrap {
  display: flex;
  justify-content: center;
}

/* ============================================
   Keyframes — Body Level
   ============================================ */

/* Gentle float / bob */
@keyframes mascot-float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}

/* Playful wiggle with more character */
@keyframes mascot-wiggle {
  0%, 100% { transform: rotate(0deg) translateY(0); }
  12%       { transform: rotate(-7deg) translateY(-3px); }
  30%       { transform: rotate(7deg)  translateY(-5px); }
  50%       { transform: rotate(-5deg) translateY(-3px); }
  70%       { transform: rotate(4deg)  translateY(-2px); }
  88%       { transform: rotate(-2deg) translateY(-1px); }
}

/* Bounce-celebrate with squash and stretch */
@keyframes mascot-bounce {
  0%   { transform: translateY(0)     scaleY(1)    scaleX(1);    }
  12%  { transform: translateY(2px)   scaleY(0.82) scaleX(1.16); } /* squash — anticipation */
  28%  { transform: translateY(-20px) scaleY(1.12) scaleX(0.90); } /* stretch — going up */
  48%  { transform: translateY(-22px) scaleY(1.06) scaleX(0.95) rotate(-5deg); } /* peak */
  65%  { transform: translateY(-18px) scaleY(1.06) scaleX(0.95) rotate(4deg);  }
  80%  { transform: translateY(2px)   scaleY(0.84) scaleX(1.14); } /* squash — landing */
  90%  { transform: translateY(-7px)  scaleY(1.04) scaleX(0.98); } /* small rebound */
  100% { transform: translateY(0)     scaleY(1)    scaleX(1);    }
}

/* Entry pop-in */
@keyframes mascot-entry {
  0%   { transform: scale(0.15) translateY(24px); opacity: 0; }
  60%  { transform: scale(1.1)  translateY(-6px); opacity: 1; }
  78%  { transform: scale(0.95) translateY(3px);  opacity: 1; }
  90%  { transform: scale(1.03) translateY(-1px); opacity: 1; }
  100% { transform: scale(1)    translateY(0);    opacity: 1; }
}

/* ============================================
   Keyframes — Sub-Element Level
   ============================================ */

/* Eye blink — double-blink at end of each cycle for character */
@keyframes walkie-blink {
  0%, 86%, 100% { transform: scaleY(1); }
  90%            { transform: scaleY(0.06); }  /* first close */
  92%            { transform: scaleY(1); }      /* reopen */
  95%            { transform: scaleY(0.06); }  /* double-blink close */
  97%            { transform: scaleY(1); }      /* reopen */
}

/* Antenna sway — pivot from shaft base, short period for wobble feel */
@keyframes walkie-antenna-sway {
  0%, 100% { transform: rotate(0deg); }
  28%       { transform: rotate(5deg); }
  72%       { transform: rotate(-4deg); }
}

/* Beret bob — slow, subtle, slightly asymmetric */
@keyframes walkie-beret-bob {
  0%, 100% { transform: rotate(0deg); }
  35%       { transform: rotate(2deg); }
  72%       { transform: rotate(-1.5deg); }
}

/* Torso breathe — very subtle vertical pulse */
@keyframes walkie-breathe {
  0%, 100% { transform: scaleY(1); }
  50%       { transform: scaleY(1.026) translateY(-0.5px); }
}

/* ============================================
   Body-Level Animation Application
   Targets .mascot-svg directly so it works
   whether or not there is a .mascot-char-wrap parent.
   ============================================ */

.mascot-svg.mascot-mood-idle {
  animation: mascot-float 3.4s ease-in-out infinite;
}

.mascot-svg.mascot-mood-happy {
  animation: mascot-wiggle 1.8s ease-in-out infinite;
}

.mascot-svg.mascot-mood-celebrating {
  animation: mascot-bounce 0.9s ease-in-out infinite;
}

.mascot-svg.mascot-mood-encouraging,
.mascot-svg.mascot-mood-thinking {
  animation: mascot-float 4s ease-in-out infinite;
}

/* ============================================
   Sub-Element Animation Application
   transform-box: fill-box makes transform-origin
   relative to the element's own bounding box.
   ============================================ */

/* Eyes — blink on moods with round eyes only */
.walkie-eyes {
  transform-box: fill-box;
  transform-origin: center center;
}

.mascot-svg.mascot-mood-idle .walkie-eyes,
.mascot-svg.mascot-mood-thinking .walkie-eyes,
.mascot-svg.mascot-mood-encouraging .walkie-eyes {
  animation: walkie-blink 4.5s ease-in-out infinite;
}

/* Antenna — pivot from base of shaft */
.walkie-antenna {
  transform-box: fill-box;
  transform-origin: center bottom;
  animation: walkie-antenna-sway 2.3s ease-in-out infinite;
}

/* Beret — pivot from brim (sits on the head) */
.walkie-beret {
  transform-box: fill-box;
  transform-origin: center bottom;
  animation: walkie-beret-bob 5.5s ease-in-out infinite;
}

/* Torso breathe — idle only */
.walkie-torso {
  transform-box: fill-box;
  transform-origin: center center;
}

.mascot-svg.mascot-mood-idle .walkie-torso {
  animation: walkie-breathe 3.1s ease-in-out infinite;
}

/* ---- Entry animation ---- */
.mascot-entry {
  animation: mascot-entry 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* ============================================
   Speech Bubble
   ============================================ */

.mascot-speech-bubble {
  background: var(--bg-primary, #ffffff);
  border: 2px solid var(--border-color, rgba(0,0,0,0.12));
  border-radius: 14px;
  padding: 0.55rem 1.05rem;
  font-size: 0.875rem;
  color: var(--text-primary);
  text-align: center;
  position: relative;
  max-width: 220px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  line-height: 1.45;
  font-weight: 500;
  order: -1; /* appear above the character in flex column */
}

/* Tail pointing DOWN toward the character */
.mascot-speech-bubble::after {
  content: '';
  position: absolute;
  bottom: -9px;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--bg-primary, #ffffff);
}

.mascot-speech-bubble::before {
  content: '';
  position: absolute;
  bottom: -12px;
  left: 50%;
  transform: translateX(-50%);
  border: 7px solid transparent;
  border-top-color: var(--border-color, rgba(0,0,0,0.12));
}

/* ============================================
   Per-Touchpoint Styles
   ============================================ */

/* ---- 1. Landing Page Hero ---- */

.mascot-hero-wrap {
  position: relative;
  z-index: 2;
  margin: 0 auto 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.mascot-hero-wrap .mascot-svg {
  filter: drop-shadow(0 12px 24px rgba(27,42,74,0.25));
}

/* ---- 2. Game Select hint strip ---- */

.mascot-game-hint {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0.75rem 1.25rem;
  margin-bottom: 1.5rem;
}

.mascot-game-hint .mascot-svg {
  flex-shrink: 0;
}

.mascot-game-hint-text {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
}

/* ---- 3. Celebration Modal ---- */

.celebrate-mascot {
  display: flex;
  justify-content: center;
  margin-bottom: 0.25rem;
}

.celebrate-mascot .mascot-svg {
  filter: drop-shadow(0 4px 10px rgba(27,42,74,0.18));
}

.celebrate-mascot-msg {
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: -0.25rem 0 0.5rem;
  line-height: 1.4;
}

/* ---- 4. Daily Widget ---- */

.dw-greeting-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.dw-mascot {
  flex-shrink: 0;
  line-height: 0;
}

.dw-mascot .mascot-svg {
  filter: drop-shadow(0 2px 5px rgba(27,42,74,0.15));
}

/* ---- 5. Chatbot Avatar ---- */

.chatbot-avatar.chatbot-avatar--walkie {
  width: 40px;
  height: 56px;
  border-radius: var(--radius-md, 10px);
  font-size: 0;
  overflow: hidden;
  padding: 0 2px;
  align-items: flex-end;
  background: linear-gradient(160deg, #E8842A 0%, #FF9A3C 100%);
}

.chatbot-avatar--walkie .mascot-svg {
  width: 36px;
  height: 53px;
  /* Chatbot avatar is small and decorative — suppress body float */
  animation: none !important;
}

/* Keep sub-element animations alive in chatbot (still blinks etc.) */
.chatbot-avatar--walkie .walkie-antenna { animation: walkie-antenna-sway 2.3s ease-in-out infinite; }
.chatbot-avatar--walkie .walkie-beret   { animation: walkie-beret-bob 5.5s ease-in-out infinite; }

/* ============================================
   Reduced Motion — all animations disabled
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  .mascot-svg,
  .walkie-eyes,
  .walkie-antenna,
  .walkie-beret,
  .walkie-torso,
  .mascot-entry,
  .mascot-char-wrap {
    animation: none !important;
  }
}

[data-reduce-motion="true"] .mascot-svg,
[data-reduce-motion="true"] .walkie-eyes,
[data-reduce-motion="true"] .walkie-antenna,
[data-reduce-motion="true"] .walkie-beret,
[data-reduce-motion="true"] .walkie-torso,
[data-reduce-motion="true"] .mascot-entry,
[data-reduce-motion="true"] .mascot-char-wrap {
  animation: none !important;
}
