// i18n.jsx — Tiny FR/EN dictionary + global toggle hook

const I18N = {
  fr: {
    'nav.manifesto': 'Manifeste',
    'nav.travaux': 'Références',
    'nav.stack': 'Technologies',
    'nav.contact': 'Contact',
    'topbar.write': 'Nous écrire',
    'hero.badge.avail': 'Disponible — Q1 2026',
    'hero.badge.slots': 'Deux missions ouvertes',
    'hero.title': ['Architecte', 'de systèmes', 'commerciaux.'],
    'hero.sub': 'Conception, développement et déploiement de plateformes commerciales sur-mesure : CRM, automatisations, scoring et programmes de recommandation.',
    'hero.cta.primary': 'Découvrir les références',
    'hero.cta.secondary': 'Prendre contact',
    'hero.kicker': '[ Assurance · Rénovation énergétique · Édition · +3 secteurs ]',
    'hero.foot.scroll': 'Défiler',
    'hero.foot.section': '— Hero',
    'man.label': 'N° 02 / 05 — Manifeste',
    'man.title.a': 'Quatre principes ',
    'man.title.b': 'non négociables.',
    'man.01.kicker': 'Méthode',
    'man.01.title': 'Le métier définit l’outil, jamais l’inverse.',
    'man.01.body': 'La majorité des solutions du marché imposent leur logique à votre organisation. Notre approche prend le chemin contraire : nous analysons vos processus, modélisons votre donnée, puis concevons un outil parfaitement aligné sur votre métier — sans dette technique de configuration.',
    'man.02.kicker': 'Exécution',
    'man.02.title': 'Un code lisible, documenté, pérenne.',
    'man.02.body': 'TypeScript, Cloudflare Workers, Airtable comme source de vérité. Pas de framework superflu, pas de sur-ingénierie. Un code revu, testé et versionné, qui peut être repris par toute équipe technique sans rupture de service.',
    'man.03.kicker': 'Système',
    'man.03.title': 'Des infrastructures qui fonctionnent en autonomie.',
    'man.03.body': 'Une fois en production, l’infrastructure opère sans intervention manuelle. Webhooks, tâches planifiées, supervision continue : vos équipes utilisent l’outil, vos données restent intègres, vos automatisations s’exécutent en continu.',
    'man.04.kicker': 'Format',
    'man.04.title': 'Un interlocuteur unique, du brief à la production.',
    'man.04.body': 'Pas de chef de projet à relancer, pas de sous-traitance opaque. Vous échangez directement avec la personne qui conçoit, développe et déploie votre solution. Cycle court, décisions rapides, qualité maîtrisée.',
    'pj.label': 'N° 03 / 05 — Références',
    'pj.title.a': 'Six secteurs, ',
    'pj.title.b': 'six systèmes en production.',
    'pj.intro': 'Par engagement de confidentialité, les noms de nos clients ne sont pas mentionnés. Seuls la méthodologie et les résultats sont rendus publics.',
    'pj.cta': 'Étude de cas détaillée',
    'st.label': 'N° 04 / 05 — Technologies',
    'st.title.a': 'Une stack ',
    'st.title.b': 'choisie, pas accumulée.',
    'st.intro': 'Chaque technologie est sélectionnée pour sa pertinence métier et sa pérennité. Un socle stable, éprouvé en production, transmissible à toute équipe technique.',
    'ct.label': 'N° 05 / 05 — Contact',
    'ct.title.a': 'On en',
    'ct.title.b': 'parle ?',
    'ct.sub': 'Mission, audit ou simple échange : nous revenons vers vous sous 24 h ouvrées.',
    'ct.cta.label': 'CONTACT',
    'ct.channels.appointment': 'Rendez-vous',
    'ct.channels.appointment.v': 'Réserver 30 minutes',
    'ct.channels.linkedin': 'LinkedIn',
    'ct.channels.linkedin.v': '/company/agence-mb',
    'ct.channels.phone': 'Téléphone',
    'ct.channels.phone.v': '+33 1 00 00 00 00',
    'ct.foot.copy': '© 2026 — Agence MB',
    'ct.foot.studio': 'Studio indépendant · SIRET 000 000 000 00000',
    'ct.foot.built': 'Site construit en HTML, sans framework superflu.',
  },
  en: {
    'nav.manifesto': 'Manifesto',
    'nav.travaux': 'Work',
    'nav.stack': 'Stack',
    'nav.contact': 'Contact',
    'topbar.write': 'Get in touch',
    'hero.badge.avail': 'Available — Q1 2026',
    'hero.badge.slots': 'Two engagements open',
    'hero.title': ['Architects', 'of revenue', 'systems.'],
    'hero.sub': 'Design, build and ship bespoke commercial platforms: CRM, automations, scoring and referral programs.',
    'hero.cta.primary': 'See references',
    'hero.cta.secondary': 'Get in touch',
    'hero.kicker': '[ Insurance · Energy retrofit · Education · +3 sectors ]',
    'hero.foot.scroll': 'Scroll',
    'hero.foot.section': '— Hero',
    'man.label': 'N° 02 / 05 — Manifesto',
    'man.title.a': 'Four principles, ',
    'man.title.b': 'non-negotiable.',
    'man.01.kicker': 'Method',
    'man.01.title': 'The business defines the tool, never the other way round.',
    'man.01.body': 'Most market solutions force your organization to bend to their logic. Our approach takes the opposite path: we map your processes, model your data, then build a tool perfectly aligned with your operations — with zero configuration debt.',
    'man.02.kicker': 'Execution',
    'man.02.title': 'Code that is readable, documented, durable.',
    'man.02.body': 'TypeScript, Cloudflare Workers, Airtable as a source of truth. No bloated frameworks, no over-engineering. Reviewed, tested and versioned code that any technical team can take over without service interruption.',
    'man.03.kicker': 'System',
    'man.03.title': 'Infrastructure that runs on its own.',
    'man.03.body': 'Once in production, the infrastructure operates without manual intervention. Webhooks, scheduled jobs, continuous monitoring: your teams use the tool, your data stays clean, your automations run around the clock.',
    'man.04.kicker': 'Format',
    'man.04.title': 'A single point of contact, from brief to production.',
    'man.04.body': 'No project manager to chase, no opaque subcontracting. You speak directly with the person who designs, builds and ships your solution. Short cycles, fast decisions, controlled quality.',
    'pj.label': 'N° 03 / 05 — Work',
    'pj.title.a': 'Six sectors, ',
    'pj.title.b': 'six systems in production.',
    'pj.intro': 'Under confidentiality agreement, our clients are not named. Only methodology and outcomes are shared publicly.',
    'pj.cta': 'Detailed case study',
    'st.label': 'N° 04 / 05 — Stack',
    'st.title.a': 'A stack ',
    'st.title.b': 'curated, not accumulated.',
    'st.intro': 'Each technology is chosen for its business relevance and longevity. A stable, production-proven foundation that any technical team can take over.',
    'ct.label': 'N° 05 / 05 — Contact',
    'ct.title.a': 'Let’s',
    'ct.title.b': 'talk.',
    'ct.sub': 'Engagement, audit or simple conversation: we reply within one business day.',
    'ct.cta.label': 'CONTACT',
    'ct.channels.appointment': 'Schedule',
    'ct.channels.appointment.v': 'Book 30 minutes',
    'ct.channels.linkedin': 'LinkedIn',
    'ct.channels.linkedin.v': '/company/agence-mb',
    'ct.channels.phone': 'Phone',
    'ct.channels.phone.v': '+33 1 00 00 00 00',
    'ct.foot.copy': '© 2026 — Agence MB',
    'ct.foot.studio': 'Independent studio · SIRET 000 000 000 00000',
    'ct.foot.built': 'Built in HTML, without superfluous frameworks.',
  },
};

const LangContext = React.createContext({ lang: 'fr', setLang: () => {} });

function LangProvider({ children }) {
  const [lang, setLangState] = React.useState(() => {
    try { return localStorage.getItem('amb_lang') || 'fr'; } catch { return 'fr'; }
  });
  const setLang = (l) => {
    setLangState(l);
    try { localStorage.setItem('amb_lang', l); } catch {}
    document.documentElement.lang = l;
  };
  React.useEffect(() => { document.documentElement.lang = lang; }, [lang]);
  return React.createElement(LangContext.Provider, { value: { lang, setLang } }, children);
}

function useT() {
  const { lang, setLang } = React.useContext(LangContext);
  const t = (key) => (I18N[lang] && I18N[lang][key]) ?? key;
  return { t, lang, setLang };
}

window.LangProvider = LangProvider;
window.LangContext = LangContext;
window.useT = useT;
