/* ================================================
   TREPUTIN x Shuffle - Animations
   ================================================ */

/* -------------------- Keyframe Animations -------------------- */
@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.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 20px rgba(124, 77, 255, 0.3);
  }
  50% {
    box-shadow: 0 0 40px rgba(124, 77, 255, 0.6);
  }
}

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

/* -------------------- Initial States -------------------- */
.animate-on-scroll {
  opacity: 0;
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-on-scroll.fade-up {
  transform: translateY(30px);
}

.animate-on-scroll.fade-down {
  transform: translateY(-30px);
}

.animate-on-scroll.fade-left {
  transform: translateX(-30px);
}

.animate-on-scroll.fade-right {
  transform: translateX(30px);
}

.animate-on-scroll.scale {
  transform: scale(0.95);
}

/* Active state when in view */
.animate-on-scroll.in-view {
  opacity: 1;
  transform: translateY(0) translateX(0) scale(1);
}

/* -------------------- Page Load Animations -------------------- */
/* Header animation */
header {
  animation: fadeInDown 0.8s ease;
}

/* Hero content animations */
.hero .eyebrow {
  animation: fadeInDown 0.8s ease 0.2s both;
}

.hero h1 {
  animation: fadeInUp 0.8s ease 0.3s both;
}

.hero .sub {
  animation: fadeInUp 0.8s ease 0.4s both;
}

.hero .cta {
  animation: fadeInUp 0.8s ease 0.5s both;
}

.hero .glow {
  animation: pulse 4s ease-in-out infinite;
}

/* Cards stagger animation */
.cards .card {
  opacity: 0;
  animation: fadeInUp 0.6s ease forwards;
}

.cards .card:nth-child(1) {
  animation-delay: 0.1s;
}

.cards .card:nth-child(2) {
  animation-delay: 0.2s;
}

.cards .card:nth-child(3) {
  animation-delay: 0.3s;
}

/* Link cards stagger */
.link-grid .link-card {
  opacity: 0;
  animation: fadeInUp 0.6s ease forwards;
}

.link-grid .link-card:nth-child(1) {
  animation-delay: 0.1s;
}

.link-grid .link-card:nth-child(2) {
  animation-delay: 0.15s;
}

.link-grid .link-card:nth-child(3) {
  animation-delay: 0.2s;
}

.link-grid .link-card:nth-child(4) {
  animation-delay: 0.25s;
}

.link-grid .link-card:nth-child(5) {
  animation-delay: 0.3s;
}

/* -------------------- Leaderboard Page Animations -------------------- */
/* Page head animation */
.page-head .eyebrow {
  animation: fadeInDown 0.8s ease 0.2s both;
}

.page-head h1 {
  animation: fadeInUp 0.8s ease 0.3s both;
}

.page-head .page-sub {
  animation: fadeInUp 0.8s ease 0.4s both;
}

/* Countdown animation */
.countdown {
  animation: scaleIn 0.8s ease 0.5s both;
}

.countdown .time-box {
  animation: pulse 2s ease-in-out infinite;
  animation-delay: calc(var(--i) * 0.2s);
}

.countdown .time-box:nth-child(1) { --i: 0; }
.countdown .time-box:nth-child(2) { --i: 1; }
.countdown .time-box:nth-child(3) { --i: 2; }
.countdown .time-box:nth-child(4) { --i: 3; }

/* Podium animations */
.podium-card {
  opacity: 0;
  animation: scaleIn 0.8s ease forwards;
}

.podium-card.second {
  animation-delay: 0.2s;
}

.podium-card.first {
  animation-delay: 0.4s;
  animation-name: scaleIn, float;
  animation-duration: 0.8s, 3s;
  animation-timing-function: ease, ease-in-out;
  animation-iteration-count: 1, infinite;
  animation-delay: 0.4s, 1.2s;
}

.podium-card.third {
  animation-delay: 0.3s;
}

/* Table animation */
.table-wrap {
  opacity: 0;
  animation: fadeInUp 0.8s ease 0.8s both;
}

tbody tr {
  opacity: 0;
  animation: fadeInLeft 0.4s ease forwards;
  animation-delay: calc(0.8s + var(--row-index) * 0.05s);
}

/* -------------------- Hover Enhancements -------------------- */
.btn {
  position: relative;
  overflow: hidden;
}

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

.btn:hover::before {
  width: 300px;
  height: 300px;
}

/* Card hover with tilt */
.card, .link-card, .podium-card {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  transform-style: preserve-3d;
}

.card:hover, .link-card:hover {
  transform: translateY(-5px) rotateX(-2deg) rotateY(2deg);
}

/* Glowing badges */
.place-badge, .badge, .eyebrow {
  position: relative;
  overflow: hidden;
}

.place-badge::after, .badge::after, .eyebrow::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transition: left 0.5s;
}

.place-badge:hover::after, .badge:hover::after, .eyebrow:hover::after {
  left: 100%;
}

/* -------------------- Loading States -------------------- */
.loading {
  position: relative;
  overflow: hidden;
}

.loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(124, 77, 255, 0.1),
    transparent
  );
  animation: shimmer 2s infinite;
}

/* -------------------- Number Animations -------------------- */
.animate-number {
  display: inline-block;
  animation: fadeInUp 0.6s ease;
}

/* -------------------- Smooth Transitions -------------------- */
* {
  transition: color 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
}

/* -------------------- Accessibility -------------------- */
@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;
  }
}
