"use client";

import Link from "next/link";
import { MapPin, BookOpen, Crown, Zap, Users, ArrowRight } from "lucide-react";
import { motion } from "framer-motion";
import { ENTRY_PATHS } from "~/lib/data";

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

const ACCENT_STYLES = {
  blue: "border-l-4 border-l-blue-500 bg-gradient-to-r from-blue-50/80 to-white hover:from-blue-100/80",
  green: "border-l-4 border-l-emerald-500 bg-gradient-to-r from-emerald-50/80 to-white hover:from-emerald-100/80",
  amber: "border-l-4 border-l-amber-500 bg-gradient-to-r from-amber-50/80 to-white hover:from-amber-100/80",
} as const;

const CARD_EMOJI: Record<string, string> = {
  nav: "🧭",
  arbitrage: "⚡",
  salon: "🎯",
};

export function EntryGrid() {
  return (
    <section className="bg-gradient-to-b from-violet-50/30 to-white py-20 md:py-28">
      <div className="container mx-auto px-4 md:px-6">
        <motion.h2
          initial={{ opacity: 0, y: 12 }}
          whileInView={{ opacity: 1, y: 0 }}
          viewport={{ once: true, margin: "-80px" }}
          className="text-center text-2xl font-bold text-neutral-900 md:text-3xl"
        >
          🚀 选择你的入口
        </motion.h2>
        <motion.p
          initial={{ opacity: 0 }}
          whileInView={{ opacity: 1 }}
          viewport={{ once: true }}
          className="mx-auto mt-3 max-w-2xl text-center text-neutral-600"
        >
          三大路径，对应不同的需求和阶段
        </motion.p>

        <div className="mt-14 grid gap-6 md:grid-cols-3">
          {ENTRY_PATHS.map((path, i) => {
            const Icon = ICON_MAP[path.icon as keyof typeof ICON_MAP] ?? MapPin;
            const accent = ACCENT_STYLES[path.accent];
            const emoji = CARD_EMOJI[path.id] ?? "✨";
            return (
              <motion.div
                key={path.id}
                initial={{ opacity: 0, y: 20 }}
                whileInView={{ opacity: 1, y: 0 }}
                viewport={{ once: true, margin: "-40px" }}
                transition={{ delay: i * 0.08 }}
                whileHover={{ y: -4 }}
              >
                <Link
                  href={path.href}
                  target="_blank"
                  rel="noopener noreferrer"
                  className={`group block rounded-2xl border border-neutral-200/80 p-6 transition-all hover:shadow-xl ${accent}`}
                >
                  <span className="text-2xl">{emoji}</span>
                  <Icon className="mt-3 h-10 w-10 text-neutral-600 transition-transform group-hover:scale-110" />
                  <h3 className="mt-4 text-lg font-bold text-neutral-900">
                    {path.title}
                  </h3>
                  <p className="mt-2 text-sm text-neutral-600">
                    {path.description}
                  </p>
                  <span className="mt-4 inline-flex items-center gap-1 text-sm font-semibold text-neutral-700 group-hover:text-neutral-900">
                    {path.cta}
                    <ArrowRight className="h-4 w-4 transition-transform group-hover:translate-x-2" />
                  </span>
                </Link>
              </motion.div>
            );
          })}
        </div>
      </div>
    </section>
  );
}
