/* global React */
// Sections — Features tabs / Demo video placeholder / Comparativo

const { useState, useEffect, useRef } = React;

/* ───────────────────── FEATURES (12 com tabs verticais) ───────────────────── */

const FEATURES = [
  {
    id: 'agenda',
    title: 'Agenda Premium',
    short: '7 ações em slot vazio. 17 em agendamento existente.',
    body: 'Clique-direito com 7 ações em slot vazio e 17 ações em agendamento existente. Drag-and-drop pra reagendar. Encaixe automático sugerido pela IA. Fila walk-in e lista de espera nativas.',
    icon: 'M3 5h18v16H3z M3 9h18 M8 3v4 M16 3v4',
    keypts: ['Drag-and-drop reagendar','Sugestão IA de encaixe','Walk-in nativo','17 ações por agendamento'],
    badge: 'CORE',
  },
  {
    id: 'comanda',
    title: 'Comanda com CSP Real',
    short: 'Rastreia insumos e calcula custo do serviço em tempo real.',
    body: 'Rastreia insumos consumidos por serviço (lâmina, toalha, shampoo) e calcula custo do serviço prestado em tempo real. Você sabe a margem de cada corte na hora.',
    icon: 'M9 2v6 M15 2v6 M9 22h6 M3 9h18v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z',
    keypts: ['Insumos por serviço','Margem em tempo real','NFC-e nativa','Split de pagamento'],
    badge: 'CORE',
  },
  {
    id: 'comissao',
    title: 'Comissão em 12 categorias',
    short: 'Recálculo retroativo em 1 clique pra corrigir o mês passado.',
    body: 'Serviço, produto, gorjeta, bonificação, pacote, vale, comanda, desconto, dedução, remuneração fixa, misto e 100%. Recálculo retroativo em 1 clique pra corrigir erro do mês passado.',
    icon: 'M12 2v20 M5 8h9a3 3 0 0 1 0 6H8a3 3 0 0 0 0 6h11',
    keypts: ['12 tipos de comissão','Recálculo retroativo','Fechamento automático','Vale conferido'],
    badge: 'POPULAR',
  },
  {
    id: 'recovery',
    title: 'Recovery dedicado',
    short: 'Régua automática WhatsApp + Email + SMS + ligação humana.',
    body: 'Régua de cobrança automática com 3 a 5 toques (WhatsApp + Email + SMS + ligação humana). Recupera 30–60% dos inadimplentes em até 14 dias. Tem quarentena diferenciada pra cartão (3 dias) vs boleto (14 dias).',
    icon: 'M21 12a9 9 0 1 1-3.5-7.1 M21 4v6h-6',
    keypts: ['30–60% recuperação','Régua multi-canal','Quarentena por método','Recovery manual escalável'],
    badge: 'DIFERENCIAL',
  },
  {
    id: 'assinatura',
    title: 'Assinatura Vindi nativa',
    short: 'Pote do mês em tempo real. Reconciliação F12 automática.',
    body: 'Cobrança recorrente com 3 tipos de vencimento (data fixa, base contratação, base contratação fixa). Pote do mês em tempo real (você vê o saldo subir a cada webhook pago). Reconciliação Vindi F12 detecta divergência API vs DB automaticamente.',
    icon: 'M3 7h18v10H3z M7 7V5a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v2 M12 12h0',
    keypts: ['Pote real-time','3 tipos de vencimento','Reconciliação F12','Webhooks ao vivo'],
    badge: 'DIFERENCIAL',
  },
  {
    id: 'portal',
    title: 'Portal do Cliente PWA',
    short: '9 telas. Login com OTP. Carteira consolidada em 5 abas.',
    body: '9 telas dedicadas: login com OTP (WhatsApp + SMS + fallback), agendar em 4 passos, carteira consolidada (5 abas: pacotes, cashback, vale-presente, fidelidade, assinatura), perfil LGPD com opt-ins separados, histórico calendário, indicar amigo com Web Share, avaliar NPS.',
    icon: 'M7 2h10a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2z M12 18h.01',
    keypts: ['PWA — sem app store','OTP multi-canal','Web Share API','LGPD com opt-ins'],
    badge: 'CORE',
  },
  {
    id: 'cashback',
    title: 'Cashback nativo',
    short: 'Cliente acumula em cada comanda e abate na próxima visita.',
    body: 'Cliente acumula automaticamente em cada comanda, vê no portal e abate na próxima visita. Sem integração externa, sem taxa de terceiro.',
    icon: 'M12 2l2.39 4.84 5.34.78-3.86 3.77.91 5.32L12 14.2l-4.78 2.51.91-5.32-3.86-3.77 5.34-.78z',
    keypts: ['Acúmulo automático','Sem terceiro','Regra customizável','Abate em comanda'],
    badge: '',
  },
  {
    id: 'cargos',
    title: 'Cargos modulares',
    short: 'Permissão por ação. Audit log universal.',
    body: 'Recepção pode lançar vale e cadastrar barbeiro, mas não mexe em permissão nem altera comissão. Cada ação tem toggle granular. Audit log universal rastreia tudo.',
    icon: 'M12 11c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4z M6 21v-2a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v2',
    keypts: ['Toggle granular','Audit log','Cargos prontos','Multi-unidade'],
    badge: '',
  },
  {
    id: 'ia',
    title: 'IA Assistente BETA',
    short: 'Pergunta em linguagem natural. Devolve gráfico.',
    body: 'Pergunta em linguagem natural ("quantos clientes fizeram corte + barba em maio?"). Ela gera SQL, executa, devolve gráfico. Zero curva de aprendizado.',
    icon: 'M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z',
    keypts: ['Texto → SQL → gráfico','Beta gratuito','Cobertura total do schema','Anti-alucinação'],
    badge: 'BETA',
  },
  {
    id: 'bi',
    title: 'BI Analítico + 32 Rankings',
    short: 'Demografia em 7 cortes. Tudo exportável.',
    body: 'Demografia em 7 cortes (sexo, idade, cidade, estado, região, bairro, cadastro/mês). Tempo no salão, no-show por cliente, cancelamento por motivo. Tudo exportável em CSV/Excel.',
    icon: 'M3 3v18h18 M7 13l4-4 4 4 5-5',
    keypts: ['32 rankings prontos','7 cortes demográficos','Export CSV/Excel','Dashboards customizáveis'],
    badge: '',
  },
  {
    id: 'zap',
    title: 'GORILLA ZAP',
    short: 'WhatsApp integrado nativo — sem terceiro.',
    body: 'WhatsApp integrado nativo — envia lembrete pré-agendamento, confirma 2h antes, agradece pós-atendimento, dispara campanha de retorno. Sem terceiro, sem dupla cobrança.',
    icon: 'M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z M9 10a3 3 0 0 1 6 0c0 2-3 3-3 3 M12 17h.01',
    keypts: ['Lembrete 24h/2h','Pós-atendimento','Campanhas de retorno','Sem dupla cobrança'],
    badge: 'POPULAR',
  },
  {
    id: 'crescimento',
    title: 'Crescimento sem dor',
    short: 'SMS + Email + Indica + Banco de Artes.',
    body: 'SMS Marketing (Twilio) + Email Marketing (Resend) + Programa Indica com 3 meses grátis pra ambos (indicador e indicado) + Banco de Artes com gerador de banners SVG→PNG (Stories, Feed, Banner) + Convite Retorno automático pra cliente sumido.',
    icon: 'M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01z',
    keypts: ['Twilio SMS','Resend email','Indica 3 meses grátis','Banco de artes auto'],
    badge: '',
  },
];

