/* global React, ArrowUpRight */
const { useState: useS, useRef: useR } = React;
const SM = window.Motion.motion;

const rise = (delay = 0) => ({
  initial: { opacity: 0, y: 26, filter: "blur(8px)" },
  whileInView: { opacity: 1, y: 0, filter: "blur(0px)" },
  viewport: { once: true, margin: "-70px" },
  transition: { duration: 0.7, ease: "easeOut", delay },
});

const Section = ({ id, children, className = "", panel = false }) => (
  panel ? (
    <section id={id} className={"relative px-6 md:px-16 lg:px-20 py-16 md:py-24 border-t border-[#ededeb] " + className} style={{ background: "var(--bg)" }}>
      <div className="max-w-6xl mx-auto">{children}</div>
    </section>
  ) : (
    <section id={id} className={"relative px-6 md:px-16 lg:px-20 py-20 md:py-28 " + className} style={{ background: "var(--bg)" }}>
      <div className="max-w-6xl mx-auto">{children}</div>
    </section>
  )
);

const Em = ({ children }) => <span className="italic" style={{ color: "var(--accent)" }}>{children}</span>;

/* kicker/eyebrow - rótulo SF Pro em caixa-alta espaçada (pareia com a Awesome) */
const Kicker = ({ children, center }) => (
  <div className={"mb-4 " + (center ? "text-center" : "")}>
    <span className="text-[11px] tracking-[0.16em] uppercase font-body font-medium text-[#9a9088]">{children}</span>
  </div>
);

/* ------------- Seção 4 - De uma referência → LUT (emocional) ------------- */
function RefToLut() {
  const passos = [
    "Encontre uma imagem de tirar o fôlego",
    "Importe para a plataforma",
    "Ajuste alguns controles",
    "Baixe seu LUT",
    "Aplique em qualquer vídeo",
  ];
  return (
    <Section>
      <SM.div {...rise()}><Kicker>Como funciona</Kicker></SM.div>

      <div className="grid grid-cols-1 lg:grid-cols-2 gap-x-12 lg:gap-x-16 gap-y-14 items-start">

        {/* título (topo-esquerda) */}
        <SM.h2 {...rise(0.05)} className="font-heading text-[#1a1814] text-4xl md:text-6xl tracking-[-2px] leading-[1.02]">
          Da referência ao <Em>look pronto.</Em>
        </SM.h2>

        {/* intro (topo-direita) — alinha com o topo do título */}
        <SM.p {...rise(0.1)} className="text-base md:text-lg text-[#2b2b2b] font-body leading-relaxed max-w-md lg:mt-4">
          A maneira mais simples de transformar uma estética que você admira em um visual que você pode usar no seu conteúdo
        </SM.p>

        {/* vídeo placeholder (baixo-esquerda) */}
        <SM.div {...rise(0.15)} className="rounded-[1.25rem] overflow-hidden relative w-full" style={{ aspectRatio: "16 / 10", background: "var(--bg-2)" }}>
          <div className="absolute inset-0 flex flex-col items-center justify-center gap-4">
            <span className="w-16 h-16 rounded-full flex items-center justify-center" style={{ border: "1px solid #c9c4bb", color: "#9a9088" }}>
              <svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M8 5v14l11-7z" /></svg>
            </span>
            <span className="text-[11px] font-body uppercase" style={{ letterSpacing: "0.16em", color: "#9a9088" }}>Vídeo em breve</span>
          </div>
        </SM.div>

        {/* lista de passos (baixo-direita) */}
        <SM.ul {...rise(0.2)} className="flex flex-col gap-1 -mx-4">
          {passos.map((p) => (
            <li key={p} className="flex items-center gap-4 rounded-xl px-4 py-2 cursor-default transition-colors duration-300 hover:bg-[#eeece8]">
              <span className="shrink-0 w-1.5 h-1.5 rounded-full" style={{ background: "var(--accent)" }} />
              <span className="font-heading no-stroke text-[#1a1814] text-xl md:text-2xl leading-snug" style={{ letterSpacing: "-0.01em" }}>{p}</span>
            </li>
          ))}
          <li className="flex items-center gap-4 rounded-xl px-4 py-2 cursor-default transition-colors duration-300 bg-[#eeece8]/35">
            <span className="shrink-0 w-1.5 h-1.5 rounded-full" style={{ background: "var(--accent)" }} />
            <span className="font-heading no-stroke text-xl md:text-2xl leading-snug italic" style={{ color: "var(--accent)", letterSpacing: "-0.01em" }}>Pronto.</span>
          </li>
        </SM.ul>

      </div>
    </Section>
  );
}

