// app.jsx — Portfolio Raphaël MRLC
// Apple-inspired dark portfolio, accent: aurora gradient.

// ── Brevo ──────────────────────────────────────────────────────────────────
const BREVO_API_KEY  = "REMPLACER_PAR_TA_CLE_BREVO";
const BREVO_SENDER   = { name: "Raphaël MRLC", email: "raphael.mrlc@gmail.com" };
const OWNER_EMAIL    = "raphael.mrlc@gmail.com";

async function brevoSend({ to, subject, html }) {
  const res = await fetch("https://api.brevo.com/v3/smtp/email", {
    method: "POST",
    headers: { "Content-Type": "application/json", "api-key": BREVO_API_KEY },
    body: JSON.stringify({ sender: BREVO_SENDER, to, subject, htmlContent: html }),
  });
  if (!res.ok) throw new Error(await res.text());
}

const TWEAK_DEFAULTS = /*EDITMODE-BEGIN*/{
  "accent": "orange",
  "heroVisual": "aurora",
  "density": "spacious",
  "font": "geist",
  "showGrain": true
}/*EDITMODE-END*/;

// ── Accents ────────────────────────────────────────────────────────────────
const ACCENTS = {
  orange:  { a: "#F97316", b: "#EA580C", c: "#FBBF24", solid: "#F97316" },
  aurora:  { a: "#A78BFA", b: "#60A5FA", c: "#34D399", solid: "#8B9DFF" },
  blue:    { a: "#0A84FF", b: "#0A84FF", c: "#0A84FF", solid: "#0A84FF" },
  violet:  { a: "#7C3AED", b: "#7C3AED", c: "#7C3AED", solid: "#7C3AED" },
  neon:    { a: "#39FF94", b: "#39FF94", c: "#39FF94", solid: "#39FF94" },
};

const FONTS = {
  geist:    "'Geist', 'Inter', system-ui, -apple-system, sans-serif",
  inter:    "'Inter', system-ui, -apple-system, sans-serif",
  sf:       "-apple-system, 'SF Pro Display', 'Inter', system-ui, sans-serif",
};

// ── Reveal hook ────────────────────────────────────────────────────────────
function useReveal() {
  React.useEffect(() => {
    const els = document.querySelectorAll("[data-reveal]");
    if (!("IntersectionObserver" in window)) {
      els.forEach((el) => el.classList.add("is-in"));
      return;
    }
    const io = new IntersectionObserver(
      (entries) => {
        entries.forEach((e) => {
          if (e.isIntersecting) {
            e.target.classList.add("is-in");
            io.unobserve(e.target);
          }
        });
      },
      { threshold: 0.12, rootMargin: "0px 0px -40px 0px" }
    );
    els.forEach((el) => io.observe(el));
    return () => io.disconnect();
  });
}

// ── Hero parallax (tiny scale on scroll) ──────────────────────────────────
function useParallax(ref) {
  React.useEffect(() => {
    if (!ref.current) return;
    const onScroll = () => {
      const y = window.scrollY;
      if (ref.current) {
        ref.current.style.setProperty("--py", `${Math.min(y * 0.18, 120)}px`);
        ref.current.style.setProperty("--ps", `${1 + Math.min(y, 600) * 0.0004}`);
      }
    };
    onScroll();
    window.addEventListener("scroll", onScroll, { passive: true });
    return () => window.removeEventListener("scroll", onScroll);
  }, [ref]);
}

// ── Hero visual variants ───────────────────────────────────────────────────
function HeroAurora({ a, b, c }) {
  return (
    <div className="hero-aurora" aria-hidden>
      <div className="aurora-blob ab1" style={{ background: `radial-gradient(closest-side, ${a}cc, transparent 70%)` }} />
      <div className="aurora-blob ab2" style={{ background: `radial-gradient(closest-side, ${b}cc, transparent 70%)` }} />
      <div className="aurora-blob ab3" style={{ background: `radial-gradient(closest-side, ${c}aa, transparent 70%)` }} />
      <div className="aurora-veil" />
    </div>
  );
}

function HeroGrid({ solid }) {
  return (
    <div className="hero-grid" aria-hidden>
      <div className="grid-floor" style={{ "--accent": solid }} />
      <div className="grid-vignette" />
    </div>
  );
}

