// Home page (hi-fi) — charte ATELIER PERF
// Structure V5 :
//   Hero "On pose les bottes" → Stats yellow → Marquee → Trois mondes
//   → 7 cartes à jouer → Section Domaine 7 → Témoignage → CTA

// ============================================
// DATA — 7 cartes d'intervention
// ============================================
const SERVICES = [
{
  id: 'performance', num: '01', title: 'Performance',
  blurb: 'KPI terrain, management visuel, amélioration de la cadence et du rendement.',
  chips: ['Lean', 'KPI', 'QVCT', 'Cadence'],
  suit: '♦', suitColor: 'var(--electric-2)',
  impact: 4, duree: '3 mois',
  family: 'action'
},
{
  id: 'continu', num: '02', title: 'Amélioration\u00a0continue',
  blurb: 'Routines 5S, ateliers Kaizen, résolution de problèmes en QRQC.',
  chips: ['5S', 'Kaizen', 'QVCT', 'Swimlane'],
  suit: '♠', suitColor: 'var(--deep)',
  impact: 3, duree: '4 mois',
  family: 'methode'
},
{
  id: 'amenagement', num: '03', title: 'Aménagement',
  blurb: "Plan d'implantation, flux matière, ergonomie postes.",
  chips: ["Plan d'implantation", 'Flux', 'Ergonomie'],
  suit: '♣', suitColor: 'var(--deep)',
  impact: 4, duree: '6 sem',
  family: 'methode'
},
{
  id: 'equipement', num: '04', title: 'Équipement',
  blurb: 'Choix machine, intégration, TPM, maintenance.',
  chips: ['TPM', 'Maintenance'],
  suit: '♥', suitColor: 'var(--electric-2)',
  impact: 3, duree: '8 sem',
  family: 'action'
},
{
  id: 'competences', num: '05', title: 'Compétences',
  blurb: 'Formation, mentoring terrain, transmission. Accompagnement des techniciens de maintenance dans la méthodologie de recherche de pannes.',
  chips: ['Formation', 'TWI', 'Coaching', 'Recherche de pannes'],
  suit: '★', suitColor: 'var(--deep)',
  impact: 4, duree: '2 mois',
  family: 'humain'
},
{
  id: 'diagnostic', num: '06', title: 'Diagnostic',
  blurb: 'Cartographie process, diagnostic organisation et flux.',
  chips: ['VSM', 'Swimlane', 'Flux'],
  suit: '✦', suitColor: 'var(--deep)',
  impact: 2, duree: '4 sem',
  family: 'humain'
},
{
  id: 'outils', num: '07', title: 'Automatisation & Outils',
  blurb: "Vous ressaisissez les mêmes données partout ? On supprime les doubles saisies — bons de livraison, planification, facturation, banque d'heures — avec les bons outils, bien connectés.",
  chips: ['Cadulis', 'Kizeo', 'EBP', 'Skello', 'Automatisation'],
  suit: '✺', suitColor: 'var(--electric)',
  impact: 5, duree: '12 sem',
  family: 'new',
  isNew: true
}];


const STATS = [
{ value: '−32%', start: 10, label: 'gaspillage' },
{ value: '+24%', start:  5, label: 'productivité' },
{ value: '−40%', start: 10, label: 'déplacements' },
{ value: '+18%', start:  5, label: 'TRS machine' }];


const PROFILES = [
{ id: 'dirigeants', title: 'Dirigeants de PME', sub: 'industrielles, services, sous-traitance', desc: 'Vous voulez voir des résultats chiffrés sans devenir spécialiste lean.' },
{ id: 'artisans', title: 'Artisans, commerçants,', sub: 'agriculteurs', desc: 'Vous voulez passer un cap sans dénaturer ce qui vous rend bon.' },
{ id: 'responsables', title: 'Responsables terrain', sub: 'prod, maintenance, qualité, admin', desc: 'Vous voulez des méthodes que vos équipes vont vraiment utiliser.' }];


const MARQUEE_ITEMS  = ['LEAN', 'KAIZEN', '5S', 'TPM', 'VSM', 'SMED', 'POKA-YOKE', 'GEMBA WALK', 'KANBAN', 'QVCT', 'PDCA', 'OEE', 'SWIMLANE', 'TWI', 'ROBOTIQUE'];
const MARQUEE_ITEMS2 = ['ORDONNANCEMENT', 'PLANIFICATION', 'FACTURATION AUTO', 'ZÉRO DOUBLE SAISIE', 'SKELLO', 'KIZEO', 'EBP', 'CADULIS', 'DOUBLES SAISIES', 'AUTOMATISATION', 'BONS DE LIVRAISON', 'BANQUE D\'HEURES'];

