// Dois mundos — toggle Empresarial vs. Construtor with animated construction scenes. function AudienceToggle() { const [mode, setMode] = React.useState("empresarial"); const [inView, setInView] = React.useState(false); const sectionRef = React.useRef(null); const empRef = React.useRef(null); const conRef = React.useRef(null); const playedRef = React.useRef({ empresarial: false, construtor: false }); // Detect when the section enters the viewport (≥35% visible). React.useEffect(() => { if (!sectionRef.current) return; const io = new IntersectionObserver( (entries) => { entries.forEach(e => { if (e.isIntersecting) setInView(true); }); }, { threshold: 0.35 } ); io.observe(sectionRef.current); return () => io.disconnect(); }, []); // Pause inactive video; start (or hold) active video. // Each video plays exactly once — the first time its tab is selected // AND the section is in view. After it ends, it freezes on the last frame. React.useEffect(() => { if (!inView) return; const active = mode === "empresarial" ? empRef.current : conRef.current; const inactive = mode === "empresarial" ? conRef.current : empRef.current; if (inactive) inactive.pause(); if (active && !playedRef.current[mode]) { try { active.currentTime = 0; } catch (e) {} const p = active.play(); if (p && p.catch) p.catch(() => {}); playedRef.current[mode] = true; } }, [mode, inView]); const data = { empresarial: { title: "Modo Empresarial", tag: "Para empreiteiros e empresas", headline: "Muitas obras. Muita equipe. Um só painel.", sub: "DRE consolidado da empresa, equipe por obra, contas a receber, assistência técnica. Tudo o que sua planilha não consegue.", bullets: [ "Múltiplas obras simultâneas com margem por projeto", "DRE consolidado da empresa toda", "Controle de equipe própria com check-in geolocalizado", "Contas a pagar/receber + assistência técnica", ], accent: "var(--blue-600)", from: "R$ 159,99", }, construtor: { title: "Modo Construtor", tag: "Para autônomos e pequenas reformas", headline: "Sua obra. Seu controle. Sem complicação.", sub: "Versão enxuta pra quem quer apenas gerenciar etapas e gastos de suas obras.", bullets: [ "Gráficos e Resultados Instantâneos", "Lançamento rápido de gastos pelo celular", "Controle de etapas da Obra", "Fechamento da obra em 1 tela", ], accent: "var(--green-600)", from: "R$ 49,00", }, }; const d = data[mode]; return (
{/* Soft ambient backdrop */}
); } // --- Scene: Empresarial (prédio com guindaste) ----------------------------- function SceneEmpresarial({ active }) { // 8-story building rises, crane swings, workers move. Pure SVG with CSS. return (
{/* Clouds */} {/* Background skyline (existing city) */} {/* Crane */} {/* Mast */} {/* Cross braces */} {[80,120,160,200,240,280].map(y => ( ))} {/* Arm */} {/* Counterweight */} {/* Pylon */} {/* Cable + hook */} {/* Building (rising floor by floor — 8 floors) */} {[7,6,5,4,3,2,1,0].map((f, idx) => { const fh = 32; const y = f * fh; return ( {/* Slab */} {/* Windows */} {[0,1,2,3,4].map(w => ( ))} ); })} {/* Scaffolding overlay */} {[0,1,2,3,4,5,6,7].map(i => ( ))} {/* Ground */} {/* Dust puffs from crane area */} {[0,1,2].map(i => ( ))} {/* Cement truck driving across the bottom */} {/* Drum */} {/* Workers */}
); } // --- Scene: Construtor (casa em construção) -------------------------------- function SceneConstrutor({ active }) { return (
{/* Sun */} {/* Distant hills */} {/* Ground / lote */} {/* Grass tufts */} {[20, 80, 540, 580].map((x, i) => ( ))} {/* Pile of bricks */} {[0,1,2].map(r => ( [0,1,2,3].slice(0, 4-r).map(c => ( )) ))} {/* House group */} {/* Foundation */} {/* Hash texture */} {[0,1,2,3,4,5,6].map(i => ( ))} {/* Walls */} {/* Brick pattern */} {[0,1,2,3,4].map(row => ( [...Array(10).keys()].map(col => ( )) ))} {/* Roof */} {/* Roof tiles */} {[0,1,2,3].map(i => ( ))} {/* Chimney */} {/* Smoke */} {/* Door */} {/* Windows */} {/* Worker with saw on right */} {/* Sawhorse */} {/* Plank */} {/* Worker */} {/* Arm with saw */} {/* Picket fence */} {[5, 18, 31, 44, 57, 70, 83, 96, 109, 122, 135, 148].map(x => ( ))}
); } window.AudienceToggle = AudienceToggle;