"use client"

import { useState, useEffect } from "react"
import { motion } from "framer-motion"
import { useLocale, useTranslations } from "next-intl"
import { ChevronLeft, ChevronRight } from "lucide-react"

type Unit = { key: string; x: number; w: number; h: number; cx: number; fr: string; en: string }

const GROUND = 405

// 6 unités du schéma de raffinage de la SAR, illustrations produites d'après recherches.
const UNITS: Unit[] = [
  { key: "prep",    x: 250,  w: 170, h: 150, cx: 335,  fr: "Préparation",            en: "Preparation" },
  // Libellé au long : « Distillation atmosph. » abrégeait sans nécessité, les
  // colonnes voisines laissent la place au mot entier.
  { key: "atm",     x: 455,  w: 130, h: 240, cx: 520,  fr: "Distillation atmosphérique", en: "Atmospheric distillation" },
  { key: "vac",     x: 620,  w: 140, h: 215, cx: 690,  fr: "Distillation sous vide", en: "Vacuum distillation" },
  { key: "reform",  x: 790,  w: 160, h: 175, cx: 870,  fr: "Reformage catalytique",  en: "Catalytic reforming" },
  { key: "merox",   x: 985,  w: 80,  h: 125, cx: 1025, fr: "Mérox",                  en: "Merox" },
  { key: "storage", x: 1095, w: 190, h: 120, cx: 1190, fr: "Stockage et produits finis", en: "Storage and finished products" },
]

const N = UNITS.length