function HeroParticles({ solid }) {
  const dots = React.useMemo(
    () => Array.from({ length: 70 }, (_, i) => ({
      id: i,
      x: Math.random() * 100,
      y: Math.random() * 100,
      s: 1 + Math.random() * 2.5,
      d: 6 + Math.random() * 12,
      o: 0.25 + Math.random() * 0.5,
    })),
    []
  );
  return (
    <div className="hero-particles" aria-hidden>
      {dots.map((p) => (
        <span
          key={p.id}
          className="dot"
          style={{
            left: `${p.x}%`,
            top: `${p.y}%`,
            width: `${p.s}px`,
            height: `${p.s}px`,
            opacity: p.o,
            background: solid,
            animationDuration: `${p.d}s`,
            animationDelay: `${-Math.random() * p.d}s`,
          }}
        />
      ))}
      <div className="part-veil" />
    </div>
  );
}

function HeroHalo({ a, b }) {
  return (
    <div className="hero-halo" aria-hidden>
      <div className="halo-core" style={{ background: `radial-gradient(closest-side, ${a}, transparent 70%)` }} />
      <div className="halo-ring" style={{ background: `radial-gradient(closest-side, transparent 60%, ${b}55 65%, transparent 75%)` }} />
    </div>
  );
}

// ── Sections ───────────────────────────────────────────────────────────────
function Nav({ accent }) {
  const [scrolled, setScrolled] = React.useState(false);
  React.useEffect(() => {
    const onScroll = () => setScrolled(window.scrollY > 24);
    onScroll();
    window.addEventListener("scroll", onScroll, { passive: true });
    return () => window.removeEventListener("scroll", onScroll);
  }, []);
  return (
    <nav className={`nav ${scrolled ? "is-scrolled" : ""}`}>
      <div className="nav-inner">
        <a href="#top" className="brand">
          <span className="brand-mark" style={{ background: `linear-gradient(135deg, ${accent.a}, ${accent.b}, ${accent.c})` }} />
          <span>Raphaël MRLC</span>
        </a>
        <div className="nav-links">
          <a href="#services">Services</a>
          <a href="#work">Réalisations</a>
          <a href="#why">Pourquoi moi</a>
          <a href="#contact">Contact</a>
        </div>
        <a href="#contact" className="nav-cta">Me contacter →</a>
      </div>
    </nav>
  );
}

function useScrollProgress(ref) {
  const [progress, setProgress] = React.useState(0);
  React.useEffect(() => {
    const update = () => {
      if (!ref.current) return;
      const rect = ref.current.getBoundingClientRect();
      const total = ref.current.offsetHeight + window.innerHeight;
      const filled = window.innerHeight - rect.top;
      setProgress(Math.max(0, Math.min(1, filled / total)));
    };
    update();
    window.addEventListener("scroll", update, { passive: true });
    return () => window.removeEventListener("scroll", update);
  }, []);
  return progress;
}

function Hero({ accent }) {
  const containerRef = React.useRef(null);
  const progress = useScrollProgress(containerRef);
  const [isMobile, setIsMobile] = React.useState(false);
  React.useEffect(() => {
    const check = () => setIsMobile(window.innerWidth <= 768);
    check();
    window.addEventListener("resize", check);
    return () => window.removeEventListener("resize", check);
  }, []);

  const p        = Math.min(progress * 1.724, 1);
  const rotate   = 40 * (1 - p);
  const scale    = isMobile ? 0.7 + 0.2 * p : 1.1 - 0.1 * p;
  const titleY   = -200 * p;

  return (
    <section id="top" className="hs-container" ref={containerRef}>
      <div className="hs-inner" style={{ perspective: "1000px" }}>

        <div className="hs-title" style={{ transform: `translateY(${titleY}px)` }}>
          <div className="eyebrow" style={{ justifyContent: "center" }}>
            <span className="dot-pulse" style={{ background: accent.solid }} />
            Disponible pour de nouveaux projets
          </div>
          <h1 className="hero-title">
            <span className="line">Je conçois.</span>
            <span className="line">J'automatise.</span>
            <span className="line gradient" style={{
              backgroundImage: `linear-gradient(120deg, ${accent.a}, ${accent.b} 50%, ${accent.c})`
            }}>Vous gagnez du temps.</span>
          </h1>
        </div>

        <div className="hs-card-wrap" style={{
          transform: `rotateX(${rotate}deg) scale(${scale})`,
        }}>
          <div className="hs-card">
            <div className="hs-card-inner">
              <iframe
                src="https://player.vimeo.com/video/1188011551?badge=0&autopause=0&autoplay=1&muted=1&loop=1&background=1&controls=0&dnt=1"
                title="Podologue Posturologue"
                frameBorder="0"
                allow="autoplay; fullscreen; picture-in-picture"
                allowFullScreen
              />
            </div>
          </div>
        </div>

        <div className="hs-ctas">
          <a href="#work" className="btn btn-primary" style={{
            background: `linear-gradient(120deg, ${accent.a}, ${accent.b} 60%, ${accent.c})`
          }}>Voir mes réalisations</a>
          <a href="#contact" className="btn btn-ghost">
            Me contacter
            <svg width="14" height="14" viewBox="0 0 14 14" fill="none">
              <path d="M3 7h8M7 3l4 4-4 4" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round"/>
            </svg>
          </a>
        </div>

      </div>
    </section>
  );
}

