import React from 'react';
import { motion, useReducedMotion } from 'framer-motion';
import { Github } 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" }
});

function Hero() {
  const shouldReduce = useReducedMotion();
  
  if (shouldReduce) {
    return (
      <section className="relative min-h-screen bg-black flex items-center justify-center overflow-hidden">
        <div 
          className="absolute inset-0 bg-cover bg-center bg-no-repeat opacity-30"
          style={{ backgroundImage: "url('https://nestjs.com/img/hero-bg.jpg')" }}
        />
        <div className="relative z-10 container-custom text-center text-white">
          <h1 className="text-5xl md:text-7xl font-bold mb-6">
            Hello, nest!
          </h1>
          <p className="text-xl md:text-2xl mb-12 max-w-3xl mx-auto leading-relaxed">
            A progressive Node.js framework for building efficient, reliable and scalable server-side applications.
          </p>
          <div className="flex flex-col sm:flex-row gap-4 justify-center">
            <button className="btn-primary text-lg px-8 py-4">
              Documentation
            </button>
            <button className="btn-secondary text-lg px-8 py-4 flex items-center justify-center gap-2">
              <Github className="h-5 w-5" />
              Source code
            </button>
          </div>
        </div>
      </section>
    );
  }

  return (
    <motion.section 
      {...fadeUpPreset(0.1, 0.8)}
      className="relative min-h-screen bg-black flex items-center justify-center overflow-hidden"
    >
      <div 
        className="absolute inset-0 bg-cover bg-center bg-no-repeat opacity-30"
        style={{ backgroundImage: "url('https://nestjs.com/img/hero-bg.jpg')" }}
      />
      <div className="relative z-10 container-custom text-center text-white">
        <motion.h1 
          {...fadeUpPreset(0.2, 0.8)}
          className="text-5xl md:text-7xl font-bold mb-6"
        >
          Hello, nest!
        </motion.h1>
        <motion.p 
          {...fadeUpPreset(0.4, 0.8)}
          className="text-xl md:text-2xl mb-12 max-w-3xl mx-auto leading-relaxed"
        >
          A progressive Node.js framework for building efficient, reliable and scalable server-side applications.
        </motion.p>
        <motion.div 
          {...fadeUpPreset(0.6, 0.8)}
          className="flex flex-col sm:flex-row gap-4 justify-center"
        >
          <button className="btn-primary text-lg px-8 py-4">
            Documentation
          </button>
          <button className="btn-secondary text-lg px-8 py-4 flex items-center justify-center gap-2">
            <Github className="h-5 w-5" />
            Source code
          </button>
        </motion.div>
      </div>
    </motion.section>
  );
}

export default Hero;