/* --------- Seção 5 - Encontrar uma estética deveria ser simples (dor) --------- */
function ProblemSolution() {
  const dores = [
    "Entender de colorização",
    "Comprar dezenas de LUTs",
    "Testar um por um",
    "Ajustar na tentativa e erro",
    "Passar horas editando",
    "Torcer pra dar certo",
  ];
  const novo = ["Escolha uma referência", "Ajuste os controles", "Exporte o LUT"];
  const eyebrowLight = "text-[11px] tracking-[0.16em] uppercase font-body font-medium";
  return (
    <section className="relative w-full overflow-hidden grain-dark" style={{ background: "#1c1c1e" }}>
      {/* marca-d'água 幽玄 ao fundo (igual ao Manifesto) */}
      <span aria-hidden="true" style={{ position: "absolute", right: "-2%", top: "50%", transform: "translateY(-50%)", fontFamily: "'Noto Serif JP', serif", fontSize: "clamp(280px, 34vw, 540px)", lineHeight: 1, color: "rgba(255,255,255,0.04)", pointerEvents: "none", whiteSpace: "nowrap", letterSpacing: "0.04em", filter: "blur(11px)", zIndex: 0 }}>幽玄</span>

      <div className="relative max-w-6xl mx-auto px-6 md:px-10 py-24 md:py-32" style={{ zIndex: 1 }}>
        <SM.div {...rise()} className="mb-12 md:mb-20 max-w-4xl">
          <span className={eyebrowLight} style={{ color: "rgba(255,255,255,0.58)" }}>Por que a Yugen Grade</span>
          <h2 className="font-heading text-[#f7f5f2] text-4xl md:text-6xl tracking-[-2px] leading-[1.02] mt-5" style={{ textWrap: "balance" }}>
            Encontrar uma estética bonita <Em>não deveria ser um sufoco.</Em>
          </h2>
        </SM.div>

        <div className="grid grid-cols-1 lg:grid-cols-2 gap-x-12 lg:gap-x-20 gap-y-12 items-start">

          {/* SEM A YUGEN GRADE — problema, secundário (menor, mais apagado) */}
          <SM.div {...rise(0.1)}>
            <span className={eyebrowLight} style={{ color: "rgba(255,255,255,0.5)" }}>Sem a Yugen Grade</span>
            <ul className="mt-8 flex flex-col" style={{ gap: "16px" }}>
              {dores.map((d) => (
                <li key={d} className="font-heading no-stroke"
                    style={{ fontSize: "19px", lineHeight: 1.35, color: "rgba(255,255,255,0.5)", letterSpacing: "-0.01em" }}>
                  <span className="risco-fade risco-fade-dark">{d}</span>
                </li>
              ))}
            </ul>
            <p className="mt-7 font-heading no-stroke italic" style={{ fontSize: "15px", lineHeight: 1.4, color: "rgba(255,255,255,0.36)" }}>…e ainda sem garantia nenhuma</p>
          </SM.div>

          {/* COM A YUGEN GRADE — solução, ênfase (maior e mais claro); alinhado no topo, sem divisória */}
          <SM.div {...rise(0.18)} style={{ paddingTop: 0 }}>
            <span className={eyebrowLight} style={{ color: "var(--accent)" }}>Com a Yugen Grade</span>
            <ul className="mt-8 flex flex-col" style={{ gap: "24px" }}>
              {novo.map((p) => (
                <li key={p} className="font-heading no-stroke text-[#f7f5f2]" style={{ fontSize: "32px", lineHeight: 1.12, letterSpacing: "-0.02em" }}>
                  {p}
                </li>
              ))}
            </ul>
            <p className="mt-8 font-heading no-stroke italic text-lg" style={{ color: "var(--accent)" }}>…e o resultado já está pronto</p>
          </SM.div>

        </div>
      </div>
    </section>
  );
}

/* ------------- Seção 6 - Como funciona (técnico, 3 boxes + GIFs) ------------- */
function HowItWorks() {
  const passos = [
    { t: "Escolha uma referência", d: "Importe qualquer imagem ou selecione um dos looks da galeria", vid: "assets/video/passo-1.mp4" },
    { t: "Construa sua estética", d: "Intensidade, contraste, saturação, temperatura... Tudo em tempo real", vid: "assets/video/passo-2.mp4?v=2" },
    { t: "Exporte e aplique", d: "Baixe seu LUT e use no CapCut, Premiere, DaVinci, Final Cut ou BlackMagic", vid: "assets/video/passo-3.mp4?v=3" },
  ];
  // mobile: garante autoplay tocando cada vídeo quando entra na tela (mais confiável que só o atributo)
  React.useEffect(() => {
    const vids = Array.from(document.querySelectorAll("#como-funciona video"));
    if (!vids.length) return;
    const tryPlay = (v) => { v.muted = true; const p = v.play(); if (p && p.catch) p.catch(() => {}); };
    if (!("IntersectionObserver" in window)) { vids.forEach(tryPlay); return; }
    const io = new IntersectionObserver((entries) => {
      entries.forEach((e) => { if (e.isIntersecting) tryPlay(e.target); });
    }, { threshold: 0.2 });
    vids.forEach((v) => io.observe(v));
    return () => io.disconnect();
  }, []);
  return (
    <Section id="como-funciona" className="!pb-10 md:!pb-14">
      <SM.div {...rise()} className="mb-12 md:mb-16 max-w-3xl">
        <Kicker>Como funciona</Kicker>
        <h2 className="font-heading text-[#1a1814] text-4xl md:text-6xl tracking-[-2px] leading-[1.02]" style={{ textWrap: "balance" }}>
          Seu novo fluxo de cor em <Em>menos de 1 minuto.</Em>
        </h2>
        <p className="mt-5 text-base md:text-lg text-[#2b2b2b] font-body">
          Com mais qualidade e menos fricção.
        </p>
      </SM.div>

      <div className="grid grid-cols-1 md:grid-cols-3 gap-x-10 gap-y-12">
        {passos.map((p, i) => (
          <SM.div key={p.t} {...rise(0.1 + i * 0.08)}>
            {/* vídeo placeholder */}
            <div className="rounded-[1rem] overflow-hidden relative w-full" style={{ aspectRatio: "4 / 3", background: "var(--bg-2)", border: "1px solid rgba(26,24,20,0.08)" }}>
              {p.vid ? (
                <video src={p.vid} autoPlay muted loop playsInline preload="auto" ref={(el) => { if (el) { el.muted = true; const pr = el.play(); if (pr && pr.catch) pr.catch(() => {}); } }} className="absolute inset-0 w-full h-full" style={{ objectFit: "cover" }} />
              ) : (
                <div className="absolute inset-0 flex flex-col items-center justify-center gap-3">
                  <span className="w-14 h-14 rounded-full flex items-center justify-center" style={{ border: "1px solid #c9c4bb", color: "#9a9088" }}>
                    <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor"><path d="M8 5v14l11-7z" /></svg>
                  </span>
                  <span className="text-[11px] font-body uppercase" style={{ letterSpacing: "0.16em", color: "#9a9088" }}>Em breve</span>
                </div>
              )}
            </div>
            {/* título + descrição */}
            <h3 className="font-heading no-stroke text-[#1a1814] text-2xl md:text-3xl tracking-[-0.5px] leading-tight mt-6">{p.t}</h3>
            <p className="mt-3 text-base text-[#2b2b2b] font-body leading-relaxed">{p.d}</p>
          </SM.div>
        ))}
      </div>
    </Section>
  );
}

