/* =============================================
   ANIMATIONS.CSS — Keyframes & Animation Classes
   Fisika SMA Kelas X — Bahan Ajar Interaktif
   ============================================= */

/* ===========================
   KEYFRAME DEFINITIONS
   =========================== */

/* Fade In */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Fade Out */
@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* Slide Up */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Slide Down */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Slide Left (enter from right) */
@keyframes slideLeft {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Slide Right (enter from left) */
@keyframes slideRight {
  from {
    opacity: 0;
    transform: translateX(-40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Pulse */
@keyframes pulse {
  0%, 100% {
    opacity: 0.4;
    transform: scale(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(1.05);
  }
}

/* Glow */
@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 5px var(--accent-glow);
  }
  50% {
    box-shadow: 0 0 20px var(--accent-glow), 0 0 40px rgba(59, 130, 246, 0.1);
  }
}

/* Float */
@keyframes float {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-20px);
  }
}

/* Scale In */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Bounce In */
@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.95);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Shake X (wrong answer) */
@keyframes shakeX {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-5px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(5px);
  }
}

/* Rotate */
@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Ripple */
@keyframes ripple {
  0% {
    transform: scale(0);
    opacity: 0.5;
  }
  100% {
    transform: scale(4);
    opacity: 0;
  }
}

/* Gradient Shift */
@keyframes gradientShift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* Typing cursor blink */
@keyframes blink {
  0%, 50% {
    opacity: 1;
  }
  51%, 100% {
    opacity: 0;
  }
}

/* Progress bar fill animation */
@keyframes progressFill {
  from {
    width: 0%;
  }
}

/* Count up number */
@keyframes countUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===========================
   HERO ORB ANIMATIONS
   =========================== */
.hero-orb-1 {
  animation: float 8s ease-in-out infinite;
}

.hero-orb-2 {
  animation: float 10s ease-in-out infinite reverse;
}

.hero-orb-3 {
  animation: pulse 6s ease-in-out infinite;
}

/* ===========================
   ANIMATE ON SCROLL
   =========================== */
.animate-on-scroll {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-on-scroll.animated {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered children */
.animate-stagger > * {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.animate-stagger.animated > *:nth-child(1) { transition-delay: 0.05s; opacity: 1; transform: translateY(0); }
.animate-stagger.animated > *:nth-child(2) { transition-delay: 0.10s; opacity: 1; transform: translateY(0); }
.animate-stagger.animated > *:nth-child(3) { transition-delay: 0.15s; opacity: 1; transform: translateY(0); }
.animate-stagger.animated > *:nth-child(4) { transition-delay: 0.20s; opacity: 1; transform: translateY(0); }
.animate-stagger.animated > *:nth-child(5) { transition-delay: 0.25s; opacity: 1; transform: translateY(0); }
.animate-stagger.animated > *:nth-child(6) { transition-delay: 0.30s; opacity: 1; transform: translateY(0); }
.animate-stagger.animated > *:nth-child(7) { transition-delay: 0.35s; opacity: 1; transform: translateY(0); }
.animate-stagger.animated > *:nth-child(8) { transition-delay: 0.40s; opacity: 1; transform: translateY(0); }

/* ===========================
   CARD HOVER TRANSITIONS
   =========================== */
.card,
.module-card,
.quiz-level-card,
.konsep-card {
  transition: transform var(--transition-base),
              box-shadow var(--transition-base),
              border-color var(--transition-base),
              background var(--transition-base);
}

/* ===========================
   PAGE TRANSITION ANIMATIONS
   =========================== */
.page-enter {
  animation: fadeIn 0.4s ease;
}

.page-enter-up {
  animation: slideUp 0.4s ease;
}

.page-enter-left {
  animation: slideLeft 0.3s ease;
}

/* ===========================
   QUIZ FEEDBACK ANIMATIONS
   =========================== */
.quiz-option.correct {
  animation: bounceIn 0.4s ease;
}

.quiz-option.wrong {
  animation: shakeX 0.4s ease;
}

.quiz-feedback.correct {
  animation: slideUp 0.3s ease;
}

.quiz-feedback.wrong {
  animation: slideUp 0.3s ease;
}

/* Quiz score reveal */
.quiz-score-reveal {
  animation: scaleIn 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===========================
   BUTTON CLICK RIPPLE
   =========================== */
.btn-ripple {
  position: relative;
  overflow: hidden;
}

.btn-ripple::before {
  content: '';
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  width: 0;
  height: 0;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
}

.btn-ripple:active::before {
  width: 300px;
  height: 300px;
  opacity: 0;
  animation: ripple 0.6s ease-out;
}

/* ===========================
   LOADING SKELETON
   =========================== */
.skeleton {
  background: linear-gradient(90deg,
    var(--bg-tertiary) 25%,
    var(--bg-card-hover) 50%,
    var(--bg-tertiary) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

.skeleton-text {
  height: 16px;
  margin-bottom: var(--space-2);
  width: 100%;
}

.skeleton-text.short {
  width: 60%;
}

.skeleton-title {
  height: 24px;
  width: 40%;
  margin-bottom: var(--space-4);
}

.skeleton-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

.skeleton-card {
  height: 200px;
}

/* ===========================
   NARRATION HIGHLIGHT ANIMATION
   =========================== */
.narasi-word-highlight {
  display: inline;
  background: linear-gradient(90deg, var(--accent-glow), transparent);
  background-size: 200% 100%;
  animation: gradientShift 2s ease infinite;
  border-radius: 2px;
  padding: 0 2px;
}

/* ===========================
   TOOLTIP
   =========================== */
.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-card);
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  color: var(--text-primary);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
  box-shadow: var(--shadow-md);
  z-index: 50;
}

.tooltip:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

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

  .animate-on-scroll {
    opacity: 1;
    transform: none;
  }

  .hero-orb {
    animation: none !important;
  }
}