// ============================================
// HERO ROTATION DATA
// ============================================
const HERO_PLACES = [
"l'atelier",
"la boutique",
"l'entrepôt",
"l'exploitation",
"le garage",
"l'agence",
"le bureau"];


const HERO_CIBLES = ['Industriels', 'Artisans', 'Commerçants', 'Agriculteurs', 'Services'];

const MISSION_SECTEURS = ['Usineur', 'Agriculture', 'Plasturgie', 'Dépanneur itinérant', 'Industrie', 'Robotique'];

function useRotator(items, intervalMs = 2400, enabled = true) {
  const [idx, setIdx] = useState(0);
  useEffect(() => {
    if (!enabled) return;
    const i = setInterval(() => setIdx((x) => (x + 1) % items.length), intervalMs);
    return () => clearInterval(i);
  }, [items.length, intervalMs, enabled]);
  return [idx, setIdx];
}

// ============================================
// PAGE
// ============================================
function HomePage({ navigate, openModal, tweaks }) {
  return (
    <main className="page-enter">
      <HomeHero navigate={navigate} tweaks={tweaks} />
      <HoneycombSection navigate={navigate} />
      <HomeMarquee />
      <HomeStats />
      <HomeManifesto />
      <HomeCards navigate={navigate} openModal={openModal} />
      <HomeDomain7 navigate={navigate} />
      <HomeTestimonial />
      <HomeCTA navigate={navigate} />
    </main>);

}