/* ----------- Card de look com slider antes/depois (sem × com o look) ----------- */
function LookSlider({ look, delay }) {
  const [pos, setPos] = useS(52);
  const stage = useR(null);
  const drag = useR(false);
  const vA = useR(null);   // depois
  const vB = useR(null);   // antes
  // vídeos tocam quando o look está visível na tela (ver useEffect); arrastar só move o corte
  const playVids = (on) => {
    const a = vA.current, b = vB.current;
    if (!a || !b) return;
    if (on) { b.currentTime = a.currentTime; a.play().catch(() => {}); b.play().catch(() => {}); }
    else { a.pause(); b.pause(); }
  };
  const set = (x) => {
    const r = stage.current.getBoundingClientRect();
    setPos(Math.max(4, Math.min(96, ((x - r.left) / r.width) * 100)));
  };
  // toca os vídeos quando o look entra na tela (pausa ao sair) — comparação "viva" sem precisar segurar.
  // Também força o 1º frame no iOS (que fica branco se o vídeo nunca tocou).
  React.useEffect(() => {
    const el = stage.current; if (!el) return;
    const t = setTimeout(() => {
      [vA.current, vB.current].forEach((v) => {
        if (v) { v.muted = true; const p = v.play(); if (p && p.then) p.then(() => v.pause()).catch(() => {}); }
      });
    }, 120);
    const io = new IntersectionObserver((ents) => { ents.forEach((e) => playVids(e.isIntersecting)); }, { threshold: 0.35 });
    io.observe(el);
    return () => { clearTimeout(t); io.disconnect(); };
  }, []);
  return (
    <SM.div {...rise(delay)} className="rounded-[1.25rem] overflow-hidden flex flex-col border border-[#ededeb]">
      {/* comparador antes/depois */}
      <div
        ref={stage}
        className="relative w-full select-none h-48 sm:h-52"
        style={{ cursor: "ew-resize", touchAction: "none" }}
        onPointerDown={(e) => { drag.current = true; set(e.clientX); e.currentTarget.setPointerCapture(e.pointerId); }}
        onPointerMove={(e) => { if (drag.current) set(e.clientX); }}
        onPointerUp={() => { drag.current = false; }}
        onPointerCancel={() => { drag.current = false; }}
      >
        {look.after ? (
          <>
            {/* DEPOIS - vídeo COM o look */}
            <video ref={vA} src={look.after} muted loop playsInline preload="auto" className="absolute inset-0 w-full h-full" style={{ objectFit: "cover" }} />
            {/* ANTES - vídeo cru, recortado pelo divisor */}
            <video ref={vB} src={look.before} muted loop playsInline preload="auto" className="absolute inset-0 w-full h-full" style={{ objectFit: "cover", clipPath: `inset(0 ${100 - pos}% 0 0)` }} />
          </>
        ) : (
          <>
            {/* DEPOIS - mockup gradiente (placeholder até ter vídeo) */}
            <div className={look.g + " absolute inset-0"} />
            {/* ANTES - cru */}
            <div className="g-raw absolute inset-0" style={{ clipPath: `inset(0 ${100 - pos}% 0 0)` }} />
          </>
        )}
        {/* labels */}
        <span className="absolute top-3 left-3 text-[10px] font-medium tracking-wide text-white bg-black/35 backdrop-blur-sm px-2.5 py-1 rounded-full z-10">Antes</span>
        <span className="absolute top-3 right-3 text-[10px] font-medium tracking-wide text-white bg-black/35 backdrop-blur-sm px-2.5 py-1 rounded-full z-10">Depois</span>
        {/* divisor + alça */}
        <div className="absolute top-0 bottom-0 w-0.5 bg-white/85 z-20" style={{ left: pos + "%", transform: "translateX(-1px)" }}>
          <div className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-8 h-8 rounded-full bg-white text-black flex items-center justify-center shadow-lg">
            <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.4" strokeLinecap="round" strokeLinejoin="round"><path d="M9 6l-6 6 6 6M15 6l6 6-6 6" /></svg>
          </div>
        </div>
      </div>
      {/* rodapé: nome + descrição */}
      <div className="p-5">
        <h3 className="font-heading text-[#1a1814] text-xl md:text-2xl tracking-[-0.5px] leading-tight">{look.nm}</h3>
      </div>
    </SM.div>
  );
}

