// i18n.jsx — Turkish & English translations + useT hook

const STRINGS = {
  tr: {
    'nav.features': 'Özellikler',
    'nav.how': 'Nasıl Çalışır',
    'nav.testimonials': 'Yorumlar',
    'nav.pricing': 'Fiyatlandırma',
    'nav.login': 'Giriş yap',
    'nav.download': 'Hemen İndir',

    'hero.badge.new': 'Yeni · Yapay Zekâ Telaffuz 2.0',
    'hero.badge.langs': '12 dil',
    'hero.h1.before': 'Yeni bir dili',
    'hero.h1.highlight': 'pürüzsüz',
    'hero.h1.after': 'bir telaffuzla öğren.',
    'hero.sub': 'Etkileşimli oyunlar, gerçek zamanlı konuşma takibi ve akıllı kartlarla daha hızlı akıcı ol. Günde beş dakika. Seni hesaba çeken bir kedi.',
    'hero.cta.primary': 'Ücretsiz Başla',
    'hero.cta.secondary': 'Nasıl Çalıştığını Gör',
    'hero.social.loved.prefix': '',
    'hero.social.loved.count': '2,1M öğrenci',
    'hero.social.loved.suffix': 'dünya genelinde seviyor',
    'hero.streak': '14 gün üst üste',
    'hero.tap': 'Konuşmak için bas',
    'hero.listening': 'Dinleniyor…',
    'hero.match': 'eşleşme',
    'hero.trusted': '70+ ülkede güveniliyor',

    'features.eyebrow': '// içinde neler var',
    'features.title.a': '5 dakikayı gerçek',
    'features.title.b': 'ilerleme',
    'features.title.c': 'ye dönüştüren bir araç kutusu.',
    'features.sub': 'Üç temel özellik. Konuş, öğren, oyna — akıcılığa giden zincirleme bir yol.',
    'f1.eyebrow': '01 · Konuşma',
    'f1.title': 'Gerçek zamanlı konuşma takibi',
    'f1.desc': 'Her hecede yapay zekâ telaffuz geri bildirimi. Kelimeye dokun, söyle, aksanının nerede kaydığını gör.',
    'f2.eyebrow': '02 · Alışkanlık',
    'f2.title': 'Seni cezalandırmayan seriler',
    'f2.desc': 'Kırılmayan, esneyen bir seri-kalkan sistemi. Bir gün atla, kedin senin için devreye girer.',
    'f3.eyebrow': '03 · Kelime',
    'f3.title': 'Akıllı 3D kartlar',
    'f3.desc': 'Kartlar tam unutmak üzereyken yeniden karşına çıkar. Çevirmek için dokun.',
    'f4.eyebrow': '04 · Oyun',
    'f4.title': 'Kelime kurma oyunları',
    'f4.desc': 'Harf bloklarını yerine sürükle. Yapışsın. Puan al. Sıradakine geç.',
    'f5.eyebrow': '05 · Topluluk',
    'f5.title': 'Canlı ligler',
    'f5.desc': 'Dünyadan 30 öğrenciyle eşleş. Yüksel. Haftalık tekrar et.',

    'speech.listening': 'Dinleniyor',
    'streak.current': 'Mevcut seri',
    'streak.days': 'gün',
    'streak.shield': '🛡 1 kalkan',
    'flash.tap': 'çevirmek için dokun',
    'flash.meaning': 'Anlamı',
    'puzzle.task': '"merhaba"yı İspanyolca yaz',
    'leader.league': 'Elmas lig · 3 gün kaldı',
    'leader.you': 'Sen',

    'how.eyebrow': '// yolculuk',
    'how.title.a': 'Nasıl çalışır.',
    'how.title.b': 'Kedin sana yol gösterir.',
    'step.label': 'ADIM',
    'step1.title': 'Dilini seç',
    'step1.desc': '12 dil arasından seç. Seviyeni belirle — sıfırdan ileri seviyeye.',
    'step2.title': 'Günlük hedef belirle',
    'step2.desc': '5, 10 veya 20 dakika. Atlarsan kedin bunu kişisel alır.',
    'step3.title': 'Konuş, kaydır, puan al',
    'step3.desc': 'İki dakikalık dersler konuşma, kart ve oyunu birleştirir. Ders ortasında reklam yok.',
    'step4.title': 'Akıcılığı yakala',
    'step4.desc': '6 haftada gerçek sohbetler. 3 ayda hikâyeler. 6 ayda kendine güven.',
    'step.minilesson': 'Mini ders',
    'step.translate': 'Çevir: "Balık yerim"',
    'step.progress': 'İlerleme · Türkçe',
    'step.words': 'kelime biliyorsun',

    'opt.casual': 'Rahat',
    'opt.regular': 'Düzenli',
    'opt.serious': 'Ciddi',
    'opt.minday': 'dk/gün',

    'test.eyebrow': '// gerçek öğrenciler',
    'test.title.a': 'Dil meraklılarının',
    'test.title.b': 'her yerde',
    'test.title.c': 'sevdiği uygulama.',
    'test.active': 'aktif öğrenci',
    'test.q1': 'Kedim bana 47 bildirim gönderdi. Artık İtalyanca rüyalar görüyorum.',
    'test.r1': 'Tasarımcı · Bangalore',
    'test.q2': 'Altı haftada bir baget aldım ve özür diler gibi konuşmadım.',
    'test.r2': 'Mühendis · Lizbon',
    'test.q3': 'Final haftası boyunca seri-kalkan akıl sağlığımı kurtardı.',
    'test.r3': 'Öğrenci · Toronto',
    'test.q4': 'Rakipten geçtim. Yapay zekâ geri bildirimi bambaşka bir seviyede.',
    'test.r4': 'Ürün Yöneticisi · Berlin',

    'cta.pill': 'Sonsuza dek ücretsiz plan · Kart gerekmez',
    'cta.title.a': 'Dil yolculuğuna',
    'cta.title.b': 'başlamaya hazır mısın?',
    'cta.sub': '2,1M öğrenciye katıl. Beş dakika, bir kedi, yepyeni bir dil.',
    'cta.button': 'Bugün LingoHub\'a Katıl',
    'cta.welcome': 'Hoş geldin!',

    'footer.tagline': 'Bir dili öğrenmenin sıcak yolu. Brooklyn\'de espresso ve kedi şekerlemeleriyle yapıldı.',
    'footer.product': 'Ürün',
    'footer.company': 'Şirket',
    'footer.resources': 'Kaynaklar',
    'footer.legal': 'Hukuki',
    'footer.copy': '© 2026 LingoHub, Inc. · Pürüzsüz tasarım.',
    'footer.status': 'Tüm sistemler normal',

    'p.features': 'Özellikler',
    'p.how': 'Nasıl çalışır',
    'p.pricing': 'Fiyatlandırma',
    'p.languages': 'Diller',
    'p.changelog': 'Sürüm notları',
    'c.about': 'Hakkımızda',
    'c.careers': 'Kariyer',
    'c.press': 'Basın',
    'c.blog': 'Blog',
    'c.contact': 'İletişim',
    'r.help': 'Yardım merkezi',
    'r.community': 'Topluluk',
    'r.api': 'API',
    'r.schools': 'Okullar',
    'r.status': 'Durum',
    'l.privacy': 'Gizlilik',
    'l.terms': 'Şartlar',
    'l.cookies': 'Çerezler',
    'l.licenses': 'Lisanslar',

    'lang.tr': 'Türkçe',
    'lang.jp': 'Japonca',
    'lang.fr': 'Fransızca',
    'lang.es': 'İspanyolca',
    'lang.de': 'Almanca',
    'lang.it': 'İtalyanca',
    'lang.kr': 'Korece'
  },
  en: {
    'nav.features': 'Features',
    'nav.how': 'How It Works',
    'nav.testimonials': 'Testimonials',
    'nav.pricing': 'Pricing',
    'nav.login': 'Log in',
    'nav.download': 'Download Now',

    'hero.badge.new': 'New · AI Pronunciation 2.0',
    'hero.badge.langs': '12 languages',
    'hero.h1.before': 'Master a new language with',
    'hero.h1.highlight': 'purr-fect',
    'hero.h1.after': 'pronunciation.',
    'hero.sub': 'Interactive games, real-time speech tracking, and smart flashcards to make you fluent faster. Five minutes a day. One charming cat to keep you accountable.',
    'hero.cta.primary': 'Start Learning for Free',
    'hero.cta.secondary': 'See How It Works',
    'hero.social.loved.prefix': 'Loved by ',
    'hero.social.loved.count': '2.1M learners',
    'hero.social.loved.suffix': ' worldwide',
    'hero.streak': '14 day streak',
    'hero.tap': 'Tap to speak',
    'hero.listening': 'Listening…',
    'hero.match': 'match',
    'hero.trusted': 'Trusted in 70+ countries',

    'features.eyebrow': "// what's inside",
    'features.title.a': 'A toolkit that turns 5 minutes into',
    'features.title.b': 'real progress',
    'features.title.c': '.',
    'features.sub': 'Three core features. Built to chain together — speak, learn, and play your way to fluency.',
    'f1.eyebrow': '01 · Speech',
    'f1.title': 'Real-time speech tracking',
    'f1.desc': 'AI pronunciation feedback on every syllable. Tap a word, speak it, see exactly where your accent drifts.',
    'f2.eyebrow': '02 · Habit',
    'f2.title': "Streaks that don't punish you",
    'f2.desc': 'A streak-shield system that bends, not breaks. Miss a day, your cat covers for you.',
    'f3.eyebrow': '03 · Vocabulary',
    'f3.title': 'Smart 3D flashcards',
    'f3.desc': "Cards re-surface exactly when you're about to forget. Tap to flip.",
    'f4.eyebrow': '04 · Play',
    'f4.title': 'Word creation games',
    'f4.desc': 'Drag letter blocks into place. Snap. Score. Move on.',
    'f5.eyebrow': '05 · Community',
    'f5.title': 'Live leagues',
    'f5.desc': 'Get matched with 30 learners worldwide. Climb. Repeat weekly.',

    'speech.listening': 'Listening',
    'streak.current': 'Current streak',
    'streak.days': 'days',
    'streak.shield': '🛡 1 shield',
    'flash.tap': 'tap to flip',
    'flash.meaning': 'Meaning',
    'puzzle.task': 'Spell "hello" in Spanish',
    'leader.league': 'Diamond league · 3 days left',
    'leader.you': 'You',

    'how.eyebrow': '// the journey',
    'how.title.a': 'How it works.',
    'how.title.b': 'Your cat leads the way.',
    'step.label': 'STEP',
    'step1.title': 'Pick your language',
    'step1.desc': 'Choose from 12 languages. Hit your level — total beginner to advanced.',
    'step2.title': 'Set a daily goal',
    'step2.desc': '5, 10, or 20 minutes. Your cat takes it personally if you skip.',
    'step3.title': 'Speak, swipe, score',
    'step3.desc': 'Two-minute lessons mix speech, flashcards and games. No mid-app ads.',
    'step4.title': 'Watch fluency click',
    'step4.desc': 'Real conversations within 6 weeks. Stories at 3 months. Confident at 6.',
    'step.minilesson': 'Mini lesson',
    'step.translate': 'Translate: "I eat fish"',
    'step.progress': 'Progress · Spanish',
    'step.words': 'words known',

    'opt.casual': 'Casual',
    'opt.regular': 'Regular',
    'opt.serious': 'Serious',
    'opt.minday': 'min/day',

    'test.eyebrow': '// real learners',
    'test.title.a': 'Loved by language nerds',
    'test.title.b': 'everywhere',
    'test.title.c': '.',
    'test.active': 'active learners',
    'test.q1': 'My cat sent me 47 push notifications. Now I dream in Italian.',
    'test.r1': 'Designer · Bangalore',
    'test.q2': 'Six weeks in, I ordered a baguette without sounding apologetic.',
    'test.r2': 'Engineer · Lisbon',
    'test.q3': 'The streak-shield saved my sanity during finals week.',
    'test.r3': 'Student · Toronto',
    'test.q4': 'I switched from a competitor. The AI feedback is on another level.',
    'test.r4': 'PM · Berlin',

    'cta.pill': 'Free forever plan · No card required',
    'cta.title.a': 'Ready to start your',
    'cta.title.b': 'language journey?',
    'cta.sub': 'Join 2.1M learners. Five minutes, one cat, a brand-new language.',
    'cta.button': 'Join LingoHub Today',
    'cta.welcome': 'Welcome!',

    'footer.tagline': 'The cozy way to learn a language. Made with espresso & cat naps in Brooklyn.',
    'footer.product': 'Product',
    'footer.company': 'Company',
    'footer.resources': 'Resources',
    'footer.legal': 'Legal',
    'footer.copy': '© 2026 LingoHub, Inc. · Purr-fectly crafted.',
    'footer.status': 'All systems normal',

    'p.features': 'Features',
    'p.how': 'How it works',
    'p.pricing': 'Pricing',
    'p.languages': 'Languages',
    'p.changelog': 'Changelog',
    'c.about': 'About',
    'c.careers': 'Careers',
    'c.press': 'Press',
    'c.blog': 'Blog',
    'c.contact': 'Contact',
    'r.help': 'Help center',
    'r.community': 'Community',
    'r.api': 'API',
    'r.schools': 'Schools',
    'r.status': 'Status',
    'l.privacy': 'Privacy',
    'l.terms': 'Terms',
    'l.cookies': 'Cookies',
    'l.licenses': 'Licenses',

    'lang.tr': 'Turkish',
    'lang.jp': 'Japanese',
    'lang.fr': 'French',
    'lang.es': 'Spanish',
    'lang.de': 'German',
    'lang.it': 'Italian',
    'lang.kr': 'Korean'
  }
};