// ============================================
// HERO — "On pose les bottes, pas dans un PowerPoint."
// ============================================
function HomeHero({ navigate, tweaks }) {
  const variant = tweaks && tweaks.heroVariant || 'option4';
  const [t, setT] = useState(0);
  useEffect(() => {
    let raf;
    const start = performance.now();
    const tick = () => {setT((performance.now() - start) / 1000);raf = requestAnimationFrame(tick);};
    raf = requestAnimationFrame(tick);
    return () => cancelAnimationFrame(raf);
  }, []);

  // Rotation des lieux + secteurs
  const speed = tweaks && tweaks.rotationSpeed || 2600;
  const [placeIdx] = useRotator(HERO_PLACES, speed);
  const [secteurIdx] = useRotator(MISSION_SECTEURS, Math.max(1200, speed - 800));
  const currentPlace = HERO_PLACES[placeIdx];
  const currentSecteur = MISSION_SECTEURS[secteurIdx];

  return (
    <section style={{
      position: 'relative',
      minHeight: '100vh',
      display: 'flex',
      alignItems: 'center',
      paddingTop: 140,
      paddingBottom: 80,
      overflow: 'hidden'
    }}>
      <div className="bg-stars"></div>
      <div className="bg-grid"></div>
      <div className="bg-glow" style={{ left: '60%', top: '20%', width: 900, height: 900 }}></div>
      <div className="bg-glow" style={{ left: '-10%', top: '50%', width: 700, height: 700, background: 'radial-gradient(closest-side, rgba(62,45,214,0.5), transparent 70%)' }}></div>

      {/* Right-side orbital visual with logo at center */}
      <div className="hero-orbit" style={{
        position: 'absolute',
        right: 'clamp(-80px, -2vw, 40px)',
        top: '50%',
        transform: 'translateY(-50%)',
        width: 'min(46vw, 520px)',
        aspectRatio: '1/1',
        pointerEvents: 'none',
        zIndex: 1
      }}>
        {/* Big ring */}
        <div style={{
          position: 'absolute', inset: 0,
          transform: `rotate(${t * 8}deg)`,
          border: '1px dashed rgba(16,30,142,0.22)',
          borderRadius: '50%'
        }}>
          <div style={{
            position: 'absolute', top: '50%', right: -8, transform: 'translateY(-50%)',
            width: 14, height: 14, borderRadius: '50%',
            background: 'var(--yellow)', boxShadow: '0 0 30px var(--yellow)'
          }}></div>
        </div>
        {/* Smaller ring */}
        <div style={{
          position: 'absolute', inset: '18%',
          transform: `rotate(${-t * 12}deg)`,
          border: '1px dashed rgba(94,76,255,0.45)',
          borderRadius: '50%'
        }}>
          <div style={{
            position: 'absolute', top: -6, left: '50%', transform: 'translateX(-50%)',
            width: 10, height: 10, borderRadius: '50%',
            background: 'var(--electric-2)', boxShadow: '0 0 24px var(--electric-2)'
          }}></div>
        </div>
        {/* Tiny ring */}
        <div style={{
          position: 'absolute', inset: '36%',
          transform: `rotate(${t * 22}deg)`,
          border: '1px solid rgba(251,220,116,0.35)',
          borderRadius: '50%'
        }}>
          <div style={{
            position: 'absolute', bottom: -3, left: '50%', transform: 'translateX(-50%)',
            width: 6, height: 6, borderRadius: '50%',
            background: 'var(--yellow)'
          }}></div>
        </div>
        {/* Logo at center */}
        <img src={typeof window !== "undefined" && window.__resources && window.__resources.logoFull || "assets/logo-full.png"} alt="Atelier Perf" style={{
          position: 'absolute', top: '50%', left: '50%',
          transform: 'translate(-50%, -50%)',
          width: '44%', height: '44%',
          objectFit: 'contain',
          filter: 'drop-shadow(0 12px 40px rgba(16,30,142,0.25)) drop-shadow(0 0 60px rgba(251,220,116,0.4))',
          animation: 'floatY 4.5s ease-in-out infinite'
        }} />
      </div>

      {/* CSS orbit chips — secteurs cibles (visible jusqu'à 600px, indépendant de hero-orbit) */}
      <div className="hero-chip-orbit-container" style={{
        position: 'absolute',
        right: 'clamp(-80px, -2vw, 40px)',
        top: '50%',
        transform: 'translateY(-50%)',
        width: 'min(46vw, 520px)',
        height: 'min(46vw, 520px)',
        pointerEvents: 'none',
        zIndex: 2,
      }}>
        {/* Conteneur centré qui tourne — toutes les chips avec lui */}
        <div style={{
          position: 'absolute', left: '50%', top: '50%',
          width: 0, height: 0,
          animation: 'chip-orbit 22s linear infinite',
        }}>
          {HERO_CIBLES.map((label, i) => {
            const angleDeg = (i / HERO_CIBLES.length) * 360 - 90;
            const rad = angleDeg * Math.PI / 180;
            const r = 213; // grand anneau : inset 8% → rayon ≈ 42% de 520px
            const x = Math.round(r * Math.cos(rad));
            const y = Math.round(r * Math.sin(rad));
            return (
              <span key={label} style={{
                position: 'absolute',
                left: x + 'px', top: y + 'px',
                transform: 'translate(-50%, -50%)',
                animation: 'chip-counter 22s linear infinite',
                padding: '5px 12px', borderRadius: 999,
                background: 'rgba(10,16,60,0.82)',
                border: '1px solid rgba(255,255,255,0.45)',
                backdropFilter: 'blur(6px)',
                color: '#fff',
                fontFamily: 'var(--f-mono)', fontSize: 9,
                letterSpacing: '0.14em', textTransform: 'uppercase',
                whiteSpace: 'nowrap',
              }}>{label}</span>
            );
          })}
        </div>
      </div>

      <div className="container hero-container" style={{ position: 'relative', zIndex: 2 }}>
        <div className="hero-grid">
          <div className="hero-text">
            <Reveal><Eyebrow>ATELIER · PERF — PERFORMANCE TERRAIN</Eyebrow></Reveal>
        <Reveal>
          <h1 className="display" style={{
                margin: '24px 0 28px',
                fontSize: 'clamp(44px, 6.2vw, 92px)',
                lineHeight: 1.08
              }}>
            On met les <span className="italic-accent">pieds</span><br />
            dans{'\u00a0'}
            <span style={{ position: 'relative', display: 'inline-block', verticalAlign: 'baseline', overflow: 'hidden' }}>
              {/* Ghost reserves max width */}
              <span aria-hidden="true" style={{ visibility: 'hidden', whiteSpace: 'nowrap', pointerEvents: 'none' }}>
                <span className="italic-accent" style={{ display: 'inline-block', paddingRight: '0.2em' }}>l&rsquo;exploitation</span>
              </span>
              <span className="hero-rotator" key={placeIdx} style={{
                    position: 'absolute', left: 0, top: 0, whiteSpace: 'nowrap'
                  }}>
                <span className="italic-accent" style={{
                      background: 'linear-gradient(90deg, var(--deep) 0%, var(--electric-2) 100%)',
                      WebkitBackgroundClip: 'text', backgroundClip: 'text', color: 'transparent',
                      display: 'inline-block', paddingRight: '0.2em'
                    }}>{currentPlace}</span>
              </span>
            </span><br />
            <span style={{
              color: 'var(--muted)',
              fontSize: '0.5em',
              fontWeight: 500,
              letterSpacing: '-0.01em',
              display: 'inline-block',
              marginTop: '0.4em'
            }}>Pas dans un PowerPoint</span>
          </h1>
          <style>{`
            @keyframes floatY { 0%,100% { transform: translate(-50%, -50%) rotate(0deg); } 50% { transform: translate(-50%, -54%) rotate(3deg); } }
            /* rotIn remplacé par wordEnter dans styles.css */
            @keyframes pied-walk {
              0%, 100% { transform: translateY(0) scaleY(1); }
              7%      { transform: translateY(-6px); }
              14%     { transform: translateY(0) scaleY(0.92); }
              22%     { transform: translateY(0) scaleY(1); }
              52%     { transform: translateY(-6px); }
              60%     { transform: translateY(0) scaleY(0.92); }
              68%     { transform: translateY(0) scaleY(1); }
            }
            .pied-walk {
              display: inline-block;
              transform-origin: 50% 90%;
              animation: pied-walk 1.3s cubic-bezier(0.34,1.2,0.64,1) infinite;
            }
            @keyframes chip-orbit   { to { transform: rotate(360deg); } }
            @keyframes chip-counter { from { transform: translate(-50%,-50%) rotate(0deg); } to { transform: translate(-50%,-50%) rotate(-360deg); } }
            @media (max-width: 980px) {
              .hero-orbit { display: none; }
              .hero-chip-orbit-container { display: none !important; }
            }
          `}</style>
        </Reveal>

        {/* Géo — sous-titre ancrage terrain */}
        <Reveal>
          <div style={{ display: 'flex', alignItems: 'center', gap: 10, margin: '0 0 20px' }}>
            <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="var(--electric)" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z"/><circle cx="12" cy="10" r="3"/></svg>
            <span style={{ fontFamily: 'var(--f-mono)', fontSize: 11, letterSpacing: '0.16em', textTransform: 'uppercase', color: 'var(--muted)' }}>
              Vendée <span style={{ opacity: 0.4, margin: '0 4px' }}>·</span> Grand Ouest <span style={{ opacity: 0.4, margin: '0 4px' }}>·</span> Partout où ça coince
            </span>
          </div>
        </Reveal>

        {/* Differentiator tagline — la promesse opérationnelle */}
        <Reveal>
          <div style={{
                display: 'inline-flex',
                alignItems: 'center', gap: 12,
                padding: '10px 18px 10px 14px',
                background: 'var(--text)',
                color: '#fff',
                borderRadius: 999,
                marginBottom: 28,
                boxShadow: '0 12px 32px rgba(0,0,0,0.18)',
                flexWrap: 'wrap'
              }}>
            <span style={{
                  width: 6, height: 6, borderRadius: '50%',
                  background: 'var(--yellow)',
                  boxShadow: '0 0 12px var(--yellow)'
                }}></span>
            <span style={{
                  fontFamily: 'var(--f-mono)', fontSize: 11, letterSpacing: '0.16em',
                  textTransform: 'uppercase', fontWeight: 600
                }}>
              Mise en place opérationnelle <span style={{ opacity: 0.5 }}>·</span> on installe, on forme, on accompagne
            </span>
          </div>
        </Reveal>
        <Reveal>
          <p style={{ maxWidth: 680, fontSize: 19, color: 'var(--muted)', lineHeight: 1.7, margin: '0 0 40px' }}>
            Atelier Perf, c&rsquo;est un facilitateur technique qui passe ses journées au pied des machines, à côté des opérateurs, du personnel administratif et de vos intervenants terrain, ou dans un champ, le carnet à la main. <span style={{ color: 'var(--text)', fontWeight: 500 }}>Sept expertises d&rsquo;intervention.</span> Vous sélectionnez celles qui vous parlent.
          </p>
        </Reveal>
        <Reveal>
          <div style={{ display: 'flex', gap: 12, flexWrap: 'wrap' }}>
            <a className="btn btn-primary" href="#cards" onClick={(e) => {
                  e.preventDefault();
                  document.getElementById('home-cards')?.scrollIntoView({ behavior: 'smooth', block: 'start' });
                }}>
              Voir nos 7 expertises <svg className="arrow" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5"><path d="M5 12h14M13 5l7 7-7 7" /></svg>
            </a>
            <a className="btn btn-ghost" href="#fp-temoignage" onClick={(e) => { e.preventDefault(); document.getElementById('fp-temoignage')?.scrollIntoView({ behavior:'smooth', block:'start' }); }}>
              Visiter un cas client
            </a>
          </div>
        </Reveal>

        {/* Missions en cours */}
        <Reveal>
          <div style={{
                display: 'inline-flex', alignItems: 'center', gap: 14,
                marginTop: 56,
                padding: '12px 18px',
                background: 'rgba(255,255,255,0.7)', backdropFilter: 'blur(20px)',
                border: '1px solid var(--line-2)', borderRadius: 999,
                flexWrap: 'wrap'
              }}>
            <span className="pulse" style={{ width: 8, height: 8, background: 'var(--electric)', borderRadius: '50%' }}></span>
            <span style={{ fontFamily: 'var(--f-mono)', fontSize: 11, letterSpacing: '0.12em', textTransform: 'uppercase' }}>
              4 missions en cours · Pays de la Loire
            </span>
            <span style={{ width: 1, height: 12, background: 'var(--line-2)' }}></span>
            <span style={{
                  fontFamily: 'var(--f-mono)', fontSize: 11, letterSpacing: '0.12em',
                  textTransform: 'uppercase', color: 'var(--electric)',
                  minWidth: 130, display: 'inline-block', textAlign: 'left'
                }}>
              <span className="hero-rotator" key={secteurIdx}>{currentSecteur}</span>
            </span>
          </div>
        </Reveal>
          </div>
        </div>

      </div>
      <style>{`
        .hero-text {
          max-width: min(820px, 56vw);
        }
        @media (max-width: 980px) {
          .hero-text { max-width: 100%; }
        }
      `}</style>
    </section>);

}

