/* global React, ReactDOM */
const { useState, useEffect, useRef, useMemo, useCallback } = React;

/* ============================================================
 *  Icons (inline SVGs: small, controllable, no extra deps)
 * ============================================================ */
const Icon = {
  ArrowRight: (p) =>
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M5 12h14M13 6l6 6-6 6" />
    </svg>,

  ArrowUpRight: (p) =>
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M7 17 17 7M8 7h9v9" />
    </svg>,

  Globe: (p) =>
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <circle cx="12" cy="12" r="9" />
      <path d="M3 12h18M12 3c2.8 3.2 4.2 6.4 4.2 9s-1.4 5.8-4.2 9c-2.8-3.2-4.2-6.4-4.2-9S9.2 6.2 12 3z" />
    </svg>,

  Shield: (p) =>
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M12 3 4 6v6c0 5 3.5 8.5 8 9 4.5-.5 8-4 8-9V6l-8-3z" />
      <path d="m9 12 2 2 4-4" />
    </svg>,

  Sparkle: (p) =>
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M12 3v4M12 17v4M3 12h4M17 12h4M6 6l2.5 2.5M15.5 15.5 18 18M6 18l2.5-2.5M15.5 8.5 18 6" />
    </svg>,

  ChevronDown: (p) =>
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="m6 9 6 6 6-6" />
    </svg>,

  Check: (p) =>
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <path d="M20 6 9 17l-5-5" />
    </svg>,

  Mail: (p) =>
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" {...p}>
      <rect x="3" y="5" width="18" height="14" rx="2" />
      <path d="m3 7 9 7 9-7" />
    </svg>

};

/* ============================================================
 *  useInView: toggles a `.in` class once element scrolls in
 * ============================================================ */
function useInView(opts = { threshold: 0.18 }) {
  const ref = useRef(null);
  const [seen, setSeen] = useState(false);
  useEffect(() => {
    if (!ref.current || seen) return;
    const io = new IntersectionObserver(
      (entries) => {
        for (const e of entries) {
          if (e.isIntersecting) {
            setSeen(true);
            io.disconnect();
            break;
          }
        }
      },
      opts
    );
    io.observe(ref.current);
    return () => io.disconnect();
  }, [seen]);
  return [ref, seen];
}

function Reveal({ as: Tag = 'div', delay = 0, className = '', children, ...rest }) {
  const [ref, seen] = useInView();
  const delayClass = ['', 'reveal-delay-1', 'reveal-delay-2', 'reveal-delay-3', 'reveal-delay-4'][delay] || '';
  return (
    <Tag ref={ref} className={`reveal ${delayClass} ${seen ? 'in' : ''} ${className}`} {...rest}>
      {children}
    </Tag>);

}

/* ============================================================
 *  HERO ·full-viewport, video background, navbar, headline
 * ============================================================ */
function Hero() {
  const videoRef = useRef(null);

  // Replicated fade-in/out from the brief: smooth crossfade-to-black loop.
  useEffect(() => {
    const v = videoRef.current;
    if (!v) return;
    v.style.opacity = '0';

    let fadeRAF = null;
    const animateOpacity = (from, to, ms, done) => {
      cancelAnimationFrame(fadeRAF);
      const start = performance.now();
      const step = (now) => {
        const t = Math.min(1, (now - start) / ms);
        v.style.opacity = String(from + (to - from) * t);
        if (t < 1) fadeRAF = requestAnimationFrame(step);else
        if (done) done();
      };
      fadeRAF = requestAnimationFrame(step);
    };

    const onCanPlay = () => {
      v.play().catch(() => {});
      animateOpacity(0, 1, 600);
    };
    const onTimeUpdate = () => {
      if (!v.duration) return;
      if (v.duration - v.currentTime <= 0.55 && parseFloat(v.style.opacity || '1') > 0.5) {
        animateOpacity(parseFloat(v.style.opacity || '1'), 0, 500);
      }
    };
    const onEnded = () => {
      v.style.opacity = '0';
      setTimeout(() => {
        v.currentTime = 0;
        v.play().catch(() => {});
        animateOpacity(0, 1, 500);
      }, 100);
    };

    v.addEventListener('canplay', onCanPlay);
    v.addEventListener('timeupdate', onTimeUpdate);
    v.addEventListener('ended', onEnded);
    return () => {
      v.removeEventListener('canplay', onCanPlay);
      v.removeEventListener('timeupdate', onTimeUpdate);
      v.removeEventListener('ended', onEnded);
      cancelAnimationFrame(fadeRAF);
    };
  }, []);

  return (
    <section className="relative min-h-screen overflow-hidden flex flex-col">
      {/* Background video */}
      <video
        ref={videoRef}
        muted
        autoPlay
        playsInline
        preload="auto"
        className="absolute inset-0 w-full h-full object-cover object-bottom"
        style={{ opacity: 0 }}
        src="https://d8j0ntlcm91z4.cloudfront.net/user_38xzZboKViGWJOttwIXH07lWA1P/hf_20260405_074625_a81f018a-956b-43fb-9aee-4d1508e30e6a.mp4" />
      
      {/* dim + vignette */}
      <div className="absolute inset-0 bg-gradient-to-b from-black/60 via-black/30 to-black pointer-events-none" />
      <div className="absolute inset-0 bg-[radial-gradient(ellipse_at_center,_transparent_40%,_rgba(0,0,0,0.65)_100%)] pointer-events-none" />

      {/* Navbar */}
      <header className="relative z-20 px-6 py-6">
        <nav className="liquid-glass rounded-full max-w-5xl mx-auto px-6 py-3 flex items-center justify-between">
          <div className="flex items-center">
            <a href="#" className="flex items-center gap-2.5">
              <img src="logo-symbol.png" alt="Vercon AI" className="w-6 h-6 select-none" draggable="false" />
              <span className="font-serif text-white text-[20px] tracking-tight leading-none">Vercon<span className="text-white/55 text-[12px] tracking-[0.18em] uppercase ml-1.5 align-middle">AI</span></span>
            </a>
            <div className="hidden md:flex items-center gap-8 ml-10">
              <a href="#roi" className="text-white/70 hover:text-white text-[13px] font-medium transition-colors">Opportunity diagnostic</a>
              <a href="#how" className="text-white/70 hover:text-white text-[13px] font-medium transition-colors">How we work</a>
              <a href="#guarantee" className="text-white/70 hover:text-white text-[13px] font-medium transition-colors">Guarantee</a>
            </div>
          </div>
          <div className="flex items-center gap-3">
            <a href="mailto:tiago@verconai.com" className="hidden sm:inline text-white/80 hover:text-white text-[13px] font-medium transition-colors">tiago@verconai.com</a>
            <a href="#contact" className="liquid-glass rounded-full px-5 py-2 text-white text-[13px] font-medium hover:bg-white/[0.04] transition-colors">Book a call</a>
          </div>
        </nav>
      </header>

      {/* Hero content */}
      <div className="relative z-10 flex-1 flex flex-col items-center justify-center px-6 py-12 text-center -translate-y-[6%]">
        <Reveal className="mb-7">
          <span className="liquid-glass rounded-full px-4 py-1.5 text-[11px] uppercase tracking-[0.18em] text-white/70 inline-flex items-center gap-2">
            <span className="w-1.5 h-1.5 rounded-full bg-emerald-400/90 shadow-[0_0_10px_rgba(52,211,153,0.7)]" />
            AI automation, built around how you actually work.
          </span>
        </Reveal>

        <Reveal delay={1}>
          <h1 className="font-serif text-white leading-[0.95] tracking-tight text-[clamp(64px,12vw,180px)] whitespace-nowrap">
            AI <em className="italic text-white/75">Automation</em>
          </h1>
        </Reveal>

        <Reveal delay={2} className="max-w-2xl mt-7">
          <p className="text-white/75 text-base md:text-lg leading-relaxed px-4">
            If it can be automated with AI, we build it. Starting with slow lead response, dormant pipeline, and admin work eating your team's hours.
          </p>
        </Reveal>

        <Reveal delay={3} className="mt-9 flex flex-col sm:flex-row items-center gap-4">
          <a href="#contact" className="group bg-white text-black rounded-full pl-6 pr-2 py-2 inline-flex items-center gap-3 text-sm font-medium hover:bg-white/90 transition-colors">
            <span>Book a diagnostic call</span>
            <span className="w-9 h-9 rounded-full bg-black text-white grid place-items-center transition-transform group-hover:translate-x-0.5">
              <Icon.ArrowRight className="w-4 h-4" />
            </span>
          </a>
          <a href="#how" className="liquid-glass rounded-full px-6 py-3 text-white text-sm font-medium hover:bg-white/[0.04] transition-colors inline-flex items-center gap-2">
            See how we work
            <Icon.ArrowRight className="w-4 h-4 text-white/70" />
          </a>
        </Reveal>
      </div>

      {/* Bottom row: trust line */}
      <div className="relative z-10 pb-10 px-6">
        <Reveal delay={4} className="max-w-5xl mx-auto flex flex-wrap items-center justify-center gap-x-8 gap-y-3 text-[11px] uppercase tracking-[0.22em] text-white/40">
          <span>Written spec on every build</span>
          <span className="w-1 h-1 rounded-full bg-white/20" />
          <span>Fix-free guarantee</span>
          <span className="w-1 h-1 rounded-full bg-white/20" />
          <span>Flat monthly · No billable hours</span>
        </Reveal>
      </div>
    </section>);
}

