/* ══════════════════════════════════════════════
   07-animations.css
   Particle Canvas, Visual Effects & Polish
   ══════════════════════════════════════════════ */

/* ── Entrance animations for cards ── */
.theory-card,
.module-card,
.prof-card {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.45s ease, transform 0.45s ease,
              border-color 0.2s ease !important;
}
.theory-card.visible,
.module-card.visible,
.prof-card.visible {
  opacity: 1;
  transform: translateY(0);
}
/* Stagger via nth-child */
.theory-card:nth-child(2)  { transition-delay: 0.06s !important; }
.theory-card:nth-child(3)  { transition-delay: 0.12s !important; }
.module-card:nth-child(2)  { transition-delay: 0.05s !important; }
.module-card:nth-child(3)  { transition-delay: 0.10s !important; }
.module-card:nth-child(4)  { transition-delay: 0.15s !important; }
.module-card:nth-child(5)  { transition-delay: 0.20s !important; }

/* ── Result bar animate ── */
.result-bar-fill { width: 0% !important; }
.result-bar-fill.animate { width: var(--target-width) !important; }

/* ── Glow ring for highlight nodes ── */
@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
  50%       { box-shadow: 0 0 12px 4px var(--accent-glow); }
}
.cloud-node.active-node { animation: glowPulse 1.2s ease 3; }

/* ── Data flow animation between cloud nodes ── */
@keyframes dataFlow {
  0%   { box-shadow: 0 0 0 0 rgba(0,212,161,0.4); }
  50%  { box-shadow: 0 0 0 8px rgba(0,212,161,0.1); }
  100% { box-shadow: 0 0 0 0 rgba(0,212,161,0); }
}
.cloud-node.data-flowing { animation: dataFlow 0.7s ease forwards; }

/* ── Toast bounce ── */
@keyframes toastIn {
  from { transform: translateY(60px) scale(0.9); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
.toast.show { animation: toastIn 0.35s cubic-bezier(0.34,1.56,0.64,1) forwards; }

/* ── Badge earn animation ── */
@keyframes badgeEarn {
  0%   { transform: scale(1) rotate(0deg); }
  30%  { transform: scale(1.5) rotate(-10deg); }
  60%  { transform: scale(1.3) rotate(8deg); }
  100% { transform: scale(1) rotate(0deg); }
}

/* ── UX error found flash ── */
@keyframes errorFlash {
  0%, 100% { background-color: transparent; }
  25%, 75%  { background-color: rgba(255,77,109,0.12); }
}
.ux-error-zone.just-found { animation: errorFlash 0.5s ease; }

/* ── Feature card select bounce ── */
@keyframes selectPop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.04); }
  100% { transform: scale(1); }
}
.feature-card.just-selected { animation: selectPop 0.3s ease forwards; }

/* ── Drag card drop ── */
@keyframes dropBounce {
  0%   { transform: scale(1.06); }
  100% { transform: scale(1); }
}
.drag-card.just-dropped { animation: dropBounce 0.25s ease forwards; }

/* ── Confetti for completion ── */
.confetti-piece {
  position: fixed;
  width: 8px; height: 8px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 9999;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  0%   { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* ── Skeleton loading shimmer ── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-card) 25%,
    var(--bg-card-hover) 50%,
    var(--bg-card) 75%
  );
  background-size: 400px 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

/* ── Focus rings for accessibility ── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Smooth scroll snap on content ── */
.tab-section { scroll-margin-top: 20px; }

/* ── Gradient border for active game containers ── */
.game-container.active-game {
  border-color: transparent;
  background-clip: padding-box;
  position: relative;
}
.game-container.active-game::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  z-index: -1;
  opacity: 0.3;
}

/* ── Number badge pop for count updates ── */
@keyframes countPop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.3); color: var(--accent); }
  100% { transform: scale(1); }
}
.count-pop { animation: countPop 0.4s ease; }

/* ── Print styles (basic) ── */
@media print {
  .sidebar, .hamburger, .overlay, #particle-canvas,
  #splash-screen, #guide-modal, .toast { display: none !important; }
  .main-content { margin-left: 0; max-width: 100%; padding: 0; }
  body { background: #fff; color: #000; }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  #particle-canvas { display: none; }
}
