/* ═══════════════════════════════════════════════════════════
   ADREON KIDS — Animations & Micro-interactions
   Scroll reveals · Page transitions · Game effects · Delight
═══════════════════════════════════════════════════════════ */

/* ─── SCROLL REVEAL SYSTEM ───────────────────────────────── */
.reveal-up,
.reveal-left,
.reveal-right,
.reveal-scale {
  opacity: 0;
  transition:
    opacity 0.7s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.7s cubic-bezier(0.34, 1.2, 0.64, 1);
  transition-delay: var(--delay, 0s);
}

.reveal-up    { transform: translateY(40px); }
.reveal-left  { transform: translateX(-50px); }
.reveal-right { transform: translateX(50px); }
.reveal-scale { transform: scale(0.85); }

.reveal-up.visible,
.reveal-left.visible,
.reveal-right.visible,
.reveal-scale.visible {
  opacity: 1;
  transform: translate(0) scale(1);
}

/* ─── PAGE LOAD ANIMATION ────────────────────────────────── */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-60px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(60px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Hero staggered entrance */
.hero-badge    { animation: fadeInUp 0.6s ease 0.2s both; }
.hero-title    { animation: fadeInUp 0.7s ease 0.35s both; }
.hero-subtitle { animation: fadeInUp 0.6s ease 0.5s both; }
.hero-actions  { animation: fadeInUp 0.6s ease 0.65s both; }
.hero-social-proof { animation: fadeInUp 0.6s ease 0.8s both; }
.hero-visual   { animation: slideInRight 0.8s cubic-bezier(0.34, 1.2, 0.64, 1) 0.4s both; }

/* Nav entrance */
.nav-header    { animation: fadeInDown 0.5s ease 0.1s both; }

/* ─── CONFETTI BURST ─────────────────────────────────────── */
@keyframes confettiFall {
  0% {
    transform: translateY(-20px) rotate(0deg) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateY(120px) rotate(720deg) scale(0.3);
    opacity: 0;
  }
}

.confetti-piece {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  animation: confettiFall 1s ease-out forwards;
  pointer-events: none;
}

/* ─── STAR BURST ─────────────────────────────────────────── */
@keyframes starBurst {
  0%   { transform: scale(0) rotate(0deg); opacity: 1; }
  50%  { transform: scale(1.5) rotate(180deg); opacity: 1; }
  100% { transform: scale(0) rotate(360deg); opacity: 0; }
}

.star-burst {
  position: absolute;
  font-size: 1.5rem;
  animation: starBurst 0.8s ease-out forwards;
  pointer-events: none;
  z-index: 100;
}

/* ─── RIPPLE EFFECT ──────────────────────────────────────── */
@keyframes ripple {
  0% {
    transform: scale(0);
    opacity: 0.6;
  }
  100% {
    transform: scale(4);
    opacity: 0;
  }
}

.ripple-effect {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  animation: ripple 0.6s ease-out forwards;
  pointer-events: none;
  transform-origin: center;
}

/* ─── BUTTON INTERACTIONS ────────────────────────────────── */
.btn {
  position: relative;
  overflow: hidden;
}

.btn .ripple-effect {
  width: 100px;
  height: 100px;
  margin-left: -50px;
  margin-top: -50px;
}

/* ─── GAME CARD HOVER EFFECTS ────────────────────────────── */
.game-card {
  position: relative;
}

.game-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    135deg,
    rgba(255,255,255,0) 0%,
    rgba(255,255,255,0.05) 50%,
    rgba(255,255,255,0) 100%
  );
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: 2;
}

.game-card:hover::before {
  opacity: 1;
}

/* Shimmer on hover */
@keyframes shimmer {
  0%   { transform: translateX(-100%) skewX(-15deg); }
  100% { transform: translateX(200%) skewX(-15deg); }
}

.game-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 40%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255,255,255,0.15),
    transparent
  );
  transform: translateX(-100%) skewX(-15deg);
  pointer-events: none;
  z-index: 3;
}

.game-card:hover::after {
  animation: shimmer 0.7s ease forwards;
}

/* ─── FLOATING ELEMENTS ──────────────────────────────────── */
@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-12px); }
}

@keyframes floatRotate {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  33%       { transform: translateY(-8px) rotate(5deg); }
  66%       { transform: translateY(-4px) rotate(-3deg); }
}

@keyframes floatSway {
  0%, 100% { transform: translateY(0) translateX(0) rotate(0deg); }
  25%       { transform: translateY(-10px) translateX(5px) rotate(3deg); }
  75%       { transform: translateY(-5px) translateX(-5px) rotate(-2deg); }
}

/* ─── PULSE ANIMATIONS ───────────────────────────────────── */
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.05); }
}

@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(108, 60, 225, 0.4);
  }
  50% {
    box-shadow: 0 0 0 12px rgba(108, 60, 225, 0);
  }
}