// ============================================
// MANIFESTO — "On déploie, pas on conseille."
// ============================================
function HomeManifesto() {
  const steps = [
  { num: '01', title: "Identifier l'opportunité", desc: 'On échange avec vous, on cadre le besoin et les enjeux — sans engagement.' },
  { num: '02', title: 'Observer, mesurer', desc: 'Sur site, on observe les flux, on mesure, on cartographie la chaîne de valeur.' },
  { num: '03', title: 'Recommander des solutions', desc: "On propose un plan d'action priorité · chiffré · applicable. Pas un PDF qui finit au tiroir.", baseline: true },
  { num: '04', title: "Chantiers d'optimisation\u00a0& innovation", desc: 'On déploie sur le terrain : implantation, outils, formation, accompagnement des équipes.' },
  { num: '05', title: 'Performer dans la durée', desc: 'Rituels en place, transfert terminé, on garde un œil — ça tourne en autonomie.' }];


  return (
    <section id="home-manifesto" style={{
      padding: 'clamp(80px, 10vw, 140px) 0',
      background: 'var(--yellow)',
      borderTop: '1px solid var(--line)',
      borderBottom: '1px solid var(--line)',
      position: 'relative', overflow: 'hidden'
    }}>
      <div style={{ position: 'absolute', top: '-30%', left: '-10%', width: 600, height: 600, borderRadius: '50%', background: 'radial-gradient(closest-side, rgba(255,255,255,0.4), transparent 70%)', pointerEvents: 'none' }}></div>

      <div className="container" style={{ position: 'relative' }}>
        {/* Header — same shape as Cas Client */}
        <div className="manifesto-head" style={{ display: 'grid', gridTemplateColumns: '1fr auto', gap: 32, alignItems: 'end', marginBottom: 56 }}>
          <div>
            <Reveal>
              <span className="eyebrow" style={{ color: 'var(--deep)' }}>
                <span className="pulse" style={{ background: 'var(--deep)' }}></span>
                NOTRE DIFFÉRENCE
              </span>
            </Reveal>
            <Reveal>
              <h2 className="display" style={{
                margin: '20px 0 12px',
                fontSize: 'clamp(34px, 4.6vw, 68px)',
                lineHeight: 1.05,
                textWrap: 'balance'
              }}>
                <span style={{ whiteSpace: 'nowrap' }}>On ne fait pas que <span style={{ opacity: 0.4, textDecoration: 'line-through', textDecorationThickness: '3px' }}>conseiller</span></span>
                <span style={{ display: 'block', marginTop: '0.25em' }}>
                  <span className="italic-accent">On déploie</span>
                </span>
              </h2>
            </Reveal>
            <Reveal>
              <p style={{ color: 'var(--deep)', opacity: 0.78, fontSize: 16, lineHeight: 1.65, maxWidth: 620, margin: 0 }}>
                Là où un consultant classique s&rsquo;arrête à la recommandation et vous laisse un rapport, on continue. On déploie les chantiers, on forme vos équipes, on opère avec vous. <span style={{ color: 'var(--text)', fontWeight: 500 }}>Quand on part, ça tourne sans nous.</span>
              </p>
            </Reveal>
          </div>
          <Reveal>
            <div style={{
              padding: '14px 20px', background: '#fff',
              border: '1px solid var(--line-2)', borderRadius: 16,
              fontFamily: 'var(--f-mono)', fontSize: 10, letterSpacing: '0.14em',
              textTransform: 'uppercase', color: 'var(--muted)',
              minWidth: 200, textAlign: 'center'
            }}>
              <div style={{ fontFamily: 'var(--f-display)', fontSize: 32, color: 'var(--deep)', letterSpacing: '-0.02em', marginBottom: 4 }}>5 / 5</div>
              phases — de l'opportunité à la durée
            </div>
          </Reveal>
        </div>

        {/* 5-step path */}
        <Reveal stagger>
          <div className="manifesto-steps">
            {steps.map((s, i) =>
            <React.Fragment key={s.num}>
                <div className={`manifesto-step ${s.baseline ? 'is-baseline' : 'is-perf'}`}>
                  <div className="step-header">
                    <span style={{
                    fontFamily: 'var(--f-mono)', fontSize: 10, letterSpacing: '0.16em',
                    textTransform: 'uppercase', color: 'var(--muted)'
                  }}>ÉTAPE {s.num}</span>
                    {s.baseline &&
                  <span className="step-tag is-end">FIN consulting</span>
                  }
                    {i === steps.length - 1 &&
                  <span className="step-tag is-ok">Atelier Perf</span>
                  }
                  </div>
                  <h3 className="step-title">{s.title}</h3>
                  <p className="step-desc">{s.desc}</p>
                  {s.baseline &&
                <div className="step-limit">
                      <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><line x1="18" y1="6" x2="6" y2="18" /><line x1="6" y1="6" x2="18" y2="18" /></svg>
                      <span>Le consultant classique s&rsquo;arrête ici</span>
                    </div>
                }
                  {i === steps.length - 1 &&
                <div className="step-limit step-limit-ok">
                      <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.4"><polyline points="20 6 9 17 4 12" /></svg>
                      <span>Et nous, on continue jusqu&rsquo;ici</span>
                    </div>
                }
                </div>
                {i < steps.length - 1 &&
              <div className={`step-arrow ${i === 2 ? 'is-cross' : ''}`}>
                    <svg width="32" height="14" viewBox="0 0 32 14" fill="none">
                      <path d="M0 7 H26 M22 3 L26 7 L22 11" stroke="currentColor" strokeWidth="1.5" />
                    </svg>
                  </div>
              }
              </React.Fragment>
            )}
          </div>
        </Reveal>

        {/* Footer tag — comme cas client */}
        <Reveal>
          <div style={{
            marginTop: 48, padding: '20px 24px',
            background: 'rgba(255,255,255,0.65)', backdropFilter: 'blur(8px)',
            border: '1px dashed var(--line-2)', borderRadius: 16,
            display: 'flex', gap: 16, alignItems: 'center', justifyContent: 'center',
            flexWrap: 'wrap'
          }}>
            <span style={{ fontFamily: 'var(--f-mono)', fontSize: 11, letterSpacing: '0.14em', textTransform: 'uppercase', color: 'var(--muted)' }}>
              ce qui change concrètement →
            </span>
            {['Installation sur site', 'Formation terrain', 'Documentation', 'Suivi post-mission'].map((s) =>
            <span key={s} style={{
              fontFamily: 'var(--f-mono)', fontSize: 11, letterSpacing: '0.1em',
              textTransform: 'uppercase', color: 'var(--text)',
              padding: '6px 12px', border: '1px solid var(--line-2)', borderRadius: 999,
              background: '#fff'
            }}>{s}</span>
            )}
          </div>
        </Reveal>
      </div>

      <style>{`
        .manifesto-steps {
          display: grid;
          grid-template-columns: 1fr 28px 1fr 28px 1fr 28px 1fr 28px 1fr;
          gap: 0;
          align-items: stretch;
        }
        .manifesto-step {
          position: relative;
          background: #fff;
          border: 1px solid var(--line-2);
          border-radius: 18px;
          padding: 18px;
          display: flex; flex-direction: column;
          min-height: 270px;
          transition: transform 280ms cubic-bezier(0.2,0.7,0.2,1), border-color 280ms, box-shadow 280ms;
          box-shadow: 0 6px 18px rgba(16,30,142,0.06);
        }
        .manifesto-step.is-baseline {
          background: rgba(255,255,255,0.55);
          border-color: rgba(230,57,70,0.35);
          box-shadow: 0 6px 18px rgba(230,57,70,0.08);
        }
        .manifesto-step.is-perf:hover {
          transform: translateY(-4px);
          border-color: var(--deep);
          box-shadow: 0 20px 50px rgba(16,30,142,0.18);
        }
        .step-header {
          display: flex; justify-content: space-between; align-items: center;
          margin-bottom: 14px; padding-bottom: 12px;
          border-bottom: 1px dashed var(--line-2);
        }
        .step-tag {
          font-family: var(--f-mono); font-size: 9px; letter-spacing: 0.12em;
          text-transform: uppercase; padding: 3px 8px; border-radius: 999px;
        }
        .step-tag.is-end {
          background: rgba(230,57,70,0.12);
          border: 1px solid rgba(230,57,70,0.35);
          color: #c1373f;
        }
        .step-tag.is-ok {
          background: var(--deep); color: #fff;
        }
        .step-title {
          font-family: var(--f-display); font-weight: 700; font-size: 22px;
          letter-spacing: -0.02em; margin: 0 0 8px; line-height: 1.1;
          color: var(--text);
        }
        .manifesto-step.is-baseline .step-title {
          color: var(--muted);
        }
        .step-desc {
          font-size: 13px; line-height: 1.55; color: var(--muted);
          margin: 0; flex: 1;
        }
        .step-limit {
          margin-top: 16px;
          padding: 8px 12px;
          background: rgba(230,57,70,0.1);
          border: 1px solid rgba(230,57,70,0.3);
          border-radius: 10px;
          font-family: var(--f-mono); font-size: 10px;
          color: #b8323a; letter-spacing: 0.06em;
          display: flex; align-items: center; gap: 8px;
        }
        .step-limit.step-limit-ok {
          background: rgba(16,30,142,0.06);
          border-color: var(--deep);
          color: var(--deep);
        }
        .step-arrow {
          display: flex; align-items: center; justify-content: center;
          color: var(--deep); opacity: 0.45;
        }
        .step-arrow.is-cross {
          color: #c1373f; opacity: 0.55;
        }
        @media (max-width: 1200px) {
          .manifesto-steps {
            grid-template-columns: 1fr 1fr 1fr;
            gap: 16px;
          }
          .step-arrow { display: none; }
        }
        @media (max-width: 760px) {
          .manifesto-steps { grid-template-columns: 1fr 1fr; }
          .manifesto-head { grid-template-columns: 1fr !important; gap: 32px !important; }
        }
        @media (max-width: 480px) {
          .manifesto-steps { grid-template-columns: 1fr; }
        }
      `}</style>
    </section>);

}