function FeatureIcon({ d }) {
  return (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round">
      <path d={d} />
    </svg>
  );
}

function Features() {
  useReveal();
  const [active, setActive] = useState(0);
  const f = FEATURES[active];
  return (
    <section id="features" className="features">
      <div className="container">
        <div className="features-head reveal">
          <span className="eyebrow">12 razões pra trocar</span>
          <h2>Tudo que sua barbearia precisa,<br/><span className="features-h2-accent">num único login.</span></h2>
          <p className="features-lede">Cada feature foi desenhada pra resolver uma dor específica que o AppBarber e o Trinks deixam de lado. Clique pra ver os detalhes.</p>
        </div>

        <div className="features-shell reveal">
          {/* Tab list */}
          <div className="features-tabs" role="tablist">
            {FEATURES.map((feat, i) => (
              <button
                key={feat.id}
                role="tab"
                aria-selected={active === i}
                className={"features-tab " + (active === i ? 'is-active' : '')}
                onClick={() => setActive(i)}
              >
                <span className="features-tab-icon"><FeatureIcon d={feat.icon} /></span>
                <span className="features-tab-text">
                  <span className="features-tab-title">{feat.title}</span>
                  <span className="features-tab-short">{feat.short}</span>
                </span>
                {feat.badge && <span className={"features-tab-badge feat-badge-"+feat.badge.toLowerCase()}>{feat.badge}</span>}
              </button>
            ))}
          </div>

          {/* Preview pane */}
          <div className="features-pane" key={f.id}>
            <div className="features-pane-head">
              <div className="features-pane-icon"><FeatureIcon d={f.icon} /></div>
              <div>
                <div className="features-pane-eye">
                  Feature {String(active+1).padStart(2,'0')} / 12
                  {f.badge && <span className={"features-tab-badge feat-badge-"+f.badge.toLowerCase()}>{f.badge}</span>}
                </div>
                <h3>{f.title}</h3>
              </div>
            </div>
            <p className="features-pane-body">{f.body}</p>

            <div className="features-pane-list">
              {f.keypts.map((k, i) => (
                <div key={i} className="features-pane-pt">
                  <span className="features-check">
                    <svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="3" strokeLinecap="round" strokeLinejoin="round"><polyline points="20 6 9 17 4 12"/></svg>
                  </span>
                  {k}
                </div>
              ))}
            </div>

            <FeaturePreview id={f.id} title={f.title} />
          </div>
        </div>
      </div>

      <style>{`
        .features-head { max-width: 760px; }
        .features-head h2 { margin-top: 18px; }
        .features-h2-accent { color: var(--accent); }
        .features-lede { margin-top: 16px; font-size: 17px; max-width: 580px; }

        .features-shell {
          margin-top: 64px;
          display: grid;
          grid-template-columns: 380px 1fr;
          gap: 24px;
          align-items: start;
        }

        .features-tabs {
          display: flex; flex-direction: column; gap: 4px;
          max-height: 680px;
          overflow-y: auto;
          padding-right: 4px;
          scrollbar-width: thin;
        }
        .features-tab {
          display: grid;
          grid-template-columns: 32px 1fr auto;
          align-items: center;
          gap: 14px;
          padding: 14px 16px;
          background: transparent;
          border: 1px solid transparent;
          border-radius: 12px;
          text-align: left;
          cursor: pointer;
          color: var(--ink-soft);
          font-family: var(--font-body);
          transition: background .15s ease, border-color .15s ease, color .15s ease;
        }
        .features-tab:hover { background: var(--bg-card); color: var(--ink); }
        .features-tab.is-active {
          background: var(--bg-card);
          border-color: var(--line);
          color: var(--ink);
        }
        .features-tab.is-active .features-tab-icon { color: var(--accent); }
        .features-tab-icon { width: 28px; height: 28px; color: var(--ink-mute); transition: color .15s; }
        .features-tab-icon svg { width: 100%; height: 100%; }
        .features-tab-title { display: block; font-weight: 600; font-size: 14.5px; color: var(--ink); }
        .features-tab-short { display: block; font-size: 12px; color: var(--ink-mute); margin-top: 2px; line-height: 1.35; }
        .features-tab-badge {
          font-family: var(--font-mono); font-size: 9.5px; font-weight: 600;
          padding: 3px 7px; border-radius: 4px; letter-spacing: .08em;
          align-self: flex-start;
        }
        .feat-badge-core        { background: rgba(122,184,255,.12); color: #bcdcff; }
        .feat-badge-popular     { background: rgba(74,222,128,.12);  color: #86efac; }
        .feat-badge-diferencial { background: rgba(255,65,3,.16);   color: #ffae7e; }
        .feat-badge-beta        { background: rgba(167,139,250,.14); color: #c4b5fd; }

        /* Pane */
        .features-pane {
          background: var(--bg-card);
          border: 1px solid var(--line-soft);
          border-radius: var(--r-lg);
          padding: 36px;
          min-height: 640px;
          animation: flyIn .4s ease both;
          display: flex; flex-direction: column;
        }
        .features-pane-head { display:flex; gap: 18px; align-items: flex-start; }
        .features-pane-icon {
          width: 56px; height: 56px;
          padding: 14px;
          background: rgba(255,65,3,.1);
          border: 1px solid rgba(255,65,3,.3);
          border-radius: 14px;
          color: var(--accent);
        }
        .features-pane-icon svg { width: 100%; height: 100%; }
        .features-pane-eye {
          font-family: var(--font-mono);
          font-size: 11px;
          color: var(--ink-mute);
          text-transform: uppercase;
          letter-spacing: .12em;
          margin-bottom: 6px;
          display: flex; gap: 10px; align-items: center;
        }
        .features-pane-body { margin-top: 20px; font-size: 16px; line-height: 1.6; }
        .features-pane-list {
          margin-top: 24px;
          display: grid;
          grid-template-columns: repeat(2, 1fr);
          gap: 10px;
        }
        .features-pane-pt {
          display:flex; align-items:center; gap: 10px;
          font-size: 13.5px;
          color: var(--ink-soft);
        }
        .features-check {
          width: 18px; height: 18px;
          background: rgba(255,65,3,.14);
          color: var(--accent);
          border-radius: 6px;
          display:flex; align-items:center; justify-content:center;
        }

        @media (max-width: 980px) {
          .features-shell { grid-template-columns: 1fr; }
          .features-tabs { max-height: none; flex-direction: row; overflow-x: auto; padding-bottom: 12px; }
          .features-tab { min-width: 280px; }
          .features-pane { min-height: 0; padding: 24px; }
          .features-pane-list { grid-template-columns: 1fr; }
        }
      `}</style>
    </section>
  );
}