/* ============================================================
 *  INTEGRATIONS ·marquee strip
 * ============================================================ */
const INTEGRATIONS = [
  { name: 'HubSpot',          slug: 'hubspot' },
  { name: 'Pipedrive',        slug: 'pipedrive' },
  { name: 'Salesforce',       slug: 'salesforce' },
  { name: 'Slack',            slug: 'slack' },
  { name: 'Stripe',           slug: 'stripe' },
  { name: 'Notion',           slug: 'notion' },
  { name: 'Airtable',         slug: 'airtable' },
  { name: 'Google Sheets',    slug: 'googlesheets' },
  { name: 'Google Ads',       slug: 'googleads' },
  { name: 'Meta',             slug: 'meta' },
  { name: 'Google Analytics', slug: 'googleanalytics' },
  { name: 'Gmail',            slug: 'gmail' },
  { name: 'Google Calendar',  slug: 'googlecalendar' },
  { name: 'Calendly',         slug: 'calendly' },
  { name: 'Zoom',             slug: 'zoom' },
  { name: 'Discord',          slug: 'discord' },
  { name: 'Mailchimp',        slug: 'mailchimp' },
  { name: 'Zapier',           slug: 'zapier' },
  { name: 'Make',             slug: 'make' },
  { name: 'n8n',              slug: 'n8n' },
  { name: 'QuickBooks',       slug: 'quickbooks' },
  { name: 'Xero',             slug: 'xero' },
  { name: 'Linear',           slug: 'linear' },
  { name: 'Asana',            slug: 'asana' },
  { name: 'ClickUp',          slug: 'clickup' },
  { name: 'Intercom',         slug: 'intercom' },
  { name: 'Shopify',          slug: 'shopify' },
  { name: 'Typeform',         slug: 'typeform' },
  { name: 'Webflow',          slug: 'webflow' },
  { name: 'Square',           slug: 'square' },
  { name: 'PayPal',           slug: 'paypal' },
  { name: 'Loom',             slug: 'loom' },
  { name: 'WordPress',        slug: 'wordpress' },
  { name: 'Cal.com',          slug: 'calcom' },
  { name: 'Trello',           slug: 'trello' },
];

function Integrations() {
  const row = [...INTEGRATIONS, ...INTEGRATIONS]; // doubled for seamless loop
  const icons = (typeof window !== 'undefined' && window.BRAND_ICONS) || {};
  return (
    <section className="bg-black pt-24 md:pt-32 pb-10 px-6 overflow-hidden">
      <Reveal className="max-w-6xl mx-auto text-center mb-10">
        <span className="text-white/40 text-xs tracking-[0.22em] uppercase">Connects with the tools your business already uses</span>
      </Reveal>
      <div className="marquee relative">
        <div className="marquee-track flex gap-2.5 whitespace-nowrap">
          {row.map((it, i) => {
            const ic = icons[it.slug];
            return (
              <div
                key={i}
                title={it.name}
                aria-label={it.name}
                className="liquid-glass rounded-xl relative overflow-hidden flex-shrink-0 flex items-center justify-center"
                style={{ width: 96, height: 64 }}
              >
                {/* Subtle radial bloom */}
                <div
                  className="absolute inset-0 pointer-events-none"
                  style={{
                    background:
                      'radial-gradient(circle at 50% 50%, rgba(255,255,255,0.05) 0%, transparent 70%)',
                  }}
                />
                {ic ? (
                  <svg
                    viewBox={ic.viewBox || '0 0 24 24'}
                    fill="#ffffff"
                    fillRule={ic.fillRule || 'nonzero'}
                    width="28" height="28"
                    style={{ opacity: 0.78 }}
                    aria-hidden="true"
                  >
                    <path d={ic.d} />
                  </svg>
                ) : (
                  <span className="text-white/70 text-[12px] font-medium">{it.name}</span>
                )}
              </div>
            );
          })}
        </div>
      </div>
    </section>
  );
}

