// ============================================================================
// MOVA RELOCATION — Sections 3 : Témoignages, Fondateur, Contact, Footer
// ============================================================================

// ----------------------------------------------------------------------------
// 9. TÉMOIGNAGES — carousel auto
// ----------------------------------------------------------------------------
function TestimonialsSection({ scrollRef }) {
  const t = useT();
  const [idx, setIdx] = useState(0);
  const [ref, inView] = useInView({ threshold: 0.3 });
  const y = useScrollY(scrollRef);
  const parallax = y * 0.18;

  useEffect(() => {
    if (!inView) return;
    const intv = setInterval(() => {
      setIdx((i) => (i + 1) % TESTIMONIALS.length);
    }, 7000);
    return () => clearInterval(intv);
  }, [inView]);

  return (
    <section
      ref={ref}
      data-screen-label="09 Témoignages"
      style={{
        position: "relative",
        background: "var(--mova-black)",
        color: "var(--mova-cream)",
        padding: "180px 32px",
        overflow: "hidden",
      }}
    >
      {/* BG parallax flou */}
      <div
        aria-hidden="true"
        style={{
          position: "absolute",
          inset: 0,
          transform: `translateY(${parallax}px)`,
          opacity: 0.22,
        }}
      >
        <svg
          viewBox="0 0 1600 900"
          preserveAspectRatio="xMidYMid slice"
          style={{ width: "100%", height: "100%", filter: "blur(8px)" }}
        >
          <defs>
            <linearGradient id="testimBg" x1="0" x2="1" y1="0" y2="1">
              <stop offset="0%" stopColor="#3a3122" />
              <stop offset="100%" stopColor="#0a0907" />
            </linearGradient>
          </defs>
          <rect width="1600" height="900" fill="url(#testimBg)" />
          <g stroke="rgba(184,148,76,0.4)" strokeWidth="0.8" fill="none">
            <path d="M0 600 C 400 500 800 700 1200 580 S 1600 620 1600 620" />
            <path d="M0 700 C 400 620 800 800 1200 680 S 1600 720 1600 720" />
          </g>
          {/* Lustres / lumières */}
          <g fill="rgba(212,180,112,0.6)">
            <circle cx="300" cy="200" r="6" />
            <circle cx="800" cy="180" r="8" />
            <circle cx="1280" cy="220" r="5" />
          </g>
        </svg>
      </div>
      <div
        aria-hidden="true"
        style={{
          position: "absolute",
          inset: 0,
          background:
            "linear-gradient(180deg, rgba(10,10,10,0.85) 0%, rgba(10,10,10,0.85) 100%)",
        }}
      />

      <div
        style={{
          position: "relative",
          maxWidth: 900,
          margin: "0 auto",
          textAlign: "center",
        }}
      >
        <Reveal>
          <Eyebrow center>{t("testimonials.eyebrow")}</Eyebrow>
        </Reveal>

        <div style={{ position: "relative", minHeight: 320, marginTop: 24 }}>
          {TESTIMONIALS.map((tm, i) => (
            <div
              key={i}
              style={{
                position: i === idx ? "relative" : "absolute",
                inset: 0,
                opacity: i === idx ? 1 : 0,
                transition: "opacity 800ms cubic-bezier(0.22,0.61,0.36,1)",
                display: "flex",
                flexDirection: "column",
                alignItems: "center",
                justifyContent: "center",
                gap: 36,
              }}
            >
              <div
                aria-hidden="true"
                style={{
                  fontFamily: "var(--font-serif)",
                  fontSize: 72,
                  lineHeight: 0.5,
                  color: "var(--mova-gold)",
                  opacity: 0.4,
                }}
              >
                "
              </div>
              <blockquote
                style={{
                  margin: 0,
                  fontFamily: "var(--font-serif)",
                  fontStyle: "italic",
                  fontWeight: 300,
                  fontSize: "clamp(24px, 2.6vw, 38px)",
                  lineHeight: 1.4,
                  color: "var(--mova-cream)",
                  maxWidth: 760,
                  textWrap: "balance",
                }}
              >
                {t(`testimonials.${tm.key}.quote`)}
              </blockquote>
              <div
                style={{
                  height: 0.5,
                  width: 40,
                  background: "var(--mova-gold)",
                }}
              />
              <div>
                <div
                  style={{
                    fontFamily: "var(--font-sans)",
                    fontSize: 11,
                    letterSpacing: "0.42em",
                    color: "var(--mova-gold)",
                    textTransform: "uppercase",
                  }}
                >
                  {t(`testimonials.${tm.key}.attribution`)}
                </div>
                <div
                  style={{
                    marginTop: 8,
                    fontFamily: "var(--font-sans)",
                    fontSize: 10,
                    letterSpacing: "0.32em",
                    color: "rgba(245,240,230,0.5)",
                    textTransform: "uppercase",
                  }}
                >
                  {tm.meta || t(`testimonials.${tm.key}.meta`)}
                </div>
              </div>
            </div>
          ))}
        </div>

        <div
          style={{
            marginTop: 64,
            display: "flex",
            justifyContent: "center",
            gap: 14,
          }}
        >
          {TESTIMONIALS.map((_, i) => (
            <button
              key={i}
              onClick={() => setIdx(i)}
              aria-label={`Voir témoignage ${i + 1}`}
              style={{
                width: 8,
                height: 8,
                borderRadius: "50%",
                background:
                  i === idx ? "var(--mova-gold)" : "transparent",
                border: "0.5px solid var(--mova-gold)",
                cursor: "pointer",
                padding: 0,
                transition: "background 320ms ease",
              }}
            />
          ))}
        </div>
      </div>
    </section>
  );
}

