// Doorly B2B — redesigned landing page

const LINKEDIN_URL = "https://www.linkedin.com/in/oscar-romero-argote-334abb51/";

// ── Icons ─────────────────────────────────────────────────────────────────────
const SearchIcon = ({ size = 20 }) => (
  <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
    <circle cx="11" cy="11" r="8"/><path d="m21 21-4.35-4.35"/>
  </svg>
);
const UserCheckIcon = ({ size = 20 }) => (
  <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
    <path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><polyline points="16 11 18 13 22 9"/>
  </svg>
);
const HandshakeIcon = ({ size = 20 }) => (
  <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
    <path d="M20.42 4.58a5.4 5.4 0 0 0-7.65 0l-.77.78-.77-.78a5.4 5.4 0 0 0-7.65 0C1.46 6.7 1.33 10.28 4 13l8 8 8-8c2.67-2.72 2.54-6.3.42-8.42z"/>
  </svg>
);
const MenuIcon = ({ size = 20 }) => (
  <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
    <line x1="3" y1="6" x2="21" y2="6"/><line x1="3" y1="12" x2="21" y2="12"/><line x1="3" y1="18" x2="21" y2="18"/>
  </svg>
);
const XIcon = ({ size = 20 }) => (
  <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
    <line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/>
  </svg>
);
const LinkedInIcon = ({ size = 15 }) => (
  <svg width={size} height={size} viewBox="0 0 24 24" fill="currentColor">
    <path d="M20.45 20.45h-3.55v-5.57c0-1.33-.03-3.04-1.85-3.04-1.85 0-2.14 1.45-2.14 2.95v5.66H9.36V9h3.41v1.56h.05c.48-.9 1.64-1.85 3.37-1.85 3.6 0 4.27 2.37 4.27 5.46v6.28zM5.34 7.43a2.06 2.06 0 1 1 0-4.13 2.06 2.06 0 0 1 0 4.13zM7.12 20.45H3.56V9h3.56v11.45zM22.22 0H1.77C.79 0 0 .77 0 1.72v20.55C0 23.23.79 24 1.77 24h20.45c.98 0 1.78-.77 1.78-1.72V1.72C24 .77 23.2 0 22.22 0z"/>
  </svg>
);
const ShieldCheckIcon = ({ size = 24 }) => (
  <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
    <path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/><polyline points="9 12 11 14 15 10"/>
  </svg>
);
const MailIcon = ({ size = 22 }) => (
  <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
    <rect width="20" height="16" x="2" y="4" rx="2"/><path d="m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"/>
  </svg>
);
const SendIcon = ({ size = 16 }) => (
  <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
    <path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/>
  </svg>
);
const CheckCircleIcon = ({ size = 18 }) => (
  <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
    <path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><polyline points="22 4 12 14.01 9 11.01"/>
  </svg>
);
const SparklesIcon = ({ size = 14 }) => (
  <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
    <path d="m12 3-1.912 5.813a2 2 0 0 1-1.275 1.275L3 12l5.813 1.912a2 2 0 0 1 1.275 1.275L12 21l1.912-5.813a2 2 0 0 1 1.275-1.275L21 12l-5.813-1.912a2 2 0 0 1-1.275-1.275L12 3Z"/>
  </svg>
);
const MoonIcon = ({ size = 15 }) => (
  <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
    <path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/>
  </svg>
);
const SunIcon = ({ size = 15 }) => (
  <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
    <circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41"/>
  </svg>
);
const XCircleIcon = ({ size = 18 }) => (
  <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
    <circle cx="12" cy="12" r="10"/><path d="m15 9-6 6"/><path d="m9 9 6 6"/>
  </svg>
);