/* Feature preview — real product screenshot */
function FeaturePreview({ id, title }) {
  return (
    <div className="fp fp-shot">
      <div className="fp-head">
        <span className="fp-eye">{title} · UI real</span>
        <span className="fp-chip"><span className="fp-chip-dot" /> live</span>
      </div>
      <div className="fp-shot-frame">
        <img
          src={`/landing-original/assets/screenshots/feat-${id}.png`}
          alt={`Screenshot — ${title}`}
          loading="lazy"
          className="fp-shot-img"
        />
      </div>
      <style>{`
        .fp {
          margin-top: auto;
          padding: 16px;
          background: var(--bg-soft);
          border: 1px solid var(--line-soft);
          border-radius: 14px;
          position: relative;
          overflow: hidden;
        }
        .fp-shot {
          display: flex; flex-direction: column;
          gap: 12px;
        }
        .fp-shot-frame {
          width: 100%;
          aspect-ratio: 16 / 10;
          border-radius: 12px;
          overflow: hidden;
          background: #0a0c10;
          border: 1px solid var(--line);
          position: relative;
          box-shadow: 0 24px 60px -24px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.04);
        }
        .fp-shot-frame::after {
          content: "";
          position: absolute; inset: 0;
          background: linear-gradient(180deg, transparent 78%, rgba(15,17,21,.55) 100%);
          pointer-events: none;
        }
        .fp-shot-img {
          display: block;
          width: 100%;
          height: 100%;
          object-fit: cover;
          object-position: top left;
        }
        .fp-head { display:flex; justify-content:space-between; align-items: center; }
        .fp-eye { font-family: var(--font-mono); font-size: 11px; color: var(--ink-mute); text-transform: uppercase; letter-spacing: .12em; }
        .fp-chip {
          font-family: var(--font-mono); font-size: 10.5px;
          color: #86efac;
          padding: 3px 10px; border-radius: 999px;
          background: rgba(74,222,128,.08); border: 1px solid rgba(74,222,128,.25);
          display: inline-flex; align-items: center; gap: 6px;
          text-transform: uppercase; letter-spacing: .1em;
        }
        .fp-chip-dot {
          width: 6px; height: 6px; border-radius: 50%;
          background: #4ade80;
          box-shadow: 0 0 0 3px rgba(74,222,128,.2);
          animation: pulseDot 1.8s infinite;
        }
      `}</style>
    </div>
  );
}

