// ─────────────────────────────────────────────────────────────
// Mezoo — Page Manifeste
// Editorial long-form, structured around 3 piliers. Dense type,
// large pull-quotes, numbered articles with mono annotations.
// Designed to read like a manifesto folio more than a marketing page.
// ─────────────────────────────────────────────────────────────

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

  const pillars = [
    {
      n: 'I.',
      slug: 'ingenierie',
      eyebrow: 'Pilier I — Ingénierie durable',
      title: 'On ne livre pas un site. On livre un actif.',
      kicker: 'Anti-dette technique',
      body: [
        'La dette technique ne s\'efface pas. Elle se paie — en bugs, en heures de reprise, en migrations forcées tous les trois ans. Un site mal architecturé coûte deux à cinq fois son prix initial sur sa durée de vie.',
        'Chez Mezoo, chaque ligne de code est revue par un senior avant d\'atteindre la production. Chaque décision est documentée dans un journal d\'architecture lisible par un dirigeant non technicien. Chaque dépendance est justifiée par écrit.',
        'Nos clients gardent leurs plateformes huit à douze ans. C\'est notre standard. Pas notre ambition.',
      ],
      quote: 'Le bon code est celui qui se lit comme un contrat — clair, signé, et toujours valable dans dix ans.',
      specs: [
        ['DÉPENDANCES MOYENNES', '18 / projet'],
        ['REVUE SENIOR', '100% des PR'],
        ['DOCUMENTATION', 'À chaque commit'],
        ['DURÉE DE VIE TYP.', '8 — 12 ans'],
      ],
      principle: 'Nous refusons d\'écrire du code que nous ne saurions plus relire dans trois ans.',
    },
    {
      n: 'II.',
      slug: 'securite',
      eyebrow: 'Pilier II — Sécurité souveraine',
      title: 'Vos données ne franchissent pas la Manche.',
      kicker: 'Souveraineté & conformité',
      body: [
        'La sécurité n\'est pas un module à installer en option. C\'est l\'air dans lequel vit le code. Tout le reste — performance, design, fonctionnalités — doit s\'y plier, jamais l\'inverse.',
        'Nos déploiements par défaut : hébergement en Europe (AWS Frankfurt, OVH Sovereign, Scaleway), chiffrement de bout en bout, séparation stricte des environnements, audit OWASP avant chaque mise en production. Aucun service tiers n\'accède à vos données sans contrat de sous-traitance signé.',
        'Pour les structures qui le demandent, nous montons des architectures 100% souveraines, hébergées en France, certifiées ISO 27001 ou HDS. C\'est plus cher. C\'est non négociable quand vos clients sont eux-mêmes contraints.',
      ],
      quote: 'Une donnée sortie du territoire ne revient jamais. Mieux vaut qu\'elle ne sorte pas.',
      specs: [
        ['HÉBERGEMENT', 'Europe par défaut'],
        ['CHIFFREMENT', 'TLS 1.3 + at-rest'],
        ['AUDIT', 'OWASP · pré-prod'],
        ['CONFORMITÉ', 'RGPD · ISO · HDS'],
      ],
      principle: 'Nous traitons vos données comme nous voudrions qu\'on traite les nôtres : sous clé, et près de chez nous.',
    },
    {
      n: 'III.',
      slug: 'agnostique',
      eyebrow: 'Pilier III — Agnosticisme technologique',
      title: 'On choisit l\'outil pour le besoin. Pas par habitude.',
      kicker: 'Stack sur-mesure',
      body: [
        'Les agences à mono-stack — uniquement WordPress, uniquement Shopify, uniquement Webflow — vendent leur expertise, pas la vôtre. Quand on n\'a qu\'un marteau, tout ressemble à un clou. Y compris ce qui aurait dû être un boulon.',
        'Chez Mezoo, le diagnostic précède toujours la recommandation. On évalue six à huit options à chaque démarrage, par écrit, avec leurs forces et leurs limites. Le client choisit en connaissance de cause. On assume ensuite le choix pendant la durée de vie du projet.',
        'Aucun partenariat préférentiel ne biaise notre conseil. Aucune commission revendeur. Aucune offre packagée qui forcerait la solution. C\'est notre conviction la plus fragile à tenir commercialement, et la plus précieuse pour vous.',
      ],
      quote: 'Le bon outil est celui qui résout le problème — pas celui qu\'on a pris l\'habitude de vendre.',
      specs: [
        ['OPTIONS ÉVALUÉES', '6 — 8 / projet'],
        ['PARTENARIATS PRÉFÉRÉS', '0'],
        ['STACKS MAÎTRISÉES', '14 frameworks'],
        ['DÉCISION DOCUMENTÉE', 'Toujours'],
      ],
      principle: 'Nous refusons de recommander une technologie parce qu\'elle nous arrange. Nous la recommandons parce qu\'elle vous sert.',
    },
  ];

  return (
    <main className="mz-page">
      {/* ── Title page ───────────────────────────────────────── */}
      <section style={{ paddingBlock: 'var(--s-9)', borderBottom: '1px solid var(--hairline-strong)' }}>
        <div className="mz-container-wide">
          <Reveal style={{ display: 'grid', gridTemplateColumns: '1fr auto', gap: 'var(--s-5)', alignItems: 'flex-start' }}>
            <Eyebrow>Manifeste — édition MMXXVI · trois piliers</Eyebrow>
            <span className="mz-mono" style={{ color: 'var(--fg-subtle)', letterSpacing: '0.12em', textTransform: 'uppercase' }}>Folio · 12 pages</span>
          </Reveal>

          <Reveal delay={80} as="h1" className="mz-display-xl"
            style={{ marginTop: 'var(--s-6)', maxWidth: '16ch' }}>
            Ce qu'on défend, depuis <Em>1996</Em>.
          </Reveal>

          <Reveal delay={160} className="mz-lead"
            style={{ marginTop: 'var(--s-6)', maxWidth: '58ch' }}>
            Trente ans à concevoir, sécuriser et maintenir des plateformes pour des dirigeants
            qui ne tolèrent pas l'approximation. <Em>Ce texte tient en trois articles.</Em>
            Trois piliers, signés à la main, et tenus contre vents et marées commerciales.
          </Reveal>

          <Reveal delay={240} style={{ marginTop: 'var(--s-7)', display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 'var(--s-3)', borderTop: '1px solid var(--hairline)', paddingTop: 'var(--s-5)' }}>
            {pillars.map((p) => (
              <a key={p.slug} href={`#manifeste-${p.slug}`}
                onClick={(e) => { e.preventDefault(); document.getElementById(`manifeste-${p.slug}`)?.scrollIntoView({ behavior: 'smooth', block: 'start' }); }}
                style={{ display: 'flex', flexDirection: 'column', gap: 8, paddingRight: 'var(--s-3)' }}>
                <span className="mz-italic" style={{ fontSize: 32, lineHeight: 1 }}>{p.n}</span>
                <span style={{ fontSize: 18, fontFamily: 'var(--font-display)', fontWeight: 500, letterSpacing: '-0.02em' }}>{p.kicker}</span>
                <span className="mz-mono" style={{ color: 'var(--fg-subtle)', letterSpacing: '0.1em', textTransform: 'uppercase' }}>Lire l'article {p.n} →</span>
              </a>
            ))}
          </Reveal>
        </div>
      </section>

      {/* ── Three pillars ───────────────────────────────────── */}
      {pillars.map((p, idx) => (
        <PillarArticle key={p.slug} pillar={p} idx={idx} />
      ))}

      {/* ── Closing colophon ────────────────────────────────── */}
      <section style={{ paddingBlock: 'var(--s-9)', background: 'var(--surface)', borderTop: '1px solid var(--hairline-strong)' }}>
        <div className="mz-container-wide" style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 'var(--s-8)', alignItems: 'flex-end' }}>
          <Reveal>
            <Eyebrow>Colophon</Eyebrow>
            <h2 className="mz-display" style={{ marginTop: 'var(--s-4)', maxWidth: '14ch' }}>
              Manifeste signé en <Em>atelier</Em>.
            </h2>
            <p className="mz-lead" style={{ marginTop: 'var(--s-4)', maxWidth: '52ch' }}>
              Ce texte est révisé tous les deux ans. Il engage l'ensemble des associés et
              s'applique à 100% de nos projets, sans exception ni avenant commercial.
            </p>
          </Reveal>

          <Reveal delay={160}>
            <SpecCard title="Mentions techniques" status="2026 / I">
              <div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--s-1)' }}>
                <SpecRow k="ÉDITION" v="MMXXVI · I" />
                <SpecRow k="RÉVISION" v="03 mars 2026" />
                <SpecRow k="SIGNATAIRES" v="Tous associés" />
                <SpecRow k="EXCEPTIONS" v="Aucune" />
                <SpecRow k="LANGUES" v="FR · EN · DE" />
                <SpecRow k="DIFFUSION" v="CC-BY-ND 4.0" />
              </div>
            </SpecCard>
          </Reveal>
        </div>
      </section>

      {/* ── CTA ─────────────────────────────────────────────── */}
      <section style={{ paddingBlock: 'var(--s-9)' }}>
        <div className="mz-container-wide">
          <Reveal as="h2" className="mz-display-xl"
            style={{ maxWidth: '18ch' }}>
            Ces principes <Em>vous parlent</Em> ?<br />
            <span style={{ color: 'var(--fg-muted)' }}>Parlons-en pour de vrai.</span>
          </Reveal>
          <Reveal delay={120} style={{ marginTop: 'var(--s-6)', 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('case')} className="mz-btn mz-btn-ghost">
              Lire la pièce n°47
            </button>
          </Reveal>
        </div>
      </section>
    </main>
  );
}

