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

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 Hero = () => {
  const shouldReduceMotion = useReducedMotion();

  const techStack = [
    { name: 'nestjs', color: 'text-red-500' },
    { name: 'mysql', color: 'text-blue-600' },
    { name: 'mongodb', color: 'text-green-600' },
    { name: 'nginx', color: 'text-green-700' },
    { name: 'redis', color: 'text-red-600' },
    { name: 'typescript', color: 'text-blue-600' }
  ];

  if (shouldReduceMotion) {
    return (
      <section className="hero-gradient pt-20 pb-16 px-4 sm:px-6 lg:px-8">
        <div className="max-w-7xl mx-auto">
          <div className="text-center max-w-4xl mx-auto">
            <h1 className="text-4xl sm:text-5xl lg:text-6xl font-bold mb-6">
              <span className="text-gradient">AI-powered</span>
              <br />
              <span className="text-gray-900">web and mobile</span>
              <br />
              <span className="text-gradient">in 12 weeks</span>
            </h1>
            
            <div className="flex items-center justify-center space-x-2 mb-8">
              <span className="text-gray-600 font-medium">Powered by</span>
              <div className="flex items-center space-x-1">
                <div className="w-6 h-6 bg-red-500 rounded-full"></div>
                <span className="font-semibold text-gray-900">n8n</span>
              </div>
            </div>

            <div className="flex flex-col sm:flex-row items-center justify-center space-y-4 sm:space-y-0 sm:space-x-4 mb-12">
              <button className="btn-primary">
                Start Discovery
              </button>
              <button className="btn-secondary flex items-center space-x-2">
                <Package className="w-5 h-5" />
                <span>Portfolio Showcase</span>
              </button>
            </div>

            <div className="flex flex-wrap items-center justify-center gap-4">
              {techStack.map((tech, index) => (
                <div key={tech.name} className="tech-badge">
                  <span className={`text-sm font-medium ${tech.color}`}>#{tech.name}</span>
                </div>
              ))}
            </div>
          </div>
        </div>
      </section>
    );
  }

  return (
    <motion.section 
      {...fadeUpPreset(0.1, 0.8)}
      className="hero-gradient pt-20 pb-16 px-4 sm:px-6 lg:px-8"
    >
      <div className="max-w-7xl mx-auto">
        <div className="text-center max-w-4xl mx-auto">
          <motion.h1 
            {...fadeUpPreset(0.2, 0.8)}
            className="text-4xl sm:text-5xl lg:text-6xl font-bold mb-6"
          >
            <span className="text-gradient">AI-powered</span>
            <br />
            <span className="text-gray-900">web and mobile</span>
            <br />
            <span className="text-gradient">in 12 weeks</span>
          </motion.h1>
          
          <motion.div 
            {...fadeUpPreset(0.3, 0.8)}
            className="flex items-center justify-center space-x-2 mb-8"
          >
            <span className="text-gray-600 font-medium">Powered by</span>
            <div className="flex items-center space-x-1">
              <div className="w-6 h-6 bg-red-500 rounded-full"></div>
              <span className="font-semibold text-gray-900">n8n</span>
            </div>
          </motion.div>

          <motion.div 
            {...fadeUpPreset(0.4, 0.8)}
            className="flex flex-col sm:flex-row items-center justify-center space-y-4 sm:space-y-0 sm:space-x-4 mb-12"
          >
            <button className="btn-primary">
              Start Discovery
            </button>
            <button className="btn-secondary flex items-center space-x-2">
              <Package className="w-5 h-5" />
              <span>Portfolio Showcase</span>
            </button>
          </motion.div>

          <motion.div 
            {...fadeUpPreset(0.5, 0.8)}
            className="flex flex-wrap items-center justify-center gap-4"
          >
            {techStack.map((tech, index) => (
              <motion.div 
                key={tech.name}
                {...fadeUpPreset(0.6 + index * 0.05, 0.6)}
                className="tech-badge"
              >
                <span className={`text-sm font-medium ${tech.color}`}>#{tech.name}</span>
              </motion.div>
            ))}
          </motion.div>
        </div>
      </div>
    </motion.section>
  );
};

export default Hero;