/* =====================================================
   GREENFLAG GAMES — ANIMATIONS
   Keyframes, Scroll Reveals, Micro-animations
   greeenflaggames.com
   ===================================================== */


/* ═══════════════════════════════════════════════════
   ENTRANCE ANIMATIONS (Intersection Observer)
   ═══════════════════════════════════════════════════ */

/* Initial state — hidden before reveal */
.reveal {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out);
}

.reveal.reveal-left {
  transform: translateX(-40px);
}

.reveal.reveal-right {
  transform: translateX(40px);
}

.reveal.reveal-scale {
  transform: scale(0.9);
  opacity: 0;
}

.reveal.reveal-fade {
  transform: none;
  opacity: 0;
}

/* Visible state — triggered by JS */
.reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* Stagger delays for grid children */
.stagger-children > *:nth-child(1) { transition-delay: 0ms; }
.stagger-children > *:nth-child(2) { transition-delay: 80ms; }
.stagger-children > *:nth-child(3) { transition-delay: 160ms; }
.stagger-children > *:nth-child(4) { transition-delay: 240ms; }
.stagger-children > *:nth-child(5) { transition-delay: 320ms; }
.stagger-children > *:nth-child(6) { transition-delay: 400ms; }
.stagger-children > *:nth-child(7) { transition-delay: 480ms; }
.stagger-children > *:nth-child(8) { transition-delay: 560ms; }
.stagger-children > *:nth-child(9) { transition-delay: 640ms; }

/* Fast stagger */
.stagger-fast > *:nth-child(1) { transition-delay: 0ms; }
.stagger-fast > *:nth-child(2) { transition-delay: 50ms; }
.stagger-fast > *:nth-child(3) { transition-delay: 100ms; }
.stagger-fast > *:nth-child(4) { transition-delay: 150ms; }
.stagger-fast > *:nth-child(5) { transition-delay: 200ms; }
.stagger-fast > *:nth-child(6) { transition-delay: 250ms; }


/* ═══════════════════════════════════════════════════
   KEYFRAME DEFINITIONS
   ═══════════════════════════════════════════════════ */

