import React from 'react';
import { motion, useReducedMotion } from 'framer-motion';

const fadeUpPreset = (delay = 0, duration = 1.2) => ({
  initial: { opacity: 0, y: 20 },
  whileInView: { opacity: 1, y: 0 },
  viewport: { once: true, amount: 0.2 },
  transition: { delay, duration, ease: "easeOut" }
});

const SupportSection = () => {
  const shouldReduce = useReducedMotion();

  const supportOptions = [
    {
      title: "PRINCIPAL SPONSORS",
      items: ["Valor Software", "Adyen"]
    },
    {
      title: "GOLD SPONSORS",
      items: ["Trilon", "Amplication"]
    },
    {
      title: "SILVER SPONSORS",
      items: ["Sentry", "JetBrains", "CodeSandbox"]
    },
    {
      title: "SPONSORS / PARTNERS",
      items: ["Various partners and supporters"]
    }
  ];

  if (shouldReduce) {
    return (
      <section className="section-padding bg-white">
        <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 text-center">
          <h2 className="text-4xl lg:text-5xl font-bold text-nest-text mb-6">
            Support us
          </h2>
          <p className="text-nest-text-light text-lg mb-12 max-w-3xl mx-auto">
            NestJS is an MIT-licensed open source project. It can grow thanks to the sponsors and support from the amazing backers. If you'd like to join them, please read more here.
          </p>
          
          <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-8 mb-12">
            {supportOptions.map((option, index) => (
              <div key={index} className="text-center">
                <h3 className="font-semibold text-sm text-nest-red mb-4 tracking-wider">
                  {option.title}
                </h3>
                <div className="space-y-2">
                  {option.items.map((item, itemIndex) => (
                    <p key={itemIndex} className="text-nest-text-light text-sm">
                      {item}
                    </p>
                  ))}
                </div>
              </div>
            ))}
          </div>
          
          <button className="btn-primary">
            Become a sponsor
          </button>
        </div>
      </section>
    );
  }

  return (
    <motion.section 
      {...fadeUpPreset(0.1, 1.0)}
      className="section-padding bg-white"
    >
      <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 text-center">
        <motion.h2 
          {...fadeUpPreset(0.2, 0.8)}
          className="text-4xl lg:text-5xl font-bold text-nest-text mb-6"
        >
          Support us
        </motion.h2>
        <motion.p 
          {...fadeUpPreset(0.3, 0.8)}
          className="text-nest-text-light text-lg mb-12 max-w-3xl mx-auto"
        >
          NestJS is an MIT-licensed open source project. It can grow thanks to the sponsors and support from the amazing backers. If you'd like to join them, please read more here.
        </motion.p>
        
        <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-8 mb-12">
          {supportOptions.map((option, index) => (
            <motion.div 
              key={index} 
              {...fadeUpPreset(0.4 + (index * 0.1), 0.6)}
              className="text-center"
            >
              <h3 className="font-semibold text-sm text-nest-red mb-4 tracking-wider">
                {option.title}
              </h3>
              <div className="space-y-2">
                {option.items.map((item, itemIndex) => (
                  <p key={itemIndex} className="text-nest-text-light text-sm">
                    {item}
                  </p>
                ))}
              </div>
            </motion.div>
          ))}
        </div>
        
        <motion.button 
          {...fadeUpPreset(0.8, 0.6)}
          className="btn-primary"
        >
          Become a sponsor
        </motion.button>
      </div>
    </motion.section>
  );
};

export default SupportSection;