// ─────────────────────────────────────────────────────────────
// One pillar article — editorial 2-col body + side spec card,
// closing principle in oversized italic serif.
// ─────────────────────────────────────────────────────────────
function PillarArticle({ pillar, idx }) {
  const isAlt = idx % 2 === 1;
  return (
    <section id={`manifeste-${pillar.slug}`}
      style={{
        paddingBlock: 'var(--s-9)',
        background: isAlt ? 'var(--surface)' : 'transparent',
        borderBottom: '1px solid var(--hairline)',
      }}>
      <div className="mz-container-wide">
        <Reveal style={{ display: 'grid', gridTemplateColumns: '1fr auto', alignItems: 'flex-start', gap: 'var(--s-5)' }}>
          <div>
            <Eyebrow>{pillar.eyebrow}</Eyebrow>
            <div style={{ marginTop: 'var(--s-4)', display: 'flex', alignItems: 'baseline', gap: 'var(--s-4)' }}>
              <span className="mz-italic" style={{ fontSize: 'clamp(64px, 8vw, 120px)', lineHeight: 0.9 }}>{pillar.n}</span>
              <span className="mz-mono" style={{ color: 'var(--fg-subtle)', letterSpacing: '0.14em', textTransform: 'uppercase', alignSelf: 'flex-start', marginTop: 16 }}>↳ {pillar.kicker}</span>
            </div>
          </div>
        </Reveal>

        <Reveal delay={120} as="h2" className="mz-display"
          style={{ marginTop: 'var(--s-6)', maxWidth: '20ch' }}>
          {pillar.title}
        </Reveal>

        <div style={{
          marginTop: 'var(--s-7)',
          display: 'grid', gridTemplateColumns: '1.5fr 1fr', gap: 'var(--s-8)', alignItems: 'flex-start',
        }}>
          <div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--s-5)' }}>
            {pillar.body.map((para, i) => (
              <Reveal key={i} delay={i * 80} className="mz-body"
                style={{ fontSize: 17, lineHeight: 1.65, maxWidth: '60ch', color: 'var(--fg)' }}>
                {i === 0 && (
                  <span style={{
                    fontFamily: 'var(--font-display)', fontSize: '4em', float: 'left',
                    lineHeight: 0.85, marginRight: 12, marginTop: 6, fontWeight: 500,
                    letterSpacing: '-0.04em', color: 'var(--accent)',
                  }}>{para.charAt(0)}</span>
                )}
                {i === 0 ? para.slice(1) : para}
              </Reveal>
            ))}
          </div>

          <Reveal delay={160} style={{ display: 'flex', flexDirection: 'column', gap: 'var(--s-4)', position: 'sticky', top: 100 }}>
            <SpecCard title={`Article ${pillar.n.replace('.', '')} · chiffres`} status="vérifié">
              <div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--s-1)' }}>
                {pillar.specs.map(([k, v]) => <SpecRow key={k} k={k} v={v} />)}
              </div>
            </SpecCard>

            <div style={{
              border: '1px solid var(--hairline-strong)', padding: 'var(--s-4) var(--s-5)',
              background: 'var(--brass-tint)',
            }}>
              <Eyebrow line={false}>Principe non négociable</Eyebrow>
              <p style={{
                marginTop: 'var(--s-3)', fontSize: 15, lineHeight: 1.5, color: 'var(--fg)',
                fontFamily: 'var(--font-display)', fontWeight: 500, letterSpacing: '-0.01em',
              }}>
                {pillar.principle}
              </p>
            </div>
          </Reveal>
        </div>

        {/* Pull quote */}
        <Reveal delay={300} as="blockquote" style={{
          margin: 'var(--s-9) 0 0', padding: 0, maxWidth: '22ch',
          fontFamily: 'var(--font-display)',
          fontSize: 'clamp(36px, 5.4vw, 92px)', fontWeight: 500,
          letterSpacing: '-0.04em', lineHeight: 1.0,
          color: 'var(--fg)', textWrap: 'balance',
        }}>
          <span aria-hidden style={{
            fontFamily: 'var(--font-serif)', fontStyle: 'italic',
            color: 'var(--accent)', fontSize: '1.2em', lineHeight: 0,
            verticalAlign: 'top', marginRight: '0.1em',
          }}>«</span>
          {' '}{pillar.quote}{' '}
          <span aria-hidden style={{
            fontFamily: 'var(--font-serif)', fontStyle: 'italic',
            color: 'var(--accent)', fontSize: '1.2em', lineHeight: 0,
            verticalAlign: 'top',
          }}>»</span>
        </Reveal>
        <Reveal delay={400} className="mz-mono" style={{
          display: 'block', marginTop: 'var(--s-4)', color: 'var(--fg-subtle)',
          letterSpacing: '0.12em', textTransform: 'uppercase',
        }}>
          ↳ extrait du registre · article {pillar.n.replace('.', '')}
        </Reveal>
      </div>
    </section>
  );
}

Object.assign(window, { ManifestePage });