/* ============================================================
 *  STATS ·three sourced numbers (mirrors the prompt's
 *  "About" + heading + supporting copy rhythm)
 * ============================================================ */
const STATS = [
{ num: '78%', label: 'of customers buy from the company that responds first', src: 'Harvard Business Review', url: 'https://hbr.org/2011/03/the-short-life-of-online-sales-leads' },
{ num: '21×', label: 'more likely to qualify a lead in 5 minutes vs. 30 minutes', src: 'MIT Sloan · Lead Response Study', url: 'https://www.leadresponsemanagement.org/lrm_study/' },
{ num: '5×', label: 'cheaper to reactivate a dormant customer than acquire a new one', src: 'Bain & Company', url: 'https://www.bain.com/insights/zero-defections-quality-comes-to-services-harvard-business-review-hbr/' }];


function Stats() {
  return (
    <section className="relative bg-black pt-20 md:pt-28 pb-16 md:pb-24 px-6 overflow-hidden">
      <div className="absolute inset-0 bg-[radial-gradient(ellipse_at_top,_rgba(255,255,255,0.04)_0%,_transparent_70%)] pointer-events-none" />

      <div className="relative max-w-6xl mx-auto">
        <Reveal>
          <span className="text-white/40 text-xs tracking-[0.22em] uppercase">The cost of slow</span>
        </Reveal>
        <Reveal delay={1} className="mt-5 max-w-4xl">
          <h2 className="font-serif text-white tracking-tight leading-[1.05] text-4xl md:text-6xl lg:text-7xl">
            Trust starts <em className="italic text-white/55">the moment</em><br className="hidden md:block" />
            you respond.
          </h2>
        </Reveal>

        <div className="mt-16 md:mt-20 grid grid-cols-1 md:grid-cols-3 gap-4 md:gap-6">
          {STATS.map((s, i) =>
          <Reveal key={i} delay={i + 1} className="liquid-glass rounded-3xl p-7 md:p-8 flex flex-col h-full">
              <div className="font-serif text-white text-6xl md:text-7xl leading-none tracking-tight">{s.num}</div>
              <p className="mt-6 text-white/70 text-[15px] leading-relaxed flex-1">{s.label}</p>
              <a href={s.url} target="_blank" rel="noreferrer" className="mt-6 pt-5 border-t border-white/10 text-white/40 hover:text-white/85 text-[11px] uppercase tracking-[0.18em] transition-colors inline-flex items-center gap-1.5 group">
                <span className="underline-offset-4 decoration-white/0 group-hover:decoration-white/40 group-hover:underline">{s.src}</span>
                <Icon.ArrowUpRight className="w-3 h-3 opacity-0 group-hover:opacity-60 transition-opacity" />
              </a>
            </Reveal>
          )}
        </div>
      </div>
    </section>);

}

/* ============================================================
 *  HOW WE WORK ·Innovation × Vision style 2-col + 3 steps
 * ============================================================ */
const STEPS = [
{
  no: '01',
  title: 'Diagnose',
  body: 'We map response lag, follow-up gaps, dormant pipeline, and admin work across the current workflow before recommending anything.',
  deliverable: 'Clear bottleneck diagnosis'
},
{
  no: '02',
  title: 'Scope',
  body: 'We shape the automation around your actual process, data sources, and team habits.',
  deliverable: 'Written scope + success criteria'
},
{
  no: '03',
  title: 'Build',
  body: 'We implement, test with real inputs, and refine until the system works as specified inside the workflow your team already runs.',
  deliverable: 'Working system'
}];


function HowWeWork() {
  return (
    <section id="how" className="relative bg-black py-28 md:py-40 px-6 overflow-hidden">
      <div className="max-w-6xl mx-auto">
        <Reveal>
          <span className="text-white/40 text-xs tracking-[0.22em] uppercase">How we work</span>
        </Reveal>

        <Reveal delay={1} className="mt-6 max-w-5xl">
          <h2 className="font-serif text-white tracking-tight leading-[1.02] text-5xl md:text-7xl lg:text-8xl">
            Process <em className="italic text-white/40">over</em> packages.
          </h2>
        </Reveal>

        <div className="mt-16 md:mt-24 grid grid-cols-1 md:grid-cols-2 gap-8 md:gap-12 items-start">
          {/* Video column */}
          <Reveal className="rounded-3xl overflow-hidden aspect-[4/3] relative liquid-glass-soft">
            <video
              muted autoPlay loop playsInline preload="auto"
              className="w-full h-full object-cover"
              src="https://d8j0ntlcm91z4.cloudfront.net/user_38xzZboKViGWJOttwIXH07lWA1P/hf_20260307_083826_e938b29f-a43a-41ec-a153-3d4730578ab8.mp4" />
            
            <div className="absolute inset-0 bg-gradient-to-t from-black/40 via-transparent to-black/20 pointer-events-none" />
            <div className="absolute bottom-0 left-0 right-0 p-6 md:p-8 flex items-end justify-between gap-4">
              <div>
                <div className="font-serif text-white text-2xl md:text-3xl leading-tight tracking-tight">
                  Built around <em className="italic text-white/65">your</em> workflow.
                </div>
              </div>
            </div>
          </Reveal>

          {/* Steps column */}
          <Reveal delay={1} className="space-y-3">
            {STEPS.map((s, i) =>
            <details key={s.no} open={i === 0} className="liquid-glass rounded-2xl group">
                <summary className="list-none cursor-pointer px-6 py-5 flex items-center justify-between gap-6">
                  <div className="flex items-center gap-5 min-w-0">
                    <span className="font-serif text-white/45 text-xl tracking-tight">{s.no}</span>
                    <span className="text-white text-lg md:text-xl font-medium tracking-tight">{s.title}</span>
                  </div>
                  <Icon.ChevronDown className="w-4 h-4 text-white/40 transition-transform group-open:rotate-180" />
                </summary>
                <div className="px-6 pb-6 pl-[3.75rem]">
                  <p className="text-white/65 text-[15px] leading-relaxed">{s.body}</p>
                  <div className="mt-4 inline-flex items-center gap-2 text-[11px] tracking-[0.18em] uppercase text-white/50">
                    <span className="w-3 h-px bg-white/30" />
                    Output: <span className="text-white/80">{s.deliverable}</span>
                  </div>
                </div>
              </details>
            )}
          </Reveal>
        </div>
      </div>
    </section>);

}

/* ============================================================
 *  GUARANTEE ·large featured-video + overlay glass card
 * ============================================================ */