/* ------------------------ Galeria de looks ---------------------- */
function LooksGallery() {
  const looks = [
    { g: "g-moss",    nm: "Moss",        ds: "verde musgo", before: "https://pub-76014c6578ed46e2882892c854766863.r2.dev/site/clips/moss-before.mp4", after: "https://pub-76014c6578ed46e2882892c854766863.r2.dev/site/clips/moss-after.mp4" },
    { g: "g-earth",   nm: "Earth",       ds: "terroso", before: "https://pub-76014c6578ed46e2882892c854766863.r2.dev/site/clips/earth2-before.mp4", after: "https://pub-76014c6578ed46e2882892c854766863.r2.dev/site/clips/earth2-after.mp4" },
    { g: "g-clean",   nm: "Clean",       ds: "neutro", before: "https://pub-76014c6578ed46e2882892c854766863.r2.dev/site/clips/clean-before.mp4", after: "https://pub-76014c6578ed46e2882892c854766863.r2.dev/site/clips/clean-after.mp4" },
    { g: "g-vintage", nm: "Vintage",     ds: "Kodak, analógico", w: true, before: "https://pub-76014c6578ed46e2882892c854766863.r2.dev/site/clips/vintage-before.mp4", after: "https://pub-76014c6578ed46e2882892c854766863.r2.dev/site/clips/vintage-after.mp4" },
    { g: "g-golden",  nm: "Golden Hour", ds: "dourado, externo, alto contraste", w: true, before: "https://pub-76014c6578ed46e2882892c854766863.r2.dev/site/clips/goldenhour-before.mp4", after: "https://pub-76014c6578ed46e2882892c854766863.r2.dev/site/clips/goldenhour-after.mp4" },
    { g: "g-matte",   nm: "Matte",       ds: "lavado, suave", before: "https://pub-76014c6578ed46e2882892c854766863.r2.dev/site/clips/matte-before.mp4", after: "https://pub-76014c6578ed46e2882892c854766863.r2.dev/site/clips/matte-after.mp4" },
    { g: "g-warm",    nm: "Warm",        ds: "quente, interno", before: "https://pub-76014c6578ed46e2882892c854766863.r2.dev/site/clips/warm-before.mp4", after: "https://pub-76014c6578ed46e2882892c854766863.r2.dev/site/clips/warm-after.mp4" },
    { g: "g-arctic",  nm: "Arctic",      ds: "azulado, frio", before: "https://pub-76014c6578ed46e2882892c854766863.r2.dev/site/clips/artic-before.mp4", after: "https://pub-76014c6578ed46e2882892c854766863.r2.dev/site/clips/artic-after.mp4" },
  ];
  return (
    <Section id="looks" className="!pt-10 md:!pt-14">
      <SM.div {...rise()} className="max-w-3xl mb-14">
        <Kicker>Galeria de looks</Kicker>
        <h2 className="font-heading text-[#1a1814] text-4xl md:text-6xl tracking-[-2px] leading-[1.02]">
          Criação ilimitada a partir das suas referências + <Em>8 looks prontos</Em>
        </h2>
      </SM.div>
      <div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-6 gap-4">
        {looks.map((l, i) => (
          <div key={l.nm} className={l.w ? "md:col-span-3" : "md:col-span-2"}>
            <LookSlider look={l} delay={0.04 * (i % 4)} />
          </div>
        ))}
      </div>
      <SM.div initial={{ opacity: 0 }} whileInView={{ opacity: 1 }} viewport={{ once: true, margin: "-70px" }} transition={{ duration: 0.6, ease: "easeOut", delay: 0.1 }} className="relative z-10 mt-16 md:mt-28 flex justify-center">
        <a href="#comprar" onClick={() => ygTrack("cta_click", { local: "looks" })} className="btn-breathe-gold btn-gold-strong" style={{ padding: "21px 56px", fontSize: 13 }}>Quero criar o meu look</a>
      </SM.div>
    </Section>
  );
}

