'use client'

import { Globe } from "@/components/ui/globe"
import { motion } from "framer-motion"
import { H2, P, CT, CP } from "@/components/Texts"
import { CountUpNumber } from './CountUpNumber'

export function WorldMap() {
  return (
    <div className="relative min-h-screen w-full overflow-hidden top-0 flex py-12 flex-col">
      {/* Background video */}
      <video
        autoPlay
        loop
        muted
        playsInline
        className="absolute inset-0 w-full h-full object-cover"
      >
        <source src="/videos/benefits.mp4" type="video/mp4" />
      </video>

      {/* Dark overlay */}
      <div className="absolute inset-0 bg-black/10" />

      {/* Content */}
      <div className="relative z-10 flex flex-col h-full px-8 md:px-16 py-12">
        {/* Title + Subtitle */}
        <motion.div
          initial={{ opacity: 0, y: 20 }}
          animate={{ opacity: 1, y: 0 }}
          transition={{ duration: 0.5 }}
          className="max-w-xl"
        >
          <H2 color="light">Mycelium Network is Live.</H2>
          <P className="hidden mt-4 text-base leading-relaxed font-light" color="light">
            Mycelium Cloud's advancement technology enables anyone to deploy
            their own Internet infrastructure, anywhere.
          </P>
        </motion.div>

        {/* Bottom Layout: Globe + Cards */}
        <div className="mt-8 flex flex-1 flex-col lg:flex-row items-center lg:items-stretch gap-x-10">
          {/* Globe Left Column */}
          <motion.div
            initial={{ opacity: 0, scale: 0.9 }}
            animate={{ opacity: 1, scale: 1 }}
            transition={{ duration: 0.5, delay: 0.2 }}
            className="flex-1 flex items-center justify-center"
          >
            <div className="relative w-[450px] h-[450px] md:w-[600px] md:h-[600px]">
              <Globe className="absolute inset-0 w-full h-full left-0 lg:-left-24" />
            </div>
          </motion.div>

          {/* Cards Right Column */}
          <div className="relative flex-1 lg:h-auto h-[700px] flex flex-col lg:block items-center gap-y-4 mt-8 lg:mt-0">
            <motion.div
              initial={{ opacity: 0, x: -20 }}
              animate={{ opacity: 1, x: 0 }}
              transition={{ duration: 0.5, delay: 0.4 }}
              whileHover={{ scale: 1.05 }}
              className="lg:absolute lg:top-12 lg:-left-12 rounded-xl bg-white/5 backdrop-blur-md border border-white/10 px-4 lg:py-8 py-6 shadow-md w-80"
            >
              <CT color="light" className="uppercase tracking-wide">CORES</CT>
              <CountUpNumber end={54958} color="light" className="mt-2 text-3xl font-bold" />
              <CP color="light" className="mt-2 text-sm">
                Total Central Processing Unit Cores available on the grid.
              </CP>
            </motion.div>

            <motion.div
              initial={{ opacity: 0, x: 20 }}
              animate={{ opacity: 1, x: 0 }}
              transition={{ duration: 0.5, delay: 0.5 }}
              whileHover={{ scale: 1.05 }}
              className="lg:absolute lg:-top-10 lg:right-0 rounded-xl bg-white/5 backdrop-blur-md border border-white/10 px-4 lg:py-8 py-6 shadow-md w-80"
            >
              <CT color="light" className="uppercase tracking-wide">NODES</CT>
              <CountUpNumber end={1493} color="light" className="mt-2 text-3xl font-bold" />
              <CP color="light" className="mt-2 text-sm">
                Total number of nodes on the grid.
              </CP>
            </motion.div>

            <motion.div
              initial={{ opacity: 0, x: -20 }}
              animate={{ opacity: 1, x: 0 }}
              transition={{ duration: 0.5, delay: 0.6 }}
              whileHover={{ scale: 1.05 }}
              className="lg:absolute lg:bottom-28 lg:-left-12 rounded-xl bg-white/5 backdrop-blur-md border border-white/10 px-4 lg:py-8 py-6 shadow-md w-80"
            >
              <CT color="light" className="uppercase tracking-wide">SSD CAPACITY</CT>
              <CountUpNumber end={5388956} color="light" className="mt-2 text-3xl font-bold" />
              <CP color="light" className="mt-2 text-sm">
                Total GB amount of storage (SSD, HDD, & RAM) on the grid.
              </CP>
            </motion.div>

            <motion.div
              initial={{ opacity: 0, x: 20 }}
              animate={{ opacity: 1, x: 0 }}
              transition={{ duration: 0.5, delay: 0.7 }}
              whileHover={{ scale: 1.05 }}
              className="lg:absolute lg:top-44 lg:right-0 rounded-xl bg-white/5 backdrop-blur-md border border-white/10 px-4 lg:py-8 py-6 shadow-md w-80"
            >
              <CT color="light" className="uppercase tracking-wide">COUNTRIES</CT>
              <CountUpNumber end={44} color="light" className="mt-2 text-3xl font-bold" />
              <CP color="light" className="mt-2 text-sm">
                Total number of countries with active nodes.
              </CP>
            </motion.div>
          </div>
        </div>
      </div>

      {/* Radial fade overlay */}
      <div className="pointer-events-none absolute inset-0 h-full bg-[radial-gradient(circle_at_50%_200%,rgba(0,0,0,0.2),rgba(255,255,255,0))]" />
    </div>
  )
}
