/* EduPlay — motion, characters, picture polish (offline) */

/* ── Theme: Haiwan (animals) ── */
@keyframes ep-paw-bounce {
  0%, 100% { transform: translateY(0) scale(1); }
  40% { transform: translateY(-14px) scale(1.08); }
  70% { transform: translateY(-4px) scale(1.02); }
}
@keyframes ep-swim {
  0%, 100% { transform: translateX(0) rotate(-2deg); }
  50% { transform: translateX(10px) rotate(2deg); }
}
@keyframes ep-fly {
  0%, 100% { transform: translate(0, 0) rotate(-3deg); }
  50% { transform: translate(6px, -12px) rotate(3deg); }
}
@keyframes ep-hop {
  0%, 100% { transform: translateY(0); }
  30% { transform: translateY(-18px); }
  50% { transform: translateY(-4px); }
  70% { transform: translateY(-12px); }
}
@keyframes ep-slither {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  25% { transform: translateX(4px) rotate(2deg); }
  75% { transform: translateX(-4px) rotate(-2deg); }
}
@keyframes ep-leaf-fall {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 0; }
  20% { opacity: 0.7; }
  100% { transform: translateY(100vh) rotate(280deg); opacity: 0; }
}
@keyframes ep-bubble-up {
  0% { transform: translateY(0) scale(0.6); opacity: 0.7; }
  100% { transform: translateY(-80px) scale(1.1); opacity: 0; }
}
@keyframes ep-paw-print {
  0% { transform: scale(0) rotate(-20deg); opacity: 0; }
  40% { transform: scale(1.2) rotate(5deg); opacity: 1; }
  100% { transform: scale(1) translateY(-30px); opacity: 0; }
}

.ep-anim-land { animation: ep-paw-bounce 1.8s ease-in-out infinite; }
.ep-anim-sea { animation: ep-swim 2.4s ease-in-out infinite; }
.ep-anim-air { animation: ep-fly 2s ease-in-out infinite; }
.ep-anim-hop { animation: ep-hop 1.4s ease-in-out infinite; }
.ep-anim-slither { animation: ep-slither 1.6s ease-in-out infinite; }

