"use client";

import { useTranslation } from "@/app/digital/i18n/navigation";
import DigitalThemeIcon from "./DigitalThemeIcon";

const featureKeys = ["location", "skill", "balance"] as const;
const featureIcons = {
  location: { name: "globe", emoji: "🌏" },
  skill: { name: "spark", emoji: "⚡" },
  balance: { name: "compass", emoji: "🔄" },
} as const;

export default function Features() {
  const { t } = useTranslation("features");
  const features = featureKeys.map((key) => ({ ...featureIcons[key], key }));
  return (
    <section id="features" className="dn-section dn-features py-20 sm:py-28 dark:bg-slate-950">
      <div className="dn-container mx-auto max-w-7xl px-4 sm:px-6 lg:px-8">
        <div className="text-center">
          <h2 className="dn-section-title text-3xl font-bold tracking-tight text-slate-900 dark:text-slate-100 sm:text-4xl">
            {t("title")} <span className="gradient-text">{t("titleHighlight")}</span>{t("titleSuffix")}
          </h2>
          <p className="dn-section-copy mx-auto mt-4 max-w-2xl text-lg text-slate-600 dark:text-slate-400">
            {t("subtitle")}
            <br className="hidden sm:block" />
            {t("subtitle2")}
          </p>
        </div>

        <div className="mt-16 grid gap-6 sm:grid-cols-2 lg:grid-cols-3">
          {features.map((f) => (
            <div
              key={f.key}
              className="dn-card card-hover rounded-2xl border border-slate-100 bg-white p-8 shadow-sm dark:border-slate-800 dark:bg-slate-900"
            >
              <div className="dn-icon-box mb-4 flex h-14 w-14 items-center justify-center rounded-2xl bg-sky-50 text-3xl dark:bg-sky-900/50">
                <DigitalThemeIcon name={f.name} emoji={f.emoji} className="h-7 w-7" />
              </div>
              <h3 className="mb-3 text-xl font-bold text-slate-900 dark:text-slate-100">
                {t(`items.${f.key}.title`)}
              </h3>
              <p className="leading-relaxed text-slate-600 dark:text-slate-400">{t(`items.${f.key}.desc`)}</p>
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}