// ============================================
// STATS — bandeau yellow avec compteurs animés
// ============================================
function StatCard({ s, tilt }) {
  const ref = useRef(null);
  const [display, setDisplay] = useState('0');
  const [done, setDone] = useState(false);

  useEffect(() => {
    const el = ref.current;
    if (!el) return;
    // Parse valeur: '−32%' → { sign:'−', num:32, unit:'%' }
    const m = s.value.match(/^([+\-−]?)(\d+)(.*)$/);
    if (!m) { setDisplay(s.value); setDone(true); return; }
    const sign = m[1], target = parseInt(m[2]), unit = m[3];
    const startNum = s.start || 0;

    let rafId = null, timerId = null, active = false;

    function run() {
      if (active) return;
      active = true;
      setDone(false);
      const DURATION = 1600;
      const t0 = performance.now();
      function tick(now) {
        const p = Math.min((now - t0) / DURATION, 1);
        const eased = 1 - Math.pow(1 - p, 3);
        setDisplay(sign + Math.round(startNum + eased * (target - startNum)) + unit);
        if (p < 1) { rafId = requestAnimationFrame(tick); }
        else { active = false; setDone(true); timerId = setTimeout(run, 2200); }
      }
      rafId = requestAnimationFrame(tick);
    }

    function stop() {
      cancelAnimationFrame(rafId); rafId = null;
      clearTimeout(timerId); timerId = null;
      active = false;
    }

    const io = new IntersectionObserver(([entry]) => {
      if (entry.isIntersecting) run(); else stop();
    }, { threshold: 0.5 });
    io.observe(el);
    return () => { io.disconnect(); stop(); };
  }, []);

  return (
    <div ref={ref} style={{
      background: '#fff',
      border: '1px solid var(--line-2)',
      borderRadius: 16,
      padding: 'clamp(20px, 2.5vw, 32px)',
      transform: `rotate(${tilt}deg)`,
      boxShadow: '0 10px 30px rgba(16,30,142,0.08)',
      transition: 'box-shadow 300ms',
    }}>
      <span className="display display-l" style={{
        color: done ? 'var(--deep)' : 'var(--electric)',
        display: 'block',
        transition: 'color 600ms ease',
        fontVariantNumeric: 'tabular-nums',
      }}>{display || s.value}</span>
      <span style={{
        fontFamily: 'var(--f-mono)', fontSize: 12,
        letterSpacing: '0.12em', textTransform: 'uppercase',
        color: 'var(--muted)', marginTop: 6, display: 'block'
      }}>{s.label}</span>
    </div>
  );
}