/* ───────────────────── GORILLA IMPACT (parallax) ───────────────────── */
// Full-bleed dramatic section with scroll-linked giant gorilla mascot.
// variant: 'rage' | 'calm'

function GorillaImpact({ variant = 'rage' }) {
  const ref = useRef(null);
  const [progress, setProgress] = useState(0);

  useEffect(() => {
    let raf = 0;
    const onScroll = () => {
      cancelAnimationFrame(raf);
      raf = requestAnimationFrame(() => {
        const el = ref.current;
        if (!el) return;
        const r = el.getBoundingClientRect();
        const vh = window.innerHeight;
        const total = vh + r.height;
        const passed = vh - r.top;
        setProgress(Math.max(0, Math.min(1, passed / total)));
      });
    };
    onScroll();
    window.addEventListener('scroll', onScroll, { passive: true });
    window.addEventListener('resize', onScroll);
    return () => {
      cancelAnimationFrame(raf);
      window.removeEventListener('scroll', onScroll);
      window.removeEventListener('resize', onScroll);
    };
  }, []);

  const variants = {
    rage: {
      eyebrow: 'Por que Gorilla?',
      h: 'Pare de perder dinheiro\nem planilha de Excel.',
      sub: 'Cada R$ 1.000 que entra na sua barbearia, em média R$ 80 escapam: inadimplência ignorada, comissão errada, comanda no fiado. O Gorilla fecha o vazamento.',
      stats: [
        { v: '8%',  l: 'vazamento médio do faturamento' },
        { v: '47%', l: 'do que escapa, recuperado em 90 dias' },
        { v: '0',   l: 'planilhas necessárias' },
      ],
    },
    calm: {
      eyebrow: 'Por barbearias, pra barbearias',
      h: 'Software de gorila.\nPra negócio de gente.',
      sub: 'O Gorilla foi desenhado lado a lado com 50 barbearias brasileiras. Cada feature aqui já matou uma planilha. Cada tela existe porque um dono pediu primeiro.',
      stats: [
        { v: '50', l: 'barbearias no design da v1' },
        { v: '0',  l: 'features inventadas em sala fechada' },
        { v: '1',  l: 'login pra operar tudo' },
      ],
    },
  };
  const v = variants[variant] || variants.rage;

  // Parallax math
  const scale = 0.55 + progress * 0.9;
  const rotate = (progress - 0.5) * 8;
  const opacity = 0.04 + progress * 0.14;
  const yShift = (0.5 - progress) * 120;
  const glowOpacity = Math.max(0, progress - 0.2) * 0.7;

  return (
    <section className={"gimpact gimpact-" + variant} ref={ref}>
      <div className="gimpact-glow" style={{opacity: glowOpacity}} />
      <div className="gimpact-bg" style={{
        transform: `translate(-50%, calc(-50% + ${yShift}px)) scale(${scale}) rotate(${rotate}deg)`,
        opacity,
      }}>
        <img src="/landing-original/assets/brand-head-transparent.png" alt="" aria-hidden="true" />
      </div>

      <div className="container gimpact-inner">
        <div className="gimpact-side">
          <span className="eyebrow">{v.eyebrow}</span>
          <h2 className="gimpact-h">
            {v.h.split('\n').map((line, i) => (
              <span key={i} className="gimpact-h-line">{line}</span>
            ))}
          </h2>
          <p className="gimpact-sub">{v.sub}</p>
        </div>

        <div className="gimpact-stats">
          {v.stats.map((s, i) => (
            <div key={i} className="gimpact-stat" style={{transitionDelay: `${i*120}ms`}}>
              <div className="gimpact-stat-v">{s.v}</div>
              <div className="gimpact-stat-l">{s.l}</div>
            </div>
          ))}
        </div>
      </div>

      <div className="gimpact-marquee" aria-hidden="true">
        <div className="gimpact-marquee-track">
          {Array.from({length: 8}).map((_, i) => (
            <span key={i} className="gimpact-marquee-item">
              {variant === 'rage' ? 'PARE O VAZAMENTO' : 'CONSTRUÍDO COM BARBEIROS'}
              <span className="gimpact-marquee-dot">●</span>
            </span>
          ))}
        </div>
      </div>

      <style>{`
        .gimpact {
          position: relative;
          min-height: 100vh;
          overflow: hidden;
          background: var(--bg);
          padding: 120px 0;
          display: flex;
          align-items: center;
        }
        .gimpact-bg {
          position: absolute;
          left: 50%; top: 50%;
          width: min(95vw, 1200px);
          height: min(95vw, 1200px);
          pointer-events: none;
          will-change: transform, opacity;
          transition: opacity .3s linear;
        }
        .gimpact-bg img {
          width: 100%; height: 100%; object-fit: contain;
          filter: grayscale(1) contrast(1.5);
        }
        .gimpact-glow {
          position: absolute; inset: -10% -10%;
          background: radial-gradient(closest-side, var(--accent-glow), transparent 70%);
          filter: blur(40px);
          pointer-events: none;
          transition: opacity .3s linear;
        }
        .gimpact-rage .gimpact-glow { background: radial-gradient(closest-side, var(--accent-glow), transparent 70%); }
        .gimpact-calm .gimpact-glow { background: radial-gradient(closest-side, rgba(122,184,255,.2), transparent 70%); }

        .gimpact-inner {
          position: relative;
          z-index: 2;
          display: grid;
          grid-template-columns: 1.2fr .8fr;
          gap: 80px;
          align-items: center;
        }
        .gimpact-side {
          max-width: 700px;
        }
        .gimpact-h {
          margin-top: 22px;
          font-family: var(--font-display);
          font-weight: 800;
          font-size: clamp(48px, 7.5vw, 112px);
          line-height: .95;
          letter-spacing: -0.04em;
          color: var(--ink);
        }
        .gimpact-h-line {
          display: block;
        }
        .gimpact-calm .gimpact-h-line:nth-child(2) {
          color: var(--accent);
          background: linear-gradient(180deg, var(--accent-soft), var(--accent-deep));
          -webkit-background-clip: text; background-clip: text;
          color: transparent;
        }
        .gimpact-rage .gimpact-h-line:nth-child(2) {
          color: var(--accent);
          background: linear-gradient(180deg, var(--accent-soft), var(--accent-deep));
          -webkit-background-clip: text; background-clip: text;
          color: transparent;
        }
        .gimpact-sub {
          margin-top: 24px;
          font-size: clamp(16px, 1.4vw, 20px);
          line-height: 1.55;
          color: var(--ink-soft);
          max-width: 580px;
        }

        .gimpact-stats {
          display: flex;
          flex-direction: column;
          gap: 18px;
        }
        .gimpact-stat {
          padding: 22px 24px;
          background: rgba(22,22,26,.7);
          -webkit-backdrop-filter: blur(14px);
          backdrop-filter: blur(14px);
          border: 1px solid var(--line);
          border-radius: 14px;
          transform: translateX(20px);
          opacity: 0;
          transition: transform .8s cubic-bezier(.2,.7,.2,1), opacity .8s ease;
        }
        .gimpact-stat:nth-child(2) { margin-left: 32px; }
        .gimpact-stat:nth-child(3) { margin-left: 64px; }
        .gimpact:hover .gimpact-stat,
        .gimpact-stat { /* always reveal */ }
        /* Reveal when section in viewport */
        .gimpact .gimpact-stat {
          /* default state; the parent's "is-in" class triggers reveal */
        }
        .gimpact.is-in .gimpact-stat { transform: none; opacity: 1; }
        .gimpact-stat-v {
          font-family: var(--font-display);
          font-weight: 800;
          font-size: 48px;
          letter-spacing: -0.03em;
          color: var(--accent);
          line-height: 1;
        }
        .gimpact-stat-l {
          margin-top: 8px;
          font-size: 13px;
          color: var(--ink-soft);
          line-height: 1.4;
          font-family: var(--font-mono);
          text-transform: uppercase;
          letter-spacing: .08em;
        }

        .gimpact-marquee {
          position: absolute;
          left: 0; right: 0; bottom: 40px;
          overflow: hidden;
          mask-image: linear-gradient(90deg, transparent, black 5%, black 95%, transparent);
          opacity: .4;
          z-index: 1;
        }
        .gimpact-marquee-track {
          display: flex;
          gap: 48px;
          animation: ticker 35s linear infinite;
          width: max-content;
        }
        .gimpact-marquee-item {
          font-family: var(--font-display);
          font-weight: 800;
          font-size: clamp(40px, 5vw, 72px);
          letter-spacing: -0.02em;
          color: transparent;
          -webkit-text-stroke: 1px var(--ink-mute);
          display: inline-flex; align-items: center; gap: 32px;
        }
        .gimpact-marquee-dot {
          color: var(--accent);
          -webkit-text-stroke: 0;
          font-size: 0.4em;
        }

        @media (max-width: 980px) {
          .gimpact-inner { grid-template-columns: 1fr; gap: 40px; }
          .gimpact-stat:nth-child(2),
          .gimpact-stat:nth-child(3) { margin-left: 0; }
        }
      `}</style>
    </section>
  );
}

