/**
 * Bull Finder Animations
 * GSAP-powered and CSS animations for enhanced UX
 */

/* ========================================
   KEYFRAME ANIMATIONS
   ======================================== */

@keyframes bf-fade-in {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes bf-slide-in-left {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes bf-slide-in-right {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes bf-scale-in {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes bf-bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes bf-pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

@keyframes bf-shake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-5px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(5px);
  }
}

@keyframes bf-rotate-in {
  from {
    opacity: 0;
    transform: rotate(-180deg) scale(0.5);
  }
  to {
    opacity: 1;
    transform: rotate(0) scale(1);
  }
}

@keyframes bf-flip-in {
  from {
    opacity: 0;
    transform: perspective(400px) rotateX(-90deg);
  }
  to {
    opacity: 1;
    transform: perspective(400px) rotateX(0);
  }
}

@keyframes bf-glow {
  0%, 100% {
    box-shadow: 0 0 5px rgba(44, 95, 45, 0.3);
  }
  50% {
    box-shadow: 0 0 20px rgba(44, 95, 45, 0.6);
  }
}

@keyframes bf-progress-fill {
  from {
    width: 0;
  }
  to {
    width: var(--progress-width);
  }
}

@keyframes bf-ring-fill {
  from {
    stroke-dashoffset: 314;
  }
  to {
    stroke-dashoffset: var(--ring-offset);
  }
}

@keyframes bf-confetti {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

@keyframes bf-sparkle {
  0%, 100% {
    opacity: 0;
    transform: scale(0);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ========================================
   ENTRANCE ANIMATIONS
   ======================================== */

.bf-animate-in {
  animation: bf-fade-in 0.6s ease-out forwards;
}

.bf-animate-in-delay-1 {
  animation: bf-fade-in 0.6s ease-out 0.1s forwards;
  opacity: 0;
}

.bf-animate-in-delay-2 {
  animation: bf-fade-in 0.6s ease-out 0.2s forwards;
  opacity: 0;
}

.bf-animate-in-delay-3 {
  animation: bf-fade-in 0.6s ease-out 0.3s forwards;
  opacity: 0;
}

.bf-slide-left {
  animation: bf-slide-in-left 0.5s ease-out;
}

.bf-slide-right {
  animation: bf-slide-in-right 0.5s ease-out;
}

.bf-scale-in {
  animation: bf-scale-in 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.bf-rotate-in {
  animation: bf-rotate-in 0.6s ease-out;
}

.bf-flip-in {
  animation: bf-flip-in 0.5s ease-out;
}

/* ========================================
   CONTINUOUS ANIMATIONS
   ======================================== */

.bf-bounce {
  animation: bf-bounce 2s ease-in-out infinite;
}

.bf-pulse {
  animation: bf-pulse 2s ease-in-out infinite;
}

.bf-glow {
  animation: bf-glow 2s ease-in-out infinite;
}

/* ========================================
   PROGRESS ANIMATIONS
   ======================================== */

.bf-progress-fill {
  transition: width 0.8s cubic-bezier(0.65, 0, 0.35, 1);
}

.bf-progress-fill-animated {
  animation: bf-progress-fill 1s ease-out forwards;
}

.bf-ring-fill {
  animation: bf-ring-fill 1.5s cubic-bezier(0.65, 0, 0.35, 1) forwards;
}

/* ========================================
   INTERACTION ANIMATIONS
   ======================================== */

.bf-operation-card,
.bf-goal-card,
.bf-choice-card {
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.bf-operation-card:active,
.bf-goal-card:active,
.bf-choice-card:active {
  transform: scale(0.95);
}

.bf-btn {
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.bf-btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.bf-btn:active::before {
  width: 300px;
  height: 300px;
}

/* ========================================
   SLIDER ANIMATIONS
   ======================================== */

.bf-slider {
  transition: all 0.3s ease;
}

.bf-slider::-webkit-slider-thumb {
  transition: all 0.2s ease;
}

.bf-slider::-moz-range-thumb {
  transition: all 0.2s ease;
}

.bf-slider:active::-webkit-slider-thumb {
  transform: scale(1.2);
}

.bf-slider:active::-moz-range-thumb {
  transform: scale(1.2);
}

/* ========================================
   CARD ANIMATIONS
   ======================================== */

.bf-bull-card {
  transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.bf-bull-card.bf-card-entering {
  animation: bf-scale-in 0.5s ease-out;
}

.bf-card-image img {
  transition: transform 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.bf-image-overlay {
  transition: opacity 0.3s ease;
}

/* ========================================
   ACHIEVEMENT ANIMATIONS
   ======================================== */

.bf-achievement-popup {
  animation: bf-achievement-enter 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes bf-achievement-enter {
  0% {
    opacity: 0;
    transform: translateY(-100px) scale(0.5);
  }
  60% {
    transform: translateY(10px) scale(1.1);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.bf-achievement-popup.bf-achievement-exit {
  animation: bf-achievement-exit 0.4s ease-out forwards;
}

@keyframes bf-achievement-exit {
  to {
    opacity: 0;
    transform: translateY(-20px);
  }
}

.bf-achievement-badge {
  animation: bf-rotate-in 0.5s ease-out 0.2s backwards;
}

/* ========================================
   CONFETTI ANIMATION
   ======================================== */

.bf-confetti-piece {
  position: fixed;
  width: 10px;
  height: 10px;
  background: var(--bf-accent);
  top: 0;
  animation: bf-confetti 3s ease-out forwards;
  z-index: 10000;
}

.bf-confetti-piece:nth-child(odd) {
  background: var(--bf-primary);
}

.bf-confetti-piece:nth-child(3n) {
  background: var(--bf-success);
}

/* ========================================
   LOADING ANIMATIONS
   ======================================== */

.bf-loading {
  position: relative;
}

.bf-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 4px solid rgba(44, 95, 45, 0.2);
  border-top-color: var(--bf-primary);
  border-radius: 50%;
  animation: bf-spin 1s linear infinite;
}

@keyframes bf-spin {
  to {
    transform: rotate(360deg);
  }
}

.bf-loading-dots::after {
  content: '';
  animation: bf-dots 1.5s steps(4) infinite;
}

@keyframes bf-dots {
  0%, 20% {
    content: '.';
  }
  40% {
    content: '..';
  }
  60%, 100% {
    content: '...';
  }
}

/* ========================================
   VISUAL FEEDBACK ANIMATIONS
   ======================================== */

.bf-success-flash {
  animation: bf-success-flash 0.6s ease-out;
}

@keyframes bf-success-flash {
  0%, 100% {
    background: inherit;
  }
  50% {
    background: rgba(76, 175, 80, 0.3);
  }
}

.bf-error-shake {
  animation: bf-shake 0.5s ease-out;
}

.bf-highlight {
  animation: bf-highlight 1s ease-out;
}

@keyframes bf-highlight {
  0%, 100% {
    background: inherit;
  }
  50% {
    background: rgba(230, 126, 34, 0.3);
  }
}

/* ========================================
   NUMBER COUNTER ANIMATION
   ======================================== */

.bf-counter {
  display: inline-block;
}

.bf-counter.bf-counting {
  animation: bf-number-roll 0.6s ease-out;
}

@keyframes bf-number-roll {
  0% {
    transform: translateY(-20px);
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ========================================
   STAGGER ANIMATIONS
   ======================================== */

.bf-stagger-item {
  opacity: 0;
  animation: bf-fade-in 0.5s ease-out forwards;
}

.bf-stagger-item:nth-child(1) {
  animation-delay: 0.1s;
}

.bf-stagger-item:nth-child(2) {
  animation-delay: 0.2s;
}

.bf-stagger-item:nth-child(3) {
  animation-delay: 0.3s;
}

.bf-stagger-item:nth-child(4) {
  animation-delay: 0.4s;
}

.bf-stagger-item:nth-child(5) {
  animation-delay: 0.5s;
}

.bf-stagger-item:nth-child(6) {
  animation-delay: 0.6s;
}

.bf-stagger-item:nth-child(7) {
  animation-delay: 0.7s;
}

.bf-stagger-item:nth-child(8) {
  animation-delay: 0.8s;
}

/* ========================================
   COMPARISON ANIMATIONS
   ======================================== */

.bf-comparison-row {
  opacity: 0;
  animation: bf-slide-in-left 0.5s ease-out forwards;
}

.bf-comparison-row:nth-child(1) {
  animation-delay: 0.1s;
}

.bf-comparison-row:nth-child(2) {
  animation-delay: 0.15s;
}

.bf-comparison-row:nth-child(3) {
  animation-delay: 0.2s;
}

.bf-comparison-row:nth-child(4) {
  animation-delay: 0.25s;
}

.bf-comparison-row:nth-child(5) {
  animation-delay: 0.3s;
}

.bf-winner-badge {
  animation: bf-bounce 1s ease-in-out infinite;
}

.bf-comparison-bull-value.winner {
  animation: bf-winner-highlight 0.6s ease-out;
}

@keyframes bf-winner-highlight {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1.05);
  }
}

/* ========================================
   TRAIT BAR ANIMATIONS
   ======================================== */

.bf-trait-bar-fill {
  transform-origin: left;
  animation: bf-bar-expand 0.8s cubic-bezier(0.65, 0, 0.35, 1) forwards;
}

@keyframes bf-bar-expand {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

.bf-trait-bar:nth-child(1) .bf-trait-bar-fill {
  animation-delay: 0.1s;
}

.bf-trait-bar:nth-child(2) .bf-trait-bar-fill {
  animation-delay: 0.2s;
}

.bf-trait-bar:nth-child(3) .bf-trait-bar-fill {
  animation-delay: 0.3s;
}

/* ========================================
   VISUAL METAPHOR ANIMATIONS
   ======================================== */

.bf-milk-bottles span,
.bf-cheese-wheels span,
.bf-health-hearts span {
  display: inline-block;
  animation: bf-pop-in 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55) backwards;
}

.bf-milk-bottles span:nth-child(1),
.bf-cheese-wheels span:nth-child(1),
.bf-health-hearts span:nth-child(1) {
  animation-delay: 0.1s;
}

.bf-milk-bottles span:nth-child(2),
.bf-cheese-wheels span:nth-child(2),
.bf-health-hearts span:nth-child(2) {
  animation-delay: 0.2s;
}

.bf-milk-bottles span:nth-child(3),
.bf-cheese-wheels span:nth-child(3),
.bf-health-hearts span:nth-child(3) {
  animation-delay: 0.3s;
}

.bf-milk-bottles span:nth-child(4),
.bf-cheese-wheels span:nth-child(4),
.bf-health-hearts span:nth-child(4) {
  animation-delay: 0.4s;
}

.bf-milk-bottles span:nth-child(5),
.bf-cheese-wheels span:nth-child(5),
.bf-health-hearts span:nth-child(5) {
  animation-delay: 0.5s;
}

@keyframes bf-pop-in {
  0% {
    opacity: 0;
    transform: scale(0);
  }
  60% {
    transform: scale(1.2);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ========================================
   SPARKLE EFFECT
   ======================================== */

.bf-sparkle {
  position: relative;
}

.bf-sparkle::before,
.bf-sparkle::after {
  content: '✨';
  position: absolute;
  font-size: 1.5em;
  animation: bf-sparkle 2s ease-in-out infinite;
}

.bf-sparkle::before {
  top: -10px;
  left: -10px;
}

.bf-sparkle::after {
  bottom: -10px;
  right: -10px;
  animation-delay: 1s;
}

/* ========================================
   PAGE TRANSITION
   ======================================== */

.bf-page-transition {
  opacity: 0;
  animation: bf-fade-in 0.5s ease-out forwards;
}

.bf-page-exit {
  animation: bf-fade-out 0.3s ease-out forwards;
}

@keyframes bf-fade-out {
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* ========================================
   GSAP ANIMATION HOOKS
   ======================================== */

.gsap-fade-in {
  opacity: 0;
}

.gsap-slide-up {
  opacity: 0;
  transform: translateY(30px);
}

.gsap-scale {
  transform: scale(0.8);
  opacity: 0;
}

.gsap-stagger {
  opacity: 0;
  transform: translateX(-20px);
}