function HomeStats() {
  const tilts = [-0.5, 0.5, -0.3, 0.4];
  return (
    <section style={{
      background: 'var(--yellow)',
      borderTop: '1px solid var(--line)',
      borderBottom: '1px solid var(--line)',
      padding: 'clamp(48px, 6vw, 80px) 0',
      position: 'relative',
      overflow: 'hidden'
    }}>
      <div className="container">
        <Reveal>
          <div style={{
            fontFamily: 'var(--f-mono)', fontSize: 12, letterSpacing: '0.18em',
            textTransform: 'uppercase', color: 'var(--deep)', marginBottom: 32
          }}>
            ↓ VOUS POUVEZ VOUS ATTENDRE À
          </div>
        </Reveal>
        <Reveal stagger>
          <div style={{ display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: 16 }} className="stats-grid">
            {STATS.map((s, i) => <StatCard key={i} s={s} tilt={tilts[i]} />)}
          </div>
        </Reveal>
      </div>
      <style>{`@media (max-width: 820px) { .stats-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 24px !important; } }`}</style>
    </section>
  );
}

// ============================================
// MARQUEE
// ============================================
function MarqueeRow({ items, reverse, fontSize, color, dotColor }) {
  const tripled = [...items, ...items, ...items];
  const anim = reverse ? 'marquee-r 50s linear infinite' : 'marquee 40s linear infinite';
  return (
    <div style={{ display: 'flex', gap: 48, animation: anim, whiteSpace: 'nowrap' }}>
      {tripled.map((it, i) =>
        <span key={i} style={{
          fontFamily: 'var(--f-display)', fontWeight: 700,
          fontSize: fontSize || 'clamp(28px, 4vw, 60px)',
          letterSpacing: '-0.02em', color: 'transparent',
          WebkitTextStroke: `1px ${color || 'rgba(16,30,142,0.5)'}`,
          display: 'flex', alignItems: 'center', gap: 40
        }}>
          {it}
          <span style={{
            width: 10, height: 10, borderRadius: '50%',
            background: dotColor || 'var(--yellow)', display: 'inline-block',
            WebkitTextStroke: 0, boxShadow: `0 0 10px ${dotColor || 'var(--yellow)'}`
          }}></span>
        </span>
      )}
    </div>
  );
}