// ── i18n ──────────────────────────────────────────────────────────────────────
const COPY = {
  EN: {
    nav: {
      links: [
        { id: "how-it-works", label: "How It Works" },
        { id: "pricing",      label: "Pricing" },
        { id: "guarantee",    label: "Guarantee" },
        { id: "founder",      label: "About" },
        { id: "contact",      label: "Contact" },
      ],
      cta: "Start Free Trial",
    },
    hero: {
      badge: "B2B Matchmaking",
      head: "We find the right people for your next business conversation.",
      sub: "Qualified B2B meetings between companies in the US and Europe. We handle research, outreach and scheduling — you just show up.",
      cta: "Start with a free trial meeting",
      fineprint: "No commitment. No credit card.",
    },
    how: {
      eyebrow: "How It Works",
      head: "From briefing to business conversation in three steps.",
      sub: "We handle the hard part — you show up to a qualified meeting.",
      steps: [
        { icon: "search",    title: "You tell us who you need to talk to",    desc: "Industry, role, company size, geography — we define the ideal profile together." },
        { icon: "usercheck", title: "We find and qualify the contact",        desc: "Research, validation and outreach. We only propose contacts that match the agreed profile." },
        { icon: "handshake", title: "The meeting happens",                    desc: "A real business conversation with the right person. If it doesn't match, it doesn't count." },
      ],
    },
    founder: {
      eyebrow: "Why trust Doorly",
      head: "Built by someone who has been on both sides of the table.",
      name: "Oscar Romero",
      role: "Founder & CEO · Doorly",
      linkedin: "LinkedIn",
      quote: "I have spent 15 years opening markets, building businesses from scratch and generating over $100M in revenue across the US, Europe, China and Africa. I know how hard it is to get in front of the right person — and how much one good meeting can change everything. That is exactly why I built Doorly.",
      metrics: [
        { v: "15+",    l: "Years CEO / COO / MD" },
        { v: "$100M+", l: "Revenue generated" },
        { v: "$45M",   l: "Built US+CA from zero" },
        { v: "4",      l: "Continents" },
      ],
      marketsTitle: "Markets & geographies",
      markets: ["United States", "Canada", "Spain", "Europe", "China", "Africa", "Asia"],
    },
    pricing: {
      badge: "Annual B2B Access Pack",
      head: "Simple annual access.",
      sub: "No monthly retainers. No payment for attempts.",
      planTag: "Includes 10 qualified B2B meetings",
      price: "$999",
      unit: "USD / year",
      desc: "Includes 10 qualified B2B meetings to help your company connect with the right people — whether you want to sell, buy, find suppliers, compare options or explore business opportunities.",
      trial: "Start with one trial meeting at no cost.",
      cta: "Request your free trial",
    },
    guarantee: {
      eyebrow: "Guarantee",
      head: "What counts as a meeting?",
      sub: "A meeting only counts when it takes place with the profile previously agreed.",
      items: [
        { cond: "If the meeting does not happen,",                     result: "it does not count." },
        { cond: "If the contact does not match the agreed profile,",   result: "it does not count." },
        { cond: "If there is no real business conversation,",          result: "it does not count." },
      ],
      finalprint: "The annual pack applies to standard B2B opportunities. Strategic accounts, enterprise targets or highly complex searches may require prior validation.",
    },
    contact: {
      eyebrow: "Contact",
      head: "Get in touch",
      sub: "Any questions? We'll get back to you within 24 hours. Or write directly to ",
      labels: { name: "Name", email: "Email", company: "Company", phone: "Phone", message: "Message" },
      send: "Send message",
      errors: { required: "Required", email: "Enter a valid email", fix: "Please fix the highlighted fields.", send: "Could not send. Please try again or email us directly." },
      sending: "Sending…",
      sent: "Message sent. We'll reply within 24 hours.",
    },
    closer: {
      head: "Ready to connect with the right people?",
      cta: "Start your free trial meeting",
    },
    footer: "© 2026 Doorly. All rights reserved.",
  },
  ES: {
    nav: {
      links: [
        { id: "how-it-works", label: "Cómo Funciona" },
        { id: "pricing",      label: "Precios" },
        { id: "guarantee",    label: "Garantía" },
        { id: "founder",      label: "Sobre Nosotros" },
        { id: "contact",      label: "Contacto" },
      ],
      cta: "Empezar Prueba Gratis",
    },
    hero: {
      badge: "Matchmaking B2B",
      head: "Encontramos a las personas adecuadas para tu próxima conversación de negocio.",
      sub: "Reuniones B2B cualificadas entre empresas en EE. UU. y Europa. Nosotros gestionamos la investigación, el contacto y la agenda — tú solo te presentas.",
      cta: "Empieza con una reunión de prueba gratis",
      fineprint: "Sin compromiso. Sin tarjeta.",
    },
    how: {
      eyebrow: "Cómo Funciona",
      head: "Del briefing a la conversación de negocio en tres pasos.",
      sub: "Nosotros gestionamos la parte difícil — tú te presentas a una reunión cualificada.",
      steps: [
        { icon: "search",    title: "Tú nos dices con quién necesitas hablar",   desc: "Industria, cargo, tamaño de empresa, geografía — definimos juntos el perfil ideal." },
        { icon: "usercheck", title: "Encontramos y cualificamos el contacto",    desc: "Investigación, validación y contacto. Solo proponemos contactos que coincidan con el perfil acordado." },
        { icon: "handshake", title: "La reunión sucede",                         desc: "Una conversación de negocio real con la persona adecuada. Si no coincide, no cuenta." },
      ],
    },
    founder: {
      eyebrow: "Por qué confiar en Doorly",
      head: "Construido por alguien que ha estado a ambos lados de la mesa.",
      name: "Oscar Romero",
      role: "Fundador y CEO · Doorly",
      linkedin: "LinkedIn",
      quote: "He pasado 15 años abriendo mercados, construyendo negocios desde cero y generando más de 100 M$ en ingresos en EE. UU., Europa, China y África. Sé lo difícil que es llegar a la persona adecuada — y cuánto puede cambiarlo todo una buena reunión. Por eso construí Doorly.",
      metrics: [
        { v: "15+",    l: "Años CEO / COO / MD" },
        { v: "$100M+", l: "Ingresos generados" },
        { v: "$45M",   l: "EE. UU.+CA desde cero" },
        { v: "4",      l: "Continentes" },
      ],
      marketsTitle: "Mercados y geografías",
      markets: ["Estados Unidos", "Canadá", "España", "Europa", "China", "África", "Asia"],
    },
    pricing: {
      badge: "Pack Anual de Acceso B2B",
      head: "Acceso anual simple.",
      sub: "Sin cuotas mensuales. Sin pago por intentos.",
      planTag: "Incluye 10 reuniones B2B cualificadas",
      price: "$999",
      unit: "USD / año",
      desc: "Incluye 10 reuniones B2B cualificadas para ayudar a tu empresa a conectar con las personas adecuadas — ya sea para vender, comprar, encontrar proveedores, comparar opciones o explorar oportunidades de negocio.",
      trial: "Empieza con una reunión de prueba sin coste.",
      cta: "Solicita tu prueba gratuita",
    },
    guarantee: {
      eyebrow: "Garantía",
      head: "¿Qué cuenta como una reunión?",
      sub: "Una reunión solo cuenta cuando tiene lugar con el perfil previamente acordado.",
      items: [
        { cond: "Si la reunión no ocurre,",                                  result: "no cuenta." },
        { cond: "Si el contacto no coincide con el perfil acordado,",        result: "no cuenta." },
        { cond: "Si no hay una conversación de negocio real,",               result: "no cuenta." },
      ],
      finalprint: "El pack anual aplica a oportunidades B2B estándar. Cuentas estratégicas, objetivos enterprise o búsquedas altamente complejas pueden requerir validación previa.",
    },
    contact: {
      eyebrow: "Contacto",
      head: "Ponte en contacto",
      sub: "¿Alguna pregunta? Te responderemos en menos de 24 horas. O escríbenos directamente a ",
      labels: { name: "Nombre", email: "Email", company: "Empresa", phone: "Teléfono", message: "Mensaje" },
      send: "Enviar mensaje",
      errors: { required: "Obligatorio", email: "Introduce un email válido", fix: "Por favor corrige los campos marcados.", send: "No se pudo enviar. Inténtalo de nuevo o escríbenos directamente." },
      sending: "Enviando…",
      sent: "Enviado. Te responderemos en menos de 24 horas.",
    },
    closer: {
      head: "¿Listo para conectar con las personas adecuadas?",
      cta: "Empieza tu reunión de prueba gratis",
    },
    footer: "© 2026 Doorly. Todos los derechos reservados.",
  },
};