@keyframes toast-in {
  from { opacity: 0; transform: translateX(100%) scale(0.9); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fade-down {
  from { opacity: 0; transform: translateY(-30px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fade-left {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes fade-right {
  from { opacity: 0; transform: translateX(-30px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes scale-in {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes scale-in-bounce {
  0%   { opacity: 0; transform: scale(0.6); }
  60%  { opacity: 1; transform: scale(1.05); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes slide-down {
  from { opacity: 0; transform: translateY(-100%); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(100%); }
  to   { opacity: 1; transform: translateY(0); }
}

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

/* Gentle pulse glow */
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 20px rgba(22, 163, 74, 0.3); }
  50%       { box-shadow: 0 0 40px rgba(22, 163, 74, 0.6), 0 0 80px rgba(22, 163, 74, 0.2); }
}

/* Text glow pulse */
@keyframes pulse-glow-text {
  0%, 100% { text-shadow: 0 0 20px rgba(34, 197, 94, 0.3); }
  50%       { text-shadow: 0 0 40px rgba(34, 197, 94, 0.7); }
}

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

/* Spin slow */
@keyframes spin-slow {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Bounce */
@keyframes bounce {
  0%, 100% { transform: translateY(0); animation-timing-function: cubic-bezier(0.8, 0, 1, 1); }
  50%       { transform: translateY(-8px); animation-timing-function: cubic-bezier(0, 0, 0.2, 1); }
}

/* Counter number roll-up */
@keyframes number-roll {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* Hero background particle drift */
@keyframes drift {
  0%   { transform: translate(0, 0) rotate(0deg); opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { transform: translate(var(--drift-x, 80px), var(--drift-y, -120px)) rotate(var(--drift-r, 360deg)); opacity: 0; }
}

/* Orbit ring */
@keyframes orbit {
  from { transform: rotate(0deg) translateX(var(--orbit-r, 120px)) rotate(0deg); }
  to   { transform: rotate(360deg) translateX(var(--orbit-r, 120px)) rotate(-360deg); }
}

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

/* Grid background pan */
@keyframes grid-pan {
  from { background-position: 0 0; }
  to   { background-position: 40px 40px; }
}

/* Wave for hero section */
@keyframes wave {
  0%, 100% { transform: scaleX(1); }
  50%       { transform: scaleX(1.05); }
}

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

/* Shimmer for skeleton */
@keyframes skeleton-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

/* Check mark draw */
@keyframes check-draw {
  from { stroke-dashoffset: 100; }
  to   { stroke-dashoffset: 0; }
}

/* Modal open */
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.95) translateY(-10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Accordion expand */
@keyframes accordion-down {
  from { opacity: 0; max-height: 0; }
  to   { opacity: 1; max-height: 500px; }
}

/* Nav menu slide in (mobile) */
@keyframes menu-slide-in {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* Badge pulse */
@keyframes badge-ping {
  0%   { transform: scale(1); opacity: 1; }
  75%, 100% { transform: scale(2); opacity: 0; }
}

/* Loading bar */
@keyframes progress-bar {
  from { width: 0%; }
  to   { width: 100%; }
}

/* Flip card */
@keyframes flip-in {
  from { transform: perspective(600px) rotateY(-90deg); opacity: 0; }
  to   { transform: perspective(600px) rotateY(0); opacity: 1; }
}

/* Particle explosion */
@keyframes particle-out {
  0%   { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--px, 20px), var(--py, -20px)) scale(0); opacity: 0; }
}


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

.animate-fade-in    { animation: fade-in    0.5s var(--ease-out) both; }
.animate-fade-up    { animation: fade-up    0.6s var(--ease-out) both; }
.animate-fade-down  { animation: fade-down  0.6s var(--ease-out) both; }
.animate-fade-left  { animation: fade-left  0.6s var(--ease-out) both; }
.animate-fade-right { animation: fade-right 0.6s var(--ease-out) both; }
.animate-scale-in   { animation: scale-in   0.5s var(--ease-spring) both; }
.animate-float      { animation: float 4s ease-in-out infinite; }
.animate-spin       { animation: spin 1s linear infinite; }
.animate-spin-slow  { animation: spin-slow 8s linear infinite; }
.animate-bounce     { animation: bounce 1s infinite; }
.animate-pulse-glow { animation: pulse-glow 2.5s ease-in-out infinite; }
.animate-gradient   { animation: gradient-shift 6s ease infinite; background-size: 300% 300%; }

/* Animation delays */
.delay-100 { animation-delay: 100ms; }
.delay-200 { animation-delay: 200ms; }
.delay-300 { animation-delay: 300ms; }
.delay-400 { animation-delay: 400ms; }
.delay-500 { animation-delay: 500ms; }
.delay-600 { animation-delay: 600ms; }
.delay-700 { animation-delay: 700ms; }
.delay-800 { animation-delay: 800ms; }
.delay-1000 { animation-delay: 1000ms; }
.delay-1200 { animation-delay: 1200ms; }

/* Duration modifiers */
.duration-fast   { animation-duration: 0.3s; }
.duration-base   { animation-duration: 0.5s; }
.duration-slow   { animation-duration: 0.8s; }
.duration-xslow  { animation-duration: 1.2s; }


/* ═══════════════════════════════════════════════════
   HERO BACKGROUND — Animated Particles & Grid
   ═══════════════════════════════════════════════════ */

.hero-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 0;
}

/* Animated grid lines */
.hero-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(22, 163, 74, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(22, 163, 74, 0.06) 1px, transparent 1px);
  background-size: 40px 40px;
  animation: grid-pan 8s linear infinite;
}

/* Radial green glow center */
.hero-glow {
  position: absolute;
  width: 700px;
  height: 700px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -60%);
  background: radial-gradient(ellipse at center, rgba(22, 163, 74, 0.18) 0%, rgba(22, 163, 74, 0.06) 40%, transparent 70%);
  border-radius: 50%;
  animation: pulse-glow 4s ease-in-out infinite;
}

.hero-glow-2 {
  position: absolute;
  width: 400px;
  height: 400px;
  bottom: -100px;
  right: 10%;
  background: radial-gradient(ellipse at center, rgba(34, 197, 94, 0.12) 0%, transparent 70%);
  border-radius: 50%;
}

/* Floating particles */
.hero-particle {
  position: absolute;
  border-radius: 50%;
  background: rgba(34, 197, 94, 0.6);
  animation: drift var(--duration, 8s) linear infinite;
  animation-delay: var(--delay, 0s);
}

/* Stars / dots background */
.hero-stars {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 20% 30%, rgba(255,255,255,0.15) 0%, transparent 100%),
    radial-gradient(1px 1px at 80% 15%, rgba(255,255,255,0.1) 0%, transparent 100%),
    radial-gradient(1px 1px at 50% 70%, rgba(255,255,255,0.12) 0%, transparent 100%),
    radial-gradient(1px 1px at 90% 60%, rgba(255,255,255,0.08) 0%, transparent 100%),
    radial-gradient(1px 1px at 10% 80%, rgba(255,255,255,0.1) 0%, transparent 100%),
    radial-gradient(1px 1px at 35% 50%, rgba(34,197,94,0.2) 0%, transparent 100%),
    radial-gradient(1px 1px at 65% 40%, rgba(34,197,94,0.15) 0%, transparent 100%);
}


/* ═══════════════════════════════════════════════════
   HOVER MICRO-ANIMATIONS
   ═══════════════════════════════════════════════════ */

/* Lift on hover */
.hover-lift {
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}
.hover-lift:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
}

.hover-lift-lg {
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}
.hover-lift-lg:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-2xl);
}

/* Scale on hover */
.hover-scale {
  transition: transform var(--transition-base);
}
.hover-scale:hover { transform: scale(1.03); }

.hover-scale-sm {
  transition: transform var(--transition-fast);
}
.hover-scale-sm:hover { transform: scale(1.015); }

/* Glow on hover */
.hover-glow {
  transition: box-shadow var(--transition-base);
}
.hover-glow:hover { box-shadow: var(--shadow-green-md); }

/* Shine effect on hover */
.hover-shine {
  position: relative;
  overflow: hidden;
}
.hover-shine::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -75%;
  width: 50%;
  height: 200%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.12) 50%,
    transparent 100%
  );
  transform: skewX(-15deg);
  transition: left 0.5s var(--ease-in-out);
}
.hover-shine:hover::after { left: 125%; }

/* Arrow bounce on hover */
.hover-arrow svg,
.hover-arrow .arrow-icon {
  transition: transform var(--transition-spring);
  display: inline-block;
}
.hover-arrow:hover svg,
.hover-arrow:hover .arrow-icon {
  transform: translateX(4px);
}

/* Icon bounce on hover */
.hover-icon-bounce .btn-icon,
.hover-icon-bounce svg {
  transition: transform var(--transition-spring);
}
.hover-icon-bounce:hover .btn-icon,
.hover-icon-bounce:hover svg {
  transform: scale(1.2) rotate(-5deg);
}


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

.page-enter {
  animation: fade-up 0.5s var(--ease-out) both;
}


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

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(22, 163, 74, 0.2);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.spinner-sm {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

.spinner-lg {
  width: 56px;
  height: 56px;
  border-width: 4px;
}

.spinner-white {
  border-color: rgba(255,255,255,0.3);
  border-top-color: white;
}

/* Loading overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 17, 32, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-overlay);
  animation: fade-in 0.2s ease;
}

/* ── Accessibility: respect reduced 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;
  }

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