/* ============================================================================
 * public/css/anime-mentor.css
 * Styling for the fixed bottom-left anime-style mentor mascot that overlays
 * the mission screen on /student/missions/<slug>. See public/js/anime-mentor.js
 * for the rotation pool + event integration. Palette mirrors the existing
 * .mentor-companion strip in public/css/app.css (dark glass #0f172a with the
 * #67e8f9 cyan accent) so the avatar reads as part of the same mentor family
 * rather than a parallel UI element.
 *
 * Stack-rank: 950 keeps it BELOW the floating #mentor-panel (z=1000) so the
 * existing chat panel still wins focus when the student opens it. Above the
 * generic mission card so it doesn't slip behind quiz UI on long pages.
 * ============================================================================
 */

.anime-mentor-avatar {
  position: fixed;
  left: 18px;
  bottom: 18px;
  width: 110px;
  height: 110px;
  z-index: 950;
  pointer-events: auto;
  display: block;
  will-change: transform;
  animation: anime-mentor-float 3s ease-in-out infinite;
  filter: drop-shadow(0 4px 12px rgba(15, 23, 42, 0.55));
  cursor: pointer;
}

.anime-mentor-avatar .anime-mentor-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.anime-mentor-avatar.is-celebrating {
  animation: anime-mentor-celebrate 600ms ease-out 1;
}

/* Victory pulse — single-cycle companion to .is-celebrating, longer duration. */
.anime-mentor-avatar.is-victorious {
  animation: anime-mentor-victory 1200ms ease-out 1;
}

.anime-mentor-bubble {
  position: fixed;
  left: 142px;
  bottom: 28px;
  z-index: 951;
  max-width: 220px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.92);
  color: #e0f7ff;
  border: 1px solid rgba(103, 232, 249, 0.45);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
  opacity: 1;
  transition: opacity 350ms ease, transform 350ms ease;
  pointer-events: auto;
}

.anime-mentor-bubble.is-hidden {
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
}

.anime-mentor-bubble::before {
  content: "";
  position: absolute;
  left: -10px;
  bottom: 14px;
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-right: 10px solid rgba(15, 23, 42, 0.92);
}

.anime-mentor-bubble::after {
  content: "";
  position: absolute;
  left: -11px;
  bottom: 14px;
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-right: 11px solid rgba(103, 232, 249, 0.45);
}

@keyframes anime-mentor-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

@keyframes anime-mentor-celebrate {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

@keyframes anime-mentor-victory {
  0%   { transform: scale(1)   rotate(0deg); }
  25%  { transform: scale(1.20) rotate(-5deg); }
  60%  { transform: scale(1.10) rotate(4deg); }
  100% { transform: scale(1)   rotate(0deg); }
}

/* ── Entrance: one-shot fade-in before the float loop resumes ─────────
   JS adds .is-entering on init and removes it on animationend so the
   existing anime-mentor-float 3s loop starts cleanly. */
@keyframes anime-mentor-enter {
  0%   { opacity: 0; transform: translateY(12px) scale(0.7); }
  100% { opacity: 1; transform: translateY(0)    scale(1);   }
}

.anime-mentor-avatar.is-entering {
  animation: anime-mentor-enter 450ms ease-out 1 forwards;
}

/* ── Keyboard affordance: screen-reader / keyboard users can reach the
   mascot for click-for-narration. The avatar's tabindex=0 + role=button
   is wired in public/js/anime-mentor.js. */
.anime-mentor-avatar:focus-visible {
  outline: 2px solid #67e8f9;
  outline-offset: 4px;
}

/* ── Mute button: small ✕ in the avatar's top-right corner. Hidden by
   default so it does not clutter the mascot; surfaces on hover/focus
   so the affordance is discoverable without permanently covering the
   SVG. Public JS injects the element on init. */
.anime-mentor-mute-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.85);
  color: #67e8f9;
  border: 1px solid rgba(103, 232, 249, 0.55);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 952;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  transition: transform 150ms ease, background 150ms ease;
}
.anime-mentor-mute-btn:hover,
.anime-mentor-mute-btn:focus-visible {
  background: rgba(15, 23, 42, 1);
  transform: scale(1.08);
  outline: none;
}
.anime-mentor-avatar:hover .anime-mentor-mute-btn,
.anime-mentor-avatar:focus-within .anime-mentor-mute-btn {
  display: flex;
}

/* ── Mute state: both the avatar and bubble vanish together when the
   student taps the ✕ (persisted to localStorage as
   chq_anime_mentor_muted=1). Important: precedence over .is-hidden,
   so the bubble stays hidden but the avatar visually disappears too. */
.anime-mentor-avatar.is-muted,
.anime-mentor-bubble.is-muted {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .anime-mentor-avatar {
    animation: none;
  }
  .anime-mentor-avatar.is-celebrating {
    animation: none;
    transform: scale(1);
  }
  .anime-mentor-avatar.is-victorious {
    animation: none;
    transform: scale(1) rotate(0deg);
  }
  .anime-mentor-avatar.is-entering {
    animation: none;
    opacity: 1;
    transform: none;
  }
  .anime-mentor-bubble {
    transition: opacity 200ms ease;
  }
}
