<section
  id="challenges"
  class="relative py-32 bg-gradient-to-tr from-amber-50 via-emerald-50 to-sky-50 overflow-hidden"
>
  <!-- Animated background patterns -->
  <div class="absolute inset-0 opacity-20">
    <div class="absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiMwZWE1ZTkiIGZpbGwtb3BhY2l0eT0iMC4wNSI+PHBhdGggZD0iTTM2IDM0aDZ2NmgtNnpNNDIgNDBoNnY2aC02ek0zMCA0MGg2djZoLTZ6TTQyIDM0aDZ2NmgtNnoiLz48L2c+PC9nPjwvc3ZnPg==')]"></div>
  </div>
  
  <!-- Colorful floating elements -->
  <div class="absolute top-1/4 left-10 w-24 h-24 bg-gradient-to-r from-amber-400 to-orange-400 rounded-full mix-blend-multiply filter blur-xl opacity-70 animate-blob"></div>
  <div class="absolute top-1/3 right-10 w-32 h-32 bg-gradient-to-r from-emerald-400 to-teal-400 rounded-full mix-blend-multiply filter blur-xl opacity-70 animate-blob animation-delay-2000"></div>
  <div class="absolute bottom-1/4 left-1/3 w-36 h-36 bg-gradient-to-r from-sky-400 to-indigo-400 rounded-full mix-blend-multiply filter blur-xl opacity-70 animate-blob animation-delay-4000"></div>
  
  <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 relative z-10">
    <!-- Section header with vibrant design -->
    <div class="text-center mb-20">
      <span class="inline-flex items-center px-3 py-1 rounded-full bg-amber-100 text-amber-800 text-sm font-medium mb-4 animate-pulse">
        <span class="w-2 h-2 bg-amber-500 rounded-full mr-2"></span>
        Achievements & Impact
      </span>
      <h2 class="text-5xl font-black mb-6 bg-clip-text text-transparent bg-gradient-to-r from-amber-500 via-emerald-500 to-sky-500">
        {{ sections.challenges.title }}
      </h2>
      <p class="text-xl text-slate-600 max-w-3xl mx-auto leading-relaxed">
        {{ sections.challenges.subtitle }}
      </p>
    </div>

    <!-- Vibrant card grid with modern animations -->
    <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-8">
      {% for item in sections.challenges.items %}
      <div class="group perspective">
        <div class="relative h-full transition-all duration-500 ease-out preserve-3d group-hover:rotate-y-6 group-hover:-rotate-x-3">
          <div class="card-front absolute inset-0 backface-hidden">
            <div class="h-full p-8 rounded-3xl bg-white shadow-lg border border-slate-100 overflow-hidden">
              <!-- Colorful top accent -->
              <div class="absolute top-0 inset-x-0 h-2 bg-gradient-to-r from-{{ item.color }}-400 to-{{ item.color }}-500"></div>
              
              <!-- Animated icon -->
              <div class="relative w-16 h-16 mb-6 group-hover:scale-110 transition-transform duration-300">
                <div class="absolute inset-0 rounded-2xl bg-gradient-to-br from-{{ item.color }}-400 to-{{ item.color }}-600 opacity-20 group-hover:opacity-30 transition-opacity"></div>
                <div class="absolute inset-0 flex items-center justify-center">
                  <i class="{{ item.icon }} text-{{ item.color }}-500 text-3xl"></i>
                </div>
              </div>
              
              <!-- Content with bright accents -->
              <h3 class="text-3xl font-extrabold text-slate-800 mb-3 group-hover:text-{{ item.color }}-500 transition-colors">
                {{ item.value }}
              </h3>
              <p class="text-slate-500 group-hover:text-slate-600 transition-colors">
                {{ item.label }}
              </p>
              
              <!-- Decorative elements -->
              <div class="absolute bottom-0 right-0 w-24 h-24 bg-gradient-to-tl from-{{ item.color }}-100 to-transparent rounded-tl-full opacity-50"></div>
              <div class="absolute -bottom-2 -right-2 w-12 h-12 bg-{{ item.color }}-100 rounded-full opacity-40 group-hover:scale-150 transition-transform duration-700"></div>
            </div>
          </div>
        </div>
      </div>
      {% endfor %}
    </div>
    
    <!-- Vibrant CTA button -->
    <div class="text-center mt-20">
      <a href="#contact" class="group relative inline-flex items-center justify-center">
        <!-- Button background with gradient -->
        <span class="absolute inset-0 w-full h-full transition duration-300 ease-out transform translate-x-1 translate-y-1 bg-emerald-500 group-hover:translate-x-0 group-hover:translate-y-0"></span>
        <span class="absolute inset-0 w-full h-full bg-white border-2 border-emerald-500 group-hover:bg-emerald-500"></span>
        
        <!-- Button content -->
        <span class="relative px-8 py-4 text-emerald-500 group-hover:text-white transition-colors flex items-center space-x-2">
          <span class="font-bold">Get Started Today</span>
          <svg class="w-5 h-5 transition-transform group-hover:translate-x-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 5l7 7m0 0l-7 7m7-7H3"></path>
          </svg>
          
          <!-- Animated dots on hover -->
          <span class="absolute -right-4 top-1/2 transform -translate-y-1/2 w-2 h-2 bg-emerald-500 rounded-full opacity-0 group-hover:opacity-100 group-hover:animate-ping"></span>
        </span>
      </a>
    </div>
  </div>
  
  <style>
    /* Custom animations */
    @keyframes blob {
      0%, 100% { transform: translate(0, 0) scale(1); }
      25% { transform: translate(20px, -20px) scale(1.1); }
      50% { transform: translate(-20px, 20px) scale(0.9); }
      75% { transform: translate(20px, 20px) scale(1.05); }
    }
    
    .animate-blob {
      animation: blob 10s infinite;
    }
    
    .animation-delay-2000 {
      animation-delay: 2s;
    }
    
    .animation-delay-4000 {
      animation-delay: 4s;
    }
    
    /* 3D card effect */
    .perspective {
      perspective: 1000px;
    }
    
    .preserve-3d {
      transform-style: preserve-3d;
    }
    
    .backface-hidden {
      backface-visibility: hidden;
    }
    
    .rotate-y-6 {
      transform: rotateY(6deg);
    }
    
    .-rotate-x-3 {
      transform: rotateX(-3deg);
    }
    
    /* Counter animation */
    .counter-value {
      display: inline-block;
      position: relative;
    }
    
    /* Mobile optimizations */
    @media (max-width: 639px) {
      .grid {
        gap: 1.5rem;
      }
    }
  </style>
  
  <script>
    document.addEventListener('DOMContentLoaded', function() {
      // Counter animation
      const counters = document.querySelectorAll('h3');
      
      counters.forEach(counter => {
        const value = counter.innerText;
        if (!isNaN(parseInt(value.replace(/,/g, '')))) {
          const target = parseInt(value.replace(/,/g, ''));
          const duration = 2500;
          const frameDuration = 1000/60;
          const totalFrames = Math.round(duration / frameDuration);
          const easeOutQuad = t => t * (2 - t);
          
          let frame = 0;
          counter.innerText = '0';
          
          const animate = () => {
            frame++;
            const progress = easeOutQuad(frame / totalFrames);
            const currentCount = Math.round(target * progress);
            
            if (currentCount === target) {
              counter.innerText = target.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
              cancelAnimationFrame(animate);
            } else {
              counter.innerText = currentCount.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
              requestAnimationFrame(animate);
            }
          };
          
          // Start animation when element is in view
          const observer = new IntersectionObserver((entries) => {
            if (entries[0].isIntersecting) {
              requestAnimationFrame(animate);
              observer.disconnect();
            }
          }, { threshold: 0.5 });
          
          observer.observe(counter);
        }
      });
    });
  </script>
</section>