/* Trigger reveal on GorillaImpact when in viewport */
function useGorillaReveal() {
  useEffect(() => {
    const sections = document.querySelectorAll('.gimpact');
    if (!sections.length) return;
    const io = new IntersectionObserver((entries) => {
      entries.forEach(e => {
        if (e.isIntersecting) e.target.classList.add('is-in');
      });
    }, { threshold: 0.2 });
    sections.forEach(s => io.observe(s));
    setTimeout(() => sections.forEach(s => s.classList.add('is-in')), 1500);
    return () => io.disconnect();
  }, []);
}

/* ───────────────────── COMPARATIVO ───────────────────── */
function Compare() {
  useReveal();
  const rows = [
    ['CSP real (custo do serviço prestado)', true, false, false],
    ['Comissão em 12 categorias', true, false, false],
    ['Recálculo retroativo 1-clique', true, false, 'parcial'],
    ['Recovery de inadimplência nativo', true, false, false],
    ['Assinatura Vindi + Pote real-time', true, 'addon', false],
    ['Reconciliação Vindi F12', true, false, false],
    ['Portal do Cliente PWA', true, true, 'parcial'],
    ['Cashback nativo (sem terceiro)', true, false, false],
    ['IA Assistente (texto → SQL)', true, false, false],
    ['Permissões por ação + audit log', true, 'parcial', false],
    ['WhatsApp integrado nativo', true, 'addon', 'addon'],
    ['32 rankings + BI exportável', true, 'parcial', false],
    ['Migração 1-clique (CSV)', true, false, false],
    ['Preço (Solo)', 'R$ 99/mês', 'R$ 149/mês*', 'R$ 129/mês*'],
  ];
  const renderCell = (v, isGorilla) => {
    if (v === true) return <span className={"cmp-yes " + (isGorilla ? 'cmp-yes-on' : '')}>✓</span>;
    if (v === false) return <span className="cmp-no">—</span>;
    if (v === 'parcial') return <span className="cmp-partial">parcial</span>;
    if (v === 'addon') return <span className="cmp-addon">add-on</span>;
    return <span className="cmp-text">{v}</span>;
  };
  return (
    <section id="compare" className="compare">
      <div className="container">
        <div className="compare-head reveal">
          <span className="eyebrow">vs concorrentes</span>
          <h2>Por que barbearias estão trocando.</h2>
          <p className="compare-lede">Comparativo direto, sem floreio. Recursos nativos, sem add-on cobrado por fora.</p>
        </div>

        <div className="compare-table reveal">
          <div className="compare-row compare-row-head">
            <div className="compare-cell compare-feat">Recurso</div>
            <div className="compare-cell compare-brand compare-brand-us">
              <img src="/landing-original/assets/brand-head-transparent.png" alt="" />
              <span>Gorilla</span>
            </div>
            <div className="compare-cell compare-brand"><span>AppBarber</span></div>
            <div className="compare-cell compare-brand"><span>Trinks</span></div>
          </div>
          {rows.map((r, i) => (
            <div key={i} className={"compare-row " + (i === rows.length-1 ? 'compare-row-final' : '')}>
              <div className="compare-cell compare-feat">{r[0]}</div>
              <div className="compare-cell compare-us">{renderCell(r[1], true)}</div>
              <div className="compare-cell">{renderCell(r[2])}</div>
              <div className="compare-cell">{renderCell(r[3])}</div>
            </div>
          ))}
        </div>
        <p className="compare-foot">* Preços de concorrentes estimados a partir de planos públicos comparáveis. Maio/2026.</p>
      </div>

      <style>{`
        .compare-head { max-width: 680px; }
        .compare-head h2 { margin-top: 18px; }
        .compare-lede { margin-top: 16px; }

        .compare-table {
          margin-top: 56px;
          border: 1px solid var(--line-soft);
          border-radius: var(--r-lg);
          overflow: hidden;
        }
        .compare-row {
          display: grid;
          grid-template-columns: 2fr 1fr 1fr 1fr;
          border-bottom: 1px solid var(--line-soft);
          background: var(--bg-card);
        }
        .compare-row:last-child { border-bottom: none; }
        .compare-row-head {
          background: var(--bg-soft);
        }
        .compare-row-final { background: var(--bg-soft); font-weight: 600; }
        .compare-cell {
          padding: 16px 20px;
          font-size: 14px;
          color: var(--ink-soft);
          display: flex; align-items: center; gap: 8px;
        }
        .compare-feat { font-weight: 500; color: var(--ink); }
        .compare-row-head .compare-cell { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-mute); padding-top: 14px; padding-bottom: 14px; }
        .compare-brand { font-weight: 700; font-size: 14px; color: var(--ink); font-family: var(--font-display); }
        .compare-brand-us img { width: 28px; height: 28px; }
        .compare-row-head .compare-brand { letter-spacing: -0.01em; text-transform: none; }
        .compare-us {
          background: rgba(255,65,3,.05);
          box-shadow: inset 0 0 0 1px rgba(255,65,3,.18);
        }

        .cmp-yes { font-size: 18px; color: var(--ink-mute); font-weight: 700; }
        .cmp-yes-on { color: var(--accent); font-size: 22px; }
        .cmp-no { font-size: 16px; color: var(--ink-mute); font-weight: 600; }
        .cmp-partial { font-family: var(--font-mono); font-size: 11px; color: #fcd34d; background: rgba(251,191,36,.1); padding: 3px 9px; border-radius: 999px; border: 1px solid rgba(251,191,36,.25); }
        .cmp-addon   { font-family: var(--font-mono); font-size: 11px; color: var(--ink-mute); background: var(--bg-elev); padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); }
        .cmp-text { font-family: var(--font-mono); font-size: 13px; }
        .compare-us .cmp-text { color: var(--accent); font-weight: 600; }

        .compare-foot { margin-top: 16px; font-size: 12px; color: var(--ink-mute); font-family: var(--font-mono); }

        @media (max-width: 800px) {
          .compare-row { grid-template-columns: 1.8fr 1fr 1fr 1fr; }
          .compare-cell { padding: 12px 8px; font-size: 12.5px; }
        }
      `}</style>
    </section>
  );
}

Object.assign(window, { Features, GorillaImpact, useGorillaReveal, Compare });