/* --------------- Seção 7 - O que você recebe (plataforma) --------------- */
function WhatYouGet() {
  const features = [
    { t: "Yugen Grade", d: "Importe qualquer referência e use ela como ponto de partida" },
    { t: "Editor Visual", d: "Refine contraste, saturação, temperatura e intensidade em tempo real" },
    { t: "Visualização Instantânea", d: "Veja exatamente como o look ficará antes de exportar" },
    { t: "Exportação Profissional", d: "Baixe seus LUTs em formato .cube para qualquer editor" },
    { t: "Galeria de Looks", d: "8 estéticas prontas para usar como ponto de partida" },
    { t: "Conversão para LOG", d: "LUTs de conversão para diferentes perfis de câmera" },
  ];
  const modulos = [
    { n: "Módulo 1", t: "Como extrair a melhor qualidade da ferramenta", img: "assets/aula1.jpg?v=2" },
    { n: "Módulo 2", t: "Como usar o LUT no editor: CapCut, FinalCut, Premiere, DaVinci", img: "assets/aula2.jpg?v=2" },
    { n: "Módulo 3", t: "Como usar o LUT no celular: CapCut, BlackMagic Cam, VN", img: "assets/aula3.jpg?v=2" },
  ];
  const eyebrow = "text-[11px] tracking-[0.16em] uppercase font-body font-medium text-[#9a9088]";
  const Play = <svg width="15" height="15" viewBox="0 0 24 24" fill="currentColor"><path d="M8 5v14l11-7z" /></svg>;
  return (
    <Section>
      <SM.div {...rise()} className="mb-10 md:mb-14 max-w-4xl">
        <Kicker>O que está incluso</Kicker>
        <h2 className="font-heading text-[#1a1814] text-4xl md:text-6xl tracking-[-2px] leading-[1.04]" style={{ textWrap: "balance" }}>
          Muito mais do que um LUT. <Em>Uma plataforma completa.</Em>
        </h2>
      </SM.div>

      {/* grid: módulos fora do box · plataforma dentro do box */}
      <SM.div {...rise(0.08)} className="grid grid-cols-1 lg:grid-cols-2 gap-x-12 lg:gap-x-16 gap-y-12 items-center">

        {/* WORKFLOW EM VÍDEO — fora do box */}
        <div className="flex flex-col lg:py-2">
          <span className={eyebrow}>Workflow em vídeo</span>
          <div className="mt-7 flex flex-col gap-10">
            {modulos.map((m) => (
              <div key={m.n} className="relative w-full max-w-[400px] rounded-xl overflow-hidden" style={{ aspectRatio: "16 / 10" }}>
                {/* imagem ilustrativa com blur (não é vídeo real) */}
                <div className="absolute inset-0" style={{ backgroundImage: `url(${m.img})`, backgroundSize: "cover", backgroundPosition: "center", filter: "blur(2px)", transform: "scale(1.06)" }} />
                {/* gradiente p/ legibilidade do título no rodapé */}
                <div className="absolute inset-0" style={{ background: "linear-gradient(to top, rgba(18,16,13,0.86) 0%, rgba(18,16,13,0.32) 44%, rgba(18,16,13,0.12) 100%)" }} />
                {/* play apenas DEMONSTRATIVO (não é player real) — fosco/mesclado p/ não parecer clicável */}
                <div className="absolute inset-0 flex items-start justify-center" style={{ paddingTop: "27%" }}>
                  <span className="w-11 h-11 rounded-full flex items-center justify-center backdrop-blur-[2px]" style={{ background: "rgba(255,255,255,0.14)", border: "1px solid rgba(255,255,255,0.28)", color: "rgba(255,255,255,0.78)" }}>{Play}</span>
                </div>
                {/* título sobre o vídeo */}
                <div className="absolute inset-x-0 bottom-0 p-4 md:p-5">
                  <span className="text-[11px] tracking-[0.16em] uppercase font-body font-medium" style={{ color: "rgba(255,255,255,0.6)" }}>{m.n}</span>
                  <div className="font-heading no-stroke text-[#f7f5f2] text-lg md:text-xl leading-snug mt-1" style={{ letterSpacing: "-0.01em" }}>{m.t}</div>
                </div>
              </div>
            ))}
          </div>
        </div>

        {/* PLATAFORMA — dentro do box (bem sutil) */}
        <div className="rounded-[1.75rem] md:rounded-[2.5rem] px-6 md:px-10 py-10 md:py-12" style={{ background: "#f9f8f5" }}>
          <span className={eyebrow}>Plataforma</span>
          <ul className="mt-7 flex flex-col gap-7">
            {features.map((it) => (
              <li key={it.t} className="flex items-start gap-4">
                <span className="shrink-0 w-1.5 h-1.5 rounded-full mt-3" style={{ background: "var(--accent)" }} />
                <div>
                  <div className="font-heading no-stroke text-[#1a1814] text-xl md:text-2xl leading-snug" style={{ letterSpacing: "-0.01em" }}>{it.t}</div>
                  <div className="mt-1.5 text-base text-[#9a9088] font-body leading-relaxed">{it.d}</div>
                </div>
              </li>
            ))}
          </ul>
        </div>

      </SM.div>
    </Section>
  );
}