// ----------------------------------------------------------------------------
// 10. FONDATEUR — portrait + bio
// ----------------------------------------------------------------------------
function FounderSection({ scrollRef }) {
  const t = useT();
  const sectionRef = useRef(null);
  const [offset, setOffset] = useState(0);

  useEffect(() => {
    const onScroll = () => {
      if (!sectionRef.current) return;
      const rect = sectionRef.current.getBoundingClientRect();
      const vh = window.innerHeight;
      const p = (vh - rect.top) / (vh + rect.height);
      const o = (p - 0.5) * 40; // -20 → +20
      setOffset(Math.max(-20, Math.min(20, o)));
    };
    onScroll();
    window.addEventListener("scroll", onScroll, { passive: true });
    return () => window.removeEventListener("scroll", onScroll);
  }, []);

  return (
    <section
      id="fondateur"
      ref={sectionRef}
      data-screen-label="10 Fondateur"
      style={{
        background: "var(--mova-cream)",
        color: "var(--mova-black)",
        padding: "160px 48px",
      }}
    >
      <div
        className="mova-founder-grid"
        style={{
          display: "grid",
          gridTemplateColumns: "40% 60%",
          gap: 96,
          maxWidth: 1280,
          margin: "0 auto",
          alignItems: "center",
        }}
      >
        <Reveal>
          <div
            className="mova-founder-portrait"
            style={{
              position: "relative",
              maxWidth: 380,
              transform: `translateY(${offset}px)`,
              transition: "transform 120ms linear",
            }}
          >
            <div
              style={{
                position: "absolute",
                inset: "-12px",
                border: "0.5px solid var(--mova-gold)",
                pointerEvents: "none",
              }}
            />
            <div
              style={{
                aspectRatio: "4/5",
                overflow: "hidden",
                boxShadow: "0 20px 60px -20px rgba(10,10,10,0.15)",
              }}
            >
              <img
                src="assets/theo-sainte-rose.jpg"
                alt="Théo Sainte-Rose, fondateur de MOVA Relocation"
                style={{
                  width: "100%",
                  height: "100%",
                  objectFit: "cover",
                  objectPosition: "top",
                  filter: "saturate(0.92) contrast(1.02)",
                  display: "block",
                }}
              />
            </div>
            <div
              style={{
                marginTop: 18,
                fontFamily: "ui-monospace, Menlo, monospace",
                fontSize: 10,
                letterSpacing: "0.25em",
                color: "var(--mova-muted)",
                textAlign: "right",
              }}
            >
              T.S.R. — PARIS, 2026
            </div>
          </div>
        </Reveal>

        <div>
          <Reveal>
            <Eyebrow>{t("founder.eyebrow")}</Eyebrow>
          </Reveal>
          <Reveal delay={120}>
            <h2
              style={{
                fontFamily: "var(--font-serif)",
                fontWeight: 400,
                fontSize: "clamp(38px, 4.8vw, 64px)",
                lineHeight: 1.1,
                margin: 0,
              }}
            >
              Théo <span style={{ fontStyle: "italic" }}>Sainte-Rose</span>
            </h2>
          </Reveal>
          <Reveal delay={250}>
            <div
              style={{
                height: 0.5,
                width: 60,
                background: "var(--mova-gold)",
                margin: "32px 0",
              }}
            />
          </Reveal>
          <div
            style={{
              fontFamily: "var(--font-sans)",
              fontWeight: 300,
              fontSize: 17,
              lineHeight: 1.85,
              color: "var(--mova-black)",
              maxWidth: 620,
              display: "flex",
              flexDirection: "column",
              gap: 24,
            }}
          >
            <Reveal delay={350}>
              <p style={{ margin: 0, textWrap: "pretty" }}>
                {t("founder.p1")}{" "}
                <span style={{ fontStyle: "italic", color: "var(--mova-muted)" }}>
                  {t("founder.p1Italic")}
                </span>
              </p>
            </Reveal>
            <Reveal delay={450}>
              <p style={{ margin: 0, textWrap: "pretty" }}>
                {t("founder.p2")}
              </p>
            </Reveal>
            <Reveal delay={550}>
              <p style={{ margin: 0, textWrap: "pretty" }}>
                {t("founder.p3")}
              </p>
            </Reveal>
            <Reveal delay={650}>
              <p
                style={{
                  margin: 0,
                  color: "var(--mova-gold)",
                  fontWeight: 500,
                  fontFamily: "var(--font-serif)",
                  fontStyle: "italic",
                  fontSize: 22,
                }}
              >
                {t("founder.p4")}
              </p>
            </Reveal>
            <Reveal delay={780}>
              <div style={{ marginTop: 20, display: "flex", gap: 28, alignItems: "center" }}>
                <span
                  style={{
                    fontFamily: "ui-monospace, Menlo, monospace",
                    fontSize: 10,
                    letterSpacing: "0.25em",
                    color: "var(--mova-muted)",
                  }}
                >
                  {t("founder.signature")}
                </span>
              </div>
            </Reveal>
          </div>
        </div>
      </div>
    </section>
  );
}

