<section id="cta-c" class="py-24 bg-gradient-to-b from-white to-gray-50 flex flex-col items-center relative overflow-hidden">
  <!-- Decorative background elements -->
  <div class="absolute inset-0 overflow-hidden pointer-events-none">
    <div class="absolute top-0 right-0 w-1/3 h-1/3 bg-secondary/5 rounded-full blur-3xl transform translate-x-1/2 -translate-y-1/2"></div>
    <div class="absolute bottom-0 left-0 w-1/3 h-1/3 bg-secondary/5 rounded-full blur-3xl transform -translate-x-1/2 translate-y-1/2"></div>
  </div>
  
  <!-- Content container with subtle animations -->
  <div class="relative z-10 w-full max-w-4xl mx-auto px-6 animate-fade-in">
    <!-- Animated badge -->
    <div class="inline-flex items-center px-3 py-1 rounded-full bg-secondary/10 text-secondary text-sm font-medium mb-6 mx-auto">
      <span class="flex h-2 w-2 mr-2">
        <span class="animate-ping absolute inline-flex h-2 w-2 rounded-full bg-secondary opacity-75"></span>
        <span class="relative inline-flex rounded-full h-2 w-2 bg-secondary"></span>
      </span>
      Join Our Community
    </div>
    
    <h2 class="text-3xl sm:text-4xl font-bold text-gray-800 mb-4 text-center relative">
      {{ sections.community.title }}
      <div class="absolute -bottom-2 left-1/2 transform -translate-x-1/2 w-20 h-1 bg-secondary/30 rounded-full"></div>
    </h2>
    
    <p class="text-center text-gray-600 mb-10 max-w-xl mx-auto leading-relaxed">
      {{ sections.community.subtitle }}
    </p>

    <!-- Enhanced form with glass effect and animations -->
    <form
      id="subscribeFormC"
      class="group flex items-center w-full max-w-xl mx-auto bg-white/80 backdrop-blur-sm border border-gray-200 rounded-full overflow-hidden shadow-lg hover:shadow-xl transition-all duration-300 hover:border-secondary/30"
    >
      <span class="pl-6 pr-2 text-secondary">
        <svg
          class="w-6 h-6"
          fill="none"
          stroke="currentColor"
          stroke-width="2"
          viewBox="0 0 24 24"
        >
          <path
            stroke-linecap="round"
            stroke-linejoin="round"
            d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8m0 8V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2h14a2 2 0 002-2z"
          />
        </svg>
      </span>
      
      <!-- Input with focus effects -->
      <div class="relative flex-1">
        <input
          type="email"
          placeholder="Enter your email address"
          class="w-full px-3 py-4 bg-transparent border-0 focus:outline-none focus:ring-0 text-gray-700 placeholder-gray-400"
          required
        />
        <!-- Subtle focus indicator -->
        <div class="absolute bottom-0 left-0 w-0 h-0.5 bg-secondary group-focus-within:w-full transition-all duration-300"></div>
      </div>
      
      <!-- Enhanced button with hover effects -->
      <button
        type="submit"
        class="relative px-8 py-4 bg-secondary text-white font-medium overflow-hidden group-hover:shadow-inner transition-all duration-300"
      >
        <!-- Button background animation -->
        <span class="absolute inset-0 w-full h-full bg-gradient-to-r from-secondary-dark to-secondary transition-transform duration-300 transform translate-x-full group-hover:translate-x-0"></span>
        <span class="relative">{{ sections.community.cta.label }}</span>
      </button>
    </form>
    
    <!-- Enhanced success message with animation -->
    <div id="subscribeMsgC" class="hidden mt-6 transform transition-all duration-500 opacity-0 translate-y-4" data-success>
      <div class="flex items-center justify-center p-4 bg-green-50 rounded-xl border border-green-100 shadow-sm">
        <div class="flex-shrink-0 w-10 h-10 rounded-full bg-green-100 flex items-center justify-center">
          <svg class="h-6 w-6 text-green-600" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
          </svg>
        </div>
        <div class="ml-3">
          <p class="text-green-600 font-medium">🎉 Welcome aboard!</p>
          <p class="text-sm text-gray-600">Thank you for joining our community.</p>
        </div>
      </div>
    </div>
    
    <!-- Trust indicators -->
    <div class="mt-10 flex flex-wrap justify-center gap-6 text-sm text-gray-500">
      <div class="flex items-center">
        <svg class="w-5 h-5 mr-2 text-secondary/70" fill="none" stroke="currentColor" viewBox="0 0 24 24">
          <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z" />
        </svg>
        <span>Your data is secure</span>
      </div>
      <div class="flex items-center">
        <svg class="w-5 h-5 mr-2 text-secondary/70" fill="none" stroke="currentColor" viewBox="0 0 24 24">
          <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
        </svg>
        <span>No spam, unsubscribe anytime</span>
      </div>
    </div>
  </div>
</section>

<style>
  /* Custom animations */
  @keyframes fade-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
  }
  
  .animate-fade-in {
    animation: fade-in 0.8s ease-out forwards;
  }
</style>

<script>
  document
    .getElementById("subscribeFormC")
    .addEventListener("submit", function (e) {
      e.preventDefault();
      const email = this.querySelector("input").value.trim();
      if (/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
        const successMsg = document.getElementById("subscribeMsgC");
        successMsg.classList.remove("hidden");
        // Add a small delay to allow the display:none to be removed before animating
        setTimeout(() => {
          successMsg.classList.remove("opacity-0", "translate-y-4");
        }, 10);
        this.reset();
      }
    });
</script>