"use client";

import Link from "next/link";
import { ArrowRight, GraduationCap, Globe2, BookOpen, Mic, Users, Award, Sparkles, Check, ChevronRight } from "lucide-react";
import { motion, useScroll, useTransform, useSpring, AnimatePresence } from "framer-motion";
import GlobeWrapper from "@/components/GlobeWrapper";
import { useRef, useState, useEffect } from "react";

// ─── Typing Hook ───────────────────────────────────────────────────────────────
function useTypewriter(words: string[], speed = 90, deleteSpeed = 45, pause = 2200) {
  const [displayed, setDisplayed] = useState("");
  const [wordIndex, setWordIndex] = useState(0);
  const [isDeleting, setIsDeleting] = useState(false);
  useEffect(() => {
    const word = words[wordIndex];
    let t: ReturnType<typeof setTimeout>;
    if (!isDeleting) {
      if (displayed.length < word.length) t = setTimeout(() => setDisplayed(word.slice(0, displayed.length + 1)), speed);
      else t = setTimeout(() => setIsDeleting(true), pause);
    } else {
      if (displayed.length > 0) t = setTimeout(() => setDisplayed(displayed.slice(0, -1)), deleteSpeed);
      else { setIsDeleting(false); setWordIndex((i) => (i + 1) % words.length); }
    }
    return () => clearTimeout(t);
  }, [displayed, isDeleting, wordIndex, words, speed, deleteSpeed, pause]);
  return displayed;
}

// ─── Real Pricing Data from WP ─────────────────────────────────────────────────
const LANGUAGES = [
  {
    slug: "ro", name: "Romanian", flag: "🇷🇴",
    badge: "For Foreigners",
    badgeColor: "bg-yellow-500/15 text-yellow-300 border-yellow-500/25",
    accentColor: "text-yellow-400",
    img: "https://images.unsplash.com/photo-1592860000046-6a3dcd0b651b?q=80&w=800&auto=format&fit=crop",
    description: "Learn Romanian from scratch — from phonetics and grammar to culture, folklore, and Eminescu. Perfect for expats, heritage speakers, and Japanophiles discovering Romania.",
    levels: [
      { level: "A1-A2", label: "Beginner", startPrice: 700, sessions: "Platform" },
      { level: "B1-B2", label: "Intermediate", startPrice: 800, sessions: "Platform" },
      { level: "C1-C2", label: "Advanced", startPrice: 1000, sessions: "Platform" },
    ],
    courses: [
      { level: "A1-A2", title: "Romanian for Beginners", price: "280 RON/mo", link: "/courses?lang=ro&level=a1" },
      { level: "B1-B2", title: "Conversational Romanian", price: "300 RON/mo", link: "/courses?lang=ro&level=b1" },
      { level: "C1-C2", title: "Advanced Romanian", price: "320 RON/mo", link: "/courses?lang=ro&level=c1" },
    ],
  },
  {
    slug: "en", name: "English", flag: "🇬🇧",
    badge: "Most Popular",
    badgeColor: "bg-sky-500/15 text-sky-300 border-sky-500/25",
    accentColor: "text-sky-400",
    img: "https://images.unsplash.com/photo-1513635269975-59663e0ac1ad?q=80&w=800&auto=format&fit=crop",
    description: "Master British English with a native-level instructor. From everyday conversation to business fluency — built around culture, authenticity, and real communication.",
    levels: [
      { level: "A1-A2", label: "Beginner", startPrice: 800, sessions: "Platform" },
      { level: "B1-B2", label: "Intermediate", startPrice: 1300, sessions: "Platform" },
      { level: "C1-C2", label: "Advanced", startPrice: 1700, sessions: "Platform" },
    ],
    courses: [
      { level: "A1-A2", title: "English for Beginners", price: "320 RON/mo", link: "/courses?lang=en&level=a1" },
      { level: "B1-B2", title: "Business English", price: "360 RON/mo", link: "/courses?lang=en&level=b1" },
      { level: "C1-C2", title: "Advanced English", price: "480 RON/mo", link: "/courses?lang=en&level=c1" },
    ],
  },
  {
    slug: "ja", name: "Japanese", flag: "🇯🇵",
    badge: "Trending",
    badgeColor: "bg-rose-500/15 text-rose-300 border-rose-500/25",
    accentColor: "text-rose-400",
    img: "https://images.unsplash.com/photo-1490806843957-31f4c9a91c65?q=80&w=800&auto=format&fit=crop",
    description: "Unlock the universe of anime, manga, bushidō and Japanese culture. Rima's bilingual approach makes Hiragana, Katakana and grammar click from day one.",
    levels: [
      { level: "A1-A2 / N5-N4", label: "Beginner", startPrice: 1150, sessions: "Platform" },
      { level: "B1-B2 / N3", label: "Intermediate", startPrice: 1600, sessions: "Platform" },
      { level: "C1-C2 / N2-N1", label: "Advanced", startPrice: 2000, sessions: "Platform" },
    ],
    courses: [
      { level: "Hiragana & N5", title: "Japanese Writing & Basics", price: "400 RON/mo", link: "/courses?lang=ja&level=n5" },
      { level: "JLPT N4-N3", title: "Intermediate Japanese", price: "600 RON/mo", link: "/courses?lang=ja&level=n3" },
      { level: "JLPT N2-N1", title: "Advanced Fluency", price: "720 RON/mo", link: "/courses?lang=ja&level=n2" },
    ],
  },
];