// ----------------------------------------------------------------------------
// 11. CONTACT / CTA FINAL
// ----------------------------------------------------------------------------
function ContactSection() {
  const t = useT();
  const lines = [
    t("contact.line1"),
    t("contact.line2"),
    t("contact.line3"),
    { text: t("contact.line4"), gold: true, italic: true },
  ];
  const [ref, inView] = useInView({ threshold: 0.3 });

  return (
    <section
      id="contact"
      ref={ref}
      data-screen-label="11 Contact"
      style={{
        background: "var(--mova-black)",
        color: "var(--mova-cream)",
        padding: "160px 32px",
        minHeight: "100vh",
        display: "flex",
        alignItems: "center",
        justifyContent: "center",
        position: "relative",
      }}
    >
      <div
        aria-hidden="true"
        style={{
          position: "absolute",
          inset: "40px",
          border: "0.5px solid rgba(184,148,76,0.16)",
          pointerEvents: "none",
        }}
      />
      <div style={{ maxWidth: 1100, textAlign: "center" }}>
        <Reveal>
          <Eyebrow center>{t("contact.eyebrow")}</Eyebrow>
        </Reveal>
        <h2
          style={{
            fontFamily: "var(--font-serif)",
            fontWeight: 400,
            fontSize: "clamp(36px, 5vw, 68px)",
            lineHeight: 1.2,
            margin: 0,
            textWrap: "balance",
          }}
        >
          {lines.map((l, i) => {
            const isObj = typeof l === "object";
            const text = isObj ? l.text : l;
            const style = isObj
              ? { color: l.gold ? "var(--mova-gold)" : undefined, fontStyle: l.italic ? "italic" : undefined }
              : {};
            return (
              <span
                key={i}
                style={{
                  display: "block",
                  opacity: inView ? 1 : 0,
                  transform: `translateY(${inView ? 0 : 24}px)`,
                  transition: `opacity 800ms ease ${i * 150}ms, transform 800ms cubic-bezier(0.22,0.61,0.36,1) ${i * 150}ms`,
                  ...style,
                }}
              >
                {text}
              </span>
            );
          })}
        </h2>

        <Reveal delay={800}>
          <div style={{ marginTop: 64 }}>
            <PillButton href={WHATSAPP_URL} variant="cream" size="lg">
              {t("contact.cta")}
            </PillButton>
          </div>
        </Reveal>

        <Reveal delay={950}>
          <div
            style={{
              marginTop: 56,
              display: "flex",
              justifyContent: "center",
              gap: 40,
              flexWrap: "wrap",
            }}
          >
            <a
              href="mailto:contact@movarelocation.com"
              style={contactLinkStyle}
              className="mova-contact-link"
            >
              {t("contact.email")}
            </a>
            <a
              href="https://www.instagram.com/mova.relocation/"
              target="_blank"
              rel="noopener noreferrer"
              style={contactLinkStyle}
              className="mova-contact-link"
            >
              {t("contact.instagram")}
            </a>
            <a
              href={WHATSAPP_URL}
              target="_blank"
              rel="noopener noreferrer"
              style={contactLinkStyle}
              className="mova-contact-link"
            >
              {t("contact.whatsapp")}
            </a>
          </div>
        </Reveal>
      </div>
    </section>
  );
}

