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

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

const Features = () => {
  const shouldReduceMotion = useReducedMotion();
  
  const features = [
    {
      icon: "/images/3d.cfabe065-1768470176517.svg",
      title: "EXTENSIBLE",
      description: "Provides unparalleled flexibility through its meticulously crafted modular architecture."
    },
    {
      icon: "/images/magic-wand.ff01fe1d-1768470176517.svg",
      title: "VERSATILE",
      description: "Serves as a robust, elegant, and well-structured foundation for all kinds of server-side applications."
    },
    {
      icon: "/images/quality.d1d04ce8-1768470176516.svg",
      title: "PROGRESSIVE",
      description: "Introduces design patterns and well-established solutions to the Node.js landscape."
    }
  ];

  if (shouldReduceMotion) {
    return (
      <section className="section-padding bg-nest-light-gray">
        <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
          <div className="grid md:grid-cols-3 gap-8 lg:gap-12">
            {features.map((feature, index) => (
              <div key={index} className="text-center">
                <div className="mb-6 flex justify-center">
                  <img src={feature.icon} alt="" className="w-16 h-16" />
                </div>
                <h3 className="text-nest-red font-bold text-lg mb-4">{feature.title}</h3>
                <p className="text-nest-gray leading-relaxed">{feature.description}</p>
              </div>
            ))}
          </div>
        </div>
      </section>
    );
  }

  return (
    <motion.section 
      {...fadeUpPreset(0.1, 1.0)}
      className="section-padding bg-nest-light-gray"
    >
      <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
        <div className="grid md:grid-cols-3 gap-8 lg:gap-12">
          {features.map((feature, index) => (
            <motion.div 
              key={index} 
              {...fadeUpPreset(index * 0.1, 0.6)}
              className="text-center"
            >
              <div className="mb-6 flex justify-center">
                <img src={feature.icon} alt="" className="w-16 h-16" />
              </div>
              <h3 className="text-nest-red font-bold text-lg mb-4">{feature.title}</h3>
              <p className="text-nest-gray leading-relaxed">{feature.description}</p>
            </motion.div>
          ))}
        </div>
      </div>
    </motion.section>
  );
};

export default Features;