// ─── Pathway from WP ──────────────────────────────────────────────────────────
const PATHWAY = [
  { num: "01", title: "Placement & Assessment", body: "Start with a free quick assessment. We evaluate your current fluency to place you in the perfect level — accurate CEFR placement guaranteed.", bullets: ["Free initial assessment", "Personalized learning roadmap", "Accurate CEFR level placement"] },
  { num: "02", title: "Choose Your Course", body: "Browse expert-curated courses from absolute beginner (A1) to mastery (C2). Individual, group, or corporate bundles available.", bullets: ["General Language Courses", "Business & Corporate Training", "Exam Prep: IELTS, JLPT, Cambridge"] },
  { num: "03", title: "Live Native Instruction", body: "Join interactive live sessions with Rima — small groups or 1-on-1 Zoom sessions blending authentic pronunciation, culture and real scenarios.", bullets: ["Interactive Zoom integration", "Small group or 1-on-1 sessions", "Real-life language, not textbook phrases"] },
  { num: "04", title: "Practice & Assignments", body: "Solidify knowledge outside of class. Interactive quizzes, homework reviewed by Rima, and real-time progress tracking on your dashboard.", bullets: ["Automated progress tracking", "Interactive quizzes & exams", "Detailed feedback from Rima"] },
  { num: "05", title: "Earn Your Certificate", body: "Complete your modules and pass the final assessment to receive your official RIMA Academy certificate, ready for CV and LinkedIn.", bullets: ["Verified Certificate of Completion", "Add directly to CV/LinkedIn", "Proof of CEFR language proficiency"] },
];

// ─── Real testimonials tone from WP ──────────────────────────────────────────
const TESTIMONIALS = [
  { text: "Rima e cea mai bună profesoară de japoneză pe care am întâlnit-o. Japoneza părea imposibilă — acum scriu hiragana perfect!", author: "Andreea M.", lang: "Japanese · A1 → A2" },
  { text: "I started Romanian from zero. After 3 months I have full conversations. The cultural depth in every lesson is incredible.", author: "James K.", lang: "Romanian · A1 → B1" },
  { text: "Rima sensei explains Japanese grammar in a way no Japanese teacher ever did. Her bilingual approach is unique and so effective.", author: "Yuki T.", lang: "English · B1 → C1" },
  { text: "Lecțiile de engleză cu Rima mi-au transformat cariera. Am trecut interviul de angajare în UK fără nicio problemă.", author: "Ștefan O.", lang: "English · B2 → C1" },
  { text: "継続は力なり — Rima sensei m-a inspirat să nu renunț niciodată. Arigatou gozaimasu!", author: "Ana R.", lang: "Japanese · N5 → N4" },
  { text: "The best language platform I have ever used. Every session feels like a conversation with a friend who happens to be an expert.", author: "Sarah T.", lang: "Romanian · A2 → B1" },
];

// ─── Why Rima — from About.php ──────────────────────────────────────────────
const WHY_RIMA = [
  { icon: BookOpen, title: "Real-life language", desc: "We practise the phrases you'll actually use — introducing yourself, ordering food, making friends. Not textbook sentences." },
  { icon: Globe2, title: "Culture in every lesson", desc: "From Romanian Mărțișor and English holidays to Japanese politeness levels — you understand the people as well as the words." },
  { icon: Mic, title: "Lessons shaped around you", desc: "Your goals, your pace, your interests guide what we study. Travel, work, study, or pleasure — every path is valid." },
  { icon: Award, title: "Cert-ready curriculum", desc: "Aligned with CEFR standards. Students regularly pass IELTS, JLPT N5-N2, Cambridge and TOEFL on their first attempt." },
];