// ── Illustrations SVG (coordonnées locales, base à y=h) ─────────────────────
const SVGS: Record<string, string> = {
  prep: `
  <rect x="8" y="56" width="64" height="92" fill="url(#steel)" stroke="#9aa6b0" stroke-width="2"/>
  <path d="M8 56 Q40 40 72 56 Z" fill="#d3dbe1" stroke="#9aa6b0" stroke-width="2"/>
  <line x1="8" y1="56" x2="72" y2="56" stroke="#9aa6b0" stroke-width="1.5"/>
  <line x1="8" y1="64" x2="72" y2="64" stroke="#6b7785" stroke-width="1"/>
  <line x1="8" y1="86" x2="72" y2="86" stroke="#6b7785" stroke-width="1"/>
  <line x1="8" y1="116" x2="72" y2="116" stroke="#6b7785" stroke-width="1"/>
  <line x1="72" y1="56" x2="72" y2="148" stroke="#7c8a96" stroke-width="1.5"/>
  <line x1="76" y1="56" x2="76" y2="148" stroke="#7c8a96" stroke-width="1.5"/>
  <line x1="72" y1="68" x2="76" y2="68" stroke="#7c8a96" stroke-width="1"/>
  <line x1="72" y1="80" x2="76" y2="80" stroke="#7c8a96" stroke-width="1"/>
  <line x1="72" y1="92" x2="76" y2="92" stroke="#7c8a96" stroke-width="1"/>
  <line x1="72" y1="104" x2="76" y2="104" stroke="#7c8a96" stroke-width="1"/>
  <line x1="72" y1="116" x2="76" y2="116" stroke="#7c8a96" stroke-width="1"/>
  <line x1="72" y1="128" x2="76" y2="128" stroke="#7c8a96" stroke-width="1"/>
  <line x1="72" y1="140" x2="76" y2="140" stroke="#7c8a96" stroke-width="1"/>
  <rect x="2" y="138" width="6" height="6" fill="#7c8a96" stroke="#6b7785" stroke-width="1"/>
  <rect x="100" y="80" width="46" height="68" fill="url(#steel)" stroke="#9aa6b0" stroke-width="2"/>
  <path d="M100 80 Q123 68 146 80 Z" fill="#d3dbe1" stroke="#9aa6b0" stroke-width="2"/>
  <line x1="100" y1="80" x2="146" y2="80" stroke="#9aa6b0" stroke-width="1.5"/>
  <line x1="100" y1="87" x2="146" y2="87" stroke="#6b7785" stroke-width="1"/>
  <line x1="100" y1="108" x2="146" y2="108" stroke="#6b7785" stroke-width="1"/>
  <line x1="100" y1="130" x2="146" y2="130" stroke="#6b7785" stroke-width="1"/>
  <line x1="146" y1="80" x2="146" y2="148" stroke="#7c8a96" stroke-width="1.5"/>
  <line x1="150" y1="80" x2="150" y2="148" stroke="#7c8a96" stroke-width="1.5"/>
  <line x1="146" y1="92" x2="150" y2="92" stroke="#7c8a96" stroke-width="1"/>
  <line x1="146" y1="104" x2="150" y2="104" stroke="#7c8a96" stroke-width="1"/>
  <line x1="146" y1="116" x2="150" y2="116" stroke="#7c8a96" stroke-width="1"/>
  <line x1="146" y1="128" x2="150" y2="128" stroke="#7c8a96" stroke-width="1"/>
  <line x1="146" y1="140" x2="150" y2="140" stroke="#7c8a96" stroke-width="1"/>
  <rect x="138" y="138" width="6" height="6" fill="#7c8a96" stroke="#6b7785" stroke-width="1"/>
  <rect x="86" y="30" width="8" height="18" fill="#7c8a96" stroke="#6b7785" stroke-width="1"/>
  <rect x="118" y="30" width="8" height="18" fill="#7c8a96" stroke="#6b7785" stroke-width="1"/>
  <rect x="80" y="10" width="80" height="22" rx="11" fill="url(#steel)" stroke="#9aa6b0" stroke-width="2"/>
  <path d="M91 10 A11 11 0 0 0 91 32" fill="none" stroke="#6b7785" stroke-width="1"/>
  <path d="M149 10 A11 11 0 0 1 149 32" fill="none" stroke="#6b7785" stroke-width="1"/>
  <rect x="98" y="4" width="5" height="6" fill="#7c8a96" stroke="#6b7785" stroke-width="1"/>
  <rect x="120" y="4" width="5" height="6" fill="#7c8a96" stroke="#6b7785" stroke-width="1"/>
  <rect x="138" y="4" width="5" height="6" fill="#7c8a96" stroke="#6b7785" stroke-width="1"/>
  <rect x="117" y="32" width="6" height="5" fill="#7c8a96" stroke="#6b7785" stroke-width="1"/>
  <path d="M120 37 L120 44 L123 44 L123 68" fill="none" stroke="#7c8a96" stroke-width="2"/>
  <path d="M86 44 L86 48 L40 48 L40 56" fill="none" stroke="#7c8a96" stroke-width="2"/>`,

  atm: `
  <path d="M38 240 L41 196 L77 196 L80 240 Z" fill="#d3dbe1" stroke="#9aa6b0" stroke-width="1.5"/>
  <line x1="48" y1="240" x2="50" y2="200" stroke="#9aa6b0" stroke-width="1"/>
  <line x1="59" y1="240" x2="59" y2="200" stroke="#9aa6b0" stroke-width="1"/>
  <line x1="70" y1="240" x2="68" y2="200" stroke="#9aa6b0" stroke-width="1"/>
  <rect x="41" y="44" width="36" height="152" fill="url(#tower)" stroke="#9aa6b0" stroke-width="2"/>
  <path d="M41 44 Q41 22 59 22 Q77 22 77 44 Z" fill="url(#tower)" stroke="#9aa6b0" stroke-width="2"/>
  <line x1="59" y1="22" x2="59" y2="12" stroke="#7c8a96" stroke-width="2.5"/>
  <line x1="59" y1="12" x2="74" y2="12" stroke="#7c8a96" stroke-width="2.5"/>
  <line x1="35" y1="70" x2="83" y2="70" stroke="#7c8a96" stroke-width="2"/>
  <line x1="35" y1="110" x2="83" y2="110" stroke="#7c8a96" stroke-width="2"/>
  <line x1="35" y1="150" x2="83" y2="150" stroke="#7c8a96" stroke-width="2"/>
  <line x1="35" y1="188" x2="83" y2="188" stroke="#7c8a96" stroke-width="2"/>
  <line x1="33" y1="46" x2="33" y2="188" stroke="#7c8a96" stroke-width="1.5"/>
  <line x1="38" y1="46" x2="38" y2="188" stroke="#7c8a96" stroke-width="1.5"/>
  <line x1="33" y1="56" x2="38" y2="56" stroke="#6b7785" stroke-width="1"/>
  <line x1="33" y1="68" x2="38" y2="68" stroke="#6b7785" stroke-width="1"/>
  <line x1="33" y1="80" x2="38" y2="80" stroke="#6b7785" stroke-width="1"/>
  <line x1="33" y1="92" x2="38" y2="92" stroke="#6b7785" stroke-width="1"/>
  <line x1="33" y1="104" x2="38" y2="104" stroke="#6b7785" stroke-width="1"/>
  <line x1="33" y1="116" x2="38" y2="116" stroke="#6b7785" stroke-width="1"/>
  <line x1="33" y1="128" x2="38" y2="128" stroke="#6b7785" stroke-width="1"/>
  <line x1="33" y1="140" x2="38" y2="140" stroke="#6b7785" stroke-width="1"/>
  <line x1="33" y1="152" x2="38" y2="152" stroke="#6b7785" stroke-width="1"/>
  <line x1="33" y1="164" x2="38" y2="164" stroke="#6b7785" stroke-width="1"/>
  <line x1="33" y1="176" x2="38" y2="176" stroke="#6b7785" stroke-width="1"/>
  <line x1="77" y1="58" x2="90" y2="58" stroke="#7c8a96" stroke-width="2.5"/>
  <line x1="90" y1="58" x2="90" y2="64" stroke="#7c8a96" stroke-width="2.5"/>
  <line x1="77" y1="92" x2="92" y2="92" stroke="#7c8a96" stroke-width="2.5"/>
  <line x1="92" y1="92" x2="92" y2="100" stroke="#7c8a96" stroke-width="2.5"/>
  <line x1="77" y1="128" x2="90" y2="128" stroke="#7c8a96" stroke-width="2.5"/>
  <line x1="90" y1="128" x2="90" y2="136" stroke="#7c8a96" stroke-width="2.5"/>
  <line x1="77" y1="170" x2="88" y2="170" stroke="#7c8a96" stroke-width="2.5"/>
  <rect x="92" y="186" width="34" height="54" fill="url(#steel)" stroke="#9aa6b0" stroke-width="1.5"/>
  <line x1="92" y1="200" x2="126" y2="200" stroke="#9aa6b0" stroke-width="1"/>
  <rect x="113" y="150" width="9" height="36" fill="#7c8a96" stroke="#6b7785" stroke-width="1.5"/>
  <rect x="111" y="146" width="13" height="6" fill="#7c8a96" stroke="#6b7785" stroke-width="1"/>
  <rect x="100" y="222" width="18" height="14" fill="#6b7785" stroke="#6b7785" stroke-width="1"/>
  <path d="M105 234 Q103 226 109 222 Q107 228 111 226 Q114 230 111 234 Z" fill="#ff8a3c"/>
  <line x1="80" y1="212" x2="92" y2="212" stroke="#7c8a96" stroke-width="2.5"/>`,

  vac: `
  <path d="M40 178 L44 215 L96 215 L100 178 Z" fill="#d3dbe1" stroke="#9aa6b0" stroke-width="1.5"/>
  <rect x="52" y="188" width="12" height="27" fill="#9aa6b0" opacity="0.5"/>
  <rect x="76" y="188" width="12" height="27" fill="#9aa6b0" opacity="0.5"/>
  <line x1="40" y1="178" x2="100" y2="178" stroke="#9aa6b0" stroke-width="1.5"/>
  <rect x="38" y="58" width="64" height="122" rx="2" fill="url(#tower)" stroke="#9aa6b0" stroke-width="2"/>
  <path d="M38 58 Q70 30 102 58 Z" fill="url(#tower)" stroke="#9aa6b0" stroke-width="2"/>
  <rect x="32" y="80" width="76" height="4" fill="#7c8a96" stroke="#6b7785" stroke-width="0.8"/>
  <rect x="32" y="120" width="76" height="4" fill="#7c8a96" stroke="#6b7785" stroke-width="0.8"/>
  <rect x="32" y="158" width="76" height="4" fill="#7c8a96" stroke="#6b7785" stroke-width="0.8"/>
  <line x1="104" y1="84" x2="104" y2="158" stroke="#6b7785" stroke-width="1"/>
  <line x1="108" y1="84" x2="108" y2="158" stroke="#6b7785" stroke-width="1"/>
  <line x1="104" y1="92" x2="108" y2="92" stroke="#6b7785" stroke-width="0.8"/>
  <line x1="104" y1="108" x2="108" y2="108" stroke="#6b7785" stroke-width="0.8"/>
  <line x1="104" y1="128" x2="108" y2="128" stroke="#6b7785" stroke-width="0.8"/>
  <line x1="104" y1="144" x2="108" y2="144" stroke="#6b7785" stroke-width="0.8"/>
  <rect x="28" y="98" width="10" height="5" fill="#7c8a96" stroke="#6b7785" stroke-width="0.8"/>
  <rect x="28" y="138" width="10" height="5" fill="#7c8a96" stroke="#6b7785" stroke-width="0.8"/>
  <rect x="100" y="166" width="12" height="5" fill="#7c8a96" stroke="#6b7785" stroke-width="0.8"/>
  <path d="M70 32 L70 18 L18 18 L18 56" fill="none" stroke="#7c8a96" stroke-width="3"/>
  <rect x="10" y="56" width="16" height="22" rx="2" fill="#d3dbe1" stroke="#7c8a96" stroke-width="1.5"/>
  <rect x="10" y="84" width="16" height="22" rx="2" fill="#d3dbe1" stroke="#7c8a96" stroke-width="1.5"/>
  <rect x="4" y="112" width="28" height="14" rx="3" fill="#eef2f5" stroke="#7c8a96" stroke-width="1.5"/>
  <line x1="18" y1="78" x2="18" y2="84" stroke="#7c8a96" stroke-width="2"/>
  <line x1="18" y1="106" x2="18" y2="112" stroke="#7c8a96" stroke-width="2"/>
  <path d="M32 119 L40 119" fill="none" stroke="#7c8a96" stroke-width="2"/>
  <rect x="14" y="190" width="22" height="22" rx="2" fill="#d3dbe1" stroke="#9aa6b0" stroke-width="1.5"/>
  <path d="M25 207 Q21 200 25 196 Q27 200 29 196 Q31 201 27 207 Z" fill="#ff8a3c"/>
  <path d="M36 200 L40 200 L40 170 L38 170" fill="none" stroke="#7c8a96" stroke-width="2"/>
  <rect x="22" y="178" width="6" height="12" fill="#7c8a96" stroke="#6b7785" stroke-width="0.8"/>`,

  reform: `
  <rect x="8" y="118" width="40" height="52" rx="2" fill="#d3dbe1" stroke="#9aa6b0" stroke-width="2"/>
  <line x1="8" y1="132" x2="48" y2="132" stroke="#9aa6b0" stroke-width="1"/>
  <line x1="8" y1="156" x2="48" y2="156" stroke="#9aa6b0" stroke-width="1"/>
  <line x1="14" y1="170" x2="14" y2="175" stroke="#7c8a96" stroke-width="2"/>
  <line x1="42" y1="170" x2="42" y2="175" stroke="#7c8a96" stroke-width="2"/>
  <rect x="32" y="78" width="10" height="42" fill="#7c8a96" stroke="#6b7785" stroke-width="1.5"/>
  <rect x="30" y="74" width="14" height="6" rx="1" fill="#7c8a96" stroke="#6b7785" stroke-width="1.5"/>
  <rect x="16" y="140" width="14" height="22" rx="1" fill="#eef2f5" stroke="#9aa6b0" stroke-width="1.5"/>
  <path d="M23 160 C20 154 26 152 24 146 C29 150 28 155 26 160 Z" fill="#ff8a3c"/>
  <path d="M48 128 H60" fill="none" stroke="#7c8a96" stroke-width="3"/>
  <path d="M60 128 V70 H70" fill="none" stroke="#7c8a96" stroke-width="3"/>
  <line x1="66" y1="148" x2="66" y2="170" stroke="#7c8a96" stroke-width="2.5"/>
  <line x1="80" y1="148" x2="80" y2="170" stroke="#7c8a96" stroke-width="2.5"/>
  <line x1="66" y1="160" x2="80" y2="160" stroke="#6b7785" stroke-width="1.5"/>
  <line x1="66" y1="170" x2="80" y2="170" stroke="#7c8a96" stroke-width="2"/>
  <rect x="65" y="86" width="16" height="62" fill="url(#steel)" stroke="#9aa6b0" stroke-width="1.5"/>
  <path d="M65 86 Q73 76 81 86 Z" fill="url(#steel)" stroke="#9aa6b0" stroke-width="1.5"/>
  <path d="M65 148 Q73 158 81 148 Z" fill="url(#steel)" stroke="#9aa6b0" stroke-width="1.5"/>
  <line x1="65" y1="104" x2="81" y2="104" stroke="#9aa6b0" stroke-width="1"/>
  <line x1="65" y1="126" x2="81" y2="126" stroke="#9aa6b0" stroke-width="1"/>
  <rect x="70" y="72" width="6" height="6" fill="#d3dbe1" stroke="#9aa6b0" stroke-width="1.5"/>
  <path d="M81 96 H92 V92" fill="none" stroke="#7c8a96" stroke-width="3"/>
  <line x1="88" y1="150" x2="88" y2="170" stroke="#7c8a96" stroke-width="2.5"/>
  <line x1="106" y1="150" x2="106" y2="170" stroke="#7c8a96" stroke-width="2.5"/>
  <line x1="88" y1="160" x2="106" y2="160" stroke="#6b7785" stroke-width="1.5"/>
  <line x1="88" y1="170" x2="106" y2="170" stroke="#7c8a96" stroke-width="2"/>
  <rect x="87" y="76" width="20" height="74" fill="url(#steel)" stroke="#9aa6b0" stroke-width="1.5"/>
  <path d="M87 76 Q97 64 107 76 Z" fill="url(#steel)" stroke="#9aa6b0" stroke-width="1.5"/>
  <path d="M87 150 Q97 162 107 150 Z" fill="url(#steel)" stroke="#9aa6b0" stroke-width="1.5"/>
  <line x1="87" y1="96" x2="107" y2="96" stroke="#9aa6b0" stroke-width="1"/>
  <line x1="87" y1="118" x2="107" y2="118" stroke="#9aa6b0" stroke-width="1"/>
  <line x1="87" y1="140" x2="107" y2="140" stroke="#9aa6b0" stroke-width="1"/>
  <rect x="94" y="60" width="6" height="6" fill="#d3dbe1" stroke="#9aa6b0" stroke-width="1.5"/>
  <path d="M107 88 H120 V80" fill="none" stroke="#7c8a96" stroke-width="3"/>
  <line x1="113" y1="152" x2="113" y2="170" stroke="#7c8a96" stroke-width="2.5"/>
  <line x1="135" y1="152" x2="135" y2="170" stroke="#7c8a96" stroke-width="2.5"/>
  <line x1="113" y1="162" x2="135" y2="162" stroke="#6b7785" stroke-width="1.5"/>
  <line x1="113" y1="170" x2="135" y2="170" stroke="#7c8a96" stroke-width="2"/>
  <rect x="112" y="64" width="24" height="88" fill="url(#steel)" stroke="#9aa6b0" stroke-width="1.5"/>
  <path d="M112 64 Q124 50 136 64 Z" fill="url(#steel)" stroke="#9aa6b0" stroke-width="1.5"/>
  <path d="M112 152 Q124 165 136 152 Z" fill="url(#steel)" stroke="#9aa6b0" stroke-width="1.5"/>
  <line x1="112" y1="84" x2="136" y2="84" stroke="#9aa6b0" stroke-width="1"/>
  <line x1="112" y1="106" x2="136" y2="106" stroke="#9aa6b0" stroke-width="1"/>
  <line x1="112" y1="128" x2="136" y2="128" stroke="#9aa6b0" stroke-width="1"/>
  <rect x="121" y="48" width="6" height="6" fill="#d3dbe1" stroke="#9aa6b0" stroke-width="1.5"/>
  <path d="M136 144 H148 V170" fill="none" stroke="#7c8a96" stroke-width="3"/>
  <line x1="138" y1="64" x2="138" y2="152" stroke="#6b7785" stroke-width="1.5"/>
  <line x1="143" y1="64" x2="143" y2="152" stroke="#6b7785" stroke-width="1.5"/>
  <line x1="138" y1="76" x2="143" y2="76" stroke="#6b7785" stroke-width="1"/>
  <line x1="138" y1="88" x2="143" y2="88" stroke="#6b7785" stroke-width="1"/>
  <line x1="138" y1="100" x2="143" y2="100" stroke="#6b7785" stroke-width="1"/>
  <line x1="138" y1="112" x2="143" y2="112" stroke="#6b7785" stroke-width="1"/>
  <line x1="138" y1="124" x2="143" y2="124" stroke="#6b7785" stroke-width="1"/>
  <line x1="138" y1="136" x2="143" y2="136" stroke="#6b7785" stroke-width="1"/>`,

  merox: `
  <rect x="14" y="121" width="52" height="4" fill="#7c8a96"/>
  <rect x="26" y="118" width="6" height="3" fill="#7c8a96"/>
  <rect x="48" y="118" width="6" height="3" fill="#7c8a96"/>
  <rect x="20" y="106" width="40" height="13" rx="2" fill="url(#steel)" stroke="#9aa6b0" stroke-width="1.5"/>
  <path d="M20 106 a20 6 0 0 1 40 0 z" fill="url(#steel)" stroke="#9aa6b0" stroke-width="1.5"/>
  <ellipse cx="40" cy="119" rx="20" ry="3.5" fill="#d3dbe1" stroke="#9aa6b0" stroke-width="1.5"/>
  <line x1="26" y1="112" x2="54" y2="112" stroke="#6b7785" stroke-width="0.8"/>
  <rect x="14" y="110" width="6" height="3" fill="#7c8a96"/>
  <rect x="60" y="110" width="6" height="3" fill="#7c8a96"/>
  <path d="M34 100 L34 102 L46 102 L46 100 Z" fill="#7c8a96"/>
  <path d="M30 18 a10 8 0 0 1 20 0 z" fill="url(#steel)" stroke="#9aa6b0" stroke-width="2"/>
  <rect x="30" y="18" width="20" height="82" fill="url(#steel)" stroke="#9aa6b0" stroke-width="2"/>
  <path d="M30 100 a10 8 0 0 0 20 0 z" fill="url(#steel)" stroke="#9aa6b0" stroke-width="2"/>
  <line x1="34" y1="30" x2="46" y2="30" stroke="#6b7785" stroke-width="0.8"/>
  <line x1="34" y1="44" x2="46" y2="44" stroke="#6b7785" stroke-width="0.8"/>
  <line x1="34" y1="58" x2="46" y2="58" stroke="#6b7785" stroke-width="0.8"/>
  <line x1="34" y1="72" x2="46" y2="72" stroke="#6b7785" stroke-width="0.8"/>
  <line x1="34" y1="86" x2="46" y2="86" stroke="#6b7785" stroke-width="0.8"/>
  <rect x="50" y="34" width="9" height="4" fill="#7c8a96"/>
  <line x1="59" y1="36" x2="63" y2="36" stroke="#7c8a96" stroke-width="2"/>
  <rect x="21" y="78" width="9" height="4" fill="#7c8a96"/>
  <line x1="17" y1="80" x2="21" y2="80" stroke="#7c8a96" stroke-width="2"/>
  <rect x="38" y="8" width="4" height="6" fill="#7c8a96"/>
  <rect x="35" y="6" width="10" height="3" fill="#d3dbe1" stroke="#9aa6b0" stroke-width="1"/>
  <g stroke="#7c8a96" stroke-width="1.5" fill="none">
    <line x1="54" y1="16" x2="54" y2="100"/>
    <line x1="60" y1="16" x2="60" y2="100"/>
    <line x1="54" y1="22" x2="60" y2="22"/>
    <line x1="54" y1="38" x2="60" y2="38"/>
    <line x1="54" y1="54" x2="60" y2="54"/>
    <line x1="54" y1="70" x2="60" y2="70"/>
    <line x1="54" y1="86" x2="60" y2="86"/>
  </g>`,

  storage: `
  <rect x="6" y="60" width="70" height="60" fill="url(#steel)" stroke="#9aa6b0" stroke-width="2"/>
  <rect x="6" y="55" width="70" height="7" rx="2" fill="#eef2f5" stroke="#9aa6b0" stroke-width="1.5"/>
  <rect x="9" y="58" width="64" height="3" fill="#d3dbe1" stroke="#6b7785" stroke-width="0.6"/>
  <line x1="6" y1="75" x2="76" y2="75" stroke="#9aa6b0" stroke-width="1"/>
  <line x1="6" y1="90" x2="76" y2="90" stroke="#9aa6b0" stroke-width="1"/>
  <line x1="6" y1="105" x2="76" y2="105" stroke="#9aa6b0" stroke-width="1"/>
  <line x1="6" y1="62" x2="76" y2="62" stroke="#6b7785" stroke-width="0.8"/>
  <line x1="76" y1="118" x2="76" y2="58" stroke="#7c8a96" stroke-width="1.5"/>
  <line x1="72" y1="118" x2="72" y2="58" stroke="#7c8a96" stroke-width="1.2"/>
  <rect x="86" y="68" width="44" height="52" fill="url(#steel)" stroke="#9aa6b0" stroke-width="2"/>
  <path d="M84,68 L108,52 L132,68 Z" fill="#d3dbe1" stroke="#9aa6b0" stroke-width="1.5"/>
  <rect x="105" y="46" width="6" height="6" rx="1" fill="#eef2f5" stroke="#9aa6b0" stroke-width="1"/>
  <line x1="108" y1="46" x2="108" y2="42" stroke="#6b7785" stroke-width="1"/>
  <line x1="86" y1="84" x2="130" y2="84" stroke="#9aa6b0" stroke-width="1"/>
  <line x1="86" y1="100" x2="130" y2="100" stroke="#9aa6b0" stroke-width="1"/>
  <line x1="128" y1="118" x2="128" y2="56" stroke="#7c8a96" stroke-width="1.4"/>
  <line x1="124" y1="118" x2="124" y2="56" stroke="#7c8a96" stroke-width="1.4"/>
  <line x1="150" y1="120" x2="156" y2="96" stroke="#7c8a96" stroke-width="2.2"/>
  <line x1="160" y1="120" x2="162" y2="96" stroke="#7c8a96" stroke-width="2.2"/>
  <line x1="172" y1="120" x2="170" y2="96" stroke="#7c8a96" stroke-width="2.2"/>
  <line x1="182" y1="120" x2="176" y2="96" stroke="#7c8a96" stroke-width="2.2"/>
  <line x1="153" y1="108" x2="179" y2="108" stroke="#6b7785" stroke-width="0.7"/>
  <circle cx="166" cy="76" r="22" fill="url(#steel)" stroke="#9aa6b0" stroke-width="2"/>
  <line x1="144" y1="76" x2="188" y2="76" stroke="#9aa6b0" stroke-width="1"/>
  <path d="M166,54 A 13 22 0 0 0 166,98" fill="none" stroke="#6b7785" stroke-width="0.7"/>
  <path d="M166,54 A 13 22 0 0 1 166,98" fill="none" stroke="#6b7785" stroke-width="0.7"/>
  <rect x="163" y="50" width="6" height="5" rx="1" fill="#eef2f5" stroke="#9aa6b0" stroke-width="1"/>`,
}

