"use client";

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

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

const ACCENT_STYLES = {
  blue: "border-l-blue-500/80 hover:border-l-blue-500",
  green: "border-l-emerald-500/80 hover:border-l-emerald-500",
  amber: "border-l-amber-500/80 hover:border-l-amber-500",
} as const;

export function EntryGrid() {
  return (
    <section className="bg-white py-16 md:py-24">
      <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-semibold 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-12 grid gap-6 md:grid-cols-3">
          {ENTRY_PATHS.map((path, i) => {
            const Icon = ICON_MAP[path.icon];
            const accent = ACCENT_STYLES[path.accent];
            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 }}
              >
                <Link
                  href={path.href}
                  target="_blank"
                  rel="noopener noreferrer"
                  className={`group block rounded-xl border border-neutral-200 bg-white p-6 transition-all hover:-translate-y-1 hover:shadow-lg ${accent} border-l-4`}
                >
                  <Icon className="h-10 w-10 text-neutral-600" />
                  <h3 className="mt-4 text-lg font-semibold 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-medium text-neutral-700 group-hover:text-neutral-900">
                    {path.cta}
                    <ArrowRight className="h-4 w-4 transition-transform group-hover:translate-x-1" />
                  </span>
                </Link>
              </motion.div>
            );
          })}
        </div>
      </div>
    </section>
  );
}
