/* ============================================================
   ANIMATIONS.CSS — All motion, particles, effects
   Load: <link rel="stylesheet" media="print" onload="this.media='all'">
   (Deferred — never blocks render)
   ============================================================ */

/* ---------- Respect reduced motion preference ---------- */
@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;
  }
  .particle, .floating-tile, .glow-orb { display: none; }
}

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

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

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

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

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

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

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

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

@keyframes float {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  33%       { transform: translateY(-12px) rotate(1deg); }
  66%       { transform: translateY(-6px) rotate(-1deg); }
}

@keyframes floatSlow {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-20px); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.6; transform: scale(0.96); }
}

@keyframes glow {
  0%, 100% { box-shadow: 0 0 10px rgba(124, 58, 237, 0.3), 0 0 20px rgba(124, 58, 237, 0.1); }
  50%       { box-shadow: 0 0 25px rgba(124, 58, 237, 0.7), 0 0 50px rgba(124, 58, 237, 0.3); }
}

@keyframes glowCyan {
  0%, 100% { box-shadow: 0 0 10px rgba(6, 182, 212, 0.3); }
  50%       { box-shadow: 0 0 30px rgba(6, 182, 212, 0.7), 0 0 60px rgba(6, 182, 212, 0.2); }
}

@keyframes glowGold {
  0%, 100% { text-shadow: 0 0 10px rgba(245, 158, 11, 0.4); }
  50%       { text-shadow: 0 0 30px rgba(245, 158, 11, 0.9), 0 0 60px rgba(245, 158, 11, 0.3); }
}

@keyframes shimmer {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}

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

@keyframes rotateReverse {
  from { transform: rotate(360deg); }
  to   { transform: rotate(0deg); }
}

@keyframes tileFlip {
  0%   { transform: perspective(400px) rotateY(0deg); }
  50%  { transform: perspective(400px) rotateY(90deg); }
  100% { transform: perspective(400px) rotateY(0deg); }
}

@keyframes tileDrop {
  0%   { transform: translateY(-60px) rotate(-5deg); opacity: 0; }
  60%  { transform: translateY(8px) rotate(1deg); opacity: 1; }
  80%  { transform: translateY(-4px) rotate(-0.5deg); }
  100% { transform: translateY(0) rotate(0deg); opacity: 1; }
}

@keyframes particleDrift {
  0%   { transform: translateY(0) translateX(0) scale(1); opacity: 0.7; }
  50%  { transform: translateY(-60px) translateX(20px) scale(1.2); opacity: 1; }
  100% { transform: translateY(-120px) translateX(-10px) scale(0); opacity: 0; }
}

@keyframes scanline {
  0%   { transform: translateY(-100%); }
  100% { transform: translateY(100vh); }
}

@keyframes borderGlow {
  0%, 100% { border-color: rgba(124, 58, 237, 0.2); }
  50%       { border-color: rgba(124, 58, 237, 0.8); }
}

@keyframes typewriter {
  from { width: 0; }
  to   { width: 100%; }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

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

@keyframes wave {
  0%, 100% { transform: rotate(0deg); }
  25%       { transform: rotate(15deg); }
  75%       { transform: rotate(-10deg); }
}

@keyframes gradientShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes orbPulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.3; }
  50%       { transform: translate(-50%, -50%) scale(1.3); opacity: 0.6; }
}

/* ============================================================
   UTILITY ANIMATION CLASSES
   ============================================================ */

.animate-fade-in       { animation: fadeIn      0.5s ease both; }
.animate-fade-in-up    { animation: fadeInUp    0.6s ease both; }
.animate-fade-in-down  { animation: fadeInDown  0.6s ease both; }
.animate-fade-in-left  { animation: fadeInLeft  0.6s ease both; }
.animate-fade-in-right { animation: fadeInRight 0.6s ease both; }
.animate-scale-in      { animation: scaleIn     0.5s ease both; }
.animate-float         { animation: float       4s ease-in-out infinite; }
.animate-float-slow    { animation: floatSlow   6s ease-in-out infinite; }
.animate-pulse         { animation: pulse       2s ease-in-out infinite; }
.animate-glow          { animation: glow        2s ease-in-out infinite; }
.animate-rotate        { animation: rotate      8s linear infinite; }
.animate-shimmer       {
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.1) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* Delay utilities */
.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-900  { animation-delay: 900ms; }
.delay-1000 { animation-delay: 1000ms; }

/* ============================================================
   SCROLL-TRIGGERED ANIMATIONS (via JS IntersectionObserver)
   ============================================================ */

[data-reveal] {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s ease, transform 0.7s ease;
  will-change: opacity, transform;
}

[data-reveal="left"]  { transform: translateX(-24px); }
[data-reveal="right"] { transform: translateX(24px); }
[data-reveal="scale"] { transform: scale(0.9); }
[data-reveal="none"]  { transform: none; }