// ── Hooks ─────────────────────────────────────────────────────────────────────
function useScrollY(threshold = 8) {
  const [past, setPast] = React.useState(false);
  React.useEffect(() => {
    const on = () => setPast(window.scrollY > threshold);
    on();
    window.addEventListener("scroll", on, { passive: true });
    return () => window.removeEventListener("scroll", on);
  }, [threshold]);
  return past;
}

function useReveal(deps = []) {
  React.useEffect(() => {
    const els = document.querySelectorAll(".reveal:not(.in), .reveal-left:not(.in)");
    const io = new IntersectionObserver(
      (entries) => { entries.forEach((e) => { if (e.isIntersecting) { e.target.classList.add("in"); io.unobserve(e.target); } }); },
      { threshold: 0.1, rootMargin: "0px 0px -40px 0px" }
    );
    els.forEach((el) => io.observe(el));
    return () => io.disconnect();
  }, deps);
}

function scrollToId(id) {
  const el = document.getElementById(id);
  if (!el) return;
  const navH = document.querySelector("nav")?.offsetHeight || 0;
  window.scrollTo({ top: el.getBoundingClientRect().top + window.scrollY - navH - 8, behavior: "smooth" });
}

// ── Nav ───────────────────────────────────────────────────────────────────────
function Nav({ lang, setLang, onStart, t, dark, setDark }) {
  const scrolled = useScrollY(6);
  const [open, setOpen] = React.useState(false);

  return (
    <nav className={`fixed top-0 left-0 right-0 z-50 transition-all duration-300 ${scrolled ? "bg-card/90 backdrop-blur-xl shadow-sm border-b border-border" : "bg-transparent"}`}>
      <div className="max-w-6xl mx-auto px-5 md:px-8 py-4 flex items-center gap-3">
        <a href="#top" className="flex items-center gap-2.5 flex-shrink-0"
          onClick={(e) => { e.preventDefault(); window.scrollTo({ top: 0, behavior: "smooth" }); setOpen(false); }}>
          <span className="w-8 h-8 rounded-lg bg-white shadow-sm border border-border flex items-center justify-center overflow-hidden">
            <img src="assets/doorly-mark.png" className="w-full h-full object-contain p-0.5" alt="Doorly" />
          </span>
          <span className="font-serif text-lg font-bold text-foreground">
            doorly<span style={{ color: "hsl(var(--secondary))" }}>.</span>
          </span>
        </a>

        <div className="hidden md:flex items-center gap-5 ml-auto">
          {t.nav.links.map((l) => (
            <a key={l.id} href={`#${l.id}`}
              onClick={(e) => { e.preventDefault(); scrollToId(l.id); }}
              className="text-sm text-muted-foreground hover:text-foreground transition-colors duration-150">
              {l.label}
            </a>
          ))}
        </div>

        <div className="hidden md:flex bg-muted rounded-full p-1 gap-0.5 ml-4">
          {["EN", "ES"].map((l) => (
            <button key={l} onClick={() => setLang(l)}
              className={`px-3 py-1 text-xs font-medium rounded-full transition-all duration-150 ${lang === l ? "bg-primary text-primary-foreground shadow-sm" : "text-muted-foreground hover:text-foreground"}`}>
              {l}
            </button>
          ))}
        </div>

        <button onClick={() => setDark(!dark)}
          className="hidden md:flex w-8 h-8 items-center justify-center rounded-full bg-muted text-muted-foreground hover:text-foreground transition-colors duration-150">
          {dark ? <SunIcon /> : <MoonIcon />}
        </button>

        <button onClick={onStart}
          className="hidden md:flex items-center gap-2 bg-primary text-primary-foreground px-5 py-2.5 rounded-full text-sm font-semibold hover:opacity-90 transition-opacity flex-shrink-0">
          {t.nav.cta} <span>→</span>
        </button>

        <button onClick={() => setOpen(!open)} className="md:hidden ml-auto p-2 rounded-lg text-foreground hover:bg-muted transition-colors">
          {open ? <XIcon /> : <MenuIcon />}
        </button>
      </div>

      {open && (
        <div className="md:hidden border-t border-border bg-card/95 backdrop-blur-xl px-5 py-4 flex flex-col gap-1">
          {t.nav.links.map((l) => (
            <a key={l.id} href={`#${l.id}`}
              onClick={(e) => { e.preventDefault(); scrollToId(l.id); setOpen(false); }}
              className="py-3 text-sm font-medium text-foreground border-b border-border/50 last:border-0">
              {l.label}
            </a>
          ))}
          <div className="flex items-center gap-3 pt-3">
            <div className="flex bg-muted rounded-full p-1">
              {["EN", "ES"].map((l) => (
                <button key={l} onClick={() => setLang(l)}
                  className={`px-3 py-1 text-xs font-medium rounded-full transition-all ${lang === l ? "bg-primary text-primary-foreground" : "text-muted-foreground"}`}>
                  {l}
                </button>
              ))}
            </div>
            <button onClick={() => setDark(!dark)} className="w-8 h-8 flex items-center justify-center rounded-full bg-muted text-muted-foreground">
              {dark ? <SunIcon /> : <MoonIcon />}
            </button>
            <button onClick={() => { onStart(); setOpen(false); }}
              className="flex-1 bg-primary text-primary-foreground py-2.5 rounded-full text-sm font-semibold text-center">
              {t.nav.cta}
            </button>
          </div>
        </div>
      )}
    </nav>
  );
}

