// Shared i18n + utility helpers used by all three directions.

const I18N = {
  fr: {
    nav_varieties: "Variétés",
    nav_research: "Recherche",
    nav_about: "Maison",
    nav_network: "Réseau",
    nav_contact: "Contact",
    cta_catalogue: "Catalogue 2026",
    cta_contact: "Nous contacter",

    hero_eyebrow: "Semencier · Bergerac · Depuis 2003",
    hero_title_1: "Tabac Virginie",
    hero_title_2: "Sélectionné en Périgord",
    hero_sub: "16 variétés en culture en France. Sélection traditionnelle, données agronomiques sur 25 ans, profils de résistance documentés.",

    stat_varieties: "variétés au catalogue",
    stat_years: "années de données d'essais",
    stat_yield: "rendement moyen catalogue",
    stat_reference: "indice ITB 683",

    section_finder: "Trouver une variété",
    section_finder_sub: "Filtrez par typologie, précocité, ou résistance ciblée. Toutes les variétés sont comparées à ITB 683, témoin national.",

    section_resistances: "Matrice de résistances",
    section_resistances_sub: "Profil bio-agresseur de chaque variété. R = résistante, S = sensible, Tol = tolérante.",

    section_map: "Distribution commerciale",
    section_map_sub: "Bergerac livre des semences certifiées dans 7 pays producteurs.",

    section_contact: "Contact",
    section_contact_sub: "Pour les producteurs, instituts techniques, et partenaires de recherche.",

    filter_all: "Toutes",
    filter_type: "Typologie",
    filter_precocity: "Précocité",
    filter_resistance: "Résistance recherchée",
    filter_clear: "Réinitialiser",
    filter_results: "résultats",

    table_yield: "Rendement",
    table_quality: "Qualité",
    table_flowering: "Floraison",
    table_lodging: "Verse",
    table_alkaloids: "Alcaloïdes",
    table_sugars: "Sucres réducteurs",
    table_year: "Inscrit",

    detail_back: "← Retour au catalogue",
    detail_principal: "Caractéristiques principales",
    detail_technician: "Le mot du technicien",
    detail_agronomic: "Données agronomiques",
    detail_chemistry: "Caractéristiques chimiques",
    detail_resistances: "Résistances aux bio-agresseurs",
    detail_vs_reference: "Rapport à ITB 683",
    detail_objective: "Teneur objectif",

    chart_yield: "Rendement (kg/ha)",
    chart_quality: "Indice qualité",

    reference_label: "Témoin national",
    new_label: "Nouveau",
    cobred_label: "Co-développée NiCoTa",

    // — workshop additions —
    nav_tobacco: "Tabac",
    nav_hemp: "Chanvre",
    nav_breeding: "Création variétale",
    nav_science: "Science & R&D",
    crop_filter: "Culture",
    crop_all: "Toutes cultures",
    crop_tobacco: "Tabac",
    crop_hemp: "Chanvre",
    cta_quote: "Demander un devis",
    cta_quote_sub: "Réponse sous 48 h",
    section_breeding: "Création variétale sur mesure",
    section_breeding_sub: "Pour cigarettiers et industriels : développement de variétés à profil ciblé (nicotine, sucres, arômes). 30 % de notre activité.",
    section_hemp: "Chanvre — la prochaine vague",
    section_hemp_sub: "Programme de sélection chanvre lancé en 2022. Variétés à fibres longues, à graines, et à cannabinoïdes.",
    section_science: "Autorité scientifique",
    section_science_sub: "25 années de données d'essais, publications, collaborations avec instituts techniques.",
    breeding_step_brief: "Brief technique",
    breeding_step_breeding: "Sélection",
    breeding_step_trials: "Essais multi-sites",
    breeding_step_release: "Inscription",
    science_pubs: "Publications",
    science_trials: "Essais en cours",
    science_partners: "Partenaires R&D",
  },
  en: {
    nav_varieties: "Varieties",
    nav_research: "Research",
    nav_about: "House",
    nav_network: "Network",
    nav_contact: "Contact",
    cta_catalogue: "2026 catalogue",
    cta_contact: "Get in touch",

    hero_eyebrow: "Seed breeder · Bergerac · Since 2003",
    hero_title_1: "Virginia tobacco",
    hero_title_2: "Bred in Périgord",
    hero_sub: "16 cultivars released in France. Traditional breeding, 25 years of trial data, documented resistance profiles.",

    stat_varieties: "catalogue cultivars",
    stat_years: "years of trial data",
    stat_yield: "catalogue mean yield",
    stat_reference: "ITB 683 index",

    section_finder: "Find a variety",
    section_finder_sub: "Filter by type, earliness, or targeted resistance. Every variety is benchmarked against ITB 683, the French reference cultivar.",

    section_resistances: "Resistance matrix",
    section_resistances_sub: "Bio-aggressor profile per variety. R = resistant, S = susceptible, Tol = tolerant.",

    section_map: "Commercial network",
    section_map_sub: "Bergerac ships certified seed across 7 producing countries.",

    section_contact: "Contact",
    section_contact_sub: "For growers, technical institutes, and research partners.",

    filter_all: "All",
    filter_type: "Type",
    filter_precocity: "Earliness",
    filter_resistance: "Resistance",
    filter_clear: "Reset",
    filter_results: "results",

    table_yield: "Yield",
    table_quality: "Quality",
    table_flowering: "Flowering",
    table_lodging: "Lodging",
    table_alkaloids: "Alkaloids",
    table_sugars: "Reducing sugars",
    table_year: "Released",

    detail_back: "← Back to catalogue",
    detail_principal: "Principal characteristics",
    detail_technician: "Technician's note",
    detail_agronomic: "Agronomic data",
    detail_chemistry: "Chemistry",
    detail_resistances: "Disease resistance",
    detail_vs_reference: "vs. ITB 683",
    detail_objective: "Target",

    chart_yield: "Yield (kg/ha)",
    chart_quality: "Quality index",

    reference_label: "French reference",
    new_label: "New",
    cobred_label: "Co-bred with NiCoTa",

    nav_tobacco: "Tobacco",
    nav_hemp: "Hemp",
    nav_breeding: "Custom breeding",
    nav_science: "Science & R&D",
    crop_filter: "Crop",
    crop_all: "All crops",
    crop_tobacco: "Tobacco",
    crop_hemp: "Hemp",
    cta_quote: "Request a quote",
    cta_quote_sub: "Reply within 48 h",
    section_breeding: "Custom breeding",
    section_breeding_sub: "For cigarette makers and industrial buyers: targeted-profile cultivars (nicotine, sugars, aromas). 30% of our business.",
    section_hemp: "Hemp — the next wave",
    section_hemp_sub: "Hemp breeding programme launched in 2022. Fibre, grain, and cannabinoid lines.",
    section_science: "Scientific authority",
    section_science_sub: "25 years of trial data, publications, collaborations with technical institutes.",
    breeding_step_brief: "Technical brief",
    breeding_step_breeding: "Selection",
    breeding_step_trials: "Multi-site trials",
    breeding_step_release: "Release",
    science_pubs: "Publications",
    science_trials: "Trials in progress",
    science_partners: "R&D partners",
  },
};