function Services({ accent }) {
  const items = [
    {
      kicker: "01",
      title: "Création de sites web",
      desc:
        "Je conçois des sites rapides, élégants et stratégiques, pensés pour donner de la crédibilité à votre marque et générer des résultats concrets.",
      tags: ["E-commerce", "Gestion locative", "Prise de rendez-vous"],
      icon: (
        <svg width="28" height="28" viewBox="0 0 28 28" fill="none">
          <rect x="3" y="5" width="22" height="16" rx="2.5" stroke="currentColor" strokeWidth="1.4"/>
          <path d="M3 9h22M7 13h6M7 16h10" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round"/>
        </svg>
      ),
    },
    {
      kicker: "02",
      title: "Agents IA & solutions intelligentes",
      desc:
        "J’intègre des agents IA utiles, connectés à votre activité, pour automatiser des actions, améliorer l’expérience client et accélérer vos opérations.",
      tags: ["OpenAI", "Claude", "Algolia", "API"],
      icon: (
        <svg width="28" height="28" viewBox="0 0 28 28" fill="none">
          <circle cx="6" cy="14" r="3" stroke="currentColor" strokeWidth="1.4"/>
          <circle cx="22" cy="6" r="3" stroke="currentColor" strokeWidth="1.4"/>
          <circle cx="22" cy="22" r="3" stroke="currentColor" strokeWidth="1.4"/>
          <path d="M9 14l10-7M9 14l10 7" stroke="currentColor" strokeWidth="1.4"/>
        </svg>
      ),
    },
    {
      kicker: "03",
      title: "Création de sites web",
      desc:
        "Landings, sites vitrine et e-commerce qui chargent vite, convertissent, et tiennent la promesse de la marque. Du wireframe au déploiement.",
      tags: ["Webflow", "Next.js", "Wordpress", "Shopify"],
      icon: (
        <svg width="28" height="28" viewBox="0 0 28 28" fill="none">
          <rect x="3" y="5" width="22" height="16" rx="2.5" stroke="currentColor" strokeWidth="1.4"/>
          <path d="M3 9h22M7 13h6M7 16h10" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round"/>
        </svg>
      ),
    },
    {
      kicker: "04",
      title: "Automatisation & digital",
      desc:
        "Workflows n8n / Make / Zapier, intégrations API, scripts internes. On supprime les tâches répétitives et on connecte vos outils.",
      tags: ["n8n", "Make", "Zapier", "OpenAI"],
      icon: (
        <svg width="28" height="28" viewBox="0 0 28 28" fill="none">
          <circle cx="6" cy="14" r="3" stroke="currentColor" strokeWidth="1.4"/>
          <circle cx="22" cy="6" r="3" stroke="currentColor" strokeWidth="1.4"/>
          <circle cx="22" cy="22" r="3" stroke="currentColor" strokeWidth="1.4"/>
          <path d="M9 14l10-7M9 14l10 7" stroke="currentColor" strokeWidth="1.4"/>
        </svg>
      ),
    },
  ];
  return (
    <section id="services" className="section services">
      <header className="section-head">
        <div className="section-kicker" data-reveal>Ce que je fais</div>
        <h2 className="section-title" data-reveal>
          Deux métiers. <span className="dim">Un même obsession :</span> ce qui marche, livré vite.
        </h2>
      </header>
      <div className="services-grid">
        {items.map((it, i) => (
          <article
            key={i}
            className="service-card"
            data-reveal
            style={{ "--i": i }}
          >
            <div className="service-glow" style={{
              background: `radial-gradient(400px 200px at var(--mx,50%) var(--my,0%), ${accent.solid}22, transparent 70%)`
            }} />
            <div className="service-icon" style={{ color: accent.solid }}>{it.icon}</div>
            <div className="service-kicker">{it.kicker}</div>
            <h3 className="service-title">{it.title}</h3>
            <p className="service-desc">{it.desc}</p>
            <div className="service-tags">
              {it.tags.map((t) => <span key={t} className="tag">{t}</span>)}
            </div>
            <a className="service-link" href="#contact">
              En discuter
              <svg width="12" height="12" viewBox="0 0 14 14" fill="none">
                <path d="M3 7h8M7 3l4 4-4 4" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round"/>
              </svg>
            </a>
          </article>
        ))}
      </div>
    </section>
  );
}