function Guarantee() {
  return (
    <section id="guarantee" className="bg-black pt-6 md:pt-10 pb-28 md:pb-40 px-6 overflow-hidden">
      <Reveal className="max-w-6xl mx-auto">
        <div className="relative rounded-3xl overflow-hidden aspect-[3/4] md:aspect-video">
          <video
            muted autoPlay loop playsInline preload="auto"
            className="absolute inset-0 w-full h-full object-cover"
            src="https://d8j0ntlcm91z4.cloudfront.net/user_38xzZboKViGWJOttwIXH07lWA1P/hf_20260402_054547_9875cfc5-155a-4229-8ec8-b7ba7125cbf8.mp4" />
          
          <div className="absolute inset-0 bg-gradient-to-t from-black/85 via-black/30 to-transparent" />
          <div className="absolute inset-0 bg-gradient-to-r from-black/40 via-transparent to-transparent" />

          {/* heading inside the frame */}
          <div className="absolute top-0 left-0 right-0 p-6 md:p-10 flex items-start justify-between gap-6">
            <div>
              <div className="text-white/50 text-[11px] tracking-[0.22em] uppercase mb-3">Guarantee</div>
              <h3 className="font-serif text-white text-2xl md:text-5xl lg:text-6xl leading-[1.05] tracking-tight max-w-2xl">
                If it doesn't work <em className="italic text-white/60">as specified</em>, we fix it free.
              </h3>
            </div>
            <div className="hidden md:flex liquid-glass rounded-full w-14 h-14 items-center justify-center text-white shrink-0">
              <Icon.Shield className="w-6 h-6" />
            </div>
          </div>

          {/* overlay copy + cta */}
          <div className="absolute bottom-0 left-0 right-0 p-6 md:p-10 flex flex-col md:flex-row md:items-end gap-6">
            <div className="liquid-glass rounded-2xl p-6 md:p-7 max-w-xl">
              <div className="text-white/50 text-[11px] tracking-[0.22em] uppercase mb-3">What you get</div>
              <p className="text-white text-sm md:text-base leading-relaxed">
                Every system comes with a written spec of exactly what it does.{' '}
                <strong className="text-white">If the delivered system doesn't match that spec, we fix it at no charge.</strong>{' '}
                No questions, no scope debates.
              </p>
            </div>
            <a href="#contact" className="liquid-glass rounded-full px-7 py-3 text-white text-sm font-medium hover:bg-white/[0.05] transition-colors inline-flex items-center gap-2 self-start md:self-auto md:ml-auto">
              Talk to us
              <Icon.ArrowUpRight className="w-4 h-4" />
            </a>
          </div>
        </div>
      </Reveal>
    </section>);

}

/* ============================================================
 *  ROI CALCULATOR
 * ============================================================ */
function clamp(n, lo, hi) {return Math.max(lo, Math.min(hi, n));}
function fmtMoney(n) {
  return '$' + Math.round(n).toLocaleString('en-US');
}
function fmtInt(n) {return Math.round(n).toLocaleString('en-US');}