/* ------------------- Seção 8 - Manifesto / CTA emocional ------------------- */
function Manifesto() {
  return (
    <section className="relative w-full overflow-hidden grain-dark" style={{ background: "#1c1c1e" }}>
      {/* marca-d'água 幽玄 ao fundo */}
      <span aria-hidden="true" style={{ position: "absolute", right: "-2%", top: "50%", transform: "translateY(-50%)", fontFamily: "'Noto Serif JP', serif", fontSize: "clamp(280px, 34vw, 540px)", lineHeight: 1, color: "rgba(255,255,255,0.04)", pointerEvents: "none", whiteSpace: "nowrap", letterSpacing: "0.04em", filter: "blur(11px)", zIndex: 0 }}>幽玄</span>

      <div className="relative max-w-6xl mx-auto px-6 md:px-10 py-24 md:py-32" style={{ zIndex: 1 }}>
        <SM.div {...rise()} className="max-w-3xl">
          <p className="font-body" style={{ fontSize: 11, fontWeight: 500, letterSpacing: "0.16em", textTransform: "uppercase", color: "rgba(255,255,255,0.58)", margin: 0, marginBottom: 22 }}>
            Yugen Grade
          </p>
          <h2 className="font-heading text-[#f7f5f2] text-4xl md:text-6xl tracking-[-2px] leading-[1.02]" style={{ textWrap: "balance" }}>
            Não perca mais tempo com tutoriais de <Em>color grading.</Em>
          </h2>
          <p className="mt-7 text-lg md:text-xl font-body leading-relaxed max-w-2xl" style={{ color: "rgba(255,255,255,0.55)" }}>
            Comece a construir a sua assinatura visual e faça sua marca ser reconhecida. A Yugen Grade foi criada pra te ajudar a encontrar uma estética que pareça sua.
          </p>
          <SM.div {...rise(0.12)} className="mt-10">
            <a href="#comprar" onClick={() => ygTrack("cta_click", { local: "oferta" })} className="font-body btn-breathe-white inline-flex items-center justify-center rounded-[14px] transition-opacity text-[#1a1814] hover:opacity-90"
               style={{ background: "#ffffff", border: "1px solid #ffffff", padding: "16px 32px", fontSize: 12, letterSpacing: "0.18em", textTransform: "uppercase", fontWeight: 600 }}>
              Quero começar agora
            </a>
          </SM.div>
        </SM.div>
      </div>
    </section>
  );
}

/* ---------------------------- Oferta ---------------------------- */
function Offer() {
  const bullets = ["Sem assinatura", "Sem mensalidade", "Pagamento único"];
  const trust = ["Compra segura", "Cartão, boleto e pix", "Acesso imediato"];
  const eyebrow = "text-[11px] tracking-[0.16em] uppercase font-body font-medium text-[#9a9088]";
  return (
    <Section id="comprar">
      <div className="grid grid-cols-1 lg:grid-cols-2 lg:items-center gap-x-12 lg:gap-x-16 gap-y-12 pt-2 md:pt-4">

        {/* esquerda: título + benefícios */}
        <SM.div {...rise(0.08)}>
          <h2 className="font-heading text-[#1a1814] text-4xl md:text-[52px] tracking-[-2px] leading-[1.05]" style={{ textWrap: "balance" }}>
            Crie quantos looks quiser. <span className="italic whitespace-nowrap" style={{ color: "var(--accent)" }}>Pra sempre.</span>
          </h2>
          <ul className="mt-10 flex flex-col gap-4">
            {bullets.map((b) => (
              <li key={b} className="flex items-center gap-4">
                <span className="shrink-0 w-1.5 h-1.5 rounded-full" style={{ background: "var(--accent)" }} />
                <span className="font-heading no-stroke text-[#1a1814] text-lg md:text-xl leading-snug" style={{ letterSpacing: "-0.01em" }}>{b}</span>
              </li>
            ))}
          </ul>
        </SM.div>

        {/* direita: botão em cima, preço + frases centralizados abaixo */}
        <SM.div {...rise(0.16)} className="lg:pl-8">
          <div className="flex flex-col items-center text-center border border-[#e5e2dc] rounded-[1.75rem] px-8 md:px-10 py-12 md:py-14">
            <p className="font-heading text-[#9a9088] mb-1" style={{ fontSize: "clamp(20px,2.4vw,26px)", letterSpacing: "-0.01em" }}>
              De <span className="risco-fade risco-fade-red">R$ 297</span>
            </p>
            <div className="relative inline-block">
              <span className="font-heading text-[#1a1814] absolute" style={{ right: "100%", marginRight: 8, top: "0.32em", fontSize: "clamp(26px,3.4vw,40px)", letterSpacing: "-0.01em" }}>R$</span>
              <span className="font-heading text-[#1a1814] block" style={{ fontSize: "clamp(76px,11vw,140px)", lineHeight: 0.85, letterSpacing: "-0.03em" }}>97</span>
            </div>
            <p className="font-heading no-stroke text-[#1a1814] mt-2" style={{ fontSize: "clamp(16px,1.7vw,21px)", letterSpacing: "-0.01em" }}>ou 12x de R$ 10,03</p>
            <a href={window.ygCheckoutHref ? window.ygCheckoutHref() : "/comprar"} onClick={() => ygTrack("checkout_click", { local: "precos" })} className="btn-breathe-gold btn-gold-strong mt-9">Quero meu acesso</a>
            <div className="mt-7 flex flex-col gap-2 items-center">
              {trust.map((t) => (
                <span key={t} className={eyebrow}>{t}</span>
              ))}
            </div>
          </div>
        </SM.div>

      </div>
    </Section>
  );
}