body[data-theme="haiwan"] {
  background: linear-gradient(180deg, #e8f5e9 0%, #c8e6c9 40%, #b2dfdb 100%) !important;
}
body[data-theme="haiwan"] .ep-ambient span {
  animation-name: ep-float, ep-paw-bounce;
}
body[data-theme="matematik"] {
  background: linear-gradient(180deg, #fff5f2 0%, #ffe8e0 100%) !important;
}
body[data-theme="english"] {
  background: linear-gradient(180deg, #f1f8f4 0%, #e0f2e9 100%) !important;
}
body[data-theme="bm"] {
  background: linear-gradient(180deg, #eef7ff 0%, #e3f0ff 100%) !important;
}

/* ── Keyframes ── */
@keyframes ep-bounce {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-12px) rotate(2deg); }
}
@keyframes ep-wiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-8deg); }
  75% { transform: rotate(8deg); }
}
@keyframes ep-pop {
  0% { transform: scale(0.4); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}
@keyframes ep-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes ep-pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(82, 183, 136, 0.35); }
  50% { box-shadow: 0 0 0 12px rgba(82, 183, 136, 0); }
}
@keyframes ep-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
@keyframes ep-correct-flash {
  0% { filter: brightness(1); }
  40% { filter: brightness(1.25); }
  100% { filter: brightness(1); }
}
@keyframes ep-star-spin {
  0% { transform: scale(0) rotate(-40deg); opacity: 0; }
  50% { transform: scale(1.3) rotate(10deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
@keyframes ep-slide-up {
  from { transform: translateY(18px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes ep-sparkle {
  0% { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(-40px) scale(0.4); opacity: 0; }
}
@keyframes ep-blob {
  0%, 100% { border-radius: 60% 40% 50% 50% / 50% 55% 45% 50%; }
  50% { border-radius: 45% 55% 48% 52% / 55% 45% 55% 45%; }
}
@keyframes ep-confetti-fall {
  0% { transform: translateY(-10vh) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0.9; }
}
@keyframes ep-heart {
  0% { transform: scale(0); opacity: 0; }
  40% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1) translateY(-20px); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Character: Comel the cat (CSS face) ── */
.ep-comel {
  --skin: #FFB347;
  --ear: #FF9F1C;
  --cheek: #FF8A80;
  width: 72px;
  height: 72px;
  position: relative;
  display: inline-block;
  animation: ep-bounce 2.4s ease-in-out infinite;
  flex-shrink: 0;
  user-select: none;
  pointer-events: none;
}
.ep-comel__head {
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 35% 30%, #ffd08a, var(--skin) 55%, #f29b2e);
  border-radius: 50%;
  position: relative;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12), inset 0 -6px 12px rgba(0, 0, 0, 0.06);
}
.ep-comel__ear {
  position: absolute;
  top: -6px;
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-bottom: 22px solid var(--ear);
  z-index: 0;
}
.ep-comel__ear--l { left: 6px; transform: rotate(-18deg); }
.ep-comel__ear--r { right: 6px; transform: rotate(18deg); }
.ep-comel__ear::after {
  content: "";
  position: absolute;
  left: -8px;
  top: 6px;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 12px solid #ffc4a8;
}
.ep-comel__eye {
  position: absolute;
  top: 38%;
  width: 10px;
  height: 12px;
  background: #2d3436;
  border-radius: 50%;
  z-index: 2;
}
.ep-comel__eye--l { left: 24%; }
.ep-comel__eye--r { right: 24%; }
.ep-comel__eye::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 3px;
  height: 3px;
  background: #fff;
  border-radius: 50%;
}
.ep-comel__nose {
  position: absolute;
  top: 54%;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 7px;
  background: #e76f51;
  border-radius: 50% 50% 60% 60%;
  z-index: 2;
}
.ep-comel__mouth {
  position: absolute;
  top: 62%;
  left: 50%;
  width: 16px;
  height: 8px;
  margin-left: -8px;
  border-bottom: 2px solid #5d4037;
  border-radius: 0 0 12px 12px;
  z-index: 2;
}
.ep-comel__cheek {
  position: absolute;
  top: 52%;
  width: 10px;
  height: 6px;
  background: var(--cheek);
  border-radius: 50%;
  opacity: 0.75;
  z-index: 1;
}
.ep-comel__cheek--l { left: 12%; }
.ep-comel__cheek--r { right: 12%; }
.ep-comel__whisker {
  position: absolute;
  top: 56%;
  width: 14px;
  height: 1.5px;
  background: #8d6e63;
  border-radius: 2px;
  z-index: 1;
  opacity: 0.7;
}
.ep-comel__whisker--l1 { left: 4%; transform: rotate(12deg); }
.ep-comel__whisker--l2 { left: 4%; top: 60%; transform: rotate(-8deg); }
.ep-comel__whisker--r1 { right: 4%; transform: rotate(-12deg); }
.ep-comel__whisker--r2 { right: 4%; top: 60%; transform: rotate(8deg); }

/* Moods */
.ep-comel--happy .ep-comel__mouth {
  width: 20px;
  height: 10px;
  margin-left: -10px;
  border-bottom-width: 3px;
}
.ep-comel--happy { animation-duration: 1.6s; }
.ep-comel--sad .ep-comel__mouth {
  border-bottom: none;
  border-top: 2px solid #5d4037;
  border-radius: 12px 12px 0 0;
  top: 66%;
  height: 6px;
}
.ep-comel--sad { animation: none; transform: translateY(4px); }
.ep-comel--wow .ep-comel__eye {
  width: 12px;
  height: 14px;
  top: 34%;
}
.ep-comel--wow .ep-comel__mouth {
  width: 10px;
  height: 10px;
  margin-left: -5px;
  border: 2px solid #5d4037;
  border-radius: 50%;
  background: #5d4037;
  top: 64%;
}
.ep-comel--think .ep-comel__eye--l { transform: scaleY(0.4); }
.ep-comel--think .ep-comel__eye--r { transform: scaleY(0.4); }
.ep-comel--celebrate {
  animation: ep-wiggle 0.5s ease-in-out infinite;
}

/* Size variants */
.ep-comel--sm { width: 48px; height: 48px; }
.ep-comel--sm .ep-comel__ear { border-left-width: 10px; border-right-width: 10px; border-bottom-width: 16px; top: -4px; }
.ep-comel--lg { width: 96px; height: 96px; }
.ep-comel--xl { width: 120px; height: 120px; }

/* ── Subject buddy badges ── */
.ep-buddy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  font-size: 1.8rem;
  border-radius: 50%;
  background: white;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
  animation: ep-float 3s ease-in-out infinite;
  border: 3px solid rgba(255, 255, 255, 0.9);
}
.ep-buddy--math { background: linear-gradient(145deg, #ffe0d6, #fff); border-color: #E76F51; }
.ep-buddy--sains { background: linear-gradient(145deg, #d4f5f1, #fff); border-color: #2A9D8F; }
.ep-buddy--bm { background: linear-gradient(145deg, #d8f3e4, #fff); border-color: #40916C; }
.ep-buddy--english { background: linear-gradient(145deg, #dceee4, #fff); border-color: #2D6A4F; }
.ep-buddy--umum { background: linear-gradient(145deg, #fff3d0, #fff); border-color: #E9C46A; }
.ep-buddy--sejarah { background: linear-gradient(145deg, #ffe8d4, #fff); border-color: #F4A261; }

/* ── Floating coach bubble ── */
.ep-coach {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 9000;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: min(320px, calc(100vw - 32px));
  pointer-events: none;
  animation: ep-slide-up 0.45s ease;
}
.ep-coach__bubble {
  background: white;
  color: #1b4332;
  padding: 12px 14px;
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 10px 28px rgba(27, 67, 50, 0.18);
  font-family: "Nunito", "Comic Neue", system-ui, sans-serif;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.35;
  border: 2px solid #d8e5dd;
  animation: ep-pop 0.4s ease;
}
.ep-coach__bubble strong { color: #2d6a4f; }
.ep-coach.is-hiding {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.3s, transform 0.3s;
}

/* ── Toast popups ── */
.ep-toast-host {
  position: fixed;
  top: 18%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9500;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.ep-toast {
  background: rgba(27, 67, 50, 0.92);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-family: "Nunito", system-ui, sans-serif;
  font-weight: 800;
  font-size: 1rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  animation: ep-pop 0.35s ease;
  white-space: nowrap;
}
.ep-toast--ok { background: linear-gradient(135deg, #52b788, #2d6a4f); }
.ep-toast--bad { background: linear-gradient(135deg, #e76f51, #c44536); }
.ep-toast--star { background: linear-gradient(135deg, #e9c46a, #f4a261); color: #1b4332; }

/* ── Sparkle layer ── */
.ep-sparkles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9400;
  overflow: hidden;
}
.ep-sparkle {
  position: absolute;
  font-size: 1.2rem;
  animation: ep-sparkle 0.9s ease-out forwards;
}

/* ── Photo frame polish ── */
.ep-photo {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
  animation: ep-pop 0.45s ease;
  object-fit: contain; /* full subject visible */
  background: #f0f4f1;
}
/* Animal game photos always full-body / uncropped */
body[data-theme="haiwan"] .ep-photo,
body[data-theme="haiwan"] .animal-display img,
body[data-theme="haiwan"] #photo {
  object-fit: contain !important;
  width: 100%;
  height: auto;
  max-height: min(48vh, 360px);
}
.ep-photo-frame {
  position: relative;
  display: inline-block;
  padding: 8px;
  background: linear-gradient(145deg, #fff, #f3faf6);
  border-radius: 22px;
  box-shadow: 0 10px 28px rgba(27, 67, 50, 0.12);
  border: 2px solid rgba(45, 106, 79, 0.08);
}
.ep-photo-frame::after {
  content: "📸";
  position: absolute;
  top: -8px;
  right: -6px;
  font-size: 1.1rem;
  animation: ep-wiggle 2.5s ease-in-out infinite;
}

/* ── Interactive polish helpers ── */
.ep-btn-pop:active { transform: scale(0.96); }
.ep-card-lift {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.ep-card-lift:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 32px rgba(27, 67, 50, 0.14);
}
.ep-correct-anim { animation: ep-correct-flash 0.5s ease, ep-pulse-glow 0.8s ease; }
.ep-wrong-anim { animation: ep-shake 0.45s ease; }
.ep-star-burst {
  display: inline-block;
  animation: ep-star-spin 0.55s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

/* ── Ambient floating stickers on hubs ── */
.ep-ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.ep-ambient span {
  position: absolute;
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  opacity: 0.14;
  animation: ep-float 5s ease-in-out infinite;
}
.ep-ambient span:nth-child(odd) { animation-duration: 6.5s; }
.ep-ambient span:nth-child(3n) { animation-duration: 4.2s; animation-delay: 0.4s; }

/* ── Header mascot row ── */
.ep-game-hero {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}
.ep-game-hero h1,
.ep-game-hero .ep-title {
  margin: 0;
}

/* ── Decorative blob bg helper ── */
.ep-blob-bg::before {
  content: "";
  position: fixed;
  width: 280px;
  height: 280px;
  top: -60px;
  right: -40px;
  background: radial-gradient(circle, rgba(82, 183, 136, 0.18), transparent 70%);
  animation: ep-blob 8s ease-in-out infinite;
  z-index: -1;
  pointer-events: none;
}
.ep-blob-bg::after {
  content: "";
  position: fixed;
  width: 220px;
  height: 220px;
  bottom: 10%;
  left: -50px;
  background: radial-gradient(circle, rgba(231, 111, 81, 0.12), transparent 70%);
  animation: ep-blob 10s ease-in-out infinite reverse;
  z-index: -1;
  pointer-events: none;
}