@keyframes pulseRing {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(108, 60, 225, 0.5);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 15px rgba(108, 60, 225, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(108, 60, 225, 0);
  }
}

/* ─── TYPING CURSOR ──────────────────────────────────────── */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.typing-cursor::after {
  content: '|';
  animation: blink 1s step-end infinite;
  color: var(--color-primary);
}

/* ─── SCORE POP ──────────────────────────────────────────── */
@keyframes scorePop {
  0%   { transform: scale(0.5) translateY(0); opacity: 0; }
  40%  { transform: scale(1.3) translateY(-10px); opacity: 1; }
  70%  { transform: scale(1) translateY(-20px); opacity: 1; }
  100% { transform: scale(0.8) translateY(-40px); opacity: 0; }
}

.score-pop {
  position: absolute;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--color-sunshine);
  text-shadow: 0 2px 8px rgba(0,0,0,0.2);
  animation: scorePop 1s ease-out forwards;
  pointer-events: none;
  z-index: 100;
}

/* ─── CORRECT ANSWER FLASH ───────────────────────────────── */
@keyframes correctFlash {
  0%   { background: white; }
  30%  { background: rgba(78, 205, 196, 0.3); }
  100% { background: white; }
}

.correct-flash {
  animation: correctFlash 0.5s ease forwards;
}

/* ─── WRONG ANSWER SHAKE ─────────────────────────────────── */
@keyframes wrongShake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-8px); }
  40%       { transform: translateX(8px); }
  60%       { transform: translateX(-5px); }
  80%       { transform: translateX(5px); }
}

.wrong-shake {
  animation: wrongShake 0.5s ease forwards;
}

/* ─── PROGRESS BAR FILL ──────────────────────────────────── */
@keyframes progressFill {
  from { width: 0%; }
  to   { width: var(--target-width, 100%); }
}