// ── Hero ──────────────────────────────────────────────────────────────────────
function Hero({ t, onStart }) {
  return (
    <section id="top" className="min-h-screen flex items-center justify-center pt-20 pb-16 relative overflow-hidden">
      <div className="absolute inset-0 overflow-hidden pointer-events-none">
        <div className="blob absolute top-1/4 right-1/4 w-96 h-96 rounded-full blur-3xl" style={{ background: "hsl(var(--secondary) / 0.12)" }} />
        <div className="blob2 absolute bottom-1/3 left-1/5 w-80 h-80 rounded-full blur-3xl" style={{ background: "hsl(var(--primary) / 0.06)" }} />
        <div className="absolute inset-x-0 top-1/2 h-px" style={{ background: "linear-gradient(to right, transparent, hsl(var(--border)), transparent)" }} />
      </div>

      <div className="relative max-w-4xl mx-auto px-5 md:px-8 text-center">
        <div className="reveal inline-flex items-center gap-2.5 px-4 py-2 rounded-full bg-muted border border-border text-xs font-semibold text-muted-foreground tracking-widest uppercase mb-8">
          <span className="w-1.5 h-1.5 rounded-full animate-pulse-dot" style={{ background: "hsl(var(--secondary))" }} />
          {t.hero.badge}
        </div>

        <h1 className="reveal font-serif text-4xl md:text-6xl lg:text-7xl font-bold text-foreground leading-tight tracking-tight mb-6" style={{ transitionDelay: "0.1s" }}>
          {t.hero.head}
        </h1>

        <p className="reveal text-lg md:text-xl text-muted-foreground max-w-2xl mx-auto leading-relaxed mb-10" style={{ transitionDelay: "0.2s" }}>
          {t.hero.sub}
        </p>

        <div className="reveal flex flex-col items-center gap-3" style={{ transitionDelay: "0.3s" }}>
          <button onClick={onStart}
            className="inline-flex items-center gap-3 bg-primary text-primary-foreground px-8 py-4 rounded-full text-base font-semibold shadow-lg hover:opacity-90 hover:shadow-xl hover:-translate-y-0.5 transition-all duration-200">
            {t.hero.cta} <span>→</span>
          </button>
          <p className="text-xs text-muted-foreground">{t.hero.fineprint}</p>
        </div>
      </div>
    </section>
  );
}