// ── Illustrations annexes (navire + utilisateurs finaux), produites d'après recherches ──
const EXTRA_SVGS: Record<string, string> = {
  ship: `
  <path d="M2 56 L150 56 L170 57 L184 60 Q190 62 192 67 L192 78 L188 86 Q186 90 178 90 L14 90 Q6 90 4 84 L2 70 Z" fill="#9b2d22" stroke="#6b1f17" stroke-width="2" stroke-linejoin="round"/>
  <path d="M2 70 L192 70 L192 78 L188 86 Q186 90 178 90 L14 90 Q6 90 4 84 L2 70 Z" fill="#b23a2f" stroke="none"/>
  <line x1="2" y1="70" x2="192" y2="70" stroke="#6b1f17" stroke-width="1.2"/>
  <rect x="2" y="52" width="146" height="5" fill="#8a3a30" stroke="#6b1f17" stroke-width="1.2"/>
  <line x1="2" y1="52" x2="148" y2="52" stroke="#aab4bc" stroke-width="1"/>
  <g stroke="#3f4a55" stroke-width="1.5" fill="#3f4a55">
    <line x1="74" y1="52" x2="74" y2="46"/>
    <rect x="69" y="44" width="10" height="3"/>
    <line x1="74" y1="44" x2="74" y2="40"/>
    <rect x="71" y="36" width="6" height="4" fill="#6b7785"/>
  </g>
  <g stroke="#3f4a55" stroke-width="1.8" fill="#6b7785">
    <line x1="40" y1="52" x2="40" y2="34"/>
    <rect x="36" y="42" width="8" height="8" fill="#3f4a55"/>
    <line x1="40" y1="36" x2="64" y2="48" stroke="#3f4a55" stroke-width="2"/>
    <line x1="40" y1="36" x2="40" y2="32"/>
    <circle cx="40" cy="31" r="2" fill="#3f4a55" stroke="none"/>
    <line x1="108" y1="52" x2="108" y2="34"/>
    <rect x="104" y="42" width="8" height="8" fill="#3f4a55"/>
    <line x1="108" y1="36" x2="132" y2="48" stroke="#3f4a55" stroke-width="2"/>
    <line x1="108" y1="36" x2="108" y2="32"/>
    <circle cx="108" cy="31" r="2" fill="#3f4a55" stroke="none"/>
  </g>
  <g fill="#3f4a55" stroke="none">
    <rect x="20" y="49" width="3" height="4"/>
    <rect x="56" y="49" width="3" height="4"/>
    <rect x="90" y="49" width="3" height="4"/>
    <rect x="124" y="49" width="3" height="4"/>
    <rect x="140" y="49" width="3" height="4"/>
  </g>
  <g stroke="#aab4bc" stroke-width="1.5">
    <rect x="8" y="34" width="34" height="18" fill="#eef2f5"/>
    <rect x="12" y="22" width="26" height="12" fill="#eef2f5"/>
    <rect x="16" y="14" width="18" height="8" fill="#eef2f5"/>
  </g>
  <g fill="#cfe6f5" stroke="#aab4bc" stroke-width="0.8">
    <rect x="11" y="37" width="4" height="4"/>
    <rect x="18" y="37" width="4" height="4"/>
    <rect x="25" y="37" width="4" height="4"/>
    <rect x="32" y="37" width="4" height="4"/>
    <rect x="11" y="44" width="4" height="4"/>
    <rect x="18" y="44" width="4" height="4"/>
    <rect x="25" y="44" width="4" height="4"/>
    <rect x="32" y="44" width="4" height="4"/>
    <rect x="15" y="25" width="4" height="4"/>
    <rect x="22" y="25" width="4" height="4"/>
    <rect x="29" y="25" width="4" height="4"/>
    <rect x="19" y="16" width="3" height="3"/>
    <rect x="25" y="16" width="3" height="3"/>
  </g>
  <rect x="22" y="6" width="8" height="8" fill="#9b2d22" stroke="#6b1f17" stroke-width="1.5"/>
  <line x1="22" y1="10" x2="30" y2="10" stroke="#eef2f5" stroke-width="1.2"/>
  <g stroke="#6b7785" stroke-width="1" fill="none">
    <line x1="42" y1="34" x2="50" y2="34"/>
    <line x1="50" y1="34" x2="50" y2="52"/>
  </g>
  <g fill="#3f4a55" stroke="none">
    <rect x="160" y="50" width="3" height="3"/>
    <rect x="170" y="51" width="3" height="3"/>
    <rect x="178" y="53" width="3" height="3"/>
  </g>
  <path d="M150 56 L168 56 Q178 56 184 60 L150 60 Z" fill="#8a3a30" stroke="#6b1f17" stroke-width="1.2"/>`,

  plane: `
  <path d="M14 32 C14 26 22 24 40 23 L118 22 C132 22 142 25 148 28 C149 28.5 149 30.5 148 31 C140 35 128 37 118 37 L40 36 C24 35.5 14 35 14 32 Z" fill="#f3f6f8" stroke="#c7d0d8" stroke-width="1.2"/>
  <path d="M138 24.5 C144 25.5 148 27.5 149.5 29 C148 30.8 144 33 138 34 Z" fill="#f3f6f8" stroke="#c7d0d8" stroke-width="1.2"/>
  <path d="M132 25.5 C137 26 141 27.5 143.5 29 C141 30.5 137.5 31.5 132.5 32 L131 28 Z" fill="#2b3440" stroke="#9aa6b0" stroke-width="0.6"/>
  <path d="M16 33.4 L118 33 C128 33 137 32 145 30.2" fill="none" stroke="#c0463a" stroke-width="1.6" stroke-linecap="round"/>
  <circle cx="40" cy="29" r="1.05" fill="#6b7785"/>
  <circle cx="47" cy="28.9" r="1.05" fill="#6b7785"/>
  <circle cx="54" cy="28.8" r="1.05" fill="#6b7785"/>
  <circle cx="61" cy="28.7" r="1.05" fill="#6b7785"/>
  <circle cx="68" cy="28.6" r="1.05" fill="#6b7785"/>
  <circle cx="75" cy="28.5" r="1.05" fill="#6b7785"/>
  <circle cx="82" cy="28.4" r="1.05" fill="#6b7785"/>
  <circle cx="89" cy="28.3" r="1.05" fill="#6b7785"/>
  <circle cx="96" cy="28.2" r="1.05" fill="#6b7785"/>
  <circle cx="103" cy="28.1" r="1.05" fill="#6b7785"/>
  <circle cx="110" cy="28" r="1.05" fill="#6b7785"/>
  <circle cx="117" cy="27.9" r="1.05" fill="#6b7785"/>
  <circle cx="124" cy="27.9" r="1.05" fill="#6b7785"/>
  <rect x="127" y="25.5" width="2.4" height="6" rx="0.8" fill="none" stroke="#c7d0d8" stroke-width="0.6"/>
  <path d="M16 32 L10 8 C9.6 6.8 10.4 6 11.6 6.4 L22 13 C26 16 28 23 28 30 Z" fill="#c0463a" stroke="#9aa6b0" stroke-width="0.8"/>
  <path d="M20 33.5 L2 38 C1 38.3 1 39.2 2 39.2 L24 37 Z" fill="#f3f6f8" stroke="#c7d0d8" stroke-width="1"/>
  <path d="M70 35.5 L36 49 C35 49.4 35 50.4 36.2 50.2 L82 39 Z" fill="#e3e9ee" stroke="#c7d0d8" stroke-width="1"/>
  <path d="M78 40 C90 39 96 40 98 41.5 C96 43.5 90 44.5 78 43.5 C75.5 43 75.5 40.4 78 40 Z" fill="#d3dbe1" stroke="#9aa6b0" stroke-width="1"/>
  <path d="M97 40.4 C99.5 40.8 99.8 43 97 43.2" fill="#2b3440" stroke="#9aa6b0" stroke-width="0.6"/>
  <path d="M82 39 L88 41 L84 41 L80 40 Z" fill="#d3dbe1" stroke="#9aa6b0" stroke-width="0.6"/>`,

  /* Voiture de profil, tournee vers la droite comme le camion : elle s'eloigne
     de la raffinerie. Le sens ne se devine pas, il se lit : long capot et
     pare-brise incline a l'avant, coffre court a l'arriere, phare jaune devant,
     feu rouge et pot d'echappement derriere, retroviseur au pied du pare-brise.
     Repere : le sol est a y=48, les roues sont posees dessus. */
  car: `
  <!-- Carrosserie : coffre court a gauche, long capot a droite -->
  <path d="M3.5,41.8 L3.5,34.2 C3.5,32.9 4.4,32.2 5.8,32 L20,30.8 L31,21.6 C31.6,20.9 32.4,20.6 33.4,20.6 L55,20.6 C56.2,20.6 57.2,20.9 58,21.6 L71,31.4 L94,32.6 C97.5,32.9 100.6,34.4 100.8,36.4 L101,40.2 C101,41.3 100.4,41.8 99.2,41.8 Z" fill="#2f7fc1" stroke="#1f3a52" stroke-width="0.7" stroke-linejoin="round"/>
  <!-- Vitrage : lunette arriere courte, pare-brise long et incline -->
  <path d="M23,30.2 L32.6,22.2 L54.8,22.2 L68.4,30.2 Z" fill="#cfe6f5" stroke="#1f3a52" stroke-width="0.6" stroke-linejoin="round"/>
  <line x1="44" y1="22.2" x2="44" y2="30.2" stroke="#1f3a52" stroke-width="0.5"/>
  <!-- Portieres -->
  <line x1="44" y1="30.6" x2="44" y2="41.4" stroke="#1f3a52" stroke-width="0.45"/>
  <line x1="69" y1="31.3" x2="69" y2="41.4" stroke="#1f3a52" stroke-width="0.45"/>
  <rect x="36" y="33.6" width="5.5" height="1.3" rx="0.6" fill="#1f3a52"/>
  <rect x="52" y="33.6" width="5.5" height="1.3" rx="0.6" fill="#1f3a52"/>
  <!-- Retroviseur, au pied du pare-brise : il pointe vers l'avant -->
  <path d="M69,30.2 L73.5,29.2 C74.3,29 74.6,30.4 73.8,30.7 L69.2,31.5 Z" fill="#1f3a52"/>
  <!-- Avant : phare jaune et calandre -->
  <path d="M100.6,34.8 L95,34.4 C93.6,34.3 93.6,37.3 95,37.2 L100.9,36.9 Z" fill="#ffe9a8" stroke="#1f3a52" stroke-width="0.4"/>
  <rect x="95.8" y="38.6" width="4.8" height="1.6" rx="0.6" fill="#6b7785"/>
  <!-- Arriere : feu rouge et pot d'echappement -->
  <rect x="3.6" y="34.6" width="3.2" height="2.6" rx="0.6" fill="#c0463a" stroke="#1f3a52" stroke-width="0.4"/>
  <rect x="2.2" y="40.2" width="2.2" height="1.2" rx="0.6" fill="#6b7785"/>
  <!-- Passages de roue -->
  <path d="M17.6,42 A6.4,6.4 0 0 1 30.4,42" fill="none" stroke="#1f3a52" stroke-width="0.5"/>
  <path d="M75.6,42 A6.4,6.4 0 0 1 88.4,42" fill="none" stroke="#1f3a52" stroke-width="0.5"/>
  <circle cx="24" cy="42" r="6" fill="#1f2530" stroke="#1f3a52" stroke-width="0.6"/>
  <circle cx="24" cy="42" r="3.2" fill="#c7d0d8" stroke="#9aa6ae" stroke-width="0.5"/>
  <circle cx="24" cy="42" r="1.1" fill="#9aa6ae"/>
  <circle cx="82" cy="42" r="6" fill="#1f2530" stroke="#1f3a52" stroke-width="0.6"/>
  <circle cx="82" cy="42" r="3.2" fill="#c7d0d8" stroke="#9aa6ae" stroke-width="0.5"/>
  <circle cx="82" cy="42" r="1.1" fill="#9aa6ae"/>`,

  truck: `
  <!-- Chassis -->
  <rect x="14" y="50" width="126" height="4" fill="#3f4a55"/>
  <!-- Caisse de transport : un porteur ordinaire, plus une citerne -->
  <rect x="14" y="14" width="88" height="36" fill="#eef2f5" stroke="#9aa6b0" stroke-width="1.6"/>
  <rect x="14" y="20" width="88" height="8" fill="#d3dbe1"/>
  <line x1="43" y1="14" x2="43" y2="50" stroke="#9aa6b0" stroke-width="1.2"/>
  <line x1="72" y1="14" x2="72" y2="50" stroke="#9aa6b0" stroke-width="1.2"/>
  <!-- Cabine a droite : le camion s'eloigne de l'usine, comme la voiture -->
  <path d="M104 50 L104 20 Q104 16 108 16 L126 16 Q130 16 132 20 L138 31 L138 50 Z" fill="#c0463a" stroke="#9aa6b0" stroke-width="0.8" stroke-linejoin="round"/>
  <path d="M110 21 L125 21 L131 31 L110 31 Z" fill="#cfe6f5" stroke="#9aa6b0" stroke-width="0.6"/>
  <rect x="104" y="40" width="18" height="3" fill="#6b7785"/>
  <!-- Phare avant, du cote ou il roule -->
  <rect x="133" y="38" width="4.5" height="4" rx="1" fill="#ffe9a8" stroke="#9aa6b0" stroke-width="0.5"/>
  <!-- Roues : deux sous la caisse, une sous la cabine -->
  <circle cx="32" cy="56" r="8" fill="#1f2530"/>
  <circle cx="32" cy="56" r="3.2" fill="#9aa6ae"/>
  <circle cx="58" cy="56" r="8" fill="#1f2530"/>
  <circle cx="58" cy="56" r="3.2" fill="#9aa6ae"/>
  <circle cx="120" cy="56" r="8" fill="#1f2530"/>
  <circle cx="120" cy="56" r="3.2" fill="#9aa6ae"/>`,
}

