"use client";

import Link from "next/link";
import { MapPin, Zap, Users, ArrowRight } from "lucide-react";
import { motion } from "framer-motion";
import { ENTRY_CARDS } from "~/lib/data";
import { Particles } from "~/components/ui/particles";

const ICON_MAP = {
  MapPin,
  Zap,
  Users,
} as const;

const ACCENT_STYLES = {
  blue: "from-blue-500/20 to-cyan-500/10 border-blue-300/80 hover:border-blue-400 hover:shadow-2xl",
  emerald: "from-emerald-500/20 to-teal-500/10 border-emerald-300/80 hover:border-emerald-400 hover:shadow-2xl",
  amber: "from-amber-500/20 to-orange-500/10 border-amber-300/80 hover:border-amber-400 hover:shadow-2xl",
} as const;

const CARD_EMOJI = {
  nav: "🧭",
  arbitrage: "⚡",
  salon: "🎯",
} as const;

const ICON_COLORS = {
  blue: "text-blue-600",
  emerald: "text-emerald-600",
  amber: "text-amber-600",
} as const;

export function Hero() {
  return (
    <section className="relative min-h-[100dvh] overflow-hidden bg-gradient-to-br from-violet-50 via-white to-cyan-50">
      <Particles />
      <div
        className="pointer-events-none absolute inset-0 opacity-30"
        style={{
          backgroundImage: `radial-gradient(circle at 20% 80%, rgba(139, 92, 246, 0.15) 0%, transparent 50%),
            radial-gradient(circle at 80% 20%, rgba(6, 182, 212, 0.15) 0%, transparent 50%)`,
        }}
      />
      <div className="container relative mx-auto flex min-h-[100dvh] flex-col justify-center px-3 py-6 sm:px-4 sm:py-8 md:px-6 md:py-16 lg:py-24">
        <div className="mx-auto max-w-4xl text-center">
          <motion.div
            initial={{ opacity: 0, y: 16 }}
            animate={{ opacity: 1, y: 0 }}
            transition={{ delay: 0.1, duration: 0.5 }}
          >
            <h1 className="text-2xl font-bold tracking-tight sm:text-4xl md:text-5xl lg:text-6xl">
              <span className="bg-gradient-to-r from-violet-600 via-fuchsia-500 to-cyan-600 bg-clip-text text-transparent">
                数字游民
              </span>{" "}
              <span className="text-neutral-800">nomadro</span>
            </h1>
          </motion.div>

          <motion.div
            initial={{ opacity: 0, y: 24 }}
            animate={{ opacity: 1, y: 0 }}
            transition={{ delay: 0.3, duration: 0.5 }}
            className="mt-6 flex flex-col gap-3 sm:mt-8 sm:gap-4 lg:mt-12 lg:grid lg:grid-cols-3 lg:gap-6"
          >
            {ENTRY_CARDS.map((card, i) => {
              const Icon = ICON_MAP[card.icon];
              const accent = ACCENT_STYLES[card.accent];
              const emoji = CARD_EMOJI[card.id];
              const iconColor = ICON_COLORS[card.accent];
              return (
                <motion.div
                  key={card.id}
                  initial={{ opacity: 0, y: 20 }}
                  animate={{ opacity: 1, y: 0 }}
                  transition={{ delay: 0.4 + i * 0.1, duration: 0.4 }}
                  whileHover={{ scale: 1.01, y: -2 }}
                >
                  <Link
                    href={card.href}
                    target="_blank"
                    rel="noopener noreferrer"
                    className={`group relative flex items-center gap-4 overflow-hidden rounded-2xl border-2 bg-gradient-to-br p-4 transition-all duration-300 active:scale-[0.99] lg:flex-col lg:items-stretch lg:gap-0 lg:p-6 ${accent}`}
                  >
                    <div className="absolute -right-6 -top-6 text-5xl opacity-20 transition-transform group-hover:scale-110 group-hover:opacity-30 sm:-right-8 sm:-top-8 sm:text-6xl">
                      {emoji}
                    </div>
                    <div className={`relative flex h-11 w-11 shrink-0 items-center justify-center self-start rounded-xl bg-white/80 shadow-sm lg:h-12 lg:w-12 ${iconColor}`}>
                      <Icon className="h-5 w-5 group-hover:scale-110 transition-transform lg:h-6 lg:w-6" />
                    </div>
                    <div className="relative min-w-0 flex-1 lg:mt-4">
                      <h2 className="text-base font-bold text-neutral-900 lg:text-xl">
                        {card.label}
                      </h2>
                      <p className="mt-0.5 text-sm text-neutral-600">
                        {card.title}
                      </p>
                      <p className="mt-1 hidden text-xs text-neutral-500 lg:block">
                        {card.description}
                      </p>
                    </div>
                    <ArrowRight className="relative h-5 w-5 shrink-0 text-neutral-400 transition-all group-hover:translate-x-1 group-hover:text-violet-500 lg:absolute lg:right-4 lg:top-4" />
                  </Link>
                </motion.div>
              );
            })}
          </motion.div>
        </div>
      </div>
    </section>
  );
}
