import { Metadata } from "next";
import { fetchPageData } from "@/lib/api";
import { Navigation } from "@/components/landing/navigation";
import { FooterSection } from "@/components/landing/footer-section";
import { WorkGrid } from "@/components/landing/work-grid";

export const metadata: Metadata = {
  title: "Our Work — NxtLab",
  description: "Explore our portfolio of digital products, from motocross platforms to e-commerce stores.",
};

const DEFAULT_PROJECTS = [
  { id: 1, slug: "", name: "Motocross India",  image_url: "/assets/ridoo-motocross.jpg", alt_text: "", tag: "Sports · Community · Events",  description: "India's premier motocross hub — events, community, and adrenaline all in one place.", category: "Sports · Community",    year: "2022", client: "Motocross India",       accent_color: "#E11D48" },
  { id: 2, slug: "", name: "Ridoo Mobility",   image_url: "/assets/ridoo-motocross.jpg", alt_text: "", tag: "Ride-Tech · Mobility",          description: "A next-gen ride platform built for speed, safety, and seamless user experience.",  category: "Mobility · Ride-Tech",  year: "2023", client: "Ridoo Mobility",         accent_color: "#FF5C00" },
  { id: 3, slug: "", name: "Magnet Ice Cream", image_url: "/assets/ridoo-motocross.jpg", alt_text: "", tag: "E-commerce · Branding",          description: "A delightful e-commerce experience for a premium artisanal ice cream brand.",       category: "E-commerce · Branding", year: "2024", client: "Magnet Ice Cream",        accent_color: "#F472B6" },
  { id: 4, slug: "", name: "Atheron Tech",     image_url: "/assets/ridoo-motocross.jpg", alt_text: "", tag: "Corporate · Tech",               description: "A sophisticated corporate identity and web presence for a cutting-edge tech firm.", category: "Corporate · Tech",      year: "2024", client: "Atheron Technologies", accent_color: "#3B82F6" },
];

export default async function WorkPage() {
  const data = await fetchPageData();
  const settings  = data?.settings  ?? null;
  const sections  = data?.sections  ?? null;
  const apiProjects = data?.projects?.filter(p => p.slug) ?? [];
  const projects    = apiProjects.length > 0 ? apiProjects : DEFAULT_PROJECTS;

  return (
    <main className="min-h-screen bg-black text-white">
      <Navigation settings={settings} />

      {/* Header */}
      <section className="relative pt-32 pb-16 lg:pb-24 overflow-hidden">
        <div className="absolute inset-0 pointer-events-none">
          <div
            className="absolute top-[-20%] left-[20%] w-[600px] h-[600px] rounded-full blur-[180px] opacity-20"
            style={{ background: "radial-gradient(circle, #F0405A 0%, transparent 70%)" }}
          />
          <div
            className="absolute bottom-[-10%] right-[10%] w-[500px] h-[500px] rounded-full blur-[160px] opacity-15"
            style={{ background: "radial-gradient(circle, #6055C8 0%, transparent 70%)" }}
          />
        </div>

        <div className="relative z-10 max-w-[1400px] mx-auto px-6 lg:px-12">
          <span className="inline-flex items-center gap-3 text-sm font-mono text-white/40 mb-6">
            <span className="w-8 h-px bg-white/20" />
            Portfolio
          </span>
          <h1 className="text-6xl md:text-7xl lg:text-[120px] font-display tracking-tight leading-[0.88]">
            Our
            <br />
            <span
              className="text-transparent bg-clip-text"
              style={{ backgroundImage: "linear-gradient(90deg, #F0405A 0%, #A04AAA 50%, #6055C8 100%)" }}
            >
              Work.
            </span>
          </h1>
          <p className="mt-6 text-lg text-white/40 max-w-xl">
            Every project is a partnership. From discovery to deployment, we craft digital experiences that move the needle.
          </p>
        </div>
      </section>

      {/* Projects Grid — lazy loaded per card */}
      <section className="max-w-[1400px] mx-auto px-6 lg:px-12 pb-24 lg:pb-32">
        <WorkGrid projects={projects} />
      </section>

      <FooterSection settings={settings} sections={sections} />
    </main>
  );
}