export default function RefiningProcess() {
  const locale = useLocale()
  const isFr = locale !== "en"
  const t = useTranslations("activites")
  const [active, setActive] = useState(0)

  const goPrev = () => setActive((a) => (a - 1 + N) % N)
  const goNext = () => setActive((a) => (a + 1) % N)

  // Sur telephone, les six unites reduites a 330 px de large ne se distinguent
  // plus. La figure se recentre alors sur l'unite courante : la pagination fait
  // avancer le texte ET le dessin, qui va chercher l'unite suivante.
  const [etroit, setEtroit] = useState(false)
  useEffect(() => {
    const mq = window.matchMedia("(max-width: 639px)")
    const sync = () => setEtroit(mq.matches)
    sync()
    mq.addEventListener("change", sync)
    return () => mq.removeEventListener("change", sync)
  }, [])

  // Fenetre de largeur constante : le cadre garde le meme rapport d'une unite a
  // l'autre, rien ne saute au changement.
  const LARGEUR_TEL = 450
  const gaucheTel =
    // La preparation recoit le brut du navire, qui est a sa gauche : le cadre
    // se cale au bord plutot que sur le centre de l'unite, sinon le navire se
    // fait couper.
    active === 0
      ? 0
      : // Le stockage debouche sur les utilisateurs finaux, a sa droite.
        active === N - 1
        ? 1090
        : Math.max(0, Math.min(1620 - LARGEUR_TEL, UNITS[active].cx - LARGEUR_TEL / 2))
  const vue = etroit ? `${gaucheTel} 145 ${LARGEUR_TEL} 335` : "0 145 1620 335"

  // Sur grand ecran, les unites inactives restent la, attenuees : la chaine se
  // lit d'un bout a l'autre. Sur telephone, la figure ne montre qu'une unite a
  // la fois, les voisines sont effacees plutot que rognees par le cadre.
  const op = (i: number) => (active === i ? 1 : etroit ? 0 : 0.32)
  const n = active + 1
  const title = t(`refiningProcess.steps.step${n}.title`)
  const desc = t(`refiningProcess.steps.step${n}.description`)

  return (
    <div className="py-8 sm:py-10">
      <div className="flex flex-col">

        {/* ── Légende de l'étape, au-dessus du schéma ───────────────────────
             On lit ce que fait l'étape, puis on regarde où elle se situe dans
             l'usine. Le texte n'est plus tronqué : il est le propos, le dessin
             l'illustre. */}
        <div className="w-full max-w-3xl mx-auto px-4 mb-6">
          {/* Encadre au gabarit des cartes du site : fond blanc et filet gris
              de meme epaisseur que les cartes de la page Contact. */}
          <motion.div
            key={active}
            initial={{ opacity: 0, y: 12 }}
            animate={{ opacity: 1, y: 0 }}
            transition={{ duration: 0.4 }}
            className="bg-white border-2 border-gray-200 p-5 sm:p-6 text-center"
          >
            <h3 className="text-lg sm:text-xl font-bold text-gray-900 mb-2">{title}</h3>
            <div className="h-0.5 w-10 bg-primary/70 rounded-full mx-auto mb-3" aria-hidden />
            <p className="text-[13px] sm:text-sm text-gray-600 leading-relaxed max-w-2xl mx-auto">{desc}</p>
          </motion.div>
        </div>

        {/* ── Schéma de l'usine, encadré par sa pagination ──────────────── */}
        {/* Le schema occupe presque toute la largeur du panneau : a 1152 px il
            restait beaucoup de blanc de chaque cote et le detail des unites se
            perdait. Les fleches de pagination l'encadrent toujours. */}
        <div className="w-full max-w-[1500px] mx-auto px-4 flex items-center gap-3 sm:gap-5">
          <button
            type="button"
            onClick={goPrev}
            aria-label={isFr ? "Étape précédente" : "Previous step"}
            /* Aplat rouge et chevron blanc, comme la pagination de l'état des
               lieux : les deux schémas de la page se paginent de la même façon. */
            className="flex-shrink-0 inline-flex items-center justify-center w-11 h-11 bg-primary text-white hover:bg-primary/90 transition-colors shadow-sm"
          >
            <ChevronLeft className="w-5 h-5" />
          </button>

          <div className="min-w-0 flex-1">
          {/* viewBox recadré sur le tracé réel : le dessin ne commence qu'à
              y=151 sur les 480 unités d'origine, soit près d'un tiers de vide en
              haut de la figure. On garde six unités de marge au-dessus. */}
          <svg viewBox={vue} className="w-full h-auto block" role="img"
               aria-label={isFr ? "Schéma du procédé de raffinage de la SAR" : "SAR refining process diagram"}>
            <defs>
              <linearGradient id="tower" x1="0" y1="0" x2="0" y2="1">
                <stop offset="0%" stopColor="#fbeee4" />
                <stop offset="55%" stopColor="#ec9a5a" />
                <stop offset="100%" stopColor="#b5481f" />
              </linearGradient>
              <linearGradient id="steel" x1="0" y1="0" x2="0" y2="1">
                <stop offset="0%" stopColor="#f4f7f9" />
                <stop offset="100%" stopColor="#c4cfd6" />
              </linearGradient>
            </defs>

            {/* sol */}
            <line x1="220" y1={GROUND} x2="1600" y2={GROUND} stroke="#cbd5dc" strokeWidth="2" />

            {/* surbrillance unité active */}
            {UNITS.map((u, i) => (
              <rect key={`hl-${i}`} x={u.x - 10} y={GROUND - u.h - 10} width={u.w + 20} height={u.h + 20} rx="12"
                    fill="rgba(229,38,33,0.05)" stroke="#E52621"
                    style={{ opacity: active === i ? 1 : 0, transition: "opacity 0.45s" }} />
            ))}

            {/* conduite principale + flux animé */}
            <line x1="240" y1={GROUND + 26} x2="1300" y2={GROUND + 26} stroke="#94a3b0" strokeWidth="6" strokeLinecap="round" opacity="0.6" />
            <motion.line x1="240" y1={GROUND + 26} x2="1300" y2={GROUND + 26} stroke="#E52621" strokeWidth="4" strokeLinecap="round"
              strokeDasharray="6 28" animate={{ strokeDashoffset: [0, -68] }} transition={{ duration: 1.6, repeat: Infinity, ease: "linear" }} />
            {UNITS.map((u, i) => <line key={`riser-${i}`} x1={u.cx} y1={GROUND} x2={u.cx} y2={GROUND + 26} stroke="#94a3b0" strokeWidth="4" opacity="0.6" />)}

            {/* navire pétrolier, arrivée du brut */}
            <g style={{ opacity: op(0), transition: "opacity 0.45s" }}>
              {/* mer */}
              <rect x="0" y={GROUND - 12} width="246" height="12" fill="#bcd9ea" />
              <line x1="6" y1={GROUND - 6} x2="240" y2={GROUND - 6} stroke="#ffffff" strokeOpacity="0.5" strokeWidth="2" strokeDasharray="10 14" />
              {/* navire */}
              <g transform={`translate(14 ${GROUND - 92})`} dangerouslySetInnerHTML={{ __html: EXTRA_SVGS.ship }} />
              {/* sealine vers la préparation */}
              <line x1="224" y1={GROUND - 32} x2={UNITS[0].x - 6} y2={GROUND - 32} stroke="#7c8a96" strokeWidth="3" strokeLinecap="round" />
              <path d={`M${UNITS[0].x - 12} ${GROUND - 37} L${UNITS[0].x - 2} ${GROUND - 32} L${UNITS[0].x - 12} ${GROUND - 27} Z`} fill="#7c8a96" />
              {/* étiquette */}
              <text x="120" y={GROUND - 104} textAnchor="middle" fontSize="13.5" fontWeight="600" fill="#374151">{isFr ? "Pétrole brut" : "Crude oil"}</text>
            </g>

            {/* sorties produits finis + utilisateurs finaux */}
            <g style={{ opacity: op(5), transition: "opacity 0.45s" }}>
              {[GROUND - 50, GROUND - 34, GROUND - 18].map((y, k) => (
                <g key={k}>
                  <line x1="1290" y1={y} x2="1330" y2={y} stroke="#7c8a96" strokeWidth="3" strokeLinecap="round" />
                  <path d={`M1324 ${y - 5} L1334 ${y} L1324 ${y + 5} Z`} fill="#7c8a96" />
                </g>
              ))}

              {/* Avion, aviation (Jet A-1) */}
              <g transform={`translate(1372 ${GROUND - 192})`} dangerouslySetInnerHTML={{ __html: EXTRA_SVGS.plane }} />
              {/* Voiture, essences */}
              <g transform={`translate(1352 ${GROUND - 48})`} dangerouslySetInnerHTML={{ __html: EXTRA_SVGS.car }} />
              {/* Camion-citerne, gazole / fioul */}
              <g transform={`translate(1466 ${GROUND - 64})`} dangerouslySetInnerHTML={{ __html: EXTRA_SVGS.truck }} />

              <text x="1466" y={GROUND + 58} textAnchor="middle" fontSize="12.5" fontWeight="500" fill="#94a3b0">{isFr ? "Utilisateurs finaux" : "End users"}</text>
            </g>

            {/* unités */}
            {UNITS.map((u, i) => (
              <g key={u.key} transform={`translate(${u.x} ${GROUND - u.h})`}
                 style={{ opacity: op(i), transition: "opacity 0.45s" }}
                 dangerouslySetInnerHTML={{ __html: SVGS[u.key] }} />
            ))}

            {/* libellés des unités */}
            {UNITS.map((u, i) => (
              <text key={`mk-${i}`} x={u.cx} y={GROUND + 58} textAnchor="middle" fontSize="12.5" fontWeight={active === i ? 700 : 500}
                    fill={active === i ? "#111827" : "#94a3b0"} className="transition-colors"
                    style={{ opacity: op(i) === 0 ? 0 : 1 }}>
                {isFr ? u.fr : u.en}
              </text>
            ))}

            {/* zones cliquables (changent l'étape au clic sur une unité) */}
            {UNITS.map((u, i) => (
              <rect
                key={`hit-${i}`}
                x={u.x - 12}
                y={GROUND - u.h - 14}
                width={u.w + 24}
                height={u.h + 80}
                fill="transparent"
                onClick={() => setActive(i)}
                style={{ cursor: "pointer" }}
              >
                <title>{isFr ? u.fr : u.en}</title>
              </rect>
            ))}
          </svg>
          </div>

          <button
            type="button"
            onClick={goNext}
            aria-label={isFr ? "Étape suivante" : "Next step"}
            className="flex-shrink-0 inline-flex items-center justify-center w-11 h-11 bg-primary text-white hover:bg-primary/90 transition-colors shadow-sm"
          >
            <ChevronRight className="w-5 h-5" />
          </button>
        </div>



      </div>
    </div>
  )
}