// ── How It Works ──────────────────────────────────────────────────────────────
const HOW_ICONS = { search: SearchIcon, usercheck: UserCheckIcon, handshake: HandshakeIcon };

function HowItWorks({ t }) {
  return (
    <section id="how-it-works" className="py-24 md:py-32" style={{ background: "linear-gradient(to bottom, hsl(var(--background)), hsl(var(--muted) / 0.3), hsl(var(--background)))" }}>
      <div className="max-w-6xl mx-auto px-5 md:px-8">
        <div className="text-center mb-16 reveal">
          <p className="text-xs font-semibold tracking-widest uppercase text-muted-foreground mb-3">{t.how.eyebrow}</p>
          <h2 className="font-serif text-3xl md:text-5xl font-bold text-foreground mb-4">{t.how.head}</h2>
          <p className="text-muted-foreground max-w-xl mx-auto">{t.how.sub}</p>
        </div>

        <div className="grid md:grid-cols-3 gap-6">
          {t.how.steps.map((step, i) => {
            const Icon = HOW_ICONS[step.icon] || SearchIcon;
            return (
              <div key={i} className="reveal group" style={{ transitionDelay: `${i * 0.12}s` }}>
                <div className="bg-card border border-border/60 rounded-2xl p-8 h-full hover:shadow-lg hover:-translate-y-1 transition-all duration-300">
                  <div className="w-12 h-12 rounded-xl flex items-center justify-center text-primary mb-6 transition-colors group-hover:bg-primary/10" style={{ background: "hsl(var(--primary) / 0.06)" }}>
                    <Icon size={22} />
                  </div>
                  <div className="font-serif text-5xl font-bold leading-none mb-4 transition-colors" style={{ color: "hsl(var(--border))" }}>
                    0{i + 1}
                  </div>
                  <h3 className="font-semibold text-foreground text-lg leading-snug mb-3">{step.title}</h3>
                  <p className="text-muted-foreground text-sm leading-relaxed">{step.desc}</p>
                </div>
              </div>
            );
          })}
        </div>
      </div>
    </section>
  );
}

// ── Founder ───────────────────────────────────────────────────────────────────
function Founder({ t }) {
  return (
    <section id="founder" className="py-24 md:py-32">
      <div className="max-w-6xl mx-auto px-5 md:px-8">
        <div className="text-center mb-12 reveal">
          <p className="text-xs font-semibold tracking-widest uppercase text-muted-foreground mb-3">{t.founder.eyebrow}</p>
          <h2 className="font-serif text-3xl md:text-4xl font-bold text-foreground max-w-2xl mx-auto">{t.founder.head}</h2>
        </div>

        <div className="reveal">
          <div className="bg-card border border-border/60 rounded-3xl shadow-lg overflow-hidden">
            <div className="flex flex-col md:flex-row">
              <div className="bg-primary md:w-72 flex-shrink-0 p-8 flex flex-col items-center md:items-start gap-5">
                <div className="w-36 h-36 rounded-2xl overflow-hidden flex-shrink-0" style={{ boxShadow: "0 0 0 4px hsl(var(--primary-foreground) / 0.12)" }}>
                  <img src="assets/oscar.png" alt={t.founder.name} className="w-full h-full object-cover" />
                </div>
                <div>
                  <div className="font-semibold text-primary-foreground text-lg">{t.founder.name}</div>
                  <div className="text-primary-foreground/60 text-sm mt-0.5">{t.founder.role}</div>
                </div>
                <a href={LINKEDIN_URL} target="_blank" rel="noopener noreferrer"
                  className="inline-flex items-center gap-2 px-4 py-2 rounded-full text-primary-foreground text-sm font-medium transition-colors hover:bg-primary-foreground/20"
                  style={{ background: "hsl(var(--primary-foreground) / 0.1)" }}>
                  <LinkedInIcon size={14} />
                  {t.founder.linkedin}
                </a>
              </div>

              <div className="flex-1 p-8 md:p-10 flex flex-col gap-8">
                <blockquote className="font-medium text-lg leading-relaxed text-foreground">
                  <span className="font-serif text-4xl leading-none" style={{ color: "hsl(var(--secondary))" }}>"</span>
                  {t.founder.quote}
                  <span className="font-serif text-4xl leading-none" style={{ color: "hsl(var(--secondary))" }}>"</span>
                </blockquote>

                <div className="grid grid-cols-2 md:grid-cols-4 gap-6 pt-6 border-t border-border/60">
                  {t.founder.metrics.map((m) => (
                    <div key={m.l}>
                      <div className="font-serif text-3xl font-bold text-foreground">{m.v}</div>
                      <div className="text-xs text-muted-foreground mt-1 leading-tight">{m.l}</div>
                    </div>
                  ))}
                </div>

                <div>
                  <p className="text-xs font-semibold tracking-widest uppercase text-muted-foreground mb-3">{t.founder.marketsTitle}</p>
                  <div className="flex flex-wrap gap-2">
                    {t.founder.markets.map((m) => (
                      <span key={m} className="px-3 py-1 rounded-full text-xs border text-foreground" style={{ background: "hsl(var(--primary) / 0.05)", borderColor: "hsl(var(--primary) / 0.12)" }}>
                        {m}
                      </span>
                    ))}
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>
  );
}