// ─── Flip Card ────────────────────────────────────────────────────────────────
function LanguageFlipCard({ lang }: { lang: typeof LANGUAGES[0] }) {
  const [flipped, setFlipped] = useState(false);
  return (
    <div className="relative w-full aspect-[3/4] cursor-pointer" style={{ perspective: "1200px" }} onClick={() => setFlipped((f) => !f)}>
      <motion.div animate={{ rotateY: flipped ? 180 : 0 }} transition={{ duration: 0.6, ease: [0.32, 0.72, 0, 1] }} style={{ transformStyle: "preserve-3d" }} className="w-full h-full relative">
        {/* FRONT */}
        <div className="absolute inset-0 rounded-3xl overflow-hidden" style={{ backfaceVisibility: "hidden" }}>
          <div className="absolute inset-0 bg-cover bg-center" style={{ backgroundImage: `url('${lang.img}')` }} />
          <div className="absolute inset-0 bg-gradient-to-t from-[#030408] via-[#030408]/55 to-transparent" />
          <div className="absolute top-5 left-5 z-10">
            <span className={`text-[10px] font-black uppercase tracking-[0.15em] px-3 py-1 rounded-full border ${lang.badgeColor}`}>{lang.badge}</span>
          </div>
          <div className="absolute bottom-0 left-0 right-0 p-7 z-10">
            <div className="flex items-center gap-2 mb-3">
              <span className="text-3xl">{lang.flag}</span>
            </div>
            <h3 className="text-4xl font-black tracking-tight text-white mb-2">{lang.name}</h3>
            <p className="text-white/50 text-sm leading-snug mb-4 line-clamp-2">{lang.description}</p>
            <div className={`flex items-center gap-2 ${lang.accentColor} text-sm font-bold`}>
              <span>View Courses</span>
              <ArrowRight className="w-4 h-4" />
            </div>
          </div>
          <div className="absolute inset-0 rounded-3xl ring-1 ring-white/10" />
        </div>
        {/* BACK */}
        <div className="absolute inset-0 rounded-3xl overflow-hidden bg-[#0a0c14] border border-white/10" style={{ backfaceVisibility: "hidden", transform: "rotateY(180deg)" }}>
          <div className="absolute inset-0 bg-cover bg-center opacity-8" style={{ backgroundImage: `url('${lang.img}')` }} />
          <div className="relative z-10 p-7 h-full flex flex-col">
            <div className="flex items-center justify-between mb-5">
              <div>
                <span className="text-xl font-black text-white">{lang.flag} {lang.name}</span>
                <div className="text-white/30 text-xs mt-0.5">Click a course to enroll</div>
              </div>
              <button onClick={(e) => { e.stopPropagation(); setFlipped(false); }} className="w-8 h-8 rounded-full bg-white/10 flex items-center justify-center hover:bg-white/20 text-white/50 hover:text-white transition-colors text-base font-bold">✕</button>
            </div>
            <div className="flex flex-col gap-3 flex-1">
              {lang.courses.map((c) => (
                <Link key={c.level} href={c.link} onClick={(e) => e.stopPropagation()} className="group flex items-center justify-between p-4 rounded-2xl bg-white/[0.04] border border-white/[0.06] hover:bg-white/[0.09] hover:border-white/15 transition-all">
                  <div>
                    <div className="text-[10px] uppercase tracking-[0.15em] font-bold text-white/35 mb-0.5">{c.level}</div>
                    <div className="text-sm font-semibold text-white">{c.title}</div>
                  </div>
                  <div className="flex items-center gap-2 shrink-0">
                    <span className={`text-xs font-bold ${lang.accentColor}`}>{c.price}</span>
                    <ChevronRight className="w-4 h-4 text-white/30 group-hover:text-white transition-colors" />
                  </div>
                </Link>
              ))}
            </div>
            <Link href={`/courses?lang=${lang.slug}`} onClick={(e) => e.stopPropagation()} className="mt-5 text-center text-sm text-white/30 hover:text-white/70 transition-colors font-semibold">
              View all {lang.name} courses →
            </Link>
          </div>
        </div>
      </motion.div>
    </div>
  );
}

