/* ============================================================================
 * SD ISLAM INSANI KARAKTER KUN ANTA • MASCOT MOTION-GRAPHICS ENGINE CSS
 * 60 FPS GPU-Composited Only (transform + opacity) • WCAG 2.2 Reduced-Motion
 * ============================================================================ */

:root {
  --mascot-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --mascot-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

.mascot-root {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  user-select: none;
  -webkit-user-select: none;
  contain: layout style;
}

.mascot-stage {
  position: relative;
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  gap: 8px;
}

.mascot-actor {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  transform-origin: center bottom;
  will-change: transform, opacity;
}

.mascot-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

/* Size presets (explicit aspect ratio prevents CLS) */
.mascot-size-xs .mascot-actor { width: 42px; height: 56px; }
.mascot-size-sm .mascot-actor { width: 64px; height: 84px; }
.mascot-size-md .mascot-actor { width: 88px; height: 116px; }
.mascot-size-lg .mascot-actor { width: 120px; height: 158px; }
.mascot-size-hero .mascot-actor { width: 142px; height: 186px; }

/* Zero-filter GPU floor contact shadow */
.mascot-shadow {
  width: 68%;
  height: 10px;
  margin-top: -4px;
  border-radius: 9999px;
  background: radial-gradient(ellipse at center, rgba(11, 37, 69, 0.24) 0%, rgba(11, 37, 69, 0) 72%);
  transform-origin: center center;
  pointer-events: none;
}

/* High-contrast speech bubble */
.mascot-speech {
  position: relative;
  margin-bottom: 6px;
  padding: 6px 12px;
  border-radius: 16px;
  background: #FFFFFF;
  color: #0B2545;
  border: 1.5px solid #FDE68A;
  box-shadow: 0 8px 20px -4px rgba(11, 37, 69, 0.16);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  max-width: 240px;
  text-align: center;
}

/* Thinking dots (pure CSS) */
.mascot-dots {
  display: none;
  position: absolute;
  top: -8px;
  right: -6px;
  padding: 4px 8px;
  border-radius: 9999px;
  background: #0B2545;
  border: 1.5px solid #F59E0B;
  gap: 3px;
  align-items: center;
}
.mascot-actor[data-state="thinking"] .mascot-dots { display: inline-flex; }
.mascot-dots span {
  width: 5px;
  height: 5px;
  border-radius: 9999px;
  background: #FCD34D;
  animation: mascotDotPulse 1.1s infinite ease-in-out;
}
.mascot-dots span:nth-child(2) { animation-delay: 0.18s; }
.mascot-dots span:nth-child(3) { animation-delay: 0.36s; }

/* Sleeping Zzz (pure CSS) */
.mascot-zzz {
  display: none;
  position: absolute;
  top: -6px;
  right: -4px;
  font-size: 11px;
  font-weight: 900;
  color: #0B2545;
  background: #FEF3C7;
  border: 1px solid #F59E0B;
  border-radius: 9999px;
  padding: 1px 6px;
  animation: mascotZzzFloat 2.4s ease-in-out infinite;
}
.mascot-actor[data-state="sleeping"] .mascot-zzz { display: inline-block; }

/* Sparkles for celebrate state */
.mascot-sparkles {
  display: none;
  position: absolute;
  inset: -6px;
  pointer-events: none;
}
.mascot-actor[data-state="celebrate"] .mascot-sparkles { display: block; }
.mascot-sparkles i {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 9999px;
  background: #F59E0B;
  animation: mascotSparkPop 1.2s var(--mascot-spring) infinite;
}
.mascot-sparkles i:nth-child(1) { top: 6%; left: 8%; background: #10B981; }
.mascot-sparkles i:nth-child(2) { top: 4%; right: 10%; background: #F59E0B; animation-delay: 0.2s; }
.mascot-sparkles i:nth-child(3) { top: 28%; right: 0%; background: #8E8AFF; animation-delay: 0.4s; }

/* ============================================================================
 * 6 CORE GPU KEYFRAMES
 * ============================================================================ */
@keyframes mascotIdleBreathe {
  0%, 100% { transform: translate3d(0, 0, 0) scale3d(1, 1, 1); }
  50%      { transform: translate3d(0, -3px, 0) scale3d(0.992, 1.016, 1); }
}

@keyframes mascotWaveGreet {
  0%   { transform: translate3d(0, 0, 0) rotate(0deg) scale3d(1, 1, 1); }
  20%  { transform: translate3d(0, -6px, 0) rotate(-3.5deg) scale3d(1.02, 1.02, 1); }
  45%  { transform: translate3d(0, -3px, 0) rotate(3.5deg) scale3d(1.02, 1.02, 1); }
  70%  { transform: translate3d(0, -5px, 0) rotate(-2.5deg) scale3d(1.01, 1.01, 1); }
  100% { transform: translate3d(0, 0, 0) rotate(0deg) scale3d(1, 1, 1); }
}

@keyframes mascotCelebrateJump {
  0%   { transform: translate3d(0, 0, 0) scale3d(1, 1, 1); }
  20%  { transform: translate3d(0, 2px, 0) scale3d(1.06, 0.92, 1); }
  50%  { transform: translate3d(0, -14px, 0) scale3d(0.96, 1.05, 1); }
  75%  { transform: translate3d(0, 1px, 0) scale3d(1.03, 0.96, 1); }
  100% { transform: translate3d(0, 0, 0) scale3d(1, 1, 1); }
}

@keyframes mascotThinkSway {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(-3deg); }
  50%      { transform: translate3d(0, -3px, 0) rotate(2deg); }
}

@keyframes mascotAlertPerk {
  0%, 100% { transform: translate3d(0, 0, 0) scale3d(1, 1, 1); }
  30%      { transform: translate3d(0, -5px, 0) rotate(-2deg) scale3d(1.03, 1.03, 1); }
  60%      { transform: translate3d(0, -2px, 0) rotate(2deg) scale3d(1.02, 1.02, 1); }
}

@keyframes mascotSleepSway {
  0%, 100% { transform: translate3d(0, 2px, 0) scale3d(1, 0.98, 1); opacity: 0.92; }
  50%      { transform: translate3d(0, 0, 0) scale3d(0.99, 1.01, 1); opacity: 1; }
}

@keyframes mascotDotPulse {
  0%, 80%, 100% { transform: scale(0.75); opacity: 0.45; }
  40%           { transform: scale(1.15); opacity: 1; }
}

@keyframes mascotZzzFloat {
  0%, 100% { transform: translate3d(0, 0, 0); opacity: 0.75; }
  50%      { transform: translate3d(3px, -5px, 0); opacity: 1; }
}

@keyframes mascotSparkPop {
  0%, 100% { transform: scale(0.4); opacity: 0; }
  50%      { transform: scale(1.15); opacity: 0.95; }
}

/* State animation bindings (wave/celebrate/alert settle cleanly after 2 cycles <= 2.4s) */
.mascot-actor[data-state="idle"]      { animation: mascotIdleBreathe 3.6s var(--mascot-ease) infinite; }
.mascot-actor[data-state="wave"]      { animation: mascotWaveGreet 1.1s var(--mascot-spring) 2 both; }
.mascot-actor[data-state="celebrate"] { animation: mascotCelebrateJump 1.15s var(--mascot-spring) 2 both; }
.mascot-actor[data-state="thinking"]  { animation: mascotThinkSway 2.4s ease-in-out infinite; }
.mascot-actor[data-state="alert"]     { animation: mascotAlertPerk 0.95s var(--mascot-spring) 2 both; }
.mascot-actor[data-state="sleeping"]  { animation: mascotSleepSway 4.8s ease-in-out infinite; }

/* Second character slight phase offset for natural duo choreography */
.mascot-actor:nth-child(2)[data-state="idle"] { animation-delay: 0.6s; }
.mascot-actor:nth-child(2)[data-state="wave"] { animation-delay: 0.18s; }

/* Off-screen / background tab pause */
.mascot-paused .mascot-actor,
.mascot-paused .mascot-dots span,
.mascot-paused .mascot-zzz,
.mascot-paused .mascot-sparkles i {
  animation-play-state: paused !important;
}

/* ============================================================================
 * FLOATING "TANYA ANTA" AI COMPANION FAB (Collision-Safe Mobile & Desktop)
 * ============================================================================ */
#kunanta-ai-companion-fab {
  position: fixed;
  right: 16px;
  bottom: 20px;
  z-index: 8000;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 8px;
  border-radius: 9999px;
  background: linear-gradient(135deg, #0B2545 0%, #133E87 100%);
  color: #FFFFFF;
  border: 1.5px solid #F59E0B;
  box-shadow: 0 12px 28px -4px rgba(11, 37, 69, 0.35);
  cursor: pointer;
  min-height: 48px;
  transition: transform 0.25s var(--mascot-spring), opacity 0.2s ease;
}
#kunanta-ai-companion-fab:hover {
  transform: translateY(-2px) scale(1.03);
}
#kunanta-ai-companion-fab:active {
  transform: scale(0.96);
}
#kunanta-ai-companion-fab img {
  width: 34px;
  height: 44px;
  object-fit: contain;
  margin-top: -10px;
}

@media (max-width: 767px) {
  /* Sit cleanly above .floating-glass-bottom-nav (height ~60px + bottom 12px) */
  #kunanta-ai-companion-fab {
    bottom: 84px;
    right: 12px;
    padding: 4px 10px 4px 6px;
  }
}

/* ============================================================================
 * ACCESSIBILITY: WCAG 2.2 SC 2.3.3 REDUCED MOTION & "MODE TENANG"
 * ============================================================================ */
@media (prefers-reduced-motion: reduce) {
  .mascot-actor,
  .mascot-dots span,
  .mascot-zzz,
  .mascot-sparkles i {
    animation: none !important;
    transition: none !important;
    transform: none !important;
  }
}

body.kunanta-reduced-motion .mascot-actor,
body.kunanta-reduced-motion .mascot-dots span,
body.kunanta-reduced-motion .mascot-zzz,
body.kunanta-reduced-motion .mascot-sparkles i {
  animation: none !important;
  transition: none !important;
  transform: none !important;
}

@media print {
  .mascot-root,
  #kunanta-ai-companion-fab {
    display: none !important;
  }
}