function useLang() {
  const [lang, setLang] = React.useState('fr');
  const t = React.useCallback((k) => (I18N[lang] && I18N[lang][k]) || I18N.fr[k] || k, [lang]);
  return { lang, setLang, t };
}

// Resistance pill colors (semantic, used by all directions)
function resistanceColor(value, palette) {
  // palette = {R, S, Tol, default}
  return palette[value] || palette.default;
}

// Real photography URLs from Unsplash (tobacco, fields, lab, hands)
const PHOTOS = {
  hero_field: "https://images.unsplash.com/photo-1500382017468-9049fed747ef?w=1600&q=80",
  tobacco_leaf: "https://images.unsplash.com/photo-1602090027836-be79ec73a6c2?w=1200&q=80",
  tobacco_leaves_close: "https://images.unsplash.com/photo-1602090027836-be79ec73a6c2?w=1200&q=80",
  field_rows: "https://images.unsplash.com/photo-1464226184884-fa280b87c399?w=1600&q=80",
  hands_soil: "https://images.unsplash.com/photo-1416879595882-3373a0480b5b?w=1200&q=80",
  greenhouse: "https://images.unsplash.com/photo-1585320806297-9794b3e4eeae?w=1200&q=80",
  seedling: "https://images.unsplash.com/photo-1416879595882-3373a0480b5b?w=1200&q=80",
  lab_microscope: "https://images.unsplash.com/photo-1581093588401-fbb62a02f120?w=1200&q=80",
  research: "https://images.unsplash.com/photo-1532187863486-abf9dbad1b69?w=1200&q=80",
  field_aerial: "https://images.unsplash.com/photo-1625246333195-78d9c38ad449?w=1600&q=80",
  drying_barn: "https://images.unsplash.com/photo-1500382017468-9049fed747ef?w=1200&q=80",
  worker_field: "https://images.unsplash.com/photo-1464226184884-fa280b87c399?w=1200&q=80",
  green_field: "https://images.unsplash.com/photo-1500382017468-9049fed747ef?w=1600&q=80",
  petri: "https://images.unsplash.com/photo-1581093588401-fbb62a02f120?w=1200&q=80",
  bergerac_landscape: "https://images.unsplash.com/photo-1500382017468-9049fed747ef?w=1600&q=80",
  leaf_macro: "https://images.unsplash.com/photo-1602090027836-be79ec73a6c2?w=1200&q=80",
};

// Lightweight SVG of Europe-ish coastline for the commercial map.
// Stylized — meant as a mood diagram, not a precise atlas.
const EUROPE_PATH = "M5,42 L8,30 L18,22 L30,18 L42,16 L55,18 L62,22 L70,28 L72,38 L68,46 L70,55 L66,62 L58,68 L52,72 L44,74 L38,72 L32,68 L26,72 L20,68 L14,62 L10,54 L8,48 Z";

Object.assign(window, { I18N, useLang, resistanceColor, PHOTOS, EUROPE_PATH });