const I18nContext = React.createContext({ locale: 'tr', t: (k) => k, setLocale: () => {} });
const useT = () => React.useContext(I18nContext);

function I18nProvider({ children, defaultLocale = 'tr' }) {
  const [locale, setLocale] = React.useState(defaultLocale);
  const t = React.useCallback((key) => {
    const table = STRINGS[locale];
    if (table && Object.prototype.hasOwnProperty.call(table, key)) return table[key];
    if (Object.prototype.hasOwnProperty.call(STRINGS.en, key)) return STRINGS.en[key];
    return key;
  }, [locale]);
  React.useEffect(() => { document.documentElement.lang = locale; }, [locale]);
  return <I18nContext.Provider value={{ locale, t, setLocale }}>{children}</I18nContext.Provider>;
}

// Site language toggle pill (TR / EN)
function LangToggle() {
  const { locale, setLocale } = useT();
  return (
    <div className="inline-flex items-center bg-white/70 backdrop-blur border border-mocha-900/[.06] rounded-full p-1 text-[12px] font-bold">
      {['tr','en'].map(c => (
        <button key={c}
          onClick={() => setLocale(c)}
          className={`px-2.5 py-1 rounded-full uppercase tracking-wide transition ${locale===c ? 'bg-mocha-900 text-white' : 'text-mocha-800/70 hover:text-mocha-900'}`}>
          {c}
        </button>
      ))}
    </div>
  );
}

Object.assign(window, { I18nProvider, useT, LangToggle, STRINGS });