[data-reveal].revealed {
  opacity: 1;
  transform: none;
}

/* Staggered children */
[data-stagger] > * {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
  will-change: opacity, transform;
}

[data-stagger].revealed > *:nth-child(1)  { opacity: 1; transform: none; transition-delay: 0ms; }
[data-stagger].revealed > *:nth-child(2)  { opacity: 1; transform: none; transition-delay: 80ms; }
[data-stagger].revealed > *:nth-child(3)  { opacity: 1; transform: none; transition-delay: 160ms; }
[data-stagger].revealed > *:nth-child(4)  { opacity: 1; transform: none; transition-delay: 240ms; }
[data-stagger].revealed > *:nth-child(5)  { opacity: 1; transform: none; transition-delay: 320ms; }
[data-stagger].revealed > *:nth-child(6)  { opacity: 1; transform: none; transition-delay: 400ms; }
[data-stagger].revealed > *:nth-child(7)  { opacity: 1; transform: none; transition-delay: 480ms; }
[data-stagger].revealed > *:nth-child(8)  { opacity: 1; transform: none; transition-delay: 560ms; }
[data-stagger].revealed > *:nth-child(n+9){ opacity: 1; transform: none; transition-delay: 640ms; }

/* ============================================================
   GAMING BACKGROUND PARTICLES (CSS-only)
   ============================================================ */

.particles-container {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: var(--z-below);
}

.particle {
  position: absolute;
  border-radius: var(--radius-sm);
  opacity: 0;
  animation: particleDrift linear infinite;
}

/* 12 particles auto-generated via nth-child */
.particle:nth-child(1)  { width:4px;  height:4px;  left:10%;  bottom:0; background:var(--clr-accent-purple); animation-duration:8s;  animation-delay:0s; }
.particle:nth-child(2)  { width:6px;  height:6px;  left:20%;  bottom:0; background:var(--clr-accent-cyan);   animation-duration:11s; animation-delay:2s; }
.particle:nth-child(3)  { width:3px;  height:3px;  left:35%;  bottom:0; background:var(--clr-accent-gold);   animation-duration:9s;  animation-delay:4s; }
.particle:nth-child(4)  { width:5px;  height:5px;  left:50%;  bottom:0; background:var(--clr-accent-purple); animation-duration:12s; animation-delay:1s; }
.particle:nth-child(5)  { width:4px;  height:4px;  left:65%;  bottom:0; background:var(--clr-accent-pink);   animation-duration:10s; animation-delay:3s; }
.particle:nth-child(6)  { width:7px;  height:7px;  left:75%;  bottom:0; background:var(--clr-accent-cyan);   animation-duration:14s; animation-delay:5s; }
.particle:nth-child(7)  { width:3px;  height:3px;  left:85%;  bottom:0; background:var(--clr-accent-gold);   animation-duration:9s;  animation-delay:7s; }
.particle:nth-child(8)  { width:5px;  height:5px;  left:5%;   bottom:0; background:var(--clr-accent-purple); animation-duration:13s; animation-delay:2s; }
.particle:nth-child(9)  { width:4px;  height:4px;  left:42%;  bottom:0; background:var(--clr-accent-cyan);   animation-duration:10s; animation-delay:6s; }
.particle:nth-child(10) { width:6px;  height:6px;  left:58%;  bottom:0; background:var(--clr-accent-pink);   animation-duration:11s; animation-delay:4s; }
.particle:nth-child(11) { width:3px;  height:3px;  left:92%;  bottom:0; background:var(--clr-accent-purple); animation-duration:8s;  animation-delay:1s; }
.particle:nth-child(12) { width:5px;  height:5px;  left:28%;  bottom:0; background:var(--clr-accent-gold);   animation-duration:15s; animation-delay:8s; }

/* ============================================================
   FLOATING TILES (Hero decoration)
   ============================================================ */

.floating-tiles {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: var(--z-below);
}

.floating-tile {
  position: absolute;
  width: 52px;
  height: 68px;
  border-radius: var(--radius-md);
  background: var(--clr-bg-card);
  border: 1px solid var(--clr-border);
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  box-shadow: var(--shadow-md);
  opacity: 0.15;
  animation: float ease-in-out infinite;
  will-change: transform;
}

.floating-tile:nth-child(1)  { top:15%; left:5%;   animation-duration:5s;   animation-delay:0s;   opacity:0.12; }
.floating-tile:nth-child(2)  { top:40%; left:2%;   animation-duration:7s;   animation-delay:1s;   opacity:0.08; }
.floating-tile:nth-child(3)  { top:70%; left:8%;   animation-duration:6s;   animation-delay:2s;   opacity:0.14; }
.floating-tile:nth-child(4)  { top:20%; right:6%;  animation-duration:8s;   animation-delay:0.5s; opacity:0.10; }
.floating-tile:nth-child(5)  { top:55%; right:3%;  animation-duration:5.5s; animation-delay:3s;   opacity:0.12; }
.floating-tile:nth-child(6)  { top:80%; right:10%; animation-duration:6.5s; animation-delay:1.5s; opacity:0.08; }
.floating-tile:nth-child(7)  { top:10%; left:15%;  animation-duration:9s;   animation-delay:4s;   opacity:0.06; }
.floating-tile:nth-child(8)  { top:85%; left:20%;  animation-duration:7.5s; animation-delay:2.5s; opacity:0.10; }