// ── Pricing ───────────────────────────────────────────────────────────────────
function Pricing({ t, onStart }) {
  return (
    <section id="pricing" className="py-24 md:py-32 relative overflow-hidden">
      <div className="absolute inset-0 flex items-center justify-center pointer-events-none">
        <div className="w-[600px] h-[600px] rounded-full blur-3xl" style={{ background: "hsl(var(--secondary) / 0.06)" }} />
      </div>

      <div className="relative max-w-2xl mx-auto px-5 md:px-8 text-center">
        <div className="reveal inline-flex items-center gap-2 px-4 py-2 rounded-full text-sm font-semibold mb-6 border" style={{ background: "hsl(var(--secondary) / 0.1)", borderColor: "hsl(var(--secondary) / 0.25)", color: "hsl(var(--secondary))" }}>
          <SparklesIcon size={14} />
          {t.pricing.badge}
        </div>

        <div className="reveal" style={{ transitionDelay: "0.1s" }}>
          <h2 className="font-serif text-3xl md:text-5xl font-bold text-foreground mb-3">{t.pricing.head}</h2>
          <p className="text-muted-foreground mb-10">{t.pricing.sub}</p>
        </div>

        <div className="reveal rounded-3xl shadow-xl overflow-hidden" style={{ transitionDelay: "0.2s" }}>
          <div className="bg-primary px-10 py-10 text-center relative overflow-hidden">
            <div className="absolute inset-0 pointer-events-none" style={{ background: "linear-gradient(135deg, hsl(var(--secondary) / 0.2), transparent 50%)" }} />
            <div className="relative">
              <div className="inline-flex items-center gap-2 px-3 py-1.5 rounded-full text-primary-foreground text-xs font-medium mb-6" style={{ background: "hsl(var(--primary-foreground) / 0.12)" }}>
                <CheckCircleIcon size={13} />
                {t.pricing.planTag}
              </div>
              <div className="font-serif text-6xl md:text-7xl font-bold text-primary-foreground leading-none">{t.pricing.price}</div>
              <div className="text-primary-foreground/55 text-sm mt-2">{t.pricing.unit}</div>
            </div>
          </div>

          <div className="bg-card px-8 md:px-10 py-8 flex flex-col gap-6 text-left">
            <p className="text-muted-foreground leading-relaxed">{t.pricing.desc}</p>
            <div className="border-t border-border/60 pt-5">
              <p className="font-serif italic text-lg text-foreground">{t.pricing.trial}</p>
            </div>
            <button onClick={onStart}
              className="w-full bg-primary text-primary-foreground py-4 rounded-full font-semibold hover:opacity-90 transition-opacity flex items-center justify-center gap-2">
              {t.pricing.cta} <span>→</span>
            </button>
          </div>
        </div>
      </div>
    </section>
  );
}

// ── Guarantee ─────────────────────────────────────────────────────────────────
function Guarantee({ t }) {
  return (
    <section id="guarantee" className="py-24 md:py-32" style={{ background: "hsl(var(--muted) / 0.35)" }}>
      <div className="max-w-3xl mx-auto px-5 md:px-8">
        <div className="text-center mb-12 reveal">
          <div className="w-14 h-14 rounded-2xl flex items-center justify-center text-primary mx-auto mb-6" style={{ background: "hsl(var(--primary) / 0.07)" }}>
            <ShieldCheckIcon size={28} />
          </div>
          <p className="text-xs font-semibold tracking-widest uppercase text-muted-foreground mb-3">{t.guarantee.eyebrow}</p>
          <h2 className="font-serif text-3xl md:text-4xl font-bold text-foreground mb-4">{t.guarantee.head}</h2>
          <p className="text-muted-foreground">{t.guarantee.sub}</p>
        </div>

        <div className="flex flex-col gap-4">
          {t.guarantee.items.map((item, i) => (
            <div key={i} className="reveal-left bg-card border border-border/60 rounded-xl p-5 flex items-start gap-4" style={{ transitionDelay: `${i * 0.1}s` }}>
              <div className="w-9 h-9 rounded-lg flex items-center justify-center flex-shrink-0 mt-0.5" style={{ background: "hsl(var(--destructive) / 0.07)", color: "hsl(var(--destructive))" }}>
                <XCircleIcon size={18} />
              </div>
              <p className="text-sm leading-relaxed">
                <span className="text-muted-foreground">{item.cond}</span>{" "}
                <span className="font-semibold text-foreground">{item.result}</span>
              </p>
            </div>
          ))}
        </div>

        <div className="mt-6 reveal" style={{ transitionDelay: "0.35s" }}>
          <p className="text-sm text-muted-foreground italic rounded-xl p-5 border border-border/40 leading-relaxed" style={{ background: "hsl(var(--muted) / 0.5)" }}>
            {t.guarantee.finalprint}
          </p>
        </div>
      </div>
    </section>
  );
}