function Work({ accent }) {
  const projects = [
    {
      title: "Podologue Posturologue",
      domain: "podologue-villeneuve-beziers.fr",
      vimeoId: "1188011551",
      desc: "Refonte d'un site vitrine pour un studio paysagiste — +38% de demandes de devis.",
      tags: ["Animation au scroll", "Wordpress", "Modèles 3D"],
      hue1: "#0E1F1A", hue2: "#173E33",
      label: "PROJECT 01"
    },
    {
      title: "Maison de vacances",
      domain: "ty-gwennili.com",
      vimeoId: "1188011565",
      desc: "Automatisation de l'onboarding client pour un cabinet de conseil (n8n + Notion + Stripe).",
      tags: ["Plan interactif", "Réservation en ligne", "Calendrier synchronisé"],
      hue1: "#1A1230", hue2: "#3B1B6B",
      label: "PROJECT 02"
    },
    {
      title: "CRM Vins · Direction",
      domain: "chateau-margaux-crm.fr",
      screenshot: "assets/dashboard-vin.webp",
      desc: "Dashboard de pilotage des ventes pour une maison de négoce — suivi d'équipe commerciale, pipeline devis et analyse du mix canal en temps réel.",
      tags: ["Dashboard Analytics", "CRM", "Vins & Spiritueux"],
      hue1: "#1a0e0e", hue2: "#3d1a1a",
      label: "PROJECT 03"
    },
    {
      title: "Medifeedback · E-réputation",
      domain: "medifeedback.fr",
      screenshot: "assets/dashboard-medi-feed-back.webp",
      desc: "Plateforme de gestion des avis Google pour cabinets médicaux — réponses assistées par IA, suivi de patientèle et pilotage de l'e-réputation.",
      tags: ["E-réputation", "Google Reviews", "IA"],
      hue1: "#0d1433", hue2: "#1a2a6b",
      label: "PROJECT 04"
    },
    {
      title: "Hôtel Belavista",
      desc: "Site multilingue + automatisation des réservations directes et réponses email IA.",
      tags: ["Wordpress", "Zapier", "OpenAI"],
      hue1: "#2B1F0E", hue2: "#5A4318",
      label: "PROJECT 05"
    },
    {
      title: "Studio Linéa",
      desc: "Portfolio motion design avec galerie immersive et capture de leads par projet.",
      tags: ["Next.js", "GSAP", "Framer"],
      hue1: "#171717", hue2: "#2E2E2E",
      label: "PROJECT 06"
    },
  ];

  const onMove = (e) => {
    const card = e.currentTarget;
    const r = card.getBoundingClientRect();
    card.style.setProperty("--mx", `${((e.clientX - r.left) / r.width) * 100}%`);
    card.style.setProperty("--my", `${((e.clientY - r.top) / r.height) * 100}%`);
  };

  return (
    <section id="work" className="section work">
      <header className="section-head">
        <div className="section-kicker" data-reveal>Réalisations</div>
        <h2 className="section-title" data-reveal>
          Sélection de projets <span className="dim">récents.</span>
        </h2>
        <p className="section-lede" data-reveal>
          Six projets. Six contraintes différentes. Une même méthode : comprendre le problème,
          livrer vite, mesurer, itérer.
        </p>
      </header>

      <div className="work-grid">
        {projects.map((p, i) => (
          <a
            key={p.title}
            href="#contact"
            className="proj-card"
            data-reveal
            style={{ "--i": i }}
            onMouseMove={onMove}
          >
            <div className="proj-mock" style={{
              background: `linear-gradient(135deg, ${p.hue1}, ${p.hue2})`
            }}>
              {p.vimeoId && (
                <div className="proj-video">
                  <iframe
                    src={`https://player.vimeo.com/video/${p.vimeoId}?badge=0&autopause=0&autoplay=1&muted=1&loop=1&background=1&controls=0&dnt=1`}
                    title={p.title}
                    frameBorder="0"
                    allow="autoplay; fullscreen; picture-in-picture"
                    allowFullScreen
                  />
                  <div className="proj-video-veil" />
                </div>
              )}
              {p.screenshot && (
                <div className="proj-screenshot">
                  <img src={p.screenshot} alt={p.title} />
                </div>
              )}
              <div className="proj-mock-shine" style={{
                background: `radial-gradient(600px 300px at var(--mx,50%) var(--my,50%), ${accent.solid}33, transparent 60%)`
              }} />

              {!p.vimeoId && !p.screenshot && (
                <div className="proj-mock-shapes">
                  <div className="shape s1" />
                  <div className="shape s2" />
                  <div className="shape s3" />
                </div>
              )}
              <div className="proj-label">{p.label}</div>
            </div>
            <div className="proj-body">
              <div className="proj-row">
                <h3 className="proj-title">{p.title}</h3>
                <span className="proj-arrow">
                  <svg width="14" height="14" viewBox="0 0 14 14" fill="none">
                    <path d="M3 11L11 3M5 3h6v6" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round"/>
                  </svg>
                </span>
              </div>
              <p className="proj-desc">{p.desc}</p>
              <div className="proj-tags">
                {p.tags.map((t) => <span key={t} className="tag">{t}</span>)}
              </div>
            </div>
          </a>
        ))}
      </div>
    </section>
  );
}