function ROICalculator() {
  const [monthlyLeads, setMonthlyLeads] = useState(40);
  const [avgDeal, setAvgDeal] = useState(8000);
  const [responseMinutes, setResponseMinutes] = useState(45);
  const [unworked, setUnworked] = useState(400);
  const [teamHours, setTeamHours] = useState(12);

  const calc = useMemo(() => {
    // ---- directional model (tuned to match the brief's example) ----
    const baseCloseRate = 0.18;
    // response decay: 5 min ~ 0; 60 min ~ 0.42; 1440 min ~ ~0.8
    const responseRisk = clamp(Math.log10(Math.max(1, responseMinutes)) * 0.32, 0, 0.85);
    const slowResponseLoss = monthlyLeads * 3 * responseRisk * baseCloseRate * avgDeal;

    // dormant: ~2% of unworked are recoverable in 90 days
    const dormantRecoveryRate = 0.022;
    const dormantLoss = unworked * dormantRecoveryRate * avgDeal;

    // manual drag: 60% of admin hrs are recoverable; assume blended $65/hr
    const recoverableHrs = teamHours * 13 * 0.6;
    const manualLoss = recoverableHrs * 65;

    const total = slowResponseLoss + dormantLoss + manualLoss;

    const buckets = [
    { key: 'dormant', label: 'Dormant pipeline sitting idle', sub: 'Old quotes and unworked opportunities are still holding recoverable revenue.', value: dormantLoss },
    { key: 'response', label: 'Slow lead response', sub: 'Long response times are making paid leads decay before your team gets to them.', value: slowResponseLoss },
    { key: 'manual', label: 'Admin work piling up', sub: 'Hours per week your team spends on follow-up and admin instead of revenue work.', value: manualLoss }].
    sort((a, b) => b.value - a.value);

    const scores = {
      response: Math.round(clamp(Math.log10(Math.max(1, responseMinutes)) / Math.log10(1440) * 100, 0, 100)),
      dormant: Math.round(clamp(unworked / Math.max(1, monthlyLeads * 12) * 100, 0, 100)),
      manual: Math.round(clamp(teamHours / 40 * 100, 0, 100))
    };

    return { total, slowResponseLoss, dormantLoss, manualLoss, recoverableHrs, buckets, scores };
  }, [monthlyLeads, avgDeal, responseMinutes, unworked, teamHours]);

  const [showMath, setShowMath] = useState(false);
  const [email, setEmail] = useState('');
  const [sent, setSent] = useState(false);
  const [sending, setSending] = useState(false);
  const [sendError, setSendError] = useState(null);

  const submitEmail = async (e) => {
    e.preventDefault();
    if (!email.includes('@')) return;
    setSending(true);
    setSendError(null);
    try {
      const res = await fetch('/api/diagnostic-email', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({
          email,
          monthlyLeads, avgDeal, responseMinutes, unworked, teamHours,
          total: calc.total,
          slowResponseLoss: calc.slowResponseLoss,
          dormantLoss: calc.dormantLoss,
          manualLoss: calc.manualLoss,
          recoverableHrs: calc.recoverableHrs,
        }),
      });
      if (!res.ok) {
        const err = await res.json().catch(() => ({}));
        throw new Error(err.error || 'Could not send. Try again.');
      }
      setSent(true);
    } catch (err) {
      setSendError(err.message || 'Could not send. Try again in a minute.');
    } finally {
      setSending(false);
    }
  };

  return (
    <section id="roi" className="relative bg-black py-28 md:py-40 px-6 overflow-hidden">
      <div className="absolute inset-0 bg-[radial-gradient(ellipse_at_center,_rgba(255,255,255,0.025)_0%,_transparent_60%)] pointer-events-none" />
      <div className="relative max-w-6xl mx-auto">
        <Reveal>
          <span className="text-white/40 text-xs tracking-[0.22em] uppercase">Opportunity diagnostic</span>
        </Reveal>
        <Reveal delay={1} className="mt-5 max-w-4xl">
          <h2 className="font-serif text-white tracking-tight leading-[1.02] text-4xl md:text-6xl lg:text-7xl">
            Estimate your current <em className="italic text-white/55">opportunity loss.</em>
          </h2>
        </Reveal>
        <Reveal delay={2} className="mt-6 max-w-2xl">
          <p className="text-white/65 text-base md:text-lg leading-relaxed">
            Enter a few current numbers. We'll show the likely cost of delayed response, dormant pipeline, and admin work across the next 90 days.
          </p>
        </Reveal>

        <div className="mt-14 md:mt-20 grid grid-cols-1 lg:grid-cols-5 gap-6">
          {/* Inputs */}
          <Reveal delay={1} className="lg:col-span-2 liquid-glass rounded-3xl p-7 md:p-8 space-y-7">
            <NumberRow label="Monthly leads" value={monthlyLeads} onChange={(v) => setMonthlyLeads(clamp(v, 1, 9999))} min={1} max={500} step={1} />
            <NumberRow label="Average deal value" prefix="$" value={avgDeal} onChange={(v) => setAvgDeal(clamp(v, 1, 10_000_000))} min={500} max={250000} step={500} />
            <NumberRow label="Average first response time" suffix="min" value={responseMinutes} onChange={(v) => setResponseMinutes(clamp(v, 1, 1440))} min={1} max={240} step={1} />
            <NumberRow label="Unworked opportunities in your database" value={unworked} onChange={(v) => setUnworked(clamp(v, 0, 99999))} min={0} max={5000} step={10} />
            <NumberRow label="Team hours per week spent on follow-up + admin" suffix="hrs" value={teamHours} onChange={(v) => setTeamHours(clamp(v, 0, 200))} min={0} max={80} step={1} />

            <p className="pt-2 text-white/45 text-xs leading-relaxed">
              Directional estimate only. On the diagnostic call, we validate the real bottleneck with your actual workflow, lead mix, and sales cycle before scoping anything.
            </p>
          </Reveal>

          {/* Output */}
          <Reveal delay={2} className="lg:col-span-3 liquid-glass rounded-3xl p-7 md:p-10 flex flex-col">
            <div className="flex items-baseline justify-between gap-4">
              <span className="text-white/50 text-[11px] uppercase tracking-[0.22em]">Directional estimate · next 90 days</span>
              <span className="text-white/40 text-xs">Updates live</span>
            </div>
            <div className="mt-4 font-serif text-white tracking-tight text-6xl md:text-8xl leading-none">
              {fmtMoney(calc.total)}
            </div>
            <p className="mt-4 text-white/55 text-[15px] leading-relaxed max-w-xl">
              Estimated opportunity currently leaking from delayed response, dormant demand, and admin work piling up.
            </p>

            {/* Buckets */}
            <div className="mt-8 grid grid-cols-1 md:grid-cols-2 gap-4">
              {calc.buckets.slice(0, 2).map((b, i) =>
              <div key={b.key} className="liquid-glass-soft rounded-2xl p-5 border border-white/5">
                  <div className="text-[10px] tracking-[0.22em] uppercase text-white/45">
                    {i === 0 ? 'Primary leak' : 'Secondary leak'}
                  </div>
                  <div className="mt-2 text-white text-base font-medium tracking-tight">{b.label}</div>
                  <div className="mt-1 text-white/55 text-sm leading-relaxed">{b.sub}</div>
                  <div className="mt-4 font-serif text-2xl text-white">{fmtMoney(b.value)}</div>
                </div>
              )}
            </div>

            {/* Hours line */}
            <div className="mt-6 flex items-center justify-between liquid-glass-soft rounded-full px-5 py-3 border border-white/5">
              <span className="text-white/65 text-sm">Recoverable operating time in 90 days</span>
              <span className="font-serif text-white text-2xl tracking-tight">{fmtInt(calc.recoverableHrs)} hrs</span>
            </div>

            {/* Score bars */}
            <div className="mt-7 space-y-4">
              <ScoreBar label="Response risk" value={calc.scores.response} />
              <ScoreBar label="Dormant pipeline pressure" value={calc.scores.dormant} />
              <ScoreBar label="Admin work drag" value={calc.scores.manual} />
            </div>

            {/* How we got here */}
            <button onClick={() => setShowMath((s) => !s)} className="mt-7 text-left text-white/55 hover:text-white/85 text-[13px] inline-flex items-center gap-2 transition-colors self-start">
              <Icon.ChevronDown className={`w-4 h-4 transition-transform ${showMath ? 'rotate-180' : ''}`} />
              {showMath ? 'Hide' : 'Show'} how we got here
            </button>
            {showMath &&
            <div className="mt-4 liquid-glass-soft rounded-2xl p-5 text-[13px] text-white/65 space-y-2 border border-white/5 font-mono">
                <MathRow label="Slow response loss" v={fmtMoney(calc.slowResponseLoss)} note={`${monthlyLeads} leads/mo × 3 mo × decay × 18% close × ${fmtMoney(avgDeal)}`} />
                <MathRow label="Dormant pipeline loss" v={fmtMoney(calc.dormantLoss)} note={`${fmtInt(unworked)} unworked × 2.2% recovery × ${fmtMoney(avgDeal)}`} />
                <MathRow label="Admin work loss" v={fmtMoney(calc.manualLoss)} note={`${teamHours} hrs/wk × 13 wks × 60% recoverable × $65/hr`} />
              </div>
            }

            {/* Email capture */}
            <div className="mt-8 liquid-glass-soft rounded-2xl p-6 border border-white/5">
              {!sent ?
              <>
                  <div className="text-white text-base font-medium tracking-tight">Email me these results</div>
                  <p className="text-white/55 text-sm mt-1">Get this breakdown sent to your inbox so you can share it with your team.</p>
                  <form onSubmit={submitEmail} className="mt-4 liquid-glass rounded-full pl-5 pr-2 py-1.5 flex items-center gap-3">
                    <Icon.Mail className="w-4 h-4 text-white/45 shrink-0" />
                    <input
                    type="email"
                    value={email}
                    onChange={(e) => setEmail(e.target.value)}
                    placeholder="you@yourcompany.com"
                    disabled={sending}
                    className="flex-1 bg-transparent text-white placeholder:text-white/40 text-sm focus:outline-none py-2 disabled:opacity-60" />

                    <button type="submit" disabled={sending} className="bg-white text-black rounded-full px-4 h-9 text-sm font-medium inline-flex items-center gap-1.5 hover:bg-white/90 transition-colors disabled:opacity-60 disabled:cursor-not-allowed">
                      {sending ? 'Sending…' : 'Send'} {!sending && <Icon.ArrowRight className="w-4 h-4" />}
                    </button>
                  </form>
                  {sendError && (
                    <p className="mt-3 text-red-300/90 text-xs leading-relaxed">{sendError}</p>
                  )}
                </> :

              <>
                  <div className="text-white text-base font-medium tracking-tight inline-flex items-center gap-2">
                    <span className="w-6 h-6 rounded-full bg-emerald-400/15 text-emerald-300 grid place-items-center">
                      <Icon.Check className="w-3.5 h-3.5" />
                    </span>
                    Sent to {email}.
                  </div>
                  <p className="text-white/55 text-sm mt-2">Check your inbox in the next minute. If you don't see it, peek in spam.</p>
                  <button onClick={() => {setSent(false);setEmail('');}} className="mt-3 text-white/60 hover:text-white text-sm underline underline-offset-4 decoration-white/20">
                    Send to a different email
                  </button>
                </>
              }
            </div>

            <a href="#contact" className="mt-8 self-start liquid-glass rounded-full px-7 py-3 text-white text-sm font-medium hover:bg-white/[0.05] transition-colors inline-flex items-center gap-2">
              Book a diagnostic call <Icon.ArrowRight className="w-4 h-4" />
            </a>
          </Reveal>
        </div>
      </div>
    </section>);

}

