import type { Metadata } from "next";
import Nav from "@/components/nav";
import Hero from "@/components/hero";
import DirectAnswer from "@/components/direct-answer";
import Playground from "@/components/playground";
import Features from "@/components/features";
import HomepageFaq, { HOMEPAGE_FAQS } from "@/components/homepage-faq";
import DeveloperEcosystem from "@/components/developer-ecosystem";
import Footer from "@/components/footer";
import DeferredScrollFlourishes from "@/components/deferred-scroll-flourishes";

const SITE_URL = "https://entscheidomat.com";

export const metadata: Metadata = {
  title: {
    absolute: "Entscheidomat – Kostenloser Zufallsgenerator & Entscheidungshilfe",
  },
  description:
    "Kostenloser Zufallsgenerator und Entscheidungshilfe für schnelle Alltagsentscheidungen: Ja-Nein-Generator, Glücksrad, Würfel, Münzwurf und mehr – direkt im Browser.",
  alternates: { canonical: "/" },
};

const jsonLd = {
  "@context": "https://schema.org",
  "@graph": [
    {
      "@type": "WebApplication",
      name: "Entscheidomat",
      url: SITE_URL,
      description:
        "Kostenloser Zufallsgenerator und digitale Entscheidungshilfe mit acht Tools: Ja-Nein-Generator, Münze, Entweder-oder-Generator, Glücksrad, Würfel, Zufallszahl, Magic 8-Ball und Listen-Auslosung.",
      applicationCategory: "UtilitiesApplication",
      operatingSystem: "Any (Web-Browser)",
      isPartOf: { "@id": `${SITE_URL}/#website` },
      offers: { "@type": "Offer", price: "0", priceCurrency: "EUR" },
    },
    {
      "@type": "FAQPage",
      mainEntity: HOMEPAGE_FAQS.map((f) => ({
        "@type": "Question",
        name: f.q,
        acceptedAnswer: { "@type": "Answer", text: f.a },
      })),
    },
  ],
};

export default function Home() {
  return (
    <>
      <script
        type="application/ld+json"
        dangerouslySetInnerHTML={{
          __html: JSON.stringify(jsonLd).replace(/</g, "\\u003c"),
        }}
      />
      <Nav />
      <main className="flex-1">
        <Hero />
        <DirectAnswer />
        <Playground />
        <Features />
        <div className="mx-auto w-full max-w-6xl px-5 sm:px-8">
          <DeveloperEcosystem />
        </div>
        <HomepageFaq />
      </main>
      <Footer />
      <DeferredScrollFlourishes />
    </>
  );
}
