// 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-[#0d1117] text-white overflow-hidden font-sans">

      {/* 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-[#0d1117]/50 to-[#0d1117] z-1"></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-white text-center uppercase text-[3rem] md:text-[6rem] font-black leading-none mt-4 drop-shadow-2xl">
            William Söderberg
          </h1>

          <div className="mt-10 flex gap-4">
            <Link href="/projects" className="bg-[#84c0a0] 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">
        {/* Background Glow */}
        <div className="absolute top-1/2 left-0 -translate-y-1/2 w-125 h-125 bg-[#84c0a0]/5 blur-[120px] rounded-full pointer-events-none"></div>

        <div className="max-w-6xl mx-auto">
          {/* Subtitle Header */}
          <div className="text-center mb-12">
            <h2 className="text-white text-4xl md:text-5xl font-black uppercase tracking-tighter">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/5 backdrop-blur-xl border border-white/10 rounded-[40px] overflow-hidden flex flex-col lg:flex-row shadow-2xl">

            {/* Left Column: Profile with "Scanning" Effect */}
            <div className="lg:w-2/5 relative group border-b lg:border-b-0 lg:border-r 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-[#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>

            {/* Right Column: Bio Content */}
            <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-white text-3xl font-bold uppercase tracking-widest">DATA CARD</h2>
              </div>
              <p className="text-gray-300 text-lg leading-relaxed font-light">
                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.
              </p>
              <div className="mt-10 grid grid-cols-2 gap-6 border-t border-white/10 pt-10">
                <div>
                  <p className="text-xs font-bold text-[#84c0a0] uppercase tracking-widest mb-1">Focus</p>
                  <p className="text-white font-medium text-sm">Industrial Design & IT</p>
                </div>
                <div>
                  <p className="text-xs font-bold text-[#84c0a0] uppercase tracking-widest mb-1">Passions</p>
                  <p className="text-white font-medium text-sm">Volleyball & Computers</p>
                </div>
              </div>
            </div>
          </div>
        </div>
      </section>

      {/* 3. WHAT DO I DO SECTION */}
      <section className="relative py-24 px-6 overflow-hidden">
        {/* Subtle Background Image Integration */}
        <Image src="/assets/images/leaves.jpg" alt="Leaves" fill className="object-cover z-0" />
        <div className="absolute inset-0 bg-[#0d1117]/50 z-0"></div>

        <div className="relative z-10 max-w-6xl mx-auto">
          <div className="text-center mb-16">
            <h2 className="text-white text-4xl md:text-5xl font-black uppercase tracking-tighter">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="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
            {[
              { icon: <FaVolleyballBall />, title: 'Volleyball', desc: 'Played for over 5 years as a middle blocker with Lerbergets and Ängelholms clubs.' },
              { 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 on film.' },
              { 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.' }
            ].map((item, idx) => (
              <div key={idx} className="group p-8 rounded-3xl bg-white/5 backdrop-blur-md border border-white/10 hover:border-[#84c0a0]/40 hover:bg-white/10 transition-all duration-300">
                <div className="text-[#84c0a0] text-4xl mb-6 w-fit group-hover:scale-110 transition-transform duration-300">{item.icon}</div>
                <h3 className="text-white text-2xl font-bold mb-4">{item.title}</h3>
                <p className="text-gray-400 text-sm leading-relaxed">{item.desc}</p>
              </div>
            ))}
          </div>
        </div>
      </section>

      {/* 4. PHOTO GALLERY SECTION */}
      <section className="py-24 px-6 bg-[#0d1117]">
        <div className="max-w-6xl mx-auto">
          <div className="text-center mb-16">
            <h2 className="text-white text-4xl md:text-5xl font-black uppercase tracking-tighter">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">

            {/* My Photos (Ynni Image) */}
            <div className="relative w-full lg:w-1/2">
              <Image src="/assets/images/ynni.jpg" alt="My Photos" width={800} height={800} className="w-full rounded-4xl shadow-2xl object-cover lg:h-125" />
              <div className="absolute top-[10%] -left-4 lg:-left-12 bg-white/10 backdrop-blur-xl border border-white/20 py-6 px-10 shadow-2xl rounded-2xl">
                <h2 className="text-[30px] lg:text-[40px] text-white font-black whitespace-nowrap uppercase tracking-wider">My Photos</h2>
              </div>
            </div>

            {/* Night Sky Collection */}
            <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-gray-200 dark:border-white/10" />
              <h3 className="text-white text-[26px] mt-8 font-bold uppercase tracking-wide">My Photography collection</h3>
              <div className="w-12 h-1 border-t-2 border-[#84c0a0] my-4"></div>
              <p className="text-gray-400 text-[18px] font-light leading-relaxed">
                Taking photos is just one of my many hobbies. Finding the best subjects to capture on film, from nature to the night skies.
              </p>
              <Link href="/gallery" className="mt-8 bg-[#84c0a0] 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>

          {/* Singapore Full Width wrapper */}
          <div className="w-full mt-32 relative h-125 md:h-175 rounded-[40px] overflow-hidden shadow-2xl border 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-[#0d1117]/90 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/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 (Compact Banner) */}
      <section className="relative py-16 px-6 overflow-hidden border-t border-white/5">
        {/* Immersive Mountain Background */}
        <Image
          src="/assets/images/snowy_mountain_peaks.jpg"
          alt="Snowy Mountains"
          fill
          className="object-cover z-0"
        />

        {/* Dark overlay */}
        <div className="absolute inset-0 bg-[#0d1117]/80 backdrop-blur-[2px] z-0"></div>

        {/* Compact Glassmorphic CTA Banner */}
        <div className="relative z-10 max-w-5xl mx-auto bg-white/5 backdrop-blur-xl border border-white/10 rounded-3xl p-8 md:px-12 md:py-10 shadow-2xl flex flex-col md:flex-row items-center justify-between gap-6">

          <div className="text-center md:text-left">
            <h2 className="text-white text-3xl md:text-4xl font-black uppercase tracking-tighter mb-2">
              Let&apos;s Connect
            </h2>
            <p className="text-[#84c0a0] font-mono uppercase text-xs md:text-sm tracking-widest font-bold">
              Transmission & Socials
            </p>
          </div>

          <Link
            href="/contact"
            className="shrink-0 inline-block bg-[#84c0a0] 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>
  );
}