.progress-animate {
  animation: progressFill 1.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* ─── COUNTER ANIMATION ──────────────────────────────────── */
@keyframes countUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── TROPHY BOUNCE ──────────────────────────────────────── */
@keyframes trophyBounce {
  0%   { transform: scale(0) rotate(-20deg); }
  50%  { transform: scale(1.3) rotate(10deg); }
  70%  { transform: scale(0.9) rotate(-5deg); }
  85%  { transform: scale(1.1) rotate(3deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.trophy-bounce {
  animation: trophyBounce 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* ─── LEVEL UP ANIMATION ─────────────────────────────────── */
@keyframes levelUp {
  0%   { transform: scale(0.5) translateY(20px); opacity: 0; }
  50%  { transform: scale(1.2) translateY(-10px); opacity: 1; }
  75%  { transform: scale(0.95) translateY(0); opacity: 1; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

.level-up-anim {
  animation: levelUp 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* ─── STREAK FIRE ────────────────────────────────────────── */
@keyframes fireDance {
  0%, 100% { transform: scaleY(1) rotate(-2deg); }
  25%       { transform: scaleY(1.1) rotate(2deg); }
  50%       { transform: scaleY(0.95) rotate(-1deg); }
  75%       { transform: scaleY(1.05) rotate(1deg); }
}

.fire-anim {
  display: inline-block;
  animation: fireDance 0.5s ease-in-out infinite;
  transform-origin: bottom center;
}

/* ─── CARD FLIP ──────────────────────────────────────────── */
.card-flip-container {
  perspective: 1000px;
}

.card-flip-inner {
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-flip-container.flipped .card-flip-inner {
  transform: rotateY(180deg);
}

.card-flip-front,
.card-flip-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: inherit;
}

.card-flip-back {
  transform: rotateY(180deg);
}

/* ─── MEMORY CARD ANIMATIONS ─────────────────────────────── */
@keyframes cardReveal {
  0%   { transform: rotateY(90deg) scale(0.8); opacity: 0; }
  100% { transform: rotateY(0deg) scale(1); opacity: 1; }
}

@keyframes cardMatch {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.15); }
  60%  { transform: scale(0.95); }
  100% { transform: scale(1); }
}

@keyframes cardMismatch {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  20%       { transform: translateX(-6px) rotate(-3deg); }
  40%       { transform: translateX(6px) rotate(3deg); }
  60%       { transform: translateX(-4px) rotate(-2deg); }
  80%       { transform: translateX(4px) rotate(2deg); }
}

.card-reveal  { animation: cardReveal 0.4s cubic-bezier(0.34, 1.2, 0.64, 1) forwards; }
.card-match   { animation: cardMatch 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }
.card-mismatch{ animation: cardMismatch 0.5s ease forwards; }

/* ─── DRAWING / TRACING ──────────────────────────────────── */
@keyframes drawPath {
  from { stroke-dashoffset: 1000; }
  to   { stroke-dashoffset: 0; }
}

.draw-path {
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  animation: drawPath 2s ease forwards;
}

/* ─── SPARKLE TRAIL ──────────────────────────────────────── */
@keyframes sparkleTrail {
  0%   { transform: scale(1) rotate(0deg); opacity: 1; }
  100% { transform: scale(0) rotate(180deg); opacity: 0; }
}

.sparkle-trail {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  font-size: 1rem;
  animation: sparkleTrail 0.8s ease-out forwards;
}

/* ─── NOTIFICATION TOAST ─────────────────────────────────── */
@keyframes toastSlideIn {
  from {
    transform: translateX(120%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes toastSlideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(120%);
    opacity: 0;
  }
}

.toast {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  background: white;
  border-radius: var(--radius-xl);
  padding: var(--space-4) var(--space-5);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text-primary);
  z-index: 9000;
  max-width: 320px;
  animation: toastSlideIn 0.4s cubic-bezier(0.34, 1.2, 0.64, 1) forwards;
}

.toast.hiding {
  animation: toastSlideOut 0.3s ease forwards;
}

.toast-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 800;
  margin-bottom: 2px;
}

.toast-message {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 600;
}

/* ─── LOADING STATES ─────────────────────────────────────── */
@keyframes skeleton {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-bg-alt) 25%,
    rgba(108, 60, 225, 0.05) 50%,
    var(--color-bg-alt) 75%
  );
  background-size: 200% 100%;
  animation: skeleton 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

/* ─── SPINNER ────────────────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ─── GAME COMPLETION OVERLAY ────────────────────────────── */
@keyframes overlayFadeIn {
  from { opacity: 0; backdrop-filter: blur(0px); }
  to   { opacity: 1; backdrop-filter: blur(8px); }
}

@keyframes completionCard {
  0%   { transform: scale(0.5) translateY(60px); opacity: 0; }
  60%  { transform: scale(1.05) translateY(-10px); opacity: 1; }
  80%  { transform: scale(0.98) translateY(5px); }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

.game-completion-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 10, 60, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  animation: overlayFadeIn 0.4s ease forwards;
}

.game-completion-card {
  background: white;
  border-radius: var(--radius-2xl);
  padding: var(--space-12) var(--space-10);
  text-align: center;
  max-width: 420px;
  width: 90%;
  animation: completionCard 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s both;
}

/* ─── FILTER TAB TRANSITION ──────────────────────────────── */
.game-card {
  transition:
    opacity 0.3s ease,
    transform 0.4s cubic-bezier(0.34, 1.2, 0.64, 1),
    box-shadow 0.3s ease;
}

.game-card.filtering-out {
  opacity: 0;
  transform: scale(0.9) translateY(10px);
  pointer-events: none;
}

.game-card.filtering-in {
  animation: filterIn 0.4s cubic-bezier(0.34, 1.2, 0.64, 1) forwards;
}

@keyframes filterIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(15px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ─── ORBIT ANIMATION ENHANCEMENT ───────────────────────── */
.orbit-item {
  transition: transform var(--transition-bounce);
}

.orbit-item:hover {
  transform: scale(1.3) !important;
  z-index: 10;
}

/* ─── HERO MATH GAME ANIMATIONS ──────────────────────────── */
@keyframes mathNumPop {
  0%   { transform: scale(0.5); opacity: 0; }
  70%  { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

.math-num-new {
  animation: mathNumPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes optionAppear {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.math-btn-new {
  animation: optionAppear 0.3s cubic-bezier(0.34, 1.2, 0.64, 1) forwards;
}

/* ─── SCROLL PROGRESS BAR ────────────────────────────────── */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-coral), var(--color-teal));
  z-index: 9999;
  transform-origin: left;
  transition: width 0.1s linear;
}

/* ─── HOVER TILT EFFECT ──────────────────────────────────── */
.tilt-card {
  transform-style: preserve-3d;
  transition: transform 0.3s ease;
}

/* ─── GRADIENT TEXT ANIMATION ────────────────────────────── */
@keyframes gradientShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.animated-gradient-text {
  background: linear-gradient(
    270deg,
    var(--color-primary),
    var(--color-coral),
    var(--color-teal),
    var(--color-lavender)
  );
  background-size: 300% 300%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradientShift 4s ease infinite;
}

/* ─── STAGGER CHILDREN ───────────────────────────────────── */
.stagger-children > *:nth-child(1) { --delay: 0s; }
.stagger-children > *:nth-child(2) { --delay: 0.08s; }
.stagger-children > *:nth-child(3) { --delay: 0.16s; }
.stagger-children > *:nth-child(4) { --delay: 0.24s; }
.stagger-children > *:nth-child(5) { --delay: 0.32s; }
.stagger-children > *:nth-child(6) { --delay: 0.40s; }

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

  .reveal-up,
  .reveal-left,
  .reveal-right,
  .reveal-scale {
    opacity: 1;
    transform: none;
  }

  .hero-badge,
  .hero-title,
  .hero-subtitle,
  .hero-actions,
  .hero-social-proof,
  .hero-visual,
  .nav-header {
    animation: none;
    opacity: 1;
    transform: none;
  }
}