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

import { FloatingPreferences } from "@/components/layout/floating-preferences";
import { HeroMotionBackdrop } from "@/components/layout/hero-motion-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" });
  const isArabic = localeKey === "ar";

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

      <section className="hero-surface hero-home 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">
        <HeroMotionBackdrop />
        <div className="hero-header-bridge" />
        <div className="hero-content-bridge" />

        <MotionFade className="relative z-10 w-full">
          <div className="mx-auto max-w-[56rem] text-center">
            <p className="inline-flex items-center gap-2 rounded-full border border-black/6 bg-white/24 px-4 py-2 text-sm font-medium tracking-[-0.02em] text-[hsl(var(--hero-ink)/0.84)] shadow-[0_14px_34px_-24px_rgba(15,23,42,0.18)] backdrop-blur-[18px] dark:border-white/10 dark:bg-white/4 dark:text-foreground/84 dark:shadow-[0_20px_48px_-28px_rgba(0,0,0,0.58)]">
              <Sparkles className="h-3.5 w-3.5 text-brand-secondary" />
              {t("kicker")}
            </p>

            <h1
              className={
                isArabic
                  ? "mx-auto mt-8 flex max-w-[40rem] flex-col items-center gap-y-2 overflow-visible pb-[0.12em] text-[3.35rem] font-bold leading-[1.12] tracking-normal text-[hsl(var(--hero-ink))] drop-shadow-[0_18px_40px_rgba(15,23,42,0.18)] sm:text-[4.7rem] lg:max-w-[44rem] lg:text-[5.5rem]"
                  : "mx-auto mt-8 flex max-w-[44rem] flex-col gap-y-0.5 overflow-visible pb-[0.2em] text-[3.15rem] font-semibold leading-[0.98] tracking-[-0.05em] text-[hsl(var(--hero-ink))] drop-shadow-[0_18px_40px_rgba(15,23,42,0.22)] sm:text-[4.8rem] lg:max-w-[46rem] lg:gap-y-1 lg:pb-[0.22em] lg:text-[5.85rem]"
              }
            >
              <span
                className={
                  isArabic
                    ? "hero-title-line hero-title-accent-soft self-center whitespace-nowrap"
                    : "hero-title-line hero-title-accent-soft self-start whitespace-nowrap"
                }
              >
                {t("titleLineOne")}
              </span>
              <span className={isArabic ? "hero-title-line self-center whitespace-nowrap" : "hero-title-line self-end whitespace-nowrap"}>
                {t("titleLineTwo")}
              </span>
              <span
                className={
                  isArabic
                    ? "hero-title-line hero-title-accent self-center whitespace-nowrap"
                    : "hero-title-line hero-title-accent self-start whitespace-nowrap"
                }
              >
                {t("titleLineThree")}
              </span>
            </h1>

            <p className="mx-auto mt-8 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>
  );
}
