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

  const features = [
    {
      icon: (
        <svg className="feature-icon" viewBox="0 0 64 64" fill="none">
          <path d="M32 8L8 20v24l24 12 24-12V20L32 8z" stroke="#333" strokeWidth="2" fill="none"/>
          <path d="M8 20l24 12 24-12" stroke="#333" strokeWidth="2"/>
          <path d="M32 32v20" stroke="#333" strokeWidth="2"/>
        </svg>
      ),
      title: "EXTENSIBLE",
      description: "Provides unparalleled flexibility through its meticulously crafted modular architecture."
    },
    {
      icon: (
        <svg className="feature-icon" viewBox="0 0 64 64" fill="none">
          <path d="M32 8l8 8-8 8-8-8 8-8z" stroke="#e0234e" strokeWidth="2" fill="none"/>
          <path d="M16 24l8 8-8 8-8-8 8-8z" stroke="#e0234e" strokeWidth="2" fill="none"/>
          <path d="M48 24l8 8-8 8-8-8 8-8z" stroke="#e0234e" strokeWidth="2" fill="none"/>
          <path d="M32 40l8 8-8 8-8-8 8-8z" stroke="#e0234e" strokeWidth="2" fill="none"/>
          <circle cx="32" cy="16" r="2" fill="#e0234e"/>
          <circle cx="16" cy="32" r="2" fill="#e0234e"/>
          <circle cx="48" cy="32" r="2" fill="#e0234e"/>
          <circle cx="32" cy="48" r="2" fill="#e0234e"/>
        </svg>
      ),
      title: "VERSATILE",
      description: "Serves as a robust, elegant, and well-structured foundation for all kinds of server-side applications."
    },
    {
      icon: (
        <svg className="feature-icon" viewBox="0 0 64 64" fill="none">
          <path d="M32 8l16 16-16 16-16-16L32 8z" stroke="#333" strokeWidth="2" fill="none"/>
          <path d="M20 20l4 4-4 4-4-4 4-4z" stroke="#333" strokeWidth="2" fill="none"/>
          <path d="M44 20l4 4-4 4-4-4 4-4z" stroke="#333" strokeWidth="2" fill="none"/>
          <path d="M32 32l4 4-4 4-4-4 4-4z" stroke="#333" strokeWidth="2" fill="none"/>
          <circle cx="32" cy="16" r="3" fill="#333"/>
          <circle cx="20" cy="24" r="2" fill="#333"/>
          <circle cx="44" cy="24" r="2" fill="#333"/>
          <circle cx="32" cy="36" r="2" fill="#333"/>
        </svg>
      ),
      title: "PROGRESSIVE",
      description: "Introduces design patterns and well-established solutions to the Node.js landscape."
    }
  ];

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

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

export default Features;