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 EverythingYouNeed = () => {
  const shouldReduce = useReducedMotion();

  const features = [
    {
      icon: "📝",
      title: "DECORATORS",
      description: "Highly useful feature that allows you to add metadata to classes and their members using a clean, declarative syntax."
    },
    {
      icon: "⚡",
      title: "PERFORMANCE",
      description: "Fastify under the hood which provides up to 20x faster JSON serialization."
    },
    {
      icon: "🔍",
      title: "DEPENDENCY INJECTION",
      description: "Nest makes it easy to create scalable, loosely coupled, and easily testable applications."
    },
    {
      icon: "📊",
      title: "FIRST-CLASS",
      description: "Nest provides an out-of-the-box application architecture which allows developers and teams to create highly testable, scalable, loosely coupled, and easily maintainable applications."
    },
    {
      icon: "🛡️",
      title: "BUILT-IN SECURITY",
      description: "Nest comes with built-in security features like authentication, authorization, rate limiting, and more."
    },
    {
      icon: "📚",
      title: "EXTENSIVE DOCS",
      description: "Nest has extensive documentation and a large community of developers who contribute to the ecosystem."
    },
    {
      icon: "🔧",
      title: "MICROSERVICES",
      description: "Nest provides a dedicated microservices package that allows you to build distributed systems."
    },
    {
      icon: "🚀",
      title: "PRODUCTION READY",
      description: "Nest is production-ready and has been used by many companies to build large-scale applications."
    }
  ];

  if (shouldReduce) {
    return (
      <section className="py-20 bg-white">
        <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
          <div className="text-center mb-16">
            <h2 className="text-4xl md:text-5xl font-bold text-nest-dark mb-4">
              Everything you need.
            </h2>
            <p className="text-xl text-nest-gray max-w-3xl mx-auto">
              Nest offers powerful, extensible and modular architecture with dependency injection, making it easy to build scalable applications.
            </p>
          </div>
          <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-8">
            {features.map((feature, index) => (
              <div key={index} className="text-center p-6">
                <div className="text-4xl mb-4">{feature.icon}</div>
                <h3 className="text-lg font-bold text-nest-dark mb-3">
                  {feature.title}
                </h3>
                <p className="text-nest-gray text-sm leading-relaxed">
                  {feature.description}
                </p>
              </div>
            ))}
          </div>
        </div>
      </section>
    );
  }

  return (
    <motion.section 
      {...fadeUpPreset(0.1, 1.0)}
      className="py-20 bg-white"
    >
      <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
        <motion.div 
          {...fadeUpPreset(0.2, 0.8)}
          className="text-center mb-16"
        >
          <h2 className="text-4xl md:text-5xl font-bold text-nest-dark mb-4">
            Everything you need.
          </h2>
          <p className="text-xl text-nest-gray max-w-3xl mx-auto">
            Nest offers powerful, extensible and modular architecture with dependency injection, making it easy to build scalable applications.
          </p>
        </motion.div>
        <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-8">
          {features.map((feature, index) => (
            <motion.div 
              key={index} 
              {...fadeUpPreset(0.3 + index * 0.05, 0.6)}
              className="text-center p-6"
            >
              <div className="text-4xl mb-4">{feature.icon}</div>
              <h3 className="text-lg font-bold text-nest-dark mb-3">
                {feature.title}
              </h3>
              <p className="text-nest-gray text-sm leading-relaxed">
                {feature.description}
              </p>
            </motion.div>
          ))}
        </div>
      </div>
    </motion.section>
  );
};

export default EverythingYouNeed;