/* ----------------------------- FAQ ------------------------------ */
function FAQItem({ q, a }) {
  const [open, setOpen] = useS(false);
  return (
    <div className="border-t border-[#ededeb] last:border-b">
      <button onClick={() => setOpen((o) => !o)} className="w-full flex items-center justify-between gap-6 py-7 text-left">
        <span className="font-heading no-stroke text-[#1a1814] text-xl md:text-2xl leading-snug" style={{ letterSpacing: "-0.01em" }}>{q}</span>
        <span className="relative w-5 h-5 shrink-0">
          <span className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-3.5 h-px bg-[#9a9088]" />
          <span className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 h-3.5 w-px bg-[#9a9088] transition-transform duration-300" style={{ transform: open ? "translate(-50%,-50%) scaleY(0)" : "translate(-50%,-50%)" }} />
        </span>
      </button>
      <div style={{ maxHeight: open ? 360 : 0, overflow: "hidden", transition: "max-height .4s ease" }}>
        <p className="pb-7 text-base text-[#9a9088] font-body leading-relaxed max-w-[62ch]">{a}</p>
      </div>
    </div>
  );
}
function FAQ() {
  const items = [
    { q: "Preciso entender de colorização?", a: "Não. A Yugen Grade foi criada justamente para quem quer um resultado bonito sem precisar dominar teoria de cor." },
    { q: "É um pack de LUTs?",               a: "Não. Você pode usar os looks prontos da galeria ou criar os seus próprios looks a partir de qualquer referência." },
    { q: "Preciso gravar em LOG?",           a: "Não. A Yugen Grade funciona para quem usa e quem não usa LOG." },
    { q: "Funciona com os vídeos que eu já gravo no celular?", a: "Funciona. Você sobe a imagem ou o print do vídeo do jeito que gravou, sem precisar de câmera ou configuração específica." },
    { q: "Meus vídeos vão pra algum servidor?", a: "Não. Tudo roda no seu navegador. Seu material não sai do seu computador em momento nenhum." },
  ];
  return (
    <Section>
      <SM.div {...rise()} className="mb-10 md:mb-12">
        <h2 className="font-heading text-[#1a1814] text-4xl md:text-6xl tracking-[-2px] leading-[1.02]">
          Perguntas <Em>frequentes.</Em>
        </h2>
      </SM.div>
      <div>
        {items.map((it) => <FAQItem key={it.q} {...it} />)}
      </div>
      <SM.div {...rise(0.1)} className="mt-12">
        <a href={window.ygCheckoutHref ? window.ygCheckoutHref() : "/comprar"} onClick={() => ygTrack("checkout_click", { local: "faq" })} className="btn-breathe-gold btn-gold-strong">Começar agora</a>
      </SM.div>
    </Section>
  );
}
/* ---------------------------- Footer ---------------------------- */
/* ------------------- Sobre / Quem está por trás ------------------- */
function About() {
  return (
    <section id="sobre" className="relative w-full overflow-hidden grain-dark" style={{ background: "#1c1c1e", minHeight: 500 }}>
      {/* foto à direita */}
      <div className="absolute inset-y-0 right-0 w-full lg:w-[60%]" aria-hidden="true"
        style={{ backgroundImage: "url(assets/sobre.jpg)", backgroundSize: "cover", backgroundPosition: "50% 44%" }}>
        {/* mobile: escurece toda a largura p/ o texto ler em qualquer posição */}
        <div className="absolute inset-0 lg:hidden" style={{ background: "linear-gradient(to right, #1c1c1e 0%, rgba(28,28,30,0.86) 42%, rgba(28,28,30,0.6) 100%)" }} />
        {/* desktop: degradê lateral suave que mescla a foto no fundo escuro */}
        <div className="absolute inset-0 hidden lg:block" style={{ background: "linear-gradient(to right, #1c1c1e 0%, rgba(28,28,30,0.72) 30%, rgba(28,28,30,0) 60%)" }} />
      </div>

      {/* texto à esquerda */}
      <div className="relative max-w-6xl mx-auto px-6 md:px-10 py-24 md:py-32 lg:py-36">
        <SM.div {...rise()} className="max-w-xl">
          <span className="text-[11px] tracking-[0.16em] uppercase font-body font-medium" style={{ color: "rgba(255,255,255,0.58)" }}>Quem está por trás</span>
          <h2 className="font-heading text-[#f7f5f2] text-4xl md:text-6xl tracking-[-2px] leading-[1.02] mt-5" style={{ textWrap: "balance" }}>
            Oi, eu sou a <Em>Renata.</Em>
          </h2>
          <div className="mt-7 flex flex-col gap-6 text-[17px] md:text-[19px] font-body leading-[1.75]" style={{ color: "rgba(255,255,255,0.66)" }}>
            <p>Nos últimos 8 anos, trabalhei criando conteúdo visual para marcas como DJI, Adobe, Samsung, Nubank, The North Face e National Geographic.</p>
            <p>Ao longo desse caminho, também mentorei criadores e especialistas que tinham muito valor para compartilhar, mas sentiam dificuldade em transformar isso em vídeos que transmitissem a mesma percepção de qualidade.</p>
            <p>Foi observando isso que percebi que a maioria das pessoas não quer se tornar filmmaker, colorista ou editora profissional. Elas só querem criar conteúdos melhores.</p>
            <p>A Yugen Grade nasceu para encurtar esse caminho. Uma ferramenta pensada para quem busca mais qualidade e menos fricção, permitindo alcançar uma estética sofisticada sem processos complexos ou anos de conhecimento técnico.</p>
          </div>
        </SM.div>
      </div>
    </section>
  );
}

function SiteFooter() {
  // links reais (atualizados por Renata)
  // ambos SÓLIDOS, mesmo tamanho de caixa, p/ igualar peso e tamanho visual
  const ig = (
    <svg width="22" height="22" viewBox="0 0 24 24" fill="currentColor">
      <path d="M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zm0-2.163C8.741 0 8.333.014 7.053.072 2.695.272.273 2.69.073 7.052.014 8.333 0 8.741 0 12c0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98C8.333 23.986 8.741 24 12 24c3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98C15.668.014 15.259 0 12 0zm0 5.838a6.162 6.162 0 100 12.324 6.162 6.162 0 000-12.324zM12 16a4 4 0 110-8 4 4 0 010 8zm6.406-11.845a1.44 1.44 0 100 2.881 1.44 1.44 0 000-2.881z" />
    </svg>
  );
  const wa = (
    <svg width="22" height="22" viewBox="-2 -2 28 28" fill="currentColor">
      <path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.71.306 1.263.489 1.694.625.712.227 1.36.195 1.872.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z" />
    </svg>
  );
  const social = [
    { label: "Instagram", href: "https://instagram.com/renatayugen", icon: ig },
    { label: "Suporte no WhatsApp", href: "https://wa.me/5551994495725", icon: wa },
  ];
  return (
    <footer className="relative section-light border-t border-[#ededeb] px-6 md:px-16 lg:px-20 pt-14 pb-10">
      <div className="max-w-6xl mx-auto flex flex-col md:flex-row md:items-center md:justify-between gap-8">
        {/* marca + copyright */}
        <div>
          <div style={{ display: "flex", alignItems: "center", gap: "13px" }}>
            <svg width="42" height="42" viewBox="18 33 240 240" fill="none" aria-hidden="true" style={{ flexShrink: 0 }}>
              <defs>
                <linearGradient id="ygFootGrad" x1="105" y1="90" x2="241" y2="255" gradientUnits="userSpaceOnUse">
                  <stop offset="0%" stopColor="#D4614A" /><stop offset="22%" stopColor="#C8883A" /><stop offset="44%" stopColor="#B8A84A" /><stop offset="66%" stopColor="#5A9E7A" /><stop offset="84%" stopColor="#4A7EA8" /><stop offset="100%" stopColor="#7A5A9E" />
                </linearGradient>
                <filter id="ygFootGrain" x="-5%" y="-5%" width="110%" height="110%">
                  <feTurbulence type="fractalNoise" baseFrequency="0.74 0.70" numOctaves="4" seed="9" stitchTiles="stitch" result="noise" />
                  <feColorMatrix type="matrix" values="0.38 0 0 0 0.34 0 0.36 0 0 0.33 0 0 0.34 0 0.32 0 0 0 1 0" in="noise" result="warmNoise" />
                  <feBlend in="SourceGraphic" in2="warmNoise" mode="overlay" result="blend" />
                  <feComposite in="blend" in2="SourceGraphic" operator="in" />
                </filter>
              </defs>
              <g stroke="url(#ygFootGrad)" strokeWidth="20" strokeLinecap="round" strokeLinejoin="round" filter="url(#ygFootGrain)">
                <path d="M241 90A105 105 0 1 0 241 210" />
                <path d="M241 150L155 150" />
                <path d="M105 90L155 150M205 90L155 150M155 150L155 228" />
              </g>
            </svg>
            <span className="font-heading no-stroke text-[#1a1814] text-2xl md:text-3xl tracking-[-0.02em]">Yugen Grade</span>
          </div>
          <p className="mt-3 text-[13px] text-[#9a9088] font-body">© 2026 Renata Yugen · Todos os direitos reservados</p>
        </div>
        {/* ícones sociais + acesso */}
        <nav className="flex items-center gap-3 -m-2">
          <a href="https://app.yugengrade.com" className="px-4 py-2 text-[13px] font-body text-[#1a1814] border border-[#e2ddd4] rounded-full hover:border-[#8c6840] hover:text-[#8c6840] transition-colors">Entrar</a>
          {social.map((s) => (
            <a key={s.label} href={s.href} target="_blank" rel="noopener noreferrer" aria-label={s.label} title={s.label} className="p-2 flex items-center justify-center text-[#9a9088] transition-colors hover:text-[#8c6840]">{s.icon}</a>
          ))}
        </nav>
      </div>
    </footer>
  );
}

Object.assign(window, { RefToLut, ProblemSolution, HowItWorks, WhatYouGet, Manifesto, LooksGallery, Offer, FAQ, About, SiteFooter });
