"use client";

import ReactLenis from "lenis/react";
import BlogCardThree from "@/components/sections/blog/BlogCardThree";
import FooterBaseCard from "@/components/sections/footer/FooterBaseCard";
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import NavbarLayoutFloatingOverlay from "@/components/navbar/NavbarLayoutFloatingOverlay/NavbarLayoutFloatingOverlay";
import { useBlogPosts } from "@/hooks/useBlogPosts";

export default function BlogPage() {
    const { posts, isLoading } = useBlogPosts();

    return (
        <ThemeProvider
            defaultButtonVariant="shift-hover"
            defaultTextAnimation="reveal-blur"
            borderRadius="pill"
            contentWidth="medium"
            sizing="largeSmallSizeLargeTitles"
            background="circleGradient"
            cardStyle="solid"
            primaryButtonStyle="gradient"
            secondaryButtonStyle="radial-glow"
            headingFontWeight="bold"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarLayoutFloatingOverlay
                        brandName="Clash of Clans"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Features", id: "features" },
                            { name: "Gameplay", id: "gameplay" },
                            { name: "Mechanics", id: "mechanics" },
                            { name: "Community", id: "testimonials" },
                            { name: "Download", id: "contact" }
                        ]}
                        button={{ text: "Play Now", href: "https://apps.apple.com/app/clash-of-clans" }}
                    />
                </div>

                {isLoading ? (
                    <div className="w-content-width mx-auto py-20 text-center">
                        <p className="text-foreground">Loading posts...</p>
                    </div>
                ) : (
                    <div id="blog" data-section="blog">
                        <BlogCardThree
                            blogs={posts}
                            title="Battle Chronicles"
                            description="Discover the latest strategies, updates, and stories from the world of Clash of Clans"
                            tag="News"
                            textboxLayout="default"
                            useInvertedBackground="noInvert"
                            animationType="slide-up"
                            carouselMode="buttons"
                        />
                    </div>
                )}

                <div id="footer" data-section="footer">
                    <FooterBaseCard
                        logoText="Clash of Clans"
                        columns={[
                            {
                                title: "Game",                                items: [
                                    { label: "Features", href: "#features" },
                                    { label: "Gameplay", href: "#gameplay" },
                                    { label: "Updates", href: "#mechanics" }
                                ]
                            },
                            {
                                title: "Community",                                items: [
                                    { label: "Clans", href: "https://clashroyale.supercell.com" },
                                    { label: "Forums", href: "https://forum.supercell.com" },
                                    { label: "Events", href: "https://clashroyale.supercell.com" }
                                ]
                            },
                            {
                                title: "Support",                                items: [
                                    { label: "Help Center", href: "https://supercell.helpshift.com" },
                                    { label: "Report Issue", href: "https://supercell.helpshift.com" },
                                    { label: "Contact Us", href: "https://supercell.com/en/contact" }
                                ]
                            },
                            {
                                title: "Company",                                items: [
                                    { label: "About Supercell", href: "https://supercell.com" },
                                    { label: "Careers", href: "https://supercell.com/en/careers" },
                                    { label: "Blog", href: "https://supercell.com/en/blog" }
                                ]
                            }
                        ]}
                        copyrightText="© 2024 Supercell Oy. Clash of Clans is a trademark of Supercell Oy."
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}