/* ============================================================
 * FREEZE ADS BOT — Animations & Keyframes
 * ============================================================
 * 
 * All @keyframes definitions, animation utility classes,
 * page transition system, skeleton loaders, and the
 * chocolate-particle canvas container.
 *
 * Dark-mode-only effects are gated behind html.theme-dark.
 * Reduced-motion preferences are respected at the bottom.
 * ========================================================== */


/* ══════════════════════════════════════════════════════════
 * KEYFRAMES
 * ════════════════════════════════════════════════════════ */

/* ── Float — gentle up/down bob for decorative elements ─── */
@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-12px);
  }
}

/* ── Glow Pulse — golden box-shadow pulsing ──────────────── */
@keyframes glowPulse {
  0%, 100% {
    box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.2),
                0 0 20px rgba(var(--accent-rgb), 0.1);
  }
  50% {
    box-shadow: 0 0 16px rgba(var(--accent-rgb), 0.4),
                0 0 40px rgba(var(--accent-rgb), 0.2);
  }
}

/* ── Shimmer — gradient sweep left → right (loading) ─────── */
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* ── Fade In Up — page entrance ──────────────────────────── */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Fade Out Down — page exit ───────────────────────────── */
@keyframes fadeOutDown {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(16px);
  }
}

/* ── Slide In Right — horizontal page enter ──────────────── */
@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ── Slide Out Left — horizontal page exit ───────────────── */
@keyframes slideOutLeft {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(-24px);
  }
}

/* ── Count Up — opacity for number counting animation ────── */
@keyframes countUp {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ── Ripple — expanding circle on tap ────────────────────── */
@keyframes ripple {
  0% {
    transform: scale(0);
    opacity: 0.5;
  }
  100% {
    transform: scale(4);
    opacity: 0;
  }
}

/* ── Spin — loading spinner ──────────────────────────────── */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* ── Scale In — subtle scale entrance ────────────────────── */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ── Particle Float — upward drift with horizontal sway ─── */
@keyframes particleFloat {
  0% {
    opacity: 0;
    transform: translate(0, 0) rotate(0deg);
  }
  10% {
    opacity: 0.6;
  }
  90% {
    opacity: 0.6;
  }
  100% {
    opacity: 0;
    transform: translate(30px, -100vh) rotate(360deg);
  }
}

/* ── Nav Indicator Slide — tab indicator gliding ─────────── */
@keyframes navIndicatorSlide {
  from {
    transform: scaleX(0.6);
    opacity: 0.5;
  }
  to {
    transform: scaleX(1);
    opacity: 1;
  }
}

/* ── Shake — input validation error ──────────────────────── */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 50%, 90% { transform: translateX(-4px); }
  30%, 70% { transform: translateX(4px); }
}

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

/* ── Slide Up (Drawer) — bottom drawer entrance ──────────── */
@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

/* ── Slide Down (Drawer) — bottom drawer exit ────────────── */
@keyframes slideDown {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(100%);
  }
}

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

/* ── Fade Out — simple opacity fade out ──────────────────── */
@keyframes fadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* ── Pulse — subtle scale breathing ──────────────────────── */
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.04); }
}


/* ══════════════════════════════════════════════════════════
 * UTILITY ANIMATION CLASSES
 * ════════════════════════════════════════════════════════ */

.animate-fade-in {
  animation: fadeInUp 0.3s var(--ease-out-expo) both;
}

.animate-fade-in-delay-1 {
  animation: fadeInUp 0.3s var(--ease-out-expo) 0.05s both;
}

.animate-fade-in-delay-2 {
  animation: fadeInUp 0.3s var(--ease-out-expo) 0.1s both;
}

.animate-fade-in-delay-3 {
  animation: fadeInUp 0.3s var(--ease-out-expo) 0.15s both;
}

.animate-slide-in {
  animation: slideInRight 0.3s var(--ease-out-expo) both;
}

.animate-scale-in {
  animation: scaleIn 0.25s var(--ease-out-expo) both;
}

.animate-bounce-in {
  animation: bounceIn 0.5s var(--ease-out-expo) both;
}

.animate-count {
  animation: countUp 0.4s ease-out both;
}

.animate-shake {
  animation: shake 0.4s ease-in-out;
}

.animate-spin {
  animation: spin 0.8s linear infinite;
}

.animate-pulse {
  animation: pulse 2s ease-in-out infinite;
}


/* ── Glow — Dark mode only ───────────────────────────────── */
html.theme-dark .animate-glow {
  animation: glowPulse 3s ease-in-out infinite;
}

/* Light mode: no glow, just a subtle shadow */
html.theme-light .animate-glow,
:root .animate-glow {
  box-shadow: var(--shadow-md);
}


/* ── Shimmer — Dark mode only ────────────────────────────── */
html.theme-dark .animate-shimmer {
  position: relative;
  overflow: hidden;
}

html.theme-dark .animate-shimmer::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(196, 122, 58, 0.06) 40%,
    rgba(196, 122, 58, 0.12) 50%,
    rgba(196, 122, 58, 0.06) 60%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: shimmer 3s ease-in-out infinite;
  pointer-events: none;
  border-radius: inherit;
}


/* ══════════════════════════════════════════════════════════
 * SKELETON LOADING PLACEHOLDER
 * ════════════════════════════════════════════════════════ */

