// app/page.tsx

'use client';

import Link from 'next/link';
import { FaCamera, FaCode, FaTree, FaVolleyballBall } from 'react-icons/fa';
import { TbCube3dSphere } from 'react-icons/tb';
import Image from 'next/image';

export default function Home() {
  const calculateAge = (birthDateString: string): number => {
    const today = new Date();
    const birthDate = new Date(birthDateString);
    let age = today.getFullYear() - birthDate.getFullYear();
    const monthDiff = today.getMonth() - birthDate.getMonth();
    if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) {
      age--;
    }
    return age;
  };

  return (
    <div className="relative w-full bg-slate-50 dark:bg-[#0d1117] text-slate-900 dark:text-white overflow-hidden font-sans transition-colors duration-300">

      {/* 1. HERO SECTION */}
      <section className="relative h-screen min-h-175 flex flex-col justify-center items-center overflow-hidden">
        {/* Ambient Overlay for contrast */}
        <div className="absolute inset-0 bg-linear-to-b from-transparent via-slate-50/50 to-slate-50 dark:via-[#0d1117]/50 dark:to-[#0d1117] z-1 transition-colors duration-300"></div>

        <div className="relative z-10 flex flex-col items-center px-4">
          <div className="bg-[#84c0a0] rounded-full h-45 w-45 md:h-55 md:w-55 flex justify-center items-center shadow-[0_0_50px_rgba(132,192,160,0.3)] animate-[zoomIn_1000ms_ease-out]">
            <Image src="/assets/logos/logo.svg" alt="Logo" width={130} height={130} className="w-[60%] h-[60%]" />
          </div>

          <h2 className="text-[#84c0a0] font-mono font-bold tracking-[0.3em] uppercase mt-12 text-sm md:text-xl text-center">
            Technical High School Engineer
          </h2>
          <h1 className="text-slate-900 dark:text-white text-center uppercase text-[3rem] md:text-[6rem] font-black leading-none mt-4 drop-shadow-lg dark:drop-shadow-2xl transition-colors">
            William Söderberg
          </h1>

          <div className="mt-10 flex gap-4">
            <Link href="/projects" className="bg-[#84c0a0] text-white dark:text-[#0d1117] px-8 py-3 rounded-full font-bold uppercase tracking-wider hover:scale-105 transition-transform shadow-lg">
              View Portfolios
            </Link>
          </div>
        </div>
      </section>

      {/* 2. ABOUT ME SECTION */}
      <section className="relative py-24 px-6">
        <div className="absolute top-1/2 left-0 -translate-y-1/2 w-125 h-125 bg-[#84c0a0]/10 dark:bg-[#84c0a0]/5 blur-[120px] rounded-full pointer-events-none"></div>

        <div className="max-w-6xl mx-auto relative z-10">
          <div className="text-center mb-12">
            <h2 className="text-slate-900 dark:text-white text-4xl md:text-5xl font-black uppercase tracking-tighter transition-colors">About Me</h2>
            <p className="text-[#84c0a0] mt-4 font-mono uppercase text-sm tracking-widest font-bold">Identity & Background</p>
          </div>

          <div className="bg-white/80 dark:bg-white/5 backdrop-blur-xl border border-slate-200 dark:border-white/10 rounded-[40px] overflow-hidden flex flex-col lg:flex-row shadow-xl dark:shadow-2xl transition-colors duration-300">
            <div className="lg:w-2/5 relative group border-b lg:border-b-0 lg:border-r border-slate-200 dark:border-white/10">
              <Image src="/assets/images/profile_picture.jpg" alt="William Söderberg" width={800} height={1000} className="w-full h-full object-cover" />
              <div className="absolute inset-0 bg-linear-to-t from-black/80 dark:from-[#0d1117] via-transparent to-transparent opacity-60"></div>
              <div className="absolute bottom-8 left-8">
                <h3 className="text-white text-2xl font-bold uppercase tracking-tight">William Söderberg</h3>
                <p className="text-[#84c0a0] font-mono text-sm mt-1">EST. 2002 | SWEDEN</p>
              </div>
            </div>

            <div className="lg:w-3/5 p-8 md:p-16 flex flex-col justify-center">
              <div className="flex items-center gap-4 mb-8">
                <div className="w-12 h-1 border-t-2 border-[#84c0a0]"></div>
                <h2 className="text-slate-900 dark:text-white text-3xl font-bold uppercase tracking-widest transition-colors">DATA CARD</h2>
              </div>
              <p className="text-slate-600 dark:text-gray-300 text-lg leading-relaxed font-light transition-colors">
                My name is William Söderberg and I&apos;m {calculateAge("2002-07-17")} years old. I have a degree in technical
                high school engineering specialized in design and industrial manufacturing, with heavy influence from IT and coding.
                I love problem solving and finding new ways to solve the most complicated problems. Currently studying Computer Science at LTH in Lund.
              </p>
              <div className="mt-10 grid grid-cols-2 gap-6 border-t border-slate-200 dark:border-white/10 pt-10 transition-colors">
                <div>
                  <p className="text-xs font-bold text-[#84c0a0] uppercase tracking-widest mb-1">Focus</p>
                  <p className="text-slate-900 dark:text-white font-medium text-sm transition-colors">Industrial Design & IT</p>
                </div>
                <div>
                  <p className="text-xs font-bold text-[#84c0a0] uppercase tracking-widest mb-1">Passions</p>
                  <p className="text-slate-900 dark:text-white font-medium text-sm transition-colors">Volleyball & Computers</p>
                </div>
              </div>
            </div>
          </div>
        </div>
      </section>

      {/* 3. WHAT DO I DO SECTION */}
      <section className="relative py-24 px-6 overflow-hidden">
        <Image src="/assets/images/leaves.jpg" alt="Leaves" fill className="object-cover z-0 opacity-80" />
        <div className="absolute inset-0 bg-slate-50/20 dark:bg-[#0d1117]/50 z-0 transition-colors duration-300"></div>

        <div className="relative z-10 max-w-6xl mx-auto">
          <div className="text-center mb-16">
            <h2 className="text-slate-900 dark:text-white text-4xl md:text-5xl font-black uppercase tracking-tighter transition-colors">What do I do?</h2>
            <p className="text-[#84c0a0] mt-4 font-mono uppercase text-sm tracking-widest font-bold">A multidisciplinary engineer</p>
          </div>

          <div className="flex flex-wrap justify-center gap-6">
            {[
              { icon: <FaVolleyballBall />, title: 'Volleyball', desc: '8 Years going strong! Currently playing middle blocker with the Elite team in Lund. Mother club is Lerbergets volleybollsällskap.' },
              { icon: <FaTree />, title: 'Young Ranger', desc: 'Part of the Youth+ Network at Europarc Federation, working in management at Kullaberg.' },
              { icon: <FaCamera />, title: 'Photography', desc: 'Capturing nature and people, finding the best subjects to save.' },
              { icon: <TbCube3dSphere />, title: 'CAD', desc: 'Specialized in design and manufacturing, modeling everything from concepts to architecture.' },
              { icon: <FaCode />, title: 'Coding', desc: 'Developing automation scripts and custom programs to solve unique problems. Check out my portfolio!' }
            ].map((item, idx) => (
              <div key={idx} className="w-full md:w-[calc(50%-12px)] lg:w-[calc(33.333%-16px)] group p-8 rounded-3xl bg-white/30 dark:bg-white/5 backdrop-blur-md border border-slate-200 dark:border-white/10 hover:border-[#84c0a0]/40 dark:hover:border-[#84c0a0]/40 hover:bg-white/90 dark:hover:bg-white/10 transition-all duration-300 shadow-md dark:shadow-none">
                <div className="text-slate-900 dark:text-[#84c0a0] text-4xl mb-6 w-fit group-hover:scale-110 transition-transform duration-300">{item.icon}</div>
                <h3 className="text-slate-900 dark:text-white text-2xl font-bold mb-4 transition-colors">{item.title}</h3>
                <p className="text-slate-600 dark:text-gray-400 text-sm leading-relaxed transition-colors">{item.desc}</p>
              </div>
            ))}
          </div>
        </div>
      </section>

      {/* 4. PHOTO GALLERY SECTION */}
      <section className="py-24 px-6 bg-slate-100 dark:bg-[#0d1117] transition-colors duration-300 border-t border-slate-200 dark:border-transparent">
        <div className="max-w-6xl mx-auto">
          <div className="text-center mb-16">
            <h2 className="text-slate-900 dark:text-white text-4xl md:text-5xl font-black uppercase tracking-tighter transition-colors">Photography</h2>
            <p className="text-[#84c0a0] mt-4 font-mono uppercase text-sm tracking-widest font-bold">Capturing the world</p>
          </div>

          <div className="flex flex-col lg:flex-row items-center lg:items-start gap-12 lg:gap-16">
            <div className="relative w-full lg:w-1/2">
              <Image src="/assets/images/ynni.jpg" alt="My Photos" quality={90} width={800} height={1000} className="w-full rounded-4xl shadow-2xl object-cover lg:h-150" />
              <div className="absolute top-[10%] -left-4 lg:-left-12 bg-white/20 dark:bg-white/10 backdrop-blur-xl border border-[#84c0a0]/40 dark:border-white/20 py-6 px-10 shadow-2xl rounded-2xl">
                <h2 className="text-[30px] lg:text-[40px] text-slate-900 dark:text-white font-black whitespace-nowrap uppercase tracking-wider transition-colors">My Photos</h2>
              </div>
            </div>

            <div className="flex flex-col items-start w-full lg:w-1/2 lg:pt-8">
              <Image src="/assets/images/night_sky.jpg" alt="Night Sky" width={600} height={400} className="w-full max-w-125 rounded-3xl shadow-xl border border-slate-200 dark:border-white/10" />
              <h3 className="text-slate-900 dark:text-white text-[26px] mt-8 font-bold uppercase tracking-wide transition-colors">My Photography collection</h3>
              <div className="w-12 h-1 border-t-2 border-[#84c0a0] my-4"></div>
              <p className="text-slate-600 dark:text-gray-400 text-[18px] font-light leading-relaxed transition-colors">
                Taking photos is just one of my many hobbies. Finding the best motives to capture, from nature to the night skies.
              </p>
              <Link href="/gallery" className="mt-8 bg-[#84c0a0] text-white dark:text-[#0d1117] px-8 py-3 rounded-full font-bold uppercase tracking-wider hover:scale-105 transition-transform shadow-[0_0_20px_rgba(132,192,160,0.3)]">
                More photos
              </Link>
            </div>
          </div>

          <div className="w-full mt-32 relative h-125 md:h-175 rounded-[40px] overflow-hidden shadow-2xl border border-slate-200 dark:border-white/10 group">
            <Image src="/assets/images/singapore.jpg" alt="Singapore" fill className="object-cover transition-transform duration-1000 group-hover:scale-105" />
            <div className="absolute inset-0 bg-linear-to-t from-black/80 dark:from-[#0d1117]/90 via-black/20 dark:via-[#0d1117]/20 to-transparent"></div>
            <div className="relative z-10 w-full h-full p-8 md:p-16 flex items-end md:items-start">
              <div className="bg-[#0d1117]/30 backdrop-blur-xl border border-white/20 dark:border-white/10 p-8 max-w-87.5 rounded-3xl shadow-2xl">
                <p className="text-[18px] font-medium text-white leading-relaxed">
                  A cloudy day in Singapore, the New Zealand trip 2019.
                </p>
                <div className="mt-4 flex items-center gap-3">
                  <span className="w-8 h-px bg-[#84c0a0]"></span>
                  <span className="text-[#84c0a0] font-mono text-xs tracking-widest uppercase">Expedition 019</span>
                </div>
              </div>
            </div>
          </div>
        </div>
      </section>

      {/* 5. CONTACT CALL-TO-ACTION */}
      <section className="relative py-16 px-6 overflow-hidden border-t border-slate-200 dark:border-white/5 transition-colors duration-300">
        <Image src="/assets/images/snowy_mountain_peaks.jpg" alt="Snowy Mountains" fill className="object-cover z-0" />
        <div className="absolute inset-0 bg-slate-100/40 dark:bg-[#0d1117]/80 backdrop-blur-[2px] z-0 transition-colors duration-300"></div>

        <div className="relative z-10 max-w-5xl mx-auto bg-white/70 dark:bg-white/5 backdrop-blur-xl border border-slate-200 dark:border-white/10 rounded-3xl p-8 md:px-12 md:py-10 shadow-xl dark:shadow-2xl flex flex-col md:flex-row items-center justify-between gap-6 transition-colors duration-300">
          <div className="text-center md:text-left">
            <h2 className="text-slate-900 dark:text-white text-3xl md:text-4xl font-black uppercase tracking-tighter mb-2 transition-colors">
              Let&apos;s Connect
            </h2>
            <p className="text-[#84c0a0] font-mono uppercase text-xs md:text-sm tracking-widest font-bold">
              Contact info & Socials
            </p>
          </div>
          <Link href="/contact" className="shrink-0 inline-block bg-[#84c0a0] text-white dark:text-[#0d1117] px-8 py-4 rounded-full font-bold uppercase tracking-wider hover:scale-105 active:scale-95 transition-all shadow-[0_0_20px_rgba(132,192,160,0.3)]">
            Contact Me
          </Link>
        </div>
      </section>
    </div>
  );
}