function Why({ accent }) {
  const items = [
    {
      n: "01",
      title: "Vitesse réelle",
      desc: "Premier livrable en 4 jours. Pas de réunions inutiles, pas de slides. Du code et des automatisations qui tournent.",
    },
    {
      n: "02",
      title: "Approche no-code/low-code",
      desc: "On choisit l'outil le plus simple qui résout le problème. Vous gardez la main, sans dépendance technique.",
    },
    {
      n: "03",
      title: "Suivi long-terme",
      desc: "Une fois livré, on ne disparaît pas. Maintenance, évolutions et mesures d'impact mensuelles.",
    },
    {
      n: "04",
      title: "Mesuré sur l'impact",
      desc: "Conversions, heures économisées, leads qualifiés. Si ça ne bouge pas l'aiguille, on n'en parle pas.",
    },
  ];
  return (
    <section id="why" className="section why">
      <header className="section-head">
        <div className="section-kicker" data-reveal>Pourquoi moi</div>
        <h2 className="section-title" data-reveal>
          Le travail freelance, <span className="dim">sans les inconvénients.</span>
        </h2>
      </header>
      <div className="why-grid">
        {items.map((it, i) => (
          <div key={it.n} className="why-card" data-reveal style={{ "--i": i }}>
            <div className="why-num" style={{ color: accent.solid }}>{it.n}</div>
            <h3 className="why-title">{it.title}</h3>
            <p className="why-desc">{it.desc}</p>
          </div>
        ))}
      </div>
    </section>
  );
}

