import type { Metadata } from "next";
import { Sparkles } from "lucide-react";
import { getTranslations } from "next-intl/server";

import { AnimatedLogo } from "@/components/layout/animated-logo";
import { FloatingPreferences } from "@/components/layout/floating-preferences";
import { HeroAtmosphere } from "@/components/layout/hero-atmosphere";
import { SiteAmbientBackdrop } from "@/components/layout/site-ambient-backdrop";
import { MotionFade } from "@/components/motion-fade";
import { getSiteSettings } from "@/lib/app-config";
import { buildLocalizedMetadata } from "@/lib/metadata";
import { resolveLocale } from "@/lib/locale";

type ComingSoonPageProps = {
  params: {
    locale: string;
  };
};

export async function generateMetadata({
  params: { locale },
}: ComingSoonPageProps): Promise<Metadata> {
  const localeKey = resolveLocale(locale);
  const t = await getTranslations({ locale: localeKey, namespace: "comingSoon" });
  const siteSettings = await getSiteSettings();

  return await buildLocalizedMetadata({
    locale: localeKey,
    pathname: "/coming-soon",
    title: siteSettings.locales[localeKey].siteName,
    description: t("description"),
    applyTitleTemplate: false,
  });
}

export default async function ComingSoonPage({
  params: { locale },
}: ComingSoonPageProps) {
  const localeKey = resolveLocale(locale);
  const t = await getTranslations({ locale: localeKey, namespace: "comingSoon" });

  return (
    <div className="relative min-h-screen overflow-hidden">
      <SiteAmbientBackdrop />
      <FloatingPreferences locale={localeKey} />

      <section className="relative isolate flex min-h-screen items-center justify-center overflow-hidden px-4 pb-10 pt-24 sm:px-6 sm:pt-28 lg:px-8">
        <HeroAtmosphere />

        <MotionFade className="relative z-10 w-full">
          <div className="mx-auto max-w-[56rem] text-center">
            <p className="inline-flex items-center gap-2 border border-white/24 bg-[linear-gradient(180deg,rgba(255,255,255,0.2),rgba(255,255,255,0.08))] px-4 py-2 text-xs font-semibold uppercase tracking-[0.18em] text-foreground/78 shadow-[inset_0_1px_0_rgba(255,255,255,0.42),0_18px_44px_-28px_rgba(15,23,42,0.22)] backdrop-blur-[24px] dark:border-white/10 dark:bg-[linear-gradient(180deg,rgba(255,255,255,0.08),rgba(255,255,255,0.03))]">
              <Sparkles className="h-3.5 w-3.5 text-brand-secondary" />
              {t("badge")}
            </p>

            <div className="mt-8">
              <AnimatedLogo />
            </div>

            <h1 className="text-balance mx-auto mt-10 max-w-4xl text-4xl font-semibold leading-[0.95] tracking-[-0.05em] text-foreground sm:text-5xl lg:text-6xl">
              {t("titleStart")}{" "}
              <span className="brand-gradient-text">{t("titleAccent")}</span>{" "}
              {t("titleEnd")}
            </h1>

            <p className="mx-auto mt-6 max-w-[34rem] text-sm leading-7 text-foreground/68 sm:text-base">
              {t("description")}
            </p>

            <p className="mx-auto mt-4 max-w-[32rem] text-sm leading-6 text-foreground/54 sm:text-base">
              {t("note")}
            </p>
          </div>
        </MotionFade>
      </section>
    </div>
  );
}