/* ============================================================
   GLOW ORBS (Background ambient)
   ============================================================ */

.glow-orbs {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: var(--z-below);
}

.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  animation: orbPulse ease-in-out infinite;
  will-change: transform, opacity;
}

.glow-orb--purple {
  width: 600px;
  height: 600px;
  background: rgba(124, 58, 237, 0.12);
  top: -10%;
  left: 20%;
  animation-duration: 8s;
}

.glow-orb--cyan {
  width: 400px;
  height: 400px;
  background: rgba(6, 182, 212, 0.08);
  bottom: 10%;
  right: 15%;
  animation-duration: 10s;
  animation-delay: 3s;
}

.glow-orb--gold {
  width: 300px;
  height: 300px;
  background: rgba(245, 158, 11, 0.06);
  top: 50%;
  left: 50%;
  animation-duration: 12s;
  animation-delay: 6s;
}

/* ============================================================
   GAME CARD HOVER EFFECTS
   ============================================================ */

.game-card {
  transition:
    transform var(--transition-base),
    box-shadow var(--transition-base),
    border-color var(--transition-base);
  will-change: transform;
}

.game-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: var(--shadow-lg), var(--shadow-glow-purple);
}

.game-card__thumb {
  overflow: hidden;
  position: relative;
}

.game-card__thumb img {
  transition: transform var(--transition-slow);
  will-change: transform;
}

.game-card:hover .game-card__thumb img {
  transform: scale(1.08);
}

.game-card__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(8, 8, 24, 0.9) 0%, transparent 60%);
  opacity: 0;
  transition: opacity var(--transition-base);
  display: grid;
  place-items: center;
}

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

.game-card__play-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--gradient-brand);
  display: grid;
  place-items: center;
  transform: scale(0.7);
  opacity: 0;
  transition: transform var(--transition-bounce), opacity var(--transition-base);
  box-shadow: 0 0 30px rgba(124, 58, 237, 0.6);
}

.game-card:hover .game-card__play-btn {
  transform: scale(1);
  opacity: 1;
}

.game-card__play-btn svg { width: 22px; height: 22px; color: #fff; }

/* ============================================================
   BUTTON ANIMATIONS
   ============================================================ */

.btn--primary::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 50%);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

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

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

.btn:active::before {
  width: 200px;
  height: 200px;
  opacity: 1;
}

/* ============================================================
   SHIMMER SKELETON (Loading state)
   ============================================================ */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--clr-surface) 25%,
    var(--clr-surface-2) 50%,
    var(--clr-surface) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

/* ============================================================
   HEADER SCROLL ANIMATION
   ============================================================ */

.site-header .site-logo__icon {
  transition: transform var(--transition-base);
}

.site-header.scrolled .site-logo__icon {
  transform: scale(0.9);
}

/* ============================================================
   ANIMATED GRADIENT TEXT (Hero)
   ============================================================ */

.animated-gradient-text {
  background: linear-gradient(
    270deg,
    var(--clr-accent-purple),
    var(--clr-accent-cyan),
    var(--clr-accent-gold),
    var(--clr-accent-pink),
    var(--clr-accent-purple)
  );
  background-size: 300% 300%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: gradientShift 5s ease infinite;
}

/* ============================================================
   TILE FLIP EFFECT (Game Previews)
   ============================================================ */

.tile-preview {
  perspective: 800px;
  cursor: pointer;
}

.tile-preview__inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

.tile-preview:hover .tile-preview__inner {
  transform: rotateY(180deg);
}

.tile-preview__front,
.tile-preview__back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: inherit;
}

.tile-preview__back {
  transform: rotateY(180deg);
  background: var(--gradient-brand);
  display: grid;
  place-items: center;
}

/* ============================================================
   COUNTER ANIMATION
   ============================================================ */

.stat-counter {
  font-variant-numeric: tabular-nums;
  transition: color var(--transition-base);
}

.stat-counter.animating {
  animation: countUp 0.4s ease both;
}

/* ============================================================
   NOTIFICATION / TOAST
   ============================================================ */

.toast {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-toast);
  background: var(--clr-bg-card);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  max-width: 360px;
  animation: slideInUp 0.4s ease;
}

.toast--success { border-left: 3px solid #10b981; }
.toast--error   { border-left: 3px solid #ef4444; }
.toast--info    { border-left: 3px solid var(--clr-accent-cyan); }