.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--bg-skeleton);
  border-radius: var(--radius-md);
  color: transparent !important;
  pointer-events: none;
  user-select: none;
}

.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(var(--accent-rgb), 0.06) 40%,
    rgba(var(--accent-rgb), 0.1) 50%,
    rgba(var(--accent-rgb), 0.06) 60%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.8s ease-in-out infinite;
}

.skeleton-text {
  height: 14px;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
}

.skeleton-text:last-child {
  width: 60%;
}

.skeleton-circle {
  border-radius: var(--radius-full);
}

.skeleton-rect {
  border-radius: var(--radius-md);
}


/* ══════════════════════════════════════════════════════════
 * PAGE TRANSITIONS
 * ════════════════════════════════════════════════════════ */

/* Initial hidden state */
.page-enter {
  /* Removed opacity: 0 to prevent inner page sections from staying hidden */
}

/* Animating to visible */
.page-enter-active {
  animation: fadeInUp 0.3s var(--ease-out-expo) forwards;
}

/* Starting exit */
.page-exit {
  opacity: 1;
  transform: translateY(0);
}

/* Animating to hidden */
.page-exit-active {
  animation: fadeOutDown 0.25s ease-in forwards;
}


/* ══════════════════════════════════════════════════════════
 * RIPPLE EFFECT
 * JS adds a .ripple child span on click, positioned at
 * the click coordinates. This styles the expanding circle.
 * ════════════════════════════════════════════════════════ */

.ripple {
  position: relative;
  overflow: hidden;
}

.ripple .ripple-circle {
  position: absolute;
  border-radius: 50%;
  background: rgba(var(--accent-rgb), 0.2);
  width: 40px;
  height: 40px;
  margin-top: -20px;
  margin-left: -20px;
  animation: ripple 0.6s ease-out forwards;
  pointer-events: none;
}


/* ══════════════════════════════════════════════════════════
 * CHOCOLATE PARTICLES CANVAS
 * Fixed behind all content. Only visible in dark theme.
 * The <canvas> element is created & drawn by JS.
 * ════════════════════════════════════════════════════════ */

#chocolate-particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;

  /* Hidden by default (light theme) */
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-slow), visibility var(--transition-slow);
}

/* Show particles only in dark theme */
html.theme-dark #chocolate-particles {
  opacity: 1;
  visibility: visible;
}


/* ══════════════════════════════════════════════════════════
 * CSS PARTICLE FALLBACK (no-canvas environments)
 * Pure CSS floating dots. Only active in dark mode.
 * ════════════════════════════════════════════════════════ */

.css-particle {
  position: fixed;
  width: 4px;
  height: 4px;
  border-radius: var(--radius-full);
  background: rgba(196, 122, 58, 0.3);
  pointer-events: none;
  z-index: 0;
  animation: particleFloat 12s ease-in-out infinite;
}

/* Only show CSS particles in dark mode */
html:not(.theme-dark) .css-particle {
  display: none;
}


/* ══════════════════════════════════════════════════════════
 * LOADING SPINNER
 * ════════════════════════════════════════════════════════ */

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner-lg {
  width: 36px;
  height: 36px;
  border-width: 3px;
}

.spinner-sm {
  width: 14px;
  height: 14px;
  border-width: 1.5px;
}


/* ══════════════════════════════════════════════════════════
 * STAGGER CHILDREN (for lists entering)
 * Add .stagger-children to a parent; each child gets delay.
 * ════════════════════════════════════════════════════════ */

.stagger-children > * {
  animation: fadeInUp 0.3s var(--ease-out-expo) both;
}

.stagger-children > *:nth-child(1)  { animation-delay: 0s;    }
.stagger-children > *:nth-child(2)  { animation-delay: 0.04s; }
.stagger-children > *:nth-child(3)  { animation-delay: 0.08s; }
.stagger-children > *:nth-child(4)  { animation-delay: 0.12s; }
.stagger-children > *:nth-child(5)  { animation-delay: 0.16s; }
.stagger-children > *:nth-child(6)  { animation-delay: 0.20s; }
.stagger-children > *:nth-child(7)  { animation-delay: 0.24s; }
.stagger-children > *:nth-child(8)  { animation-delay: 0.28s; }
.stagger-children > *:nth-child(9)  { animation-delay: 0.32s; }
.stagger-children > *:nth-child(10) { animation-delay: 0.36s; }


/* ══════════════════════════════════════════════════════════
 * REDUCED MOTION
 * Respect user preference for minimal motion.
 * ════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  #chocolate-particles {
    display: none !important;
  }

  .css-particle {
    display: none !important;
  }

  .animate-glow,
  .animate-shimmer::after {
    animation: none !important;
  }

  .orb {
    animation: none !important;
    display: none !important;
  }
}

/* ── floatOrb — dynamic movement and scale shifts for background nebular blobs ─── */
@keyframes floatOrb {
  0% {
    transform: translate(0, 0) scale(1) rotate(0deg);
  }
  33% {
    transform: translate(30px, -50px) scale(1.15) rotate(120deg);
  }
  66% {
    transform: translate(-20px, 20px) scale(0.9) rotate(240deg);
  }
  100% {
    transform: translate(0, 0) scale(1) rotate(360deg);
  }
}