// ─── Main Page ────────────────────────────────────────────────────────────────
export default function Home() {
  const typed = useTypewriter(["Romanian", "English", "Japanese"]);
  const [activeStep, setActiveStep] = useState(0);
  const { scrollY } = useScroll();
  const globeY = useSpring(useTransform(scrollY, [0, 700], [0, 90]), { stiffness: 55, damping: 18 });
  const globeScale = useTransform(scrollY, [0, 700], [1, 0.86]);
  const heroOpacity = useTransform(scrollY, [0, 500], [1, 0]);
  const heroTextY = useTransform(scrollY, [0, 500], [0, -65]);

  return (
    <main className="min-h-[100dvh] bg-[#030408] text-white overflow-x-hidden">

      {/* ── Ambient mesh ── */}
      <div className="fixed inset-0 pointer-events-none z-0 overflow-hidden">
        <div className="absolute -top-[10%] -left-[5%] w-[55%] h-[55%] rounded-full bg-[#102d56]/22 blur-[120px]" />
        <div className="absolute top-[35%] -right-[15%] w-[45%] h-[45%] rounded-full bg-rose-900/14 blur-[130px]" />
        <div className="absolute bottom-0 left-[25%] w-[40%] h-[35%] rounded-full bg-indigo-900/14 blur-[100px]" />
        <div className="absolute inset-0 opacity-[0.022]" style={{ backgroundImage: "linear-gradient(rgba(255,255,255,0.15) 1px,transparent 1px),linear-gradient(90deg,rgba(255,255,255,0.15) 1px,transparent 1px)", backgroundSize: "60px 60px" }} />
      </div>

      {/* ═══════════════════════════════════════════════
          1. HERO — Globe Parallax + Typewriter
      ═══════════════════════════════════════════════ */}
      <section className="relative min-h-[100dvh] flex items-center justify-center overflow-hidden z-10">
        {/* Globe parallax */}
        <motion.div style={{ y: globeY, scale: globeScale, top: "-20%" }} className="absolute inset-x-0 flex items-start justify-center pointer-events-none select-none">
          <div className="w-[85vw] max-w-[780px] aspect-square opacity-85">
            <GlobeWrapper />
          </div>
        </motion.div>
        {/* Vignette */}
        <div className="absolute inset-0 pointer-events-none z-10" style={{ background: "radial-gradient(ellipse 55% 55% at 50% 38%, transparent 0%, #030408 68%)" }} />

        {/* Hero text */}
        <motion.div style={{ y: heroTextY, opacity: heroOpacity }} className="relative z-20 flex flex-col items-center text-center px-4 max-w-4xl mx-auto w-full">
          <motion.div initial={{ opacity: 0, y: -20 }} animate={{ opacity: 1, y: 0 }} transition={{ duration: 0.8 }} className="mb-6 md:mb-10 hidden md:block">
            <img src="/logo-2.png" alt="RIMA Academy" className="h-14 md:h-16 w-auto mx-auto drop-shadow-2xl" />
          </motion.div>
          <motion.h1 initial={{ opacity: 0, y: 30, filter: "blur(8px)" }} animate={{ opacity: 1, y: 0, filter: "blur(0px)" }} transition={{ duration: 1, ease: [0.32, 0.72, 0, 1], delay: 0.2 }} className="text-[clamp(3.8rem,14vw,6rem)] md:text-[clamp(2.8rem,9vw,6rem)] font-black tracking-[-0.04em] leading-[1.0] mb-5">
            <span className="text-white drop-shadow-lg">Master</span>
            <br />
            <span className="text-transparent bg-clip-text bg-gradient-to-r from-[#ff4b4b] via-[#dc2626] to-[#7f1d1d] drop-shadow-md">
              {typed}<span className="animate-pulse text-[#dc2626]/80">|</span>
            </span>
          </motion.h1>
          <motion.p initial={{ opacity: 0, y: 20 }} animate={{ opacity: 1, y: 0 }} transition={{ duration: 0.8, delay: 0.38 }} className="text-lg md:text-xl text-white/40 font-light leading-relaxed max-w-lg mb-12">
            Unlock global opportunities with native tutors and live interactive sessions — from Bucharest to Tokyo.
          </motion.p>
          <motion.div initial={{ opacity: 0, scale: 0.92 }} animate={{ opacity: 1, scale: 1 }} transition={{ duration: 0.7, delay: 0.52 }} className="flex flex-col sm:flex-row gap-4 w-full md:w-auto mt-4">
            <Link href="/courses" className="group flex items-center justify-center gap-3 bg-gradient-to-r from-[#991b1b] to-[#dc2626] text-white rounded-full px-8 py-4 md:pl-7 md:pr-2 md:py-2 font-bold text-[16px] md:text-sm tracking-wide hover:brightness-110 transition-all shadow-[0_10px_40px_rgba(220,38,38,0.3)] w-full md:w-auto">
              Start Learning
              <span className="w-9 h-9 rounded-full bg-black/20 flex items-center justify-center group-hover:translate-x-0.5 transition-transform"><ArrowRight className="w-4 h-4 text-white" /></span>
            </Link>
            <a href="#how-it-works" className="hidden md:flex items-center justify-center border border-white/14 text-white/55 hover:text-white hover:border-white/28 rounded-full px-7 py-3 text-sm font-semibold transition-all">
              How it works

            </a>
          </motion.div>
        </motion.div>

        {/* Scroll indicator */}
        <motion.div initial={{ opacity: 0 }} animate={{ opacity: 1 }} transition={{ delay: 1.8 }} className="absolute bottom-8 left-1/2 -translate-x-1/2 z-20 flex flex-col items-center gap-1 text-white/20">
          <motion.div animate={{ y: [0, 8, 0] }} transition={{ duration: 1.5, repeat: Infinity }} className="w-px h-10 bg-gradient-to-b from-transparent via-white/25 to-transparent" />
          <span className="text-[9px] uppercase tracking-[0.2em]">Scroll</span>
        </motion.div>
      </section>

      {/* ═══════════════════════════════════════════════
          1.5 TRUSTED BY + STATS
      ═══════════════════════════════════════════════ */}
      <section className="relative z-10 border-y border-white/5 bg-white/[0.015]">
        <div className="max-w-6xl mx-auto px-4 py-8 flex flex-col md:flex-row items-center justify-between gap-6">
          <div className="flex flex-col gap-1">
            <p className="text-white/25 text-[10px] uppercase tracking-[0.2em] font-bold">Trusted by learners worldwide</p>
            <div className="flex items-center gap-5 flex-wrap">
              {["IELTS", "JLPT", "Cambridge", "TOEFL", "CEFR"].map((c) => (
                <span key={c} className="text-white/20 font-black text-sm tracking-widest hover:text-white/45 transition-colors cursor-default">{c}</span>
              ))}
            </div>
          </div>
          <div className="h-px md:h-12 md:w-px bg-white/5 w-full" />
          <div className="grid grid-cols-4 gap-6 text-center shrink-0">
            {[["500+", "Students"], ["4.9★", "Rating"], ["3", "Languages"], ["100%", "Satisfaction"]].map(([v, l]) => (
              <div key={l} className="flex flex-col">
                <span className="font-black text-xl text-white">{v}</span>
                <span className="text-[10px] text-white/30 uppercase tracking-wider">{l}</span>
              </div>
            ))}
          </div>
        </div>
      </section>

      {/* ═══════════════════════════════════════════════
          2. 3D FLIP CARDS
      ═══════════════════════════════════════════════ */}
      <section className="relative z-10 px-4 md:px-8 py-24 md:py-32" id="courses">
        <div className="max-w-6xl mx-auto">
          <motion.div initial={{ opacity: 0, y: 30 }} whileInView={{ opacity: 1, y: 0 }} viewport={{ once: true }} className="text-center mb-14">
            <div className="text-[11px] uppercase tracking-[0.2em] text-white/35 font-semibold mb-4">Course Catalog</div>
            <h2 className="text-4xl md:text-5xl font-black tracking-[-0.03em]">
              Choose Your <span className="text-transparent bg-clip-text bg-gradient-to-r from-sky-400 to-rose-400">Language.</span>
            </h2>
            <p className="text-white/35 mt-4 max-w-sm mx-auto text-sm">Click on a language card to reveal available course levels and pricing.</p>
          </motion.div>
          <div className="grid grid-cols-1 md:grid-cols-3 gap-6">
            {LANGUAGES.map((lang, i) => (
              <motion.div key={lang.slug} initial={{ opacity: 0, y: 50 }} whileInView={{ opacity: 1, y: 0 }} viewport={{ once: true, margin: "-50px" }} transition={{ duration: 0.8, delay: i * 0.12 }}>
                <LanguageFlipCard lang={lang} />
              </motion.div>
            ))}
          </div>
        </div>
      </section>

      {/* ═══════════════════════════════════════════════
          3. WHO IS RIMA — from About.php
      ═══════════════════════════════════════════════ */}
      <section className="relative z-10 border-t border-white/5 bg-white/[0.015] px-4 md:px-8 py-24 md:py-32">
        <div className="max-w-7xl mx-auto grid grid-cols-1 lg:grid-cols-2 gap-16 items-center">

          {/* Left: bio */}
          <motion.div initial={{ opacity: 0, x: -40 }} whileInView={{ opacity: 1, x: 0 }} viewport={{ once: true }} transition={{ duration: 0.9 }}>
            <div className="text-[11px] uppercase tracking-[0.2em] text-rose-400 font-semibold mb-5">Meet Your Instructor</div>
            <h2 className="text-4xl md:text-5xl font-black tracking-[-0.03em] leading-[1.1] mb-6">
              Hi, I'm <span className="text-transparent bg-clip-text bg-gradient-to-r from-rose-400 to-amber-400">Rima</span> 👋
            </h2>
            <p className="text-white/55 text-lg leading-relaxed mb-6">
              Languages have always fascinated me — the sounds, the stories, and the beautiful ways people connect across the world. My love for Japanese culture inspired me to create a space where learning feels warm, clear, and truly enjoyable.
            </p>
            <p className="text-white/45 leading-relaxed mb-8">
              I studied at <strong className="text-white/80">Dimitrie Cantemir Christian University</strong>, earning a BA in English & Japanese. I then completed an MA in <strong className="text-white/80">Intercultural Communication & Translation</strong> — which taught me that every expression carries culture, history, and a way of thinking.
            </p>
            {/* Credentials */}
            <div className="flex flex-col gap-3 mb-10">
              {[
                { icon: GraduationCap, text: "BA in English & Japanese — Dimitrie Cantemir Christian University" },
                { icon: GraduationCap, text: "MA in Intercultural Communication & Translation" },
                { icon: Award, text: "Certified CEFR, JLPT & Cambridge exam preparation" },
              ].map((c, i) => (
                <div key={i} className="flex items-start gap-3 text-sm text-white/55">
                  <c.icon className="w-4 h-4 text-rose-400 shrink-0 mt-0.5" />
                  {c.text}
                </div>
              ))}
            </div>
            <Link href="/about" className="group inline-flex items-center gap-3 border border-white/15 text-white/60 hover:text-white hover:border-white/30 rounded-full pl-6 pr-2 py-2 text-sm font-semibold transition-all">
              Read Full Story
              <span className="w-8 h-8 rounded-full bg-white/8 flex items-center justify-center group-hover:translate-x-0.5 transition-transform"><ChevronRight className="w-4 h-4" /></span>
            </Link>
          </motion.div>

          {/* Right: photo + Why Rima */}
          <motion.div initial={{ opacity: 0, x: 40 }} whileInView={{ opacity: 1, x: 0 }} viewport={{ once: true }} transition={{ duration: 0.9 }}>
            {/* Photo card */}
            <div className="relative mb-8 rounded-3xl overflow-hidden aspect-[4/3] border border-white/8">
              <img
                src="https://rima-academy.com/wp-content/uploads/2026/07/rima-about-image.jpg"
                alt="Rima — Founder & Language Instructor"
                className="w-full h-full object-cover"
                onError={(e) => {
                  (e.target as HTMLImageElement).src = "https://images.unsplash.com/photo-1607746882042-944635dfe10e?q=80&w=800&auto=format&fit=crop";
                }}
              />
              <div className="absolute inset-0 bg-gradient-to-t from-[#030408]/60 to-transparent" />
              <div className="absolute bottom-5 left-5">
                <div className="font-black text-white text-lg">Rima</div>
                <div className="text-white/50 text-xs font-semibold uppercase tracking-widest">Founder & Language Instructor</div>
              </div>
            </div>
            {/* Why cards */}
            <div className="grid grid-cols-2 gap-3">
              {WHY_RIMA.map((item, i) => (
                <motion.div key={item.title} initial={{ opacity: 0, y: 20 }} whileInView={{ opacity: 1, y: 0 }} viewport={{ once: true }} transition={{ delay: i * 0.08 }} className="rounded-2xl p-5 bg-white/[0.03] border border-white/6 hover:border-white/12 transition-all">
                  <item.icon className="w-5 h-5 text-sky-400 mb-3" />
                  <div className="text-sm font-bold text-white mb-1">{item.title}</div>
                  <div className="text-xs text-white/35 leading-snug">{item.desc}</div>
                </motion.div>
              ))}
            </div>
          </motion.div>
        </div>
      </section>

      {/* ═══════════════════════════════════════════════
          4. HOW IT WORKS — The RIMA Pathway
      ═══════════════════════════════════════════════ */}
      <section className="relative z-10 px-4 md:px-8 py-24 md:py-32" id="how-it-works">
        <div className="max-w-6xl mx-auto">
          <motion.div initial={{ opacity: 0, y: 30 }} whileInView={{ opacity: 1, y: 0 }} viewport={{ once: true }} className="text-center mb-14">
            <div className="text-[11px] uppercase tracking-[0.2em] text-sky-400 font-semibold mb-4">Process</div>
            <h2 className="text-4xl md:text-5xl font-black tracking-[-0.03em]">
              The <span className="text-transparent bg-clip-text bg-gradient-to-r from-sky-400 to-indigo-400">RIMA</span> Pathway
            </h2>
            <p className="text-white/35 mt-4 text-sm">A proven step-by-step method to achieve fluency and global certification.</p>
          </motion.div>
          <div className="grid grid-cols-1 lg:grid-cols-[260px_1fr] gap-8 lg:gap-10 items-start">
            {/* Tabs */}
            <div className="flex flex-row lg:flex-col gap-2 overflow-x-auto pb-2 lg:pb-0">
              {PATHWAY.map((step, i) => (
                <button key={step.num} onClick={() => setActiveStep(i)} className={`shrink-0 lg:w-full flex items-center gap-3 px-5 py-4 rounded-2xl text-left transition-all ${activeStep === i ? "bg-white/7 border border-white/14" : "border border-transparent hover:bg-white/3"}`}>
                  <span className={`font-black text-sm shrink-0 ${activeStep === i ? "text-sky-400" : "text-white/22"}`}>{step.num}</span>
                  <span className={`text-sm font-semibold leading-tight ${activeStep === i ? "text-white" : "text-white/38"}`}>{step.title}</span>
                </button>
              ))}
            </div>
            {/* Content */}
            <AnimatePresence mode="wait">
              <motion.div key={activeStep} initial={{ opacity: 0, x: 20 }} animate={{ opacity: 1, x: 0 }} exit={{ opacity: 0, x: -10 }} transition={{ duration: 0.4 }} className="rounded-3xl bg-white/[0.028] border border-white/7 p-8 md:p-10">
                <div className="text-5xl font-black text-white/7 mb-3">{PATHWAY[activeStep].num}</div>
                <h3 className="text-2xl md:text-3xl font-black text-white mb-4">{PATHWAY[activeStep].title}</h3>
                <p className="text-white/48 leading-relaxed mb-8">{PATHWAY[activeStep].body}</p>
                <ul className="flex flex-col gap-3">
                  {PATHWAY[activeStep].bullets.map((b) => (
                    <li key={b} className="flex items-center gap-3 text-sm text-white/58">
                      <Check className="w-4 h-4 text-sky-400 shrink-0" />{b}
                    </li>
                  ))}
                </ul>
              </motion.div>
            </AnimatePresence>
          </div>
        </div>
      </section>

      {/* ═══════════════════════════════════════════════
          5. PARALLAX BREAK
      ═══════════════════════════════════════════════ */}
      <section className="relative z-10 h-[260px] md:h-[360px] overflow-hidden border-y border-white/5">
        <div className="absolute inset-0 bg-cover bg-center bg-fixed" style={{ backgroundImage: "url('https://images.unsplash.com/photo-1523240795612-9a054b0db644?q=80&w=2000&auto=format&fit=crop')" }} />
        <div className="absolute inset-0 bg-gradient-to-r from-[#030408] via-[#030408]/80 to-[#030408]" />
        <div className="relative z-10 h-full flex items-center justify-center">
          <motion.h2 initial={{ opacity: 0, letterSpacing: "0.05em" }} whileInView={{ opacity: 1, letterSpacing: "0.22em" }} viewport={{ once: true }} transition={{ duration: 1.2 }} className="text-4xl md:text-7xl font-black uppercase tracking-[0.18em] text-white/12 select-none text-center">
            FLUENCY IS POWER
          </motion.h2>
        </div>
      </section>

      {/* ═══════════════════════════════════════════════
          6. MARQUEE TESTIMONIALS (dual direction)
      ═══════════════════════════════════════════════ */}
      <section className="relative z-10 py-20 overflow-hidden">
        {/* Row 1 → */}
        <div className="flex gap-5 mb-5 overflow-hidden mask-x">
          <motion.div animate={{ x: [0, "-50%"] }} transition={{ duration: 32, repeat: Infinity, ease: "linear" }} className="flex gap-5 shrink-0">
            {[...TESTIMONIALS, ...TESTIMONIALS].map((t, i) => (
              <div key={i} className="shrink-0 w-[320px] rounded-2xl bg-white/[0.028] border border-white/5 p-6">
                <div className="flex gap-0.5 mb-4">
                  {Array.from({ length: 5 }).map((_, j) => (<span key={j} className="text-yellow-400 text-sm">★</span>))}
                </div>
                <p className="text-white/58 text-sm leading-relaxed italic mb-4">&ldquo;{t.text}&rdquo;</p>
                <div>
                  <div className="text-white/70 text-xs font-bold">{t.author}</div>
                  <div className="text-white/25 text-[10px]">{t.lang}</div>
                </div>
              </div>
            ))}
          </motion.div>
        </div>
        {/* Row 2 ← */}
        <div className="flex gap-5 overflow-hidden">
          <motion.div animate={{ x: ["-50%", "0%"] }} transition={{ duration: 28, repeat: Infinity, ease: "linear" }} className="flex gap-5 shrink-0">
            {[...TESTIMONIALS.slice().reverse(), ...TESTIMONIALS.slice().reverse()].map((t, i) => (
              <div key={i} className="shrink-0 w-[320px] rounded-2xl bg-white/[0.028] border border-white/5 p-6">
                <div className="flex gap-0.5 mb-4">
                  {Array.from({ length: 5 }).map((_, j) => (<span key={j} className="text-yellow-400 text-sm">★</span>))}
                </div>
                <p className="text-white/58 text-sm leading-relaxed italic mb-4">&ldquo;{t.text}&rdquo;</p>
                <div>
                  <div className="text-white/70 text-xs font-bold">{t.author}</div>
                  <div className="text-white/25 text-[10px]">{t.lang}</div>
                </div>
              </div>
            ))}
          </motion.div>
        </div>
      </section>

      {/* ═══════════════════════════════════════════════
          7. PRICING TEASER
      ═══════════════════════════════════════════════ */}
      <section className="relative z-10 border-t border-white/5 bg-white/[0.012] px-4 md:px-8 py-24 md:py-28">
        <div className="max-w-5xl mx-auto">
          <motion.div initial={{ opacity: 0, y: 30 }} whileInView={{ opacity: 1, y: 0 }} viewport={{ once: true }} className="text-center mb-12">
            <div className="text-[11px] uppercase tracking-[0.2em] text-yellow-400 font-semibold mb-4">Transparent Pricing</div>
            <h2 className="text-4xl md:text-5xl font-black tracking-[-0.03em] mb-4">
              Learn more, pay less.<br />
              <span className="text-white/28">No hidden fees.</span>
            </h2>
            <p className="text-white/38 text-sm max-w-md mx-auto">All prices include course materials. Individual and corporate bundles available. Discounts for 3 and 6-month commitments.</p>
          </motion.div>
          <div className="grid grid-cols-1 md:grid-cols-3 gap-5">
            {LANGUAGES.map((lang, i) => (
              <motion.div key={lang.slug} initial={{ opacity: 0, y: 30 }} whileInView={{ opacity: 1, y: 0 }} viewport={{ once: true }} transition={{ delay: i * 0.1 }} className="rounded-3xl p-7 bg-white/[0.03] border border-white/6 hover:border-white/14 transition-all">
                <div className="flex items-center gap-3 mb-6">
                  <span className="text-3xl">{lang.flag}</span>
                  <div>
                    <div className="font-black text-white text-lg">{lang.name}</div>
                    <div className={`text-xs font-bold ${lang.accentColor}`}>3 levels available</div>
                  </div>
                </div>
                <div className="flex flex-col gap-2 mb-6">
                  {lang.levels.map((lv) => (
                    <div key={lv.level} className="flex items-center justify-between py-2 border-b border-white/5 last:border-0">
                      <div>
                        <div className="text-xs text-white/40 font-semibold">{lv.level}</div>
                        <div className="text-sm font-bold text-white">{lv.label}</div>
                      </div>
                      <div className="text-right">
                        <div className="text-white/30 text-[10px]">Platform from</div>
                        <div className={`font-black text-sm ${lang.accentColor}`}>{lv.startPrice} RON</div>
                      </div>
                    </div>
                  ))}
                </div>
                <Link href={`/courses?lang=${lang.slug}`} className={`w-full flex items-center justify-center gap-2 py-3 rounded-2xl border text-sm font-bold transition-all ${lang.accentColor} border-white/10 hover:bg-white/5`}>
                  View Details <ChevronRight className="w-4 h-4" />
                </Link>
              </motion.div>
            ))}
          </div>
          <p className="text-center text-white/20 text-xs mt-6">Individual sessions available from 280 RON/month · Corporate packages with dedicated manager</p>
        </div>
      </section>

      {/* ═══════════════════════════════════════════════
          8. JAPANESE MOTTO BANNER
      ═══════════════════════════════════════════════ */}
      <div className="relative z-10 border-y border-white/5 bg-white/[0.015] py-16 px-4 text-center overflow-hidden">
        <div className="absolute inset-0 bg-[radial-gradient(ellipse_at_center,rgba(220,38,38,0.04)_0%,transparent_65%)] pointer-events-none" />
        <div className="text-[clamp(3rem,10vw,7rem)] font-black tracking-[0.05em] text-white/8 mb-3 select-none leading-none">継続は力なり</div>
        <div className="text-white/28 text-sm italic mb-2">Keizoku wa chikara nari</div>
        <div className="text-white/65 font-semibold text-lg">&ldquo;Continuing is strength. Every step brings you closer.&rdquo;</div>
        <div className="text-white/18 text-xs uppercase tracking-widest mt-3">— Rima Academy Motto</div>
      </div>

      {/* ═══════════════════════════════════════════════
          9. FINAL CTA
      ═══════════════════════════════════════════════ */}
      <section className="relative z-10 px-4 md:px-8 py-28 md:py-36">
        <motion.div initial={{ opacity: 0, y: 50 }} whileInView={{ opacity: 1, y: 0 }} viewport={{ once: true }} transition={{ duration: 1 }} className="max-w-[1000px] mx-auto">
          <div className="relative rounded-[3rem] overflow-hidden border border-white/10">
            <div className="absolute inset-0 bg-gradient-to-br from-[#102d56]/38 via-[#030408] to-rose-950/28" />
            <div className="absolute top-0 left-1/2 -translate-x-1/2 w-3/4 h-[1px] bg-gradient-to-r from-transparent via-white/18 to-transparent" />
            <div className="relative z-10 flex flex-col items-center text-center py-24 md:py-28 px-4">
              <div className="w-14 h-14 rounded-2xl bg-gradient-to-br from-[#102d56] to-rose-800 flex items-center justify-center mb-8 shadow-[0_0_40px_rgba(16,45,86,0.45)]">
                <Sparkles className="w-6 h-6 text-white" />
              </div>
              <h2 className="text-3xl md:text-5xl font-black tracking-[-0.03em] mb-5">Your Future Starts Now.</h2>
              <p className="text-white/38 text-lg font-light mb-12 max-w-sm">Join a global community of language learners. Free placement test, no commitment.</p>
              <div className="flex flex-col sm:flex-row gap-4">
                <Link href="/register" className="group flex items-center gap-3 bg-white text-[#030408] rounded-full pl-7 pr-2 py-2 font-bold text-sm hover:bg-slate-100 transition-all shadow-[0_0_40px_rgba(255,255,255,0.11)]">
                  Create Free Account
                  <span className="w-9 h-9 rounded-full bg-black/10 flex items-center justify-center group-hover:translate-x-0.5 transition-transform"><ArrowRight className="w-4 h-4" /></span>
                </Link>
                <Link href="/courses" className="flex items-center justify-center border border-white/14 text-white/55 hover:text-white hover:border-white/28 rounded-full px-7 py-3 text-sm font-semibold transition-all">
                  Browse Courses
                </Link>
              </div>
            </div>
            <div className="absolute bottom-0 left-1/2 -translate-x-1/2 w-3/4 h-[1px] bg-gradient-to-r from-transparent via-white/8 to-transparent" />
          </div>
        </motion.div>
      </section>

      {/* Footer */}
      <footer className="relative z-10 border-t border-white/5 py-10 px-4 md:px-8">
        <div className="max-w-7xl mx-auto flex flex-col md:flex-row items-center justify-between gap-5">
          <img src="/logo-2.png" alt="RIMA Academy" className="h-8 w-auto" />
          <p className="text-xs text-white/18">© 2026 RIMA Academy · Founded by Rima · Learn English · Romanian · Japanese</p>
          <div className="flex gap-5 text-xs font-medium text-white/22">
            {[["Home", "/"], ["Courses", "/courses"], ["About", "/about"], ["Contact", "/contact"]].map(([l, h]) => (
              <Link key={l} href={h} className="hover:text-white transition-colors">{l}</Link>
            ))}
          </div>
        </div>
      </footer>

    </main>
  );
}