function NumberRow({ label, value, onChange, min, max, step, prefix, suffix }) {
  return (
    <label className="block">
      <div className="flex items-baseline justify-between gap-4 mb-2">
        <span className="text-white/65 text-sm">{label}</span>
        <span className="liquid-glass rounded-full px-3 py-1 inline-flex items-center gap-1.5 text-white text-sm font-medium">
          {prefix && <span className="text-white/45">{prefix}</span>}
          <input
            type="number"
            value={value}
            onChange={(e) => onChange(Number(e.target.value) || 0)}
            className="w-20 bg-transparent text-white text-sm font-medium focus:outline-none text-right" />
          
          {suffix && <span className="text-white/45 text-xs">{suffix}</span>}
        </span>
      </div>
      <input
        type="range"
        value={value}
        min={min} max={max} step={step}
        onChange={(e) => onChange(Number(e.target.value))}
        className="w-full" />
      
    </label>);

}

function ScoreBar({ label, value }) {
  return (
    <div>
      <div className="flex items-center justify-between text-sm mb-1.5">
        <span className="text-white/65">{label}</span>
        <span className="text-white/85 font-medium tabular-nums">{value}<span className="text-white/40">/100</span></span>
      </div>
      <div className="relative h-1.5 rounded-full bg-white/[0.06] overflow-hidden">
        <div
          className="absolute inset-y-0 left-0 rounded-full bg-gradient-to-r from-white/40 via-white/70 to-white"
          style={{ width: `${value}%`, transition: 'width 500ms cubic-bezier(.2,.7,.2,1)' }} />
        
      </div>
    </div>);

}

function MathRow({ label, v, note }) {
  return (
    <div className="flex items-start justify-between gap-4">
      <div>
        <div className="text-white/85">{label}</div>
        <div className="text-white/40 text-xs mt-0.5">{note}</div>
      </div>
      <div className="text-white whitespace-nowrap">{v}</div>
    </div>);

}

/* ============================================================
 *  CONTACT FORM
 * ============================================================ */
const BUSINESS_TYPES = ['SaaS / software', 'E-commerce', 'Professional services / agency', 'Service business (field / trades)', 'Marketplace', 'Education', 'Healthcare', 'Real estate', 'Finance / insurance', 'Other'];
const LEAD_RANGES = ['Under 20', '20–50', '50–150', '150–500', '500+'];
const DEAL_RANGES = ['Under $1k', '$1k–$5k', '$5k–$25k', '$25k–$100k', '$100k+'];
const STACK_OPTIONS = ['HubSpot', 'Salesforce', 'Pipedrive', 'Notion', 'Airtable', 'Slack', 'Google Sheets', 'Linear', 'Asana', 'ClickUp', 'Intercom', 'Zapier', 'Make', 'n8n', 'Mailchimp', 'ActiveCampaign', 'Calendly', 'QuickBooks', 'ChatGPT / OpenAI', 'Anthropic / Claude', 'Shopify', 'Stripe', 'Webflow', 'WordPress'];
const LEAK_OPTIONS = ['Slow lead response', 'Dormant pipeline', 'Manual follow-up', 'Reporting & visibility', 'Internal ops / busywork', 'Custom AI build', 'Not sure yet'];