function Contact({ accent }) {
  const EMPTY = { prenom: "", nom: "", email: "", telephone: "", entreprise: "", typeProjet: "", budget: "", message: "" };
  const [form, setForm]     = React.useState(EMPTY);
  const [status, setStatus] = React.useState("idle"); // idle | loading | success | error

  const onChange = (e) => setForm(f => ({ ...f, [e.target.name]: e.target.value }));

  const onSubmit = async (e) => {
    e.preventDefault();
    setStatus("loading");
    const fullName = `${form.prenom} ${form.nom}`.trim();
    try {
      // Notification à Raphaël
      await brevoSend({
        to: [{ email: OWNER_EMAIL, name: "Raphaël MRLC" }],
        subject: `📬 Nouveau contact — ${fullName} · ${form.typeProjet}`,
        html: `
          <div style="font-family:sans-serif;max-width:560px;margin:auto;color:#1a1a1a">
            <h2 style="margin:0 0 24px;font-size:22px">Nouveau message reçu</h2>
            <table style="width:100%;border-collapse:collapse;font-size:14px">
              <tr><td style="padding:8px 0;color:#666;width:160px">Nom</td><td style="padding:8px 0;font-weight:600">${fullName}</td></tr>
              <tr><td style="padding:8px 0;color:#666">Email</td><td style="padding:8px 0"><a href="mailto:${form.email}">${form.email}</a></td></tr>
              ${form.telephone ? `<tr><td style="padding:8px 0;color:#666">Téléphone</td><td style="padding:8px 0">${form.telephone}</td></tr>` : ""}
              ${form.entreprise ? `<tr><td style="padding:8px 0;color:#666">Entreprise</td><td style="padding:8px 0">${form.entreprise}</td></tr>` : ""}
              <tr><td style="padding:8px 0;color:#666">Type de projet</td><td style="padding:8px 0">${form.typeProjet}</td></tr>
              ${form.budget ? `<tr><td style="padding:8px 0;color:#666">Budget</td><td style="padding:8px 0">${form.budget}</td></tr>` : ""}
            </table>
            <div style="margin-top:24px;padding:20px;background:#f5f5f5;border-radius:8px;font-size:14px;line-height:1.6;white-space:pre-wrap">${form.message}</div>
          </div>`,
      });
      // Confirmation personnalisée au contact
      await brevoSend({
        to: [{ email: form.email, name: fullName }],
        subject: `Bonjour ${form.prenom}, on se parle bientôt 👋`,
        html: `
          <div style="font-family:sans-serif;max-width:560px;margin:auto;color:#1a1a1a">
            <h2 style="margin:0 0 8px;font-size:22px">Merci ${form.prenom} !</h2>
            <p style="color:#555;font-size:15px;line-height:1.6;margin:0 0 20px">
              J'ai bien reçu votre message concernant <strong>${form.typeProjet.toLowerCase()}</strong>.
              Je reviens vers vous sous <strong>24 h</strong> pour fixer un premier appel — sans engagement — afin de cadrer ensemble votre besoin.
            </p>
            <p style="color:#555;font-size:15px;line-height:1.6;margin:0 0 32px">
              En attendant, n'hésitez pas à consulter <a href="https://raphaelmrlc.fr/#work" style="color:#F97316">mes réalisations</a> ou à me contacter directement sur
              <a href="https://wa.me/0760419157" style="color:#F97316">WhatsApp</a>.
            </p>
            <p style="font-size:14px;color:#888;border-top:1px solid #eee;padding-top:20px;margin:0">
              Raphaël MRLC · Freelance Web &amp; Automatisation<br>
              <a href="mailto:${OWNER_EMAIL}" style="color:#F97316">${OWNER_EMAIL}</a>
            </p>
          </div>`,
      });
      setStatus("success");
    } catch {
      setStatus("error");
    }
  };

  const accent1 = accent.a, accent2 = accent.b, accent3 = accent.c;
  const gradStyle = { backgroundImage: `linear-gradient(120deg, ${accent1}, ${accent2} 50%, ${accent3})` };

  return (
    <section id="contact" className="section contact">
      <div className="contact-card" data-reveal>
        <div className="contact-glow" style={{
          background: `radial-gradient(800px 400px at 50% 0%, ${accent.solid}22, transparent 60%)`
        }} />
        <div className="section-kicker">Contact</div>
        <h2 className="contact-title">
          Un projet en tête ?{" "}
          <span className="gradient" style={gradStyle}>Parlons-en.</span>
        </h2>
        <p className="contact-sub">
          Remplissez le formulaire — je vous réponds sous 24 h pour fixer un premier appel offert.
        </p>

        {status === "success" ? (
          <div className="contact-success">
            <div className="contact-success-icon" style={{ background: `linear-gradient(135deg, ${accent1}, ${accent3})` }}>
              <svg width="28" height="28" viewBox="0 0 24 24" fill="none">
                <path d="M5 13l4 4L19 7" stroke="#fff" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
              </svg>
            </div>
            <h3>Message envoyé !</h3>
            <p>Un email de confirmation vient de vous être envoyé. Je reviens vers vous sous 24 h.</p>
            <button className="btn btn-ghost" style={{ marginTop: 8 }} onClick={() => { setStatus("idle"); setForm(EMPTY); }}>
              Envoyer un autre message
            </button>
          </div>
        ) : (
          <form className="contact-form" onSubmit={onSubmit} noValidate>
            <div className="form-row">
              <div className="form-group">
                <label className="form-label" htmlFor="cf-prenom">Prénom *</label>
                <input id="cf-prenom" className="form-input" type="text" name="prenom" value={form.prenom} onChange={onChange} placeholder="Jean" required />
              </div>
              <div className="form-group">
                <label className="form-label" htmlFor="cf-nom">Nom *</label>
                <input id="cf-nom" className="form-input" type="text" name="nom" value={form.nom} onChange={onChange} placeholder="Dupont" required />
              </div>
            </div>
            <div className="form-row">
              <div className="form-group">
                <label className="form-label" htmlFor="cf-email">Email *</label>
                <input id="cf-email" className="form-input" type="email" name="email" value={form.email} onChange={onChange} placeholder="jean@exemple.fr" required />
              </div>
              <div className="form-group">
                <label className="form-label" htmlFor="cf-telephone">Téléphone</label>
                <input id="cf-telephone" className="form-input" type="tel" name="telephone" value={form.telephone} onChange={onChange} placeholder="+33 6 00 00 00 00" />
              </div>
            </div>
            <div className="form-row">
              <div className="form-group">
                <label className="form-label" htmlFor="cf-entreprise">Entreprise</label>
                <input id="cf-entreprise" className="form-input" type="text" name="entreprise" value={form.entreprise} onChange={onChange} placeholder="Nom de votre structure" />
              </div>
              <div className="form-group">
                <label className="form-label" htmlFor="cf-budget">Budget estimé</label>
                <select id="cf-budget" className="form-input form-select" name="budget" value={form.budget} onChange={onChange}>
                  <option value="">Non défini</option>
                  <option>Moins de 500 €</option>
                  <option>500 – 2 000 €</option>
                  <option>2 000 – 5 000 €</option>
                  <option>5 000 – 10 000 €</option>
                  <option>Plus de 10 000 €</option>
                </select>
              </div>
            </div>
            <div className="form-group">
              <label className="form-label" htmlFor="cf-type">Type de projet *</label>
              <select id="cf-type" className="form-input form-select" name="typeProjet" value={form.typeProjet} onChange={onChange} required>
                <option value="">Sélectionner…</option>
                <option>Site web sur-mesure</option>
                <option>Automatisation / No-code</option>
                <option>Site web + Automatisation</option>
                <option>Refonte de site existant</option>
                <option>Audit &amp; conseil</option>
                <option>Autre</option>
              </select>
            </div>
            <div className="form-group">
              <label className="form-label" htmlFor="cf-message">Décrivez votre projet *</label>
              <textarea id="cf-message" className="form-input form-textarea" name="message" value={form.message} onChange={onChange} placeholder="Parlez-moi de votre projet, vos objectifs, vos contraintes…" required rows={5} />
            </div>
            {status === "error" && (
              <p className="form-error">Une erreur est survenue. Réessayez ou contactez-moi directement par email.</p>
            )}
            <button
              type="submit"
              className="form-submit btn btn-primary"
              style={gradStyle}
              disabled={status === "loading"}
            >
              {status === "loading" ? (
                <><span className="form-spinner" /> Envoi en cours…</>
              ) : (
                <>Envoyer ma demande <svg width="14" height="14" viewBox="0 0 14 14" fill="none"><path d="M3 7h8M7 3l4 4-4 4" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round"/></svg></>
              )}
            </button>
          </form>
        )}

        <div className="contact-socials">
          <a href="https://www.linkedin.com/in/raphaelmarlec/" target="_blank" rel="noreferrer">
            <svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor"><path d="M3.5 2a1.5 1.5 0 100 3 1.5 1.5 0 000-3zM2.25 6.25h2.5v7.5h-2.5v-7.5zM6.5 6.25h2.4v1.05h.03c.34-.6 1.16-1.23 2.4-1.23 2.55 0 3.02 1.6 3.02 3.7v3.98h-2.5v-3.53c0-.84-.02-1.92-1.21-1.92-1.22 0-1.4.9-1.4 1.85v3.6h-2.5v-7.5z"/></svg>
            LinkedIn
          </a>
          <span className="dotsep" />
          <a href="https://wa.me/0760419157" target="_blank" rel="noreferrer">
            <svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor"><path d="M13.601 2.326A7.85 7.85 0 0 0 7.994 0C3.627 0 .068 3.558.064 7.926c0 1.399.366 2.76 1.057 3.965L0 16l4.204-1.102a7.9 7.9 0 0 0 3.79.965h.004c4.368 0 7.926-3.558 7.93-7.93A7.9 7.9 0 0 0 13.6 2.326zM7.994 14.521a6.6 6.6 0 0 1-3.356-.92l-.24-.144-2.494.654.666-2.433-.156-.251a6.56 6.56 0 0 1-1.007-3.505c0-3.626 2.957-6.584 6.591-6.584a6.56 6.56 0 0 1 4.66 1.931 6.56 6.56 0 0 1 1.928 4.66c-.004 3.639-2.961 6.592-6.592 6.592m3.615-4.934c-.197-.099-1.17-.578-1.353-.646-.182-.065-.315-.099-.445.099-.133.197-.513.646-.627.775-.114.133-.232.148-.43.05-.197-.1-.836-.308-1.592-.985-.59-.525-.985-1.175-1.103-1.372-.114-.198-.011-.304.088-.403.087-.088.197-.232.296-.346.1-.114.133-.198.198-.33.065-.134.034-.248-.015-.347-.05-.099-.445-1.076-.612-1.47-.16-.389-.323-.335-.445-.34-.114-.007-.247-.007-.38-.007a.73.73 0 0 0-.529.247c-.182.198-.691.677-.691 1.654s.71 1.916.81 2.049c.098.133 1.394 2.132 3.383 2.992.47.205.84.326 1.129.418.475.152.904.129 1.246.08.38-.058 1.171-.48 1.338-.943.164-.464.164-.86.114-.943-.049-.084-.182-.133-.38-.232"/></svg>
            WhatsApp
          </a>
        </div>
      </div>
    </section>
  );
}