const contactLinkStyle = {
  fontFamily: "var(--font-sans)",
  fontWeight: 300,
  fontSize: 13,
  letterSpacing: "0.32em",
  color: "var(--mova-cream)",
  textTransform: "uppercase",
  textDecoration: "none",
  borderBottom: "0.5px solid rgba(184,148,76,0.4)",
  paddingBottom: 4,
  transition: "color 320ms ease, border-color 320ms ease",
};

// ----------------------------------------------------------------------------
// 12. FOOTER
// ----------------------------------------------------------------------------
function Footer() {
  const t = useT();
  const { lang, setLang } = useLang();
  return (
    <footer
      style={{
        background: "var(--mova-black)",
        color: "var(--mova-cream)",
        padding: "80px 48px 32px",
        borderTop: "0.5px solid rgba(184,148,76,0.18)",
      }}
    >
      <div
        className="mova-footer-grid"
        style={{
          display: "grid",
          gridTemplateColumns: "1.4fr 1fr 1fr",
          gap: 80,
          maxWidth: 1380,
          margin: "0 auto",
        }}
      >
        {/* Col 1 — Logo + adresse */}
        <div>
          <MovaWordmark size={22} stacked />
          <div
            style={{
              marginTop: 32,
              fontFamily: "var(--font-sans)",
              fontWeight: 300,
              fontSize: 13,
              lineHeight: 1.7,
              color: "rgba(245,240,230,0.65)",
              maxWidth: 280,
            }}
          >
            231 Rue Saint-Honoré
            <br />
            75001 Paris
          </div>
          <div
            style={{
              marginTop: 18,
              fontFamily: "var(--font-sans)",
              fontWeight: 300,
              fontSize: 12,
              letterSpacing: "0.2em",
              color: "rgba(184,148,76,0.7)",
            }}
          >
            FR · EU
          </div>
        </div>

        {/* Col 2 — Liens */}
        <div>
          <div
            style={{
              fontFamily: "var(--font-sans)",
              fontSize: 10,
              letterSpacing: "0.42em",
              color: "var(--mova-gold)",
              textTransform: "uppercase",
              marginBottom: 20,
            }}
          >
            {t("footer.infos")}
          </div>
          <ul style={{ listStyle: "none", padding: 0, margin: 0, display: "flex", flexDirection: "column", gap: 12 }}>
            {[
              { label: t("footer.mentions"), href: "#mentions-legales" },
              { label: t("footer.privacy"), href: "#politique-de-confidentialite" },
              { label: t("footer.contact"), href: "#contact" },
            ].map((l) => (
              <li key={l.label}>
                <a
                  href={l.href}
                  style={{
                    fontFamily: "var(--font-sans)",
                    fontWeight: 300,
                    fontSize: 13,
                    color: "rgba(245,240,230,0.75)",
                    textDecoration: "none",
                    transition: "color 320ms ease",
                  }}
                  className="mova-footer-link"
                >
                  {l.label}
                </a>
              </li>
            ))}
          </ul>
        </div>

        {/* Col 3 — Langue + réseaux */}
        <div>
          <div
            style={{
              fontFamily: "var(--font-sans)",
              fontSize: 10,
              letterSpacing: "0.42em",
              color: "var(--mova-gold)",
              textTransform: "uppercase",
              marginBottom: 20,
            }}
          >
            {t("footer.langue")}
          </div>
          <div style={{ display: "flex", alignItems: "center", gap: 4, marginBottom: 36 }}>
            {LANGUAGES.map((l, i) => (
              <React.Fragment key={l}>
                {i > 0 && (
                  <span style={{ color: "rgba(245,240,230,0.25)", fontSize: 12, padding: "0 6px" }}>|</span>
                )}
                <button
                  onClick={() => setLang(l)}
                  style={{
                    background: "transparent",
                    border: "none",
                    cursor: "pointer",
                    padding: "4px 2px",
                    fontFamily: "var(--font-sans)",
                    fontSize: 11,
                    letterSpacing: "0.32em",
                    color: lang === l ? "var(--mova-gold)" : "rgba(245,240,230,0.5)",
                    transition: "color 320ms ease",
                  }}
                >
                  {l}
                </button>
              </React.Fragment>
            ))}
          </div>

          <div
            style={{
              fontFamily: "var(--font-sans)",
              fontSize: 10,
              letterSpacing: "0.42em",
              color: "var(--mova-gold)",
              textTransform: "uppercase",
              marginBottom: 16,
            }}
          >
            {t("footer.suivre")}
          </div>
          <div style={{ display: "flex", gap: 18 }}>
            <a
              href="https://www.instagram.com/mova.relocation/"
              target="_blank"
              rel="noopener noreferrer"
              aria-label="Instagram"
              style={{ color: "var(--mova-gold)" }}
            >
              <Icon name="instagram" size={28} />
            </a>
            <a href="https://www.linkedin.com/in/th%C3%A9o-sainte-rose-749a5b410/" target="_blank" rel="noopener noreferrer" aria-label="LinkedIn de Théo Sainte-Rose" style={{ color: "var(--mova-gold)" }}>
              <Icon name="linkedin" size={28} />
            </a>
          </div>
        </div>
      </div>

      <div
        style={{
          marginTop: 80,
          paddingTop: 28,
          borderTop: "0.5px solid rgba(184,148,76,0.14)",
          textAlign: "center",
          fontFamily: "var(--font-sans)",
          fontWeight: 300,
          fontSize: 11,
          letterSpacing: "0.22em",
          color: "rgba(245,240,230,0.5)",
          textTransform: "uppercase",
        }}
      >
        {t("footer.copyright")}
      </div>
    </footer>
  );
}

Object.assign(window, {
  TestimonialsSection,
  FounderSection,
  ContactSection,
  Footer,
});