// ── Contact ───────────────────────────────────────────────────────────────────
function Contact({ t }) {
  const [form, setForm] = React.useState({ name: "", email: "", company: "", phone: "", message: "" });
  const [errors, setErrors] = React.useState({});
  const [status, setStatus] = React.useState({ kind: "", msg: "" });

  React.useEffect(() => { setStatus({ kind: "", msg: "" }); setErrors({}); }, [t]);

  const validate = () => {
    const e = {};
    if (!form.name.trim()) e.name = t.contact.errors.required;
    if (!form.email.trim()) e.email = t.contact.errors.required;
    else if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(form.email)) e.email = t.contact.errors.email;
    if (!form.message.trim()) e.message = t.contact.errors.required;
    return e;
  };

  const update = (k) => (ev) => {
    setForm({ ...form, [k]: ev.target.value });
    if (errors[k]) setErrors({ ...errors, [k]: undefined });
  };

  const onSubmit = async (e) => {
    e.preventDefault();
    const eobj = validate();
    setErrors(eobj);
    if (Object.keys(eobj).length) { setStatus({ kind: "err", msg: t.contact.errors.fix }); return; }
    setStatus({ kind: "loading", msg: t.contact.sending });
    try {
      await emailjs.send(window.EMAILJS_SERVICE_ID, window.EMAILJS_TEMPLATE_ID,
        { from_name: form.name, from_email: form.email, company: form.company, phone: form.phone, message: form.message });
      setStatus({ kind: "ok", msg: t.contact.sent });
      setForm({ name: "", email: "", company: "", phone: "", message: "" });
    } catch (_) {
      setStatus({ kind: "err", msg: t.contact.errors.send });
    }
  };

  const inputCls = (f) => `w-full px-4 py-3 rounded-xl border text-sm text-foreground bg-background placeholder-muted-foreground outline-none transition-all duration-150 focus:ring-2 ${errors[f] ? "border-destructive focus:ring-destructive/20" : "border-border focus:ring-primary/20"}`;

  return (
    <section id="contact" className="py-24 md:py-32">
      <div className="max-w-5xl mx-auto px-5 md:px-8">
        <div className="grid md:grid-cols-2 gap-12 md:gap-20 items-start">
          <div className="reveal">
            <div className="w-12 h-12 rounded-xl flex items-center justify-center text-primary mb-6" style={{ background: "hsl(var(--primary) / 0.07)" }}>
              <MailIcon size={22} />
            </div>
            <p className="text-xs font-semibold tracking-widest uppercase text-muted-foreground mb-3">{t.contact.eyebrow}</p>
            <h2 className="font-serif text-3xl md:text-4xl font-bold text-foreground mb-4">{t.contact.head}</h2>
            <p className="text-muted-foreground leading-relaxed">
              {t.contact.sub}
              <a href="mailto:info@doorlyb2b.com" className="text-primary hover:underline font-medium">info@doorlyb2b.com</a>
            </p>
          </div>

          <div className="reveal" style={{ transitionDelay: "0.1s" }}>
            <form onSubmit={onSubmit} noValidate className="bg-card border border-border/60 rounded-3xl p-8 md:p-10 flex flex-col gap-5">
              <div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
                <div className="flex flex-col gap-1.5">
                  <label className="text-xs font-semibold text-muted-foreground uppercase tracking-wide">{t.contact.labels.name} <span style={{ color: "hsl(var(--secondary))" }}>*</span></label>
                  <input value={form.name} onChange={update("name")} type="text" autoComplete="name" className={inputCls("name")} />
                  {errors.name && <span className="text-xs text-destructive">{errors.name}</span>}
                </div>
                <div className="flex flex-col gap-1.5">
                  <label className="text-xs font-semibold text-muted-foreground uppercase tracking-wide">{t.contact.labels.email} <span style={{ color: "hsl(var(--secondary))" }}>*</span></label>
                  <input value={form.email} onChange={update("email")} type="email" autoComplete="email" className={inputCls("email")} />
                  {errors.email && <span className="text-xs text-destructive">{errors.email}</span>}
                </div>
              </div>

              <div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
                <div className="flex flex-col gap-1.5">
                  <label className="text-xs font-semibold text-muted-foreground uppercase tracking-wide">{t.contact.labels.company}</label>
                  <input value={form.company} onChange={update("company")} type="text" autoComplete="organization" className={inputCls("company")} />
                </div>
                <div className="flex flex-col gap-1.5">
                  <label className="text-xs font-semibold text-muted-foreground uppercase tracking-wide">{t.contact.labels.phone}</label>
                  <input value={form.phone} onChange={update("phone")} type="tel" autoComplete="tel" className={inputCls("phone")} />
                </div>
              </div>

              <div className="flex flex-col gap-1.5">
                <label className="text-xs font-semibold text-muted-foreground uppercase tracking-wide">{t.contact.labels.message} <span style={{ color: "hsl(var(--secondary))" }}>*</span></label>
                <textarea value={form.message} onChange={update("message")} rows={5} className={`${inputCls("message")} resize-none`} />
                {errors.message && <span className="text-xs text-destructive">{errors.message}</span>}
              </div>

              {status.kind === "ok" ? (
                <div className="flex items-center gap-3 p-4 rounded-xl text-sm font-medium" style={{ background: "hsl(142 71% 45% / 0.1)", color: "hsl(142 71% 35%)" }}>
                  <CheckCircleIcon size={18} /> {status.msg}
                </div>
              ) : (
                <>
                  <button type="submit" className="w-full bg-primary text-primary-foreground py-4 rounded-full font-semibold flex items-center justify-center gap-2 hover:opacity-90 transition-opacity">
                    {t.contact.send} <SendIcon size={16} />
                  </button>
                  {status.msg && (
                    <p className={`text-xs text-center ${status.kind === "err" ? "text-destructive" : "text-muted-foreground"}`}>{status.msg}</p>
                  )}
                </>
              )}
            </form>
          </div>
        </div>
      </div>
    </section>
  );
}

