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

  if (shouldReduce) {
    return (
      <section className="py-20 bg-nest-dark text-white">
        <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 text-center">
          <h2 className="text-3xl font-bold mb-4">Live preview</h2>
          <p className="text-gray-300 mb-8">
            See how fast you can build and deploy a NestJS application with our interactive playground.
          </p>
          <div className="bg-gray-800 rounded-lg p-8 max-w-4xl mx-auto">
            <div className="text-left">
              <div className="text-green-400 mb-2">$ npm i -g @nestjs/cli</div>
              <div className="text-green-400 mb-2">$ nest new project-name</div>
              <div className="text-gray-400">Creating a new NestJS application...</div>
            </div>
          </div>
        </div>
      </section>
    );
  }

  return (
    <motion.section 
      {...fadeUpPreset(0.1, 1.0)}
      className="py-20 bg-nest-dark text-white"
    >
      <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 text-center">
        <motion.h2 
          {...fadeUpPreset(0.2, 0.8)}
          className="text-3xl font-bold mb-4"
        >
          Live preview
        </motion.h2>
        <motion.p 
          {...fadeUpPreset(0.3, 0.8)}
          className="text-gray-300 mb-8"
        >
          See how fast you can build and deploy a NestJS application with our interactive playground.
        </motion.p>
        <motion.div 
          {...fadeUpPreset(0.4, 0.8)}
          className="bg-gray-800 rounded-lg p-8 max-w-4xl mx-auto"
        >
          <div className="text-left">
            <div className="text-green-400 mb-2">$ npm i -g @nestjs/cli</div>
            <div className="text-green-400 mb-2">$ nest new project-name</div>
            <div className="text-gray-400">Creating a new NestJS application...</div>
          </div>
        </motion.div>
      </div>
    </motion.section>
  );
};

export default LivePreview;