function Footer() {
  const year = new Date().getFullYear();
  return (
    <footer className="footer">
      <div className="footer-inner">
        <span>© {year} Raphaël MRLC — Auto-entrepreneur</span>
        <div className="footer-links">
          <a href="#services">Services</a>
          <a href="#work">Réalisations</a>
          <a href="#contact">Contact</a>
          <a href="#">Mentions légales</a>
        </div>
      </div>
    </footer>
  );
}

// ── App ────────────────────────────────────────────────────────────────────
function App() {
  const [t, setTweak] = useTweaks(TWEAK_DEFAULTS);
  const accent = ACCENTS[t.accent] || ACCENTS.aurora;
  useReveal();

  React.useEffect(() => {
    document.documentElement.style.setProperty("--font-stack", FONTS[t.font] || FONTS.geist);
    document.documentElement.dataset.density = t.density;
    document.documentElement.dataset.grain = t.showGrain ? "on" : "off";
  }, [t.font, t.density, t.showGrain]);

  return (
    <div className="page" style={{ fontFamily: FONTS[t.font] || FONTS.geist }}>
      <Nav accent={accent} />
      <Hero accent={accent} heroVisual={t.heroVisual} />
      <Services accent={accent} />
      <Work accent={accent} />
      <Why accent={accent} />
      <Contact accent={accent} />
      <Footer />

      <TweaksPanel title="Tweaks">
        <TweakSection label="Visuel">
          <TweakRadio
            label="Hero"
            value={t.heroVisual}
            options={[
              { value: "aurora", label: "Aurora" },
              { value: "grid", label: "Grille" },
              { value: "particles", label: "Particules" },
              { value: "halo", label: "Halo" },
            ]}
            onChange={(v) => setTweak("heroVisual", v)}
          />
          <TweakSelect
            label="Accent"
            value={t.accent}
            options={[
              { value: "aurora", label: "Aurora (gradient)" },
              { value: "blue", label: "Bleu électrique" },
              { value: "violet", label: "Violet" },
              { value: "neon", label: "Vert néon" },
            ]}
            onChange={(v) => setTweak("accent", v)}
          />
          <TweakToggle label="Grain" value={t.showGrain} onChange={(v) => setTweak("showGrain", v)} />
        </TweakSection>
        <TweakSection label="Typographie">
          <TweakRadio
            label="Police"
            value={t.font}
            options={[
              { value: "geist", label: "Geist" },
              { value: "inter", label: "Inter" },
              { value: "sf", label: "SF" },
            ]}
            onChange={(v) => setTweak("font", v)}
          />
          <TweakRadio
            label="Densité"
            value={t.density}
            options={[
              { value: "compact", label: "Compact" },
              { value: "regular", label: "Regular" },
              { value: "spacious", label: "Spacious" },
            ]}
            onChange={(v) => setTweak("density", v)}
          />
        </TweakSection>
      </TweaksPanel>
    </div>
  );
}

const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(<App />);