// ── Footer ────────────────────────────────────────────────────────────────────
function Footer({ t, onStart }) {
  return (
    <footer>
      <div className="py-24 md:py-32 text-center">
        <div className="max-w-3xl mx-auto px-5 md:px-8 reveal">
          <h2 className="font-serif text-3xl md:text-5xl font-bold text-foreground mb-8 leading-tight">{t.closer.head}</h2>
          <button onClick={onStart}
            className="inline-flex items-center gap-3 bg-primary text-primary-foreground px-10 py-5 rounded-full text-base font-semibold shadow-lg hover:opacity-90 hover:shadow-xl hover:-translate-y-0.5 transition-all duration-200">
            {t.closer.cta} <span>→</span>
          </button>
        </div>
      </div>

      <div className="border-t border-border/60 py-6">
        <div className="max-w-6xl mx-auto px-5 md:px-8 flex items-center justify-between gap-4 flex-wrap">
          <a href="#top" onClick={(e) => { e.preventDefault(); window.scrollTo({ top: 0, behavior: "smooth" }); }}
            className="flex items-center gap-2 font-serif text-base font-bold text-foreground">
            <span className="w-6 h-6 rounded-md bg-white border border-border shadow-sm overflow-hidden flex items-center justify-center">
              <img src="assets/doorly-mark.png" className="w-full h-full object-contain p-0.5" alt="Doorly" />
            </span>
            doorly<span style={{ color: "hsl(var(--secondary))" }}>.</span>
          </a>
          <p className="text-sm text-muted-foreground">{t.footer}</p>
        </div>
      </div>
    </footer>
  );
}

// ── App ───────────────────────────────────────────────────────────────────────
function App() {
  const [lang, setLang] = React.useState("EN");
  const [dark, setDark] = React.useState(false);
  const t = COPY[lang] || COPY.EN;

  React.useEffect(() => {
    document.documentElement.classList.toggle("dark", dark);
  }, [dark]);

  React.useEffect(() => {
    document.documentElement.lang = lang === "ES" ? "es" : "en";
    document.title = lang === "ES"
      ? "Doorly — Reuniones B2B Cualificadas en EE. UU. y Europa"
      : "Doorly — Qualified B2B Meetings in US & Europe";
    const desc = document.querySelector('meta[name="description"]');
    if (desc) desc.content = lang === "ES"
      ? "Doorly concerta reuniones B2B cualificadas entre empresas de EE. UU. y Europa. Gestionamos investigación, contacto y agenda — tú solo te presentas."
      : "Doorly books qualified B2B meetings between companies in the US and Europe. We handle research, outreach and scheduling — you just show up.";
  }, [lang]);

  useReveal([lang, dark]);

  const onStart = React.useCallback(() => scrollToId("contact"), []);

  return (
    <div className="min-h-screen bg-background text-foreground font-sans antialiased">
      <Nav lang={lang} setLang={setLang} onStart={onStart} t={t} dark={dark} setDark={setDark} />
      <Hero t={t} onStart={onStart} />
      <HowItWorks t={t} />
      <Founder t={t} />
      <Pricing t={t} onStart={onStart} />
      <Guarantee t={t} />
      <Contact t={t} />
      <Footer t={t} onStart={onStart} />
    </div>
  );
}

const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(<App />);