function ContactForm() {
  const [form, setForm] = useState({
    name: '', email: '', company: '',
    bizType: '', leadVol: '', dealVal: '',
    stack: [], stackOther: '',
    leak: '', notes: ''
  });
  const [open, setOpen] = useState({ biz: false, stack: false, help: false });
  const [submitted, setSubmitted] = useState(false);
  const [submitting, setSubmitting] = useState(false);
  const [submitError, setSubmitError] = useState(null);

  const upd = (k, v) => setForm((f) => ({ ...f, [k]: v }));
  const toggleStack = (t) => setForm((f) => ({ ...f, stack: f.stack.includes(t) ? f.stack.filter((x) => x !== t) : [...f.stack, t] }));

  const submit = async (e) => {
    e.preventDefault();
    if (!form.name || !form.email || !form.company) return;
    setSubmitting(true);
    setSubmitError(null);
    try {
      const res = await fetch('/api/contact', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify(form),
      });
      if (!res.ok) {
        const err = await res.json().catch(() => ({}));
        throw new Error(err.error || 'Could not send. Try again.');
      }
      setSubmitted(true);
    } catch (err) {
      setSubmitError(err.message || 'Could not send. Try again or email tiago@verconai.com directly.');
    } finally {
      setSubmitting(false);
    }
  };

  return (
    <section id="contact" className="relative bg-black py-28 md:py-40 px-6 overflow-hidden">
      <div className="absolute inset-0 bg-[radial-gradient(ellipse_at_bottom,_rgba(255,255,255,0.04)_0%,_transparent_70%)] pointer-events-none" />
      <div className="relative max-w-5xl mx-auto">
        <Reveal>
          <span className="text-white/40 text-xs tracking-[0.22em] uppercase">Contact</span>
        </Reveal>
        <Reveal delay={1} className="mt-5 max-w-3xl">
          <h2 className="font-serif text-white tracking-tight leading-[1.02] text-4xl md:text-6xl lg:text-7xl">
            Book a <em className="italic text-white/55">diagnostic</em> call.
          </h2>
        </Reveal>
        <Reveal delay={2} className="mt-6 max-w-2xl">
          <p className="text-white/65 text-base md:text-lg leading-relaxed">
            Tell us a bit about your operation. We'll come prepared with a specific plan for your situation.
          </p>
        </Reveal>

        {submitted ?
        <Reveal className="mt-14 liquid-glass rounded-3xl p-10 md:p-14 text-center">
            <div className="w-14 h-14 rounded-full liquid-glass mx-auto grid place-items-center text-white">
              <Icon.Check className="w-6 h-6" />
            </div>
            <h3 className="mt-6 font-serif text-white text-4xl md:text-5xl tracking-tight">
              Got it. We'll be in <em className="italic text-white/65">touch.</em>
            </h3>
            <p className="mt-4 text-white/65 max-w-xl mx-auto leading-relaxed">
              We'll review your details and reach out within one business day. If you'd rather move faster, grab a slot directly:
            </p>
            <a href="https://calendly.com/tiago-verconai/30-minute-meeting-clone" target="_blank" rel="noreferrer" className="mt-7 inline-flex items-center gap-2 bg-white text-black rounded-full pl-6 pr-2 py-2 text-sm font-medium hover:bg-white/90 transition-colors">
              Book a slot now
              <span className="w-9 h-9 rounded-full bg-black text-white grid place-items-center">
                <Icon.ArrowRight className="w-4 h-4" />
              </span>
            </a>
          </Reveal> :

        <Reveal delay={3} className="mt-14 liquid-glass rounded-3xl p-6 md:p-10">
          <p className="text-white/60 text-sm md:text-[15px] leading-relaxed mb-8">
            <strong className="text-white">Only name, email, and company are required.</strong> The more you share, the more useful our first call will be. We'll come prepared with a specific plan instead of asking the basics.
          </p>

          <form onSubmit={submit} className="space-y-6">
            {/* Section 1 */}
            <FormSection number="01" title="About you" hint="Always open">
              <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
                <Field label="Your name" required>
                  <input value={form.name} onChange={(e) => upd('name', e.target.value)} placeholder="Alex Rivera" className="form-input" />
                </Field>
                <Field label="Work email" required>
                  <input type="email" value={form.email} onChange={(e) => upd('email', e.target.value)} placeholder="alex@yourcompany.com" className="form-input" />
                </Field>
                <Field label="Company name" required className="md:col-span-2">
                  <input value={form.company} onChange={(e) => upd('company', e.target.value)} placeholder="e.g. Northwind Co." className="form-input" />
                </Field>
              </div>
            </FormSection>

            {/* Section 2 */}
            <Collapsible
              number="02"
              title="About your business"
              hint="Type, leads, average deal · 30 sec"
              open={open.biz}
              onToggle={() => setOpen((o) => ({ ...o, biz: !o.biz }))}>
              
              <div className="space-y-6">
                <ChipGroup label="What kind of business?" options={BUSINESS_TYPES} value={form.bizType} onChange={(v) => upd('bizType', v)} />
                <ChipGroup label="Monthly leads (rough)" options={LEAD_RANGES} value={form.leadVol} onChange={(v) => upd('leadVol', v)} />
                <ChipGroup label="Average deal value" options={DEAL_RANGES} value={form.dealVal} onChange={(v) => upd('dealVal', v)} />
              </div>
            </Collapsible>

            {/* Section 3 */}
            <Collapsible
              number="03"
              title="Your stack"
              hint="Which tools you already use"
              open={open.stack}
              onToggle={() => setOpen((o) => ({ ...o, stack: !o.stack }))}>
              
              <div className="space-y-5">
                <div className="flex flex-wrap gap-2">
                  {STACK_OPTIONS.map((opt) => {
                    const on = form.stack.includes(opt);
                    return (
                      <button
                        key={opt}
                        type="button"
                        onClick={() => toggleStack(opt)}
                        className={`rounded-full px-4 py-2 text-sm transition-colors ${on ? 'bg-white text-black' : 'liquid-glass text-white/75 hover:text-white'}`}>
                        
                        {on && <Icon.Check className="w-3.5 h-3.5 inline -ml-1 mr-1.5" />}
                        {opt}
                      </button>);

                  })}
                </div>
                <Field label="Other tools? Type them here…">
                  <input value={form.stackOther} onChange={(e) => upd('stackOther', e.target.value)} placeholder="e.g. internal CRM, custom dashboard" className="form-input" />
                </Field>
              </div>
            </Collapsible>

            {/* Section 4 */}
            <Collapsible
              number="04"
              title="How we can help"
              hint="Where the biggest leak is + anything else"
              open={open.help}
              onToggle={() => setOpen((o) => ({ ...o, help: !o.help }))}>
              
              <div className="space-y-6">
                <ChipGroup label="Where's the biggest leak right now?" options={LEAK_OPTIONS} value={form.leak} onChange={(v) => upd('leak', v)} />
                <Field label="Anything else we should know?">
                  <textarea
                    value={form.notes}
                    onChange={(e) => upd('notes', e.target.value)}
                    placeholder="Context, constraints, what you've already tried… whatever helps us prep."
                    rows={4}
                    className="form-input resize-none" />
                  
                </Field>
              </div>
            </Collapsible>

            {submitError && (
              <div className="liquid-glass-soft rounded-2xl px-5 py-4 border border-red-400/20 text-red-300/90 text-sm">
                {submitError}
              </div>
            )}
            <div className="pt-4 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-5 border-t border-white/5">
              <p className="text-white/50 text-sm">No pitch, no pressure. Just a real conversation about your business.</p>
              <button type="submit" disabled={submitting} className="group bg-white text-black rounded-full pl-6 pr-2 py-2 inline-flex items-center gap-3 text-sm font-medium hover:bg-white/90 transition-colors disabled:opacity-60 disabled:cursor-not-allowed">
                <span>{submitting ? 'Sending…' : 'Send my info'}</span>
                <span className="w-9 h-9 rounded-full bg-black text-white grid place-items-center transition-transform group-hover:translate-x-0.5">
                  <Icon.ArrowRight className="w-4 h-4" />
                </span>
              </button>
            </div>
          </form>
        </Reveal>
        }
      </div>

      <style>{`
        .form-input {
          width: 100%;
          background: rgba(255,255,255,0.02);
          border: 1px solid rgba(255,255,255,0.08);
          color: #fff;
          font-size: 14px;
          padding: 12px 16px;
          border-radius: 14px;
          transition: border-color .2s, background .2s;
        }
        .form-input::placeholder { color: rgba(255,255,255,0.35); }
        .form-input:focus { outline: none; border-color: rgba(255,255,255,0.25); background: rgba(255,255,255,0.04); }
      `}</style>
    </section>);

}