function HomeMarquee() {
  return (
    <section style={{
      padding: '32px 0',
      borderBottom: '1px solid var(--line)',
      overflow: 'hidden', background: 'var(--ink-2)',
      display: 'flex', flexDirection: 'column', gap: 20
    }}>
      <MarqueeRow items={MARQUEE_ITEMS} />
      <MarqueeRow items={MARQUEE_ITEMS2} reverse dotColor="var(--electric)" color="rgba(62,45,214,0.45)" />
      <style>{`
        @keyframes marquee   { from { transform: translateX(0); }         to { transform: translateX(-33.333%); } }
        @keyframes marquee-r { from { transform: translateX(-33.333%); } to { transform: translateX(0); } }
      `}</style>
    </section>
  );
}

// ============================================
// PROFILES — Trois mondes, un même atelier
// ============================================
function HomeProfiles() {
  return (
    <section className="section-pad-sm" style={{ position: 'relative', background: 'var(--ink-2)' }}>
      <div className="container">
        <div style={{ marginBottom: 48 }}>
          <Reveal><Eyebrow>POUR QUI ON BOSSE</Eyebrow></Reveal>
          <Reveal>
            <h2 className="display display-l" style={{ margin: '20px 0 0', maxWidth: 800 }}>
              Trois mondes — un même <span className="italic-accent">terrain</span>
            </h2>
          </Reveal>
        </div>
        <Reveal stagger>
          <div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 20 }} className="profiles-grid">
            {PROFILES.map((p, i) =>
            <MagCard key={p.id} style={{ padding: 0, overflow: 'hidden' }}>
                <div style={{
                aspectRatio: '16/9',
                background: '#000',
                position: 'relative',
                overflow: 'hidden',
                borderBottom: '1px solid var(--line-2)'
              }}>
                  <div style={{
                  position: 'absolute', inset: 0,
                  background: 'linear-gradient(135deg, var(--deep) 0%, var(--electric) 100%)',
                  opacity: 0.7
                }}></div>
                  <div style={{
                  position: 'absolute', inset: 0,
                  backgroundImage: 'radial-gradient(circle at 30% 50%, rgba(251,220,116,0.3), transparent 50%)'
                }}></div>
                  <span style={{
                  position: 'absolute', bottom: 16, left: 18,
                  fontFamily: 'var(--f-mono)', fontSize: 10, letterSpacing: '0.18em',
                  textTransform: 'uppercase', color: 'rgba(255,255,255,0.85)'
                }}>PROFIL · 0{i + 1}</span>
                </div>
                <div style={{ padding: 28 }}>
                  <h3 className="display" style={{ fontSize: 28, margin: '0 0 4px' }}>
                    {p.title}<br />
                    <span className="italic-accent" style={{ fontSize: 28 }}>{p.sub}</span>
                  </h3>
                  <p style={{ color: 'var(--muted)', fontSize: 15, lineHeight: 1.6, margin: '12px 0 0' }}>
                    {p.desc}
                  </p>
                </div>
              </MagCard>
            )}
          </div>
        </Reveal>
      </div>
      <style>{`
        @media (max-width: 980px) { .profiles-grid { grid-template-columns: 1fr !important; } }
      `}</style>
    </section>);

}

Object.assign(window, { HomePage, HomeHero, HomeManifesto, HomeStats, HomeMarquee, MarqueeRow, HomeProfiles, SERVICES, STATS, PROFILES, MARQUEE_ITEMS, MARQUEE_ITEMS2, HERO_PLACES, HERO_CIBLES, MISSION_SECTEURS, useRotator });