// ─────────────────────────────────────────────────────────────
// Mezoo — Page Étude de cas (Hortis SA · pièce n°47)
// Editorial layout with tech proof side-bar. Demonstrates the same
// hybrid system applied to a content-heavy page.
// ─────────────────────────────────────────────────────────────

function CasePage() {
  useReveal();
  const { go } = useRouter();

  return (
    <main className="mz-page">
      {/* ── Header ───────────────────────────────────────────── */}
      <section style={{ paddingBlock: 'var(--s-7)', borderBottom: '1px solid var(--hairline)' }}>
        <div className="mz-container-wide">
          <Reveal style={{ display: 'flex', alignItems: 'center', gap: 'var(--s-3)' }}>
            <button onClick={() => go('home')} className="mz-link" style={{ fontSize: 13, color: 'var(--fg-muted)' }}>← Atelier</button>
            <span className="mz-mono" style={{ color: 'var(--fg-subtle)' }}>/</span>
            <span className="mz-mono" style={{ color: 'var(--fg-subtle)' }}>Pièce 47</span>
          </Reveal>

          <Reveal delay={80} style={{ marginTop: 'var(--s-5)' }}>
            <Eyebrow>Hortis SA — Refonte 2025</Eyebrow>
          </Reveal>

          <Reveal delay={140} as="h1" className="mz-display-xl"
            style={{ marginTop: 'var(--s-5)', maxWidth: '18ch' }}>
            Reconstruire <Em>cinq sites locaux</Em> en un seul outil métier.
          </Reveal>

          <Reveal delay={220} className="mz-lead"
            style={{ marginTop: 'var(--s-6)', maxWidth: '64ch' }}>
            Hortis SA exploite cinq enseignes horticoles régionales sous une bannière commune.
            Chaque site avait été codé séparément, à dix ans d'intervalle, par trois prestataires
            différents. Un back-office partagé essayait de tenir l'ensemble. <Em>L'ensemble fuyait
            de partout.</Em> 40 heures de maintenance par mois, un score Lighthouse moyen de 54,
            zéro déploiement en moins de 6h. Onze jours plus tard, le tout marche sur un
            seul outil — score 99, ops divisées par six, et zéro régression à 90 jours.
          </Reveal>
        </div>
      </section>

      {/* ── Vitals ───────────────────────────────────────────── */}
      <section style={{ paddingBlock: 'var(--s-6)', borderBottom: '1px solid var(--hairline)' }}>
        <div className="mz-container-wide" style={{
          display: 'grid', gridTemplateColumns: 'repeat(6, 1fr)', gap: 'var(--s-4)',
        }}>
          {[
            ['Secteur', 'Horticulture pro.'],
            ['Effectif client', '240 personnes'],
            ['Durée', '11 jours ouvrés'],
            ['Équipe Mezoo', '2 seniors'],
            ['Stack', 'Next · PG · Stripe'],
            ['Période', 'Q1 2025'],
          ].map(([k, v], i) => (
            <Reveal key={k} delay={i * 60} style={{ display: 'flex', flexDirection: 'column', gap: 4 }}>
              <span className="mz-mono" style={{ color: 'var(--fg-subtle)', letterSpacing: '0.12em', textTransform: 'uppercase' }}>{k}</span>
              <span style={{ fontSize: 18, fontFamily: 'var(--font-display)', fontWeight: 500, letterSpacing: '-0.02em', color: 'var(--fg)' }}>{v}</span>
            </Reveal>
          ))}
        </div>
      </section>

      {/* ── Cover capture ────────────────────────────────────── */}
      <section style={{ paddingBlock: 'var(--s-7)' }}>
        <div className="mz-container-wide">
          <Reveal>
            <ArchitectureDiagram />
          </Reveal>
        </div>
      </section>

      {/* ── Body grid ───────────────────────────────────────── */}
      <section style={{ paddingBlock: 'var(--s-7)' }}>
        <div className="mz-container-wide" style={{ display: 'grid', gridTemplateColumns: '1.4fr 1fr', gap: 'var(--s-8)', alignItems: 'flex-start' }}>

          {/* Body */}
          <div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--s-6)' }}>
            <Reveal>
              <Eyebrow>I — Contexte</Eyebrow>
              <h2 className="mz-h2" style={{ marginTop: 'var(--s-3)' }}>
                Cinq enseignes, <Em>une seule</Em> direction.
              </h2>
              <p className="mz-body" style={{ marginTop: 'var(--s-4)', maxWidth: '60ch' }}>
                Hortis SA fédère cinq pépinières historiques, chacune avec sa clientèle locale
                et son catalogue propre. La direction voulait préserver les marques régionales
                tout en consolidant le système d'information. Verdict : refonte complète,
                outil unique, déploiement par bascule sans interruption commerciale.
              </p>
            </Reveal>

            <Reveal>
              <Eyebrow>II — Diagnostic</Eyebrow>
              <h2 className="mz-h2" style={{ marginTop: 'var(--s-3)' }}>
                On a commencé par <Em>mesurer</Em>.
              </h2>
              <p className="mz-body" style={{ marginTop: 'var(--s-4)', maxWidth: '60ch' }}>
                Cinq jours d'audit côté code, sécurité, infrastructure, SEO. Restitution écrite
                de 42 pages remise sous deux semaines. Le constat tenait en une ligne :
                la dette technique cumulée coûtait plus cher à maintenir qu'à réécrire.
              </p>

              {/* Diagnostic stat block */}
              <div style={{ marginTop: 'var(--s-5)', display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 'var(--s-3)' }}>
                {[
                  ['54 / 100', 'Lighthouse moyen pré-refonte'],
                  ['6 h', 'Délai déploiement d\'un correctif'],
                  ['40 h / mois', 'Maintenance accumulée'],
                ].map(([v, l]) => (
                  <div key={l} style={{ border: '1px solid var(--hairline)', padding: 'var(--s-4)', display: 'flex', flexDirection: 'column', gap: 4 }}>
                    <span style={{ fontFamily: 'var(--font-display)', fontSize: 32, fontWeight: 500, letterSpacing: '-0.03em', color: 'var(--fg)' }}>{v}</span>
                    <span className="mz-mono" style={{ color: 'var(--fg-subtle)', letterSpacing: '0.08em', textTransform: 'uppercase' }}>{l}</span>
                  </div>
                ))}
              </div>
            </Reveal>

            <Reveal>
              <Eyebrow>III — Conception</Eyebrow>
              <h2 className="mz-h2" style={{ marginTop: 'var(--s-3)' }}>
                Un seul codebase, <Em>cinq vitrines</Em>.
              </h2>
              <p className="mz-body" style={{ marginTop: 'var(--s-4)', maxWidth: '60ch' }}>
                Architecture monorepo. Front en Next.js (App Router, RSC). CMS headless pour
                contenu éditorial régional. Catalogue unifié en PostgreSQL avec règles de
                visibilité par enseigne. Paiement Stripe. Hébergement AWS Frankfurt, CDN
                Cloudflare. Tout sous IaC, tout testé, tout documenté.
              </p>

              <div style={{ marginTop: 'var(--s-5)', display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 'var(--s-3)' }}>
                <AppDashboardMock />
                <CatalogGridMock />
              </div>
            </Reveal>

            <Reveal>
              <Eyebrow>IV — Livraison</Eyebrow>
              <h2 className="mz-h2" style={{ marginTop: 'var(--s-3)' }}>
                Onze jours ouvrés <Em>de bout en bout</Em>.
              </h2>
              <p className="mz-body" style={{ marginTop: 'var(--s-4)', maxWidth: '60ch' }}>
                Migration nuit du 18 mars. Bascule DNS à 03h00, mise en production validée
                à 03h41. Aucune commande perdue. Aucune URL cassée — 14 000 redirections
                301 pré-calculées. Trois mois plus tard, aucune ligne réécrite.
              </p>
            </Reveal>

            <Reveal>
              <blockquote style={{
                margin: 0, padding: 'var(--s-5) var(--s-6)',
                background: 'var(--brass-tint)', borderLeft: '2px solid var(--accent)',
                borderRadius: '0 var(--r-card) var(--r-card) 0',
              }}>
                <p style={{ fontFamily: 'var(--font-display)', fontSize: 26, lineHeight: 1.3, letterSpacing: '-0.015em', fontWeight: 500 }}>
                  « On avait trois devis. Mezoo était au milieu en prix, mais le seul
                  à <Em>refuser de chiffrer</Em> avant l'audit. C'est ça qui nous a décidés. »
                </p>
                <footer style={{ marginTop: 'var(--s-4)', fontSize: 13, color: 'var(--fg-muted)' }}>
                  Christine Vasseur, Directrice des opérations — Hortis SA
                </footer>
              </blockquote>
            </Reveal>
          </div>

          {/* Sticky tech sidebar */}
          <aside style={{ position: 'sticky', top: 100, display: 'flex', flexDirection: 'column', gap: 'var(--s-4)' }}>
            <Reveal delay={100}>
              <SpecCard title="Mesures · post-refonte" status="90 jours"
                meta={<><span>↳ Snapshot · 18 juin 2025</span><span>● Stable</span></>}>
                <div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--s-1)' }}>
                  <SpecRow k="LIGHTHOUSE PERF." v="99 / 100" />
                  <SpecRow k="LIGHTHOUSE ACC." v="100 / 100" />
                  <SpecRow k="LIGHTHOUSE SEO" v="100 / 100" />
                  <SpecRow k="TTFB · p50" v="76 ms" />
                  <SpecRow k="LCP · p75" v="1.1 s" />
                  <SpecRow k="CLS" v="0.00" />
                  <SpecRow k="SSL Labs" v="A+ · TLS 1.3" />
                  <SpecRow k="CVE OUVERTES" v="0" />
                </div>
              </SpecCard>
            </Reveal>

            <Reveal delay={200}>
              <SpecCard title="Stack — 18 dépendances" status="agnostique">
                <div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--s-1)' }}>
                  <SpecRow k="FRONT" v="Next 14 · RSC" />
                  <SpecRow k="CMS" v="Sanity v3" />
                  <SpecRow k="DB" v="PostgreSQL 16" />
                  <SpecRow k="PAIEMENT" v="Stripe + SCA" />
                  <SpecRow k="CLOUD" v="AWS EU-C-1" />
                  <SpecRow k="CDN / WAF" v="Cloudflare" />
                  <SpecRow k="OBSERVABILITÉ" v="Grafana + Sentry" />
                </div>
              </SpecCard>
            </Reveal>

            <Reveal delay={300}>
              <div style={{ border: '1px solid var(--hairline-strong)', padding: 'var(--s-4)' }}>
                <Eyebrow line={false}>Continue · Pièce 48</Eyebrow>
                <h4 style={{ margin: 'var(--s-3) 0 var(--s-2)', fontSize: 18, fontFamily: 'var(--font-display)', fontWeight: 500, letterSpacing: '-0.02em' }}>
                  Berger & Associés — <Em>portail client</Em>
                </h4>
                <p style={{ fontSize: 13, color: 'var(--fg-muted)', lineHeight: 1.5, margin: 0 }}>
                  Comment on a remplacé un échange de pièces jointes mail par un coffre-fort
                  conforme ISO 27001 — en 21 jours.
                </p>
                <button onClick={() => go('home')} className="mz-link" style={{ marginTop: 'var(--s-3)', fontSize: 13 }}>
                  Lire la pièce →
                </button>
              </div>
            </Reveal>
          </aside>
        </div>
      </section>

      {/* ── Closing CTA ──────────────────────────────────────── */}
      <section style={{ paddingBlock: 'var(--s-9)', background: 'var(--surface)', borderTop: '1px solid var(--hairline)' }}>
        <div className="mz-container-wide" style={{ display: 'flex', flexDirection: 'column', alignItems: 'flex-start', gap: 'var(--s-5)' }}>
          <Reveal>
            <Eyebrow>§ Démarrer · sous 48h</Eyebrow>
          </Reveal>
          <Reveal delay={80} as="h2" className="mz-display" style={{ maxWidth: '22ch' }}>
            On peut faire pareil avec votre <Em>outil métier</Em>.
          </Reveal>
          <Reveal delay={160} style={{ display: 'flex', gap: 12, flexWrap: 'wrap' }}>
            <button onClick={() => go('contact')} className="mz-btn mz-btn-primary">
              Prendre rendez-vous
              <svg width="13" height="13" viewBox="0 0 12 12" fill="none" stroke="currentColor" strokeWidth="1.4"><path d="M2 6h8M6 2l4 4-4 4" /></svg>
            </button>
            <button onClick={() => go('home')} className="mz-btn mz-btn-ghost">
              Voir les 47 pièces de l'atelier
            </button>
          </Reveal>
        </div>
      </section>
    </main>
  );
}

Object.assign(window, { CasePage });