function FormSection({ number, title, hint, children }) {
  return (
    <div className="liquid-glass-soft rounded-2xl border border-white/5">
      <div className="px-6 py-5 flex items-center justify-between border-b border-white/5">
        <div className="flex items-center gap-4">
          <span className="font-serif text-white/45 text-lg">{number}</span>
          <span className="text-white text-base font-medium tracking-tight">{title}</span>
        </div>
        <span className="text-white/40 text-xs tracking-wide uppercase hidden sm:inline">{hint}</span>
      </div>
      <div className="p-6">{children}</div>
    </div>);

}

function Collapsible({ number, title, hint, open, onToggle, children }) {
  return (
    <div className="liquid-glass-soft rounded-2xl border border-white/5">
      <button
        type="button"
        onClick={onToggle}
        className="w-full px-6 py-5 flex items-center justify-between gap-4">
        
        <div className="flex items-center gap-4 min-w-0">
          <span className="font-serif text-white/45 text-lg">{number}</span>
          <span className="text-white text-base font-medium tracking-tight">{title}</span>
        </div>
        <div className="flex items-center gap-4">
          <span className="text-white/40 text-xs tracking-wide hidden sm:inline">{hint}</span>
          <Icon.ChevronDown className={`w-4 h-4 text-white/45 transition-transform ${open ? 'rotate-180' : ''}`} />
        </div>
      </button>
      {open &&
      <div className="px-6 pb-6 border-t border-white/5 pt-6">{children}</div>
      }
    </div>);

}

function Field({ label, required, className = '', children }) {
  return (
    <label className={`block ${className}`}>
      <span className="block text-white/55 text-xs uppercase tracking-[0.16em] mb-2">
        {label}{required && <span className="text-white/85"> *</span>}
      </span>
      {children}
    </label>);

}

function ChipGroup({ label, options, value, onChange }) {
  return (
    <div>
      <div className="text-white/55 text-xs uppercase tracking-[0.16em] mb-3">{label}</div>
      <div className="flex flex-wrap gap-2">
        {options.map((opt) => {
          const on = opt === value;
          return (
            <button
              key={opt}
              type="button"
              onClick={() => onChange(opt)}
              className={`rounded-full px-4 py-2 text-sm transition-colors ${on ? 'bg-white text-black' : 'liquid-glass text-white/75 hover:text-white'}`}>
              
              {opt}
            </button>);

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

}

/* ============================================================
 *  WHO'S BEHIND IT ·founder section before contact
 * ============================================================ */
function WhoBehind() {
  return (
    <section className="relative bg-black py-20 md:py-28 px-6 overflow-hidden">
      <div className="absolute inset-0 bg-[radial-gradient(ellipse_at_top,_rgba(255,255,255,0.03)_0%,_transparent_70%)] pointer-events-none" />
      <div className="relative max-w-3xl mx-auto text-center">
        <Reveal>
          <span className="text-white/40 text-xs tracking-[0.22em] uppercase">Who's behind it</span>
        </Reveal>
        <Reveal delay={1} className="mt-5">
          <h2 className="font-serif text-white tracking-tight leading-[1.05] text-3xl md:text-5xl lg:text-6xl">
            Talk to the <em className="italic text-white/55">person</em> who'll build it.
          </h2>
        </Reveal>

        <Reveal delay={2} className="mt-12">
          <div className="liquid-glass rounded-2xl overflow-hidden aspect-[4/5] relative max-w-[220px] mx-auto">
            <img
              src="tiago.jpg"
              alt="Tiago Ramagli"
              className="w-full h-full object-cover"
              draggable="false" />
            <div className="absolute inset-0 bg-gradient-to-t from-black/40 via-transparent to-transparent pointer-events-none" />
          </div>
        </Reveal>

        <Reveal delay={3} className="mt-8">
          <p className="font-serif text-white text-2xl md:text-3xl leading-snug tracking-tight">
            Hi, I'm <em className="italic text-white/75">Tiago Ramagli</em>.
          </p>
          <div className="mt-5 space-y-2 max-w-xl mx-auto">
            <p className="text-white/55 text-sm md:text-base text-pretty leading-relaxed">
              I build every Vercon AI system myself.
            </p>
            <p className="text-white/55 text-sm md:text-base text-pretty leading-relaxed">
              Each build is shaped 100% around your business.
            </p>
            <p className="text-white/55 text-sm md:text-base text-pretty leading-relaxed">
              While we're working together, <strong className="text-white font-medium">you're the priority</strong>.
            </p>
          </div>
        </Reveal>
      </div>
    </section>);

}

/* ============================================================
 *  FOOTER
 * ============================================================ */
function Footer() {
  return (
    <footer className="bg-black border-t border-white/[0.06] px-6 py-14">
      <div className="max-w-6xl mx-auto">
        <div className="flex flex-col md:flex-row md:items-end md:justify-between gap-10">
          <div>
            <a href="#" className="inline-flex items-center gap-3">
              <img src="logo-symbol.png" alt="Vercon AI" className="w-9 h-9 select-none" draggable="false" />
              <span className="font-serif text-white text-3xl tracking-tight">Vercon<span className="text-white/55 text-sm tracking-[0.2em] uppercase ml-2 align-middle">AI</span></span>
            </a>
            <p className="mt-5 max-w-md text-white/55 text-sm leading-relaxed">
              If it can be automated with AI, we build it. Starting with slow lead response, dormant pipeline, and admin work eating your team's hours.
            </p>
          </div>

          <div className="grid grid-cols-2 gap-x-12 gap-y-3 text-sm">
            <a href="mailto:tiago@verconai.com" className="text-white/65 hover:text-white transition-colors">tiago@verconai.com</a>
            <a href="#how" className="text-white/65 hover:text-white transition-colors">How we work</a>
            <a href="#roi" className="text-white/65 hover:text-white transition-colors">Opportunity diagnostic</a>
            <a href="#contact" className="text-white/65 hover:text-white transition-colors">Contact</a>
          </div>
        </div>

        <div className="mt-14 flex flex-col md:flex-row md:items-center md:justify-between gap-4 pt-8 border-t border-white/[0.06]">
          <span className="text-white/35 text-xs">© {new Date().getFullYear()} Vercon AI. All rights reserved.</span>
          <span className="text-white/35 text-xs tracking-[0.18em] uppercase">verconai.com</span>
        </div>
      </div>
    </footer>);

}

/* ============================================================
 *  APP
 * ============================================================ */
function App() {
  return (
    <main className="bg-black text-white">
      <Hero />
      <Integrations />
      <Stats />
      <HowWeWork />
      <Guarantee />
      <ROICalculator />
      <WhoBehind />
      <ContactForm />
      <Footer />
    </main>);

}

ReactDOM.createRoot(document.getElementById('root')).render(<App />);