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

  if (shouldReduceMotion) {
    return (
      <section className="pt-24 pb-16 bg-gradient-to-br from-gray-50 to-gray-100">
        <div className="container-custom">
          <div className="max-w-4xl mx-auto text-center">
            <h1 className="text-4xl 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">Powered by</span>
              <div className="flex items-center space-x-1">
                <div className="w-6 h-6 bg-red-500 rounded-full flex items-center justify-center">
                  <span className="text-white text-xs font-bold">n</span>
                </div>
                <span className="font-semibold text-gray-900">n8n</span>
              </div>
            </div>

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

            <div className="flex flex-wrap justify-center gap-4 mb-16">
              {[
                { name: 'Telegram', color: 'bg-blue-500' },
                { name: 'Instagram', color: 'bg-pink-500' },
                { name: 'Whatsapp', color: 'bg-green-500' }
              ].map((platform, index) => (
                <div key={platform.name} className="tech-badge">
                  <div className={`w-4 h-4 ${platform.color} rounded-full`}></div>
                  <span>{platform.name}</span>
                </div>
              ))}
            </div>

            <div className="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-4">
              {[
                { name: '#nestjs', color: 'text-red-500' },
                { name: '#mysql', color: 'text-blue-500' },
                { name: '#mongodb', color: 'text-green-500' },
                { name: '#nginx', color: 'text-green-600' },
                { name: '#redis', color: 'text-red-600' },
                { name: '#typescript', color: 'text-blue-600' }
              ].map((tech, index) => (
                <div key={tech.name} className="tech-badge">
                  <span className={`font-mono text-sm ${tech.color}`}>{tech.name}</span>
                </div>
              ))}
            </div>
          </div>
        </div>
      </section>
    );
  }

  return (
    <motion.section 
      {...fadeUpPreset(0.1, 0.8)}
      className="pt-24 pb-16 bg-gradient-to-br from-gray-50 to-gray-100"
    >
      <div className="container-custom">
        <div className="max-w-4xl mx-auto text-center">
          <motion.h1 
            {...fadeUpPreset(0.2, 0.8)}
            className="text-4xl 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">Powered by</span>
            <div className="flex items-center space-x-1">
              <div className="w-6 h-6 bg-red-500 rounded-full flex items-center justify-center">
                <span className="text-white text-xs font-bold">n</span>
              </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 gap-4 justify-center mb-12"
          >
            <button className="btn-primary">
              Start Discovery
            </button>
            <button className="btn-secondary flex items-center justify-center space-x-2">
              <span>Portfolio Showcase</span>
            </button>
          </motion.div>

          <motion.div 
            {...fadeUpPreset(0.5, 0.8)}
            className="flex flex-wrap justify-center gap-4 mb-16"
          >
            {[
              { name: 'Telegram', color: 'bg-blue-500' },
              { name: 'Instagram', color: 'bg-pink-500' },
              { name: 'Whatsapp', color: 'bg-green-500' }
            ].map((platform, index) => (
              <motion.div 
                key={platform.name} 
                {...fadeUpPreset(0.6 + index * 0.1, 0.6)}
                className="tech-badge"
              >
                <div className={`w-4 h-4 ${platform.color} rounded-full`}></div>
                <span>{platform.name}</span>
              </motion.div>
            ))}
          </motion.div>

          <motion.div 
            {...fadeUpPreset(0.7, 0.8)}
            className="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-4"
          >
            {[
              { name: '#nestjs', color: 'text-red-500' },
              { name: '#mysql', color: 'text-blue-500' },
              { name: '#mongodb', color: 'text-green-500' },
              { name: '#nginx', color: 'text-green-600' },
              { name: '#redis', color: 'text-red-600' },
              { name: '#typescript', color: 'text-blue-600' }
            ].map((tech, index) => (
              <motion.div 
                key={tech.name} 
                {...fadeUpPreset(0.8 + index * 0.05, 0.6)}
                className="tech-badge"
              >
                <span className={`font-mono text-sm ${tech.color}`}>{tech.name}</span>
              </motion.div>
            ))}
          </motion.div>
        </div>
      </div>
    </motion.section>
  );
};

export default Hero;