// sections.jsx — page sections

const { useState: useStateS, useEffect: useEffectS, useRef: useRefS } = React;

// ────────── TOP CONTACT BAR ──────────
function TopBar({ t, lang, onToggleLang }) {
  return (
    <div style={{
      background: "var(--bg-deep)",
      color: "var(--paper)",
      fontSize: 12.5,
      fontFamily: "var(--mono)",
      letterSpacing: "0.04em",
    }}>
      <div className="wrap topbar-row" style={{ display: "flex", alignItems: "center", justifyContent: "space-between", minHeight: 38 }}>
        <div style={{ display: "flex", gap: 22, opacity: 0.92, alignItems: "center" }}>
          <a href={window.PHONE_TEL} className="topbar-phone" style={{ display: "inline-flex", alignItems: "center", gap: 8, textDecoration: "none" }}>
            <IconPhone /> {window.PHONE_DISPLAY}
          </a>
          <span style={{ display: "inline-flex", alignItems: "center", gap: 8, opacity: 0.7 }} className="hide-sm">
            <IconPin /> Miami · Hialeah · Doral
          </span>
          <span style={{ display: "inline-flex", alignItems: "center", gap: 7, opacity: 0.95 }} className="hide-sm">
            <span style={{ width: 6, height: 6, background: "var(--brass)", borderRadius: "50%" }} />
            Hablamos Español
          </span>
        </div>
        <div style={{ display: "flex", gap: 18, opacity: 0.95, alignItems: "center" }}>
          <span className="hide-sm">{lang === "en" ? "Select Your Language" : "Seleccione Su Idioma"}</span>
          <button
            onClick={onToggleLang}
            className="lang-toggle"
            style={{
              background: "var(--brass)", color: "var(--bg-deep)", border: "1px solid var(--brass)",
              padding: "5px 14px", borderRadius: 999, fontFamily: "inherit", fontSize: 12, fontWeight: 600,
              letterSpacing: "0.06em", cursor: "pointer", display: "inline-flex", alignItems: "center", gap: 6,
            }}
            title="Toggle language"
          >
            <IconGlobe size={13} /> {t.langToggle === "ES" ? "Español" : "English"}
          </button>
        </div>
      </div>
    </div>
  );
}

// ────────── NAV ──────────
function Nav({ t }) {
  const [scrolled, setScrolled] = useStateS(false);
  const [mobileOpen, setMobileOpen] = useStateS(false);
  useEffectS(() => {
    const onScroll = () => setScrolled(window.scrollY > 12);
    window.addEventListener("scroll", onScroll);
    return () => window.removeEventListener("scroll", onScroll);
  }, []);
  useEffectS(() => {
    document.body.style.overflow = mobileOpen ? "hidden" : "";
    return () => { document.body.style.overflow = ""; };
  }, [mobileOpen]);
  const closeDrawer = () => setMobileOpen(false);
  return (
    <>
    <header style={{
      position: "sticky", top: 0, zIndex: 50,
      background: scrolled ? "rgba(11,17,30,.82)" : "transparent",
      backdropFilter: scrolled ? "blur(14px) saturate(140%)" : "none",
      WebkitBackdropFilter: scrolled ? "blur(14px) saturate(140%)" : "none",
      borderBottom: scrolled ? "1px solid var(--line-soft)" : "1px solid transparent",
      transition: "background .25s ease, border-color .25s ease",
    }}>
      <div className="wrap" style={{ display: "flex", alignItems: "center", justifyContent: "space-between", height: 180 }}>
        <a href="#top" style={{ display: "flex", alignItems: "center", textDecoration: "none", color: "var(--ink)" }}>
          <img src="assets/logo.png" alt="Tu Abogado Miami — Immigration Law" style={{ height: 162, width: "auto", display: "block", borderRadius: 14 }} />
        </a>

        <nav className="primary-nav-react hide-md">
          <ul>
            <li><a href="about">About</a></li>
            <li className="has-dd">
              <a href="services">Services <span className="caret">▾</span></a>
              <ul className="dd">
                <li><a href="services/asylum">Asylum</a></li>
                <li><a href="services/deportation-defense">Deportation Defense</a></li>
                <li><a href="services/immigration-court">Immigration Court</a></li>
                <li><a href="services/sijs">SIJS</a></li>
                <li><a href="services/green-card">Green Card / Residency</a></li>
                <li><a href="services/work-permit">Work Permit (EAD)</a></li>
              </ul>
            </li>
            <li><a href="case-results">Case Results</a></li>
            <li className="has-dd">
              <a href="locations/miami">Locations <span className="caret">▾</span></a>
              <ul className="dd">
                <li><a href="locations/miami">Miami</a></li>
                <li><a href="locations/hialeah">Hialeah</a></li>
                <li><a href="locations/doral">Doral</a></li>
                <li><a href="locations/kendall">Kendall</a></li>
                <li><a href="locations/little-havana">Little Havana</a></li>
                <li><a href="locations/north-miami">North Miami / Miami Gardens</a></li>
              </ul>
            </li>
            <li><a href="contact">Contact</a></li>
          </ul>
        </nav>

        <div style={{ display: "flex", gap: 10, alignItems: "center" }}>
          <a href={window.PHONE_TEL} className="hide-sm" style={{
            textDecoration: "none", color: "var(--ink)", fontFamily: "var(--mono)",
            fontSize: 18, fontWeight: 600, display: "inline-flex", alignItems: "center", gap: 10,
          }}>
            <IconPhone size={18} /> {window.PHONE_DISPLAY}
          </a>
          <a href="#consult" className="btn btn-primary btn-sm hide-sm">
            {t.cta} <IconArrow />
          </a>
          <button
            className="menu-toggle"
            aria-label="Open menu"
            aria-expanded={mobileOpen ? "true" : "false"}
            onClick={() => setMobileOpen(true)}
            style={{
              background: "transparent", border: "1px solid var(--line)",
              borderRadius: 10, width: 44, height: 44, cursor: "pointer",
              alignItems: "center", justifyContent: "center", color: "var(--ink)",
            }}
          >
            <svg width="20" height="14" viewBox="0 0 20 14" fill="none" aria-hidden="true">
              <line x1="0" y1="1" x2="20" y2="1" stroke="currentColor" strokeWidth="2" strokeLinecap="round" />
              <line x1="0" y1="7" x2="20" y2="7" stroke="currentColor" strokeWidth="2" strokeLinecap="round" />
              <line x1="0" y1="13" x2="20" y2="13" stroke="currentColor" strokeWidth="2" strokeLinecap="round" />
            </svg>
          </button>
        </div>
      </div>
    </header>

      {/* Mobile drawer — kept OUTSIDE <header> so the header's backdrop-filter
          doesn't become this fixed element's containing block on scroll */}
      <div
        className="mobile-drawer"
        data-open={mobileOpen ? "true" : "false"}
        aria-hidden={mobileOpen ? "false" : "true"}
      >
        <div className="drawer-head">
          <img src="assets/logo.png" alt="Tu Abogado Miami — Immigration Law" style={{ height: 144, width: "auto", display: "block", borderRadius: 14 }} />
          <button
            className="drawer-close"
            aria-label="Close menu"
            onClick={closeDrawer}
            style={{
              background: "transparent", border: "1px solid var(--line)",
              borderRadius: 10, width: 44, height: 44, cursor: "pointer",
              display: "grid", placeItems: "center", color: "var(--ink)",
            }}
          >
            <svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true">
              <path d="M3 3l10 10M13 3L3 13" stroke="currentColor" strokeWidth="2" strokeLinecap="round" />
            </svg>
          </button>
        </div>
        <nav className="drawer-nav">
          <a href="about" onClick={closeDrawer}>About</a>
          <details>
            <summary>Services</summary>
            <ul>
              <li><a href="services/asylum" onClick={closeDrawer}>Asylum</a></li>
              <li><a href="services/deportation-defense" onClick={closeDrawer}>Deportation Defense</a></li>
              <li><a href="services/immigration-court" onClick={closeDrawer}>Immigration Court</a></li>
              <li><a href="services/sijs" onClick={closeDrawer}>SIJS</a></li>
              <li><a href="services/green-card" onClick={closeDrawer}>Green Card / Residency</a></li>
              <li><a href="services/work-permit" onClick={closeDrawer}>Work Permit (EAD)</a></li>
            </ul>
          </details>
          <a href="case-results" onClick={closeDrawer}>Case Results</a>
          <details>
            <summary>Locations</summary>
            <ul>
              <li><a href="locations/miami" onClick={closeDrawer}>Miami</a></li>
              <li><a href="locations/hialeah" onClick={closeDrawer}>Hialeah</a></li>
              <li><a href="locations/doral" onClick={closeDrawer}>Doral</a></li>
              <li><a href="locations/kendall" onClick={closeDrawer}>Kendall</a></li>
              <li><a href="locations/little-havana" onClick={closeDrawer}>Little Havana</a></li>
              <li><a href="locations/north-miami" onClick={closeDrawer}>North Miami / Miami Gardens</a></li>
            </ul>
          </details>
          <a href="contact" onClick={closeDrawer}>Contact</a>
        </nav>
        <div className="drawer-cta">
          <a href={window.PHONE_TEL} className="btn btn-primary btn-lg" style={{ justifyContent: "center" }}>
            <IconPhone size={16} /> {window.PHONE_DISPLAY}
          </a>
          <a href="#consult" onClick={closeDrawer} className="btn btn-brass btn-lg" style={{ justifyContent: "center" }}>
            {t.cta} <IconArrow />
          </a>
        </div>
      </div>
    </>
  );
}

// ────────── HERO ──────────
function Hero({ t, variant }) {
  return (
    <section id="top" style={{ position: "relative", overflow: "hidden" }}>
      {/* Faint editorial backdrop */}
      <div aria-hidden style={{
        position: "absolute", inset: 0, pointerEvents: "none",
        background: "radial-gradient(900px 500px at 80% -10%, oklch(70% 0.11 75 / 0.18), transparent 60%), radial-gradient(700px 400px at -10% 30%, oklch(40% 0.06 165 / 0.10), transparent 60%)",
      }} />
      <div className="wrap" style={{ position: "relative", paddingTop: "clamp(32px, 3vw, 48px)", paddingBottom: "clamp(32px, 5vw, 64px)" }}>
        <div style={{
          display: "grid",
          gridTemplateColumns: variant === "wide-image" ? "1fr 1fr" : "1.15fr 1fr",
          gap: "clamp(28px, 4vw, 64px)",
          alignItems: "center",
        }} className="hero-grid">

          {/* Text column */}
          <div>
            <h1 className="display" style={{ fontSize: "clamp(38px, 5vw, 72px)", margin: 0, lineHeight: 1.02 }}>
              <Reveal delay={60} as="span" style={{ display: "block" }}>{t.hero.title1}</Reveal>
              <Reveal delay={140} as="span" style={{ display: "block" }}>{t.hero.title2}</Reveal>
              <Reveal delay={220} as="span" style={{ display: "block", fontStyle: "italic", color: "var(--brand)" }}>{t.hero.title3}</Reveal>
            </h1>

            <Reveal delay={320}>
              <p className="lead" style={{ marginTop: 28, maxWidth: 520 }}>
                {t.hero.sub}
              </p>
            </Reveal>

            <Reveal delay={380}>
              <div style={{ display: "flex", gap: 12, marginTop: 32, flexWrap: "wrap" }}>
                <a href="#consult" className="btn btn-primary btn-lg">{t.hero.ctaPrimary} <IconArrow /></a>
                <a href={window.PHONE_TEL} className="btn btn-ghost btn-lg"><IconPhone size={15} /> {t.hero.ctaSecondary}</a>
              </div>
            </Reveal>

            <Reveal delay={460}>
              <div style={{
                marginTop: 36,
              }}>
                <div className="eyebrow" style={{ marginBottom: 14 }}>
                  <span style={{ display: "inline-block", width: 22, height: 1, background: "var(--ink-soft)", verticalAlign: "middle", marginRight: 10 }}></span>
                  {window._lang === "es" ? "Elija su ubicación" : "Choose your location"}
                </div>
                <div style={{ display: "flex", flexWrap: "wrap", gap: 8 }}>
                  {t.findHelp.locations.map((l) => (
                    <a key={l} href="#consult" style={{
                      cursor: "pointer", textDecoration: "none",
                      background: "var(--surface)",
                      color: "var(--ink)",
                      border: "1px solid var(--line)",
                      borderRadius: 999, padding: "9px 14px", fontSize: 13.5,
                      fontFamily: "inherit", display: "inline-flex", alignItems: "center", gap: 6,
                      transition: "all .18s ease",
                    }}>
                      <IconPin /> {l}
                    </a>
                  ))}
                </div>
              </div>
            </Reveal>
          </div>

          {/* Image column */}
          <Reveal delay={200}>
            <div style={{ position: "relative" }}>
              {/* Brass frame */}
              <div style={{ position: "absolute", inset: "-14px 14px 14px -14px", border: "1px solid var(--brass)", borderRadius: 6 }} />
              <div style={{
                position: "relative", zIndex: 1, aspectRatio: "4 / 5",
                borderRadius: 6, overflow: "hidden",
                background: "var(--cream)",
                boxShadow: "0 20px 60px rgba(12, 29, 46, 0.18)",
              }}>
                <img
                  src="assets/hero-family.png"
                  alt="A family in Miami"
                  style={{
                    width: "100%", height: "100%",
                    objectFit: "cover", objectPosition: "center 25%",
                    display: "block",
                  }}
                />
              </div>
              {/* Floating credential card */}
              <div style={{
                position: "absolute", left: -32, bottom: 32, zIndex: 3,
                background: "var(--surface)", border: "1px solid var(--line)", borderRadius: 10,
                padding: "16px 18px", boxShadow: "0 14px 40px rgba(0,0,0,.35)",
                maxWidth: 240,
              }} className="hide-sm">
                <div style={{ display: "flex", alignItems: "center", gap: 8, color: "var(--brass-deep)", marginBottom: 6 }}>
                  {Array.from({ length: 5 }).map((_, i) => <IconStar key={i} />)}
                </div>
                <div style={{ fontSize: 13, lineHeight: 1.45, color: "var(--ink-mid)" }}>
                  "{(window.CONTENT[window._lang || 'en']?.voices?.items?.[0]?.quote || '').slice(0, 90)}…"
                </div>
                <div style={{ fontFamily: "var(--mono)", fontSize: 11, letterSpacing: "0.06em", color: "var(--ink-soft)", marginTop: 10 }}>
                  G★★★★★ · 612 REVIEWS
                </div>
              </div>
              {/* Floating badge */}
              <a href="#consult" style={{
                position: "absolute", right: -24, top: -24, zIndex: 3,
                width: 110, height: 110, borderRadius: "50%",
                background: "var(--brass)", color: "var(--bg-deep)",
                display: "grid", placeItems: "center", textAlign: "center",
                fontFamily: "var(--serif)", lineHeight: 1.15,
                transform: "rotate(-8deg)", textDecoration: "none",
                boxShadow: "0 10px 30px rgba(120,90,30,.25)",
              }} className="hide-sm">
                <div style={{ fontSize: 18, letterSpacing: "-0.01em", padding: "0 10px" }}>
                  Take the<br/>first step
                </div>
              </a>
            </div>
          </Reveal>
        </div>
      </div>

      {/* Popular services marquee */}
      <div style={{ borderTop: "1px solid var(--line)", borderBottom: "1px solid var(--line)", background: "var(--bg-soft)", padding: "18px 0", overflow: "hidden", marginTop: 20 }}>
        <div style={{ display: "flex", whiteSpace: "nowrap", animation: "marquee 40s linear infinite", width: "max-content" }}>
          {[...Array(2)].flatMap(() => t.findHelp.services).map((label, i) => {
            const display = label === "SIJS"
              ? (t.langToggle === "EN" ? "Estatus Especial para Jóvenes Inmigrantes" : "Special Immigrant Juvenile Status")
              : label;
            return (
              <a key={i} href="#consult" style={{
                fontFamily: "var(--mono)", fontSize: 12, letterSpacing: "0.08em",
                textTransform: "uppercase", color: "var(--ink-soft)", textDecoration: "none",
                display: "inline-flex", alignItems: "center", gap: 14,
                marginRight: 56, flexShrink: 0,
              }}>
                <span style={{ width: 6, height: 6, background: "var(--brass)", borderRadius: "50%" }} />
                {display}
              </a>
            );
          })}
        </div>
      </div>
    </section>
  );
}

// ────────── BIG PHONE BANNER ──────────
function PhoneBanner({ t, lang }) {
  return (
    <section style={{
      background: "var(--bg-deep)",
      color: "var(--paper)",
      padding: "clamp(48px, 6vw, 88px) 0",
      borderTop: "1px solid rgba(255,255,255,.06)",
      borderBottom: "1px solid rgba(255,255,255,.06)",
      position: "relative",
      overflow: "hidden",
    }}>
      <div aria-hidden style={{
        position: "absolute", inset: 0, pointerEvents: "none",
        background: "radial-gradient(700px 300px at 20% 50%, oklch(78% 0.14 210 / 0.15), transparent 70%), radial-gradient(500px 300px at 90% 50%, oklch(82% 0.14 85 / 0.10), transparent 70%)",
      }} />
      <div className="wrap" style={{ position: "relative", textAlign: "center" }}>
        <div className="eyebrow" style={{ marginBottom: 18, color: "var(--brass)" }}>
          {lang === "en" ? "Available 24/7 · Hablamos español" : "Disponible 24/7 · We speak English"}
        </div>
        <a href={window.PHONE_TEL} style={{
          display: "inline-block", textDecoration: "none",
          fontFamily: "var(--serif)", fontWeight: 800,
          fontSize: "clamp(56px, 11vw, 168px)",
          color: "var(--brand)",
          letterSpacing: "-0.04em",
          lineHeight: 1,
          textShadow: "0 0 80px rgba(34, 211, 238, 0.25)",
        }}>
          {window.PHONE_DISPLAY}
        </a>
        <div style={{
          marginTop: 24,
          fontSize: 18,
          color: "oklch(85% 0.012 230)",
          maxWidth: 600, marginLeft: "auto", marginRight: "auto",
        }}>
          {lang === "en"
            ? "Call now for a free, confidential consultation. We answer every call personally — no call centers, no bots, no waiting."
            : "Llame ahora para una consulta gratuita y confidencial. Respondemos cada llamada personalmente — sin call centers, sin bots, sin esperas."}
        </div>
      </div>
    </section>
  );
}

// ────────── SERVICES ──────────
function Services({ t }) {
  const [hover, setHover] = useStateS(null);
  return (
    <section style={{
      background: "var(--bg-deep)", color: "var(--paper)",
      padding: "clamp(28px, 3.4vw, 56px) 0 clamp(80px, 10vw, 140px)",
    }}>
      <div className="wrap">
        <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 64, alignItems: "end", marginBottom: 64 }} className="services-head">
          <div>
            <div className="eyebrow" style={{ marginBottom: 18, color: "var(--brass)" }}>
              <span style={{ display: "inline-block", width: 22, height: 1, background: "var(--brass)", verticalAlign: "middle", marginRight: 10 }}></span>
              {t.services.eyebrow}
            </div>
            <h2 className="display" style={{ fontSize: "clamp(34px, 4.4vw, 64px)", margin: 0 }}>
              {t.services.title}
            </h2>
          </div>
          <p className="lead" style={{ color: "oklch(85% 0.01 80)", maxWidth: 480 }}>{t.services.sub}</p>
        </div>

        <div style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 0, borderTop: "1px solid rgba(255,255,255,.12)" }} className="services-grid">
          {t.services.items.map((s, i) => {
            const isHover = hover === i;
            return (
              <div key={s.k}
                onMouseEnter={() => setHover(i)}
                onMouseLeave={() => setHover(null)}
                style={{
                  borderBottom: "1px solid rgba(255,255,255,.12)",
                  borderRight: i % 3 !== 2 ? "1px solid rgba(255,255,255,.12)" : "none",
                  padding: "36px 32px 32px",
                  position: "relative",
                  background: isHover ? "rgba(255,255,255,.04)" : "transparent",
                  transition: "background .25s ease",
                  cursor: "default",
                }}
              >
                <div style={{ display: "flex", justifyContent: "flex-end", alignItems: "start", marginBottom: 28 }}>
                  <IconArrow size={16} />
                </div>
                <h3 style={{
                  fontFamily: "var(--serif)", fontWeight: 500,
                  fontSize: "clamp(24px, 2.4vw, 34px)", margin: 0, lineHeight: 1.1,
                  letterSpacing: "-0.01em",
                }}>{s.k}</h3>
                <p style={{ color: "oklch(80% 0.01 80)", fontSize: 14.5, lineHeight: 1.55, marginTop: 14, marginBottom: 0 }}>{s.d}</p>
              </div>
            );
          })}
        </div>

        <div style={{ marginTop: 48, display: "flex", gap: 12, flexWrap: "wrap" }}>
          <a href="#consult" className="btn btn-brass">{t.cta} <IconArrow /></a>
          <a href="#" className="btn" style={{ background: "transparent", color: "var(--paper)", border: "1px solid rgba(255,255,255,.2)" }}>
            {t.cases.cta} <IconArrow />
          </a>
        </div>
      </div>
    </section>
  );
}

// ────────── CASE RESULTS ──────────
function CaseResults({ t }) {
  return (
    <section style={{ padding: "clamp(28px, 3.4vw, 56px) 0 clamp(80px, 10vw, 140px)" }}>
      <div className="wrap">
        <SectionHead title={t.cases.title} sub={t.cases.sub} />

        <div style={{ display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: 18, marginTop: 56 }} className="cases-grid">
          {t.cases.items.map((c, i) => (
            <Reveal key={i} delay={i * 80}>
              <div style={{
                border: "1px solid var(--line)", background: "var(--surface)", borderRadius: 8, overflow: "hidden",
                display: "flex", flexDirection: "column", height: "100%",
              }}>
                <div style={{ position: "relative", aspectRatio: "5 / 4", background: "var(--bg-deep)" }}>
                  {/* Faux "redacted document" */}
                  <svg viewBox="0 0 200 160" width="100%" height="100%" preserveAspectRatio="none" style={{ filter: "blur(1.5px) opacity(0.35)" }} aria-hidden>
                    <rect width="200" height="160" fill="oklch(30% 0.02 165)" />
                    {Array.from({ length: 14 }).map((_, j) => (
                      <rect key={j} x="20" y={20 + j * 8} width={Math.random() * 100 + 60} height="3" fill="oklch(80% 0.02 80)" opacity={0.7 - j * 0.03} />
                    ))}
                    <rect x="20" y="20" width="80" height="6" fill="oklch(85% 0.04 80)" />
                  </svg>
                  <div style={{
                    position: "absolute", inset: 0, display: "grid", placeItems: "center",
                  }}>
                    <div style={{
                      transform: "rotate(-6deg)",
                      border: "2px solid var(--brass)",
                      color: "var(--brass)",
                      fontFamily: "var(--serif)",
                      fontSize: 18,
                      letterSpacing: "0.04em",
                      padding: "10px 20px",
                      background: "rgba(255,255,255,.04)",
                      textTransform: "uppercase",
                    }}>{c.title}</div>
                  </div>
                  <div style={{
                    position: "absolute", top: 12, left: 12,
                    fontFamily: "var(--mono)", fontSize: 10.5, letterSpacing: "0.1em",
                    color: "var(--paper)", background: "rgba(0,0,0,.45)",
                    padding: "4px 8px", borderRadius: 4, textTransform: "uppercase",
                  }}>{c.tag}</div>
                </div>
                <div style={{ padding: "20px 22px 24px" }}>
                  <div className="eyebrow" style={{ display: "flex", justifyContent: "space-between", fontSize: 10.5 }}>
                    <span>{c.court}</span>
                    <span>{c.date}</span>
                  </div>
                  <p style={{ marginTop: 12, marginBottom: 0, fontSize: 14.5, lineHeight: 1.5, color: "var(--ink-mid)" }}>{c.note}</p>
                </div>
              </div>
            </Reveal>
          ))}
        </div>

        <div style={{ marginTop: 40 }}>
          <a href="#" className="btn btn-ghost">{t.cases.cta} <IconArrow /></a>
        </div>
      </div>
    </section>
  );
}

// ────────── WHY US ──────────
function WhyUs({ t }) {
  return (
    <section style={{ padding: "clamp(80px, 10vw, 140px) 0", background: "var(--bg-soft)" }}>
      <div className="wrap">
        <div style={{ display: "grid", gridTemplateColumns: "1fr 1.3fr", gap: 80, alignItems: "start" }} className="why-grid">
          <div>
            <SectionHead eyebrow={t.why.eyebrow} title={t.why.title} titleSize="clamp(28px, 3.4vw, 44px)" />
            <div style={{ position: "relative", marginTop: 36 }}>
              <div style={{
                aspectRatio: "4 / 3", borderRadius: 6, overflow: "hidden",
                border: "1px solid var(--line)", background: "var(--cream)",
              }}>
                <img
                  src="assets/why-family.png"
                  alt="A family in Miami"
                  style={{ width: "100%", height: "100%", objectFit: "cover", display: "block" }}
                />
              </div>
              <div style={{
                position: "absolute", right: -16, bottom: -16,
                background: "var(--brand)", color: "var(--paper)",
                padding: "20px 24px", borderRadius: 8, fontFamily: "var(--serif)",
                fontSize: 28, lineHeight: 1.05, maxWidth: 200,
              }} className="hide-sm">
                "Cada caso es <i>personal</i>."
                <div style={{ fontFamily: "var(--mono)", fontSize: 10.5, letterSpacing: "0.1em", marginTop: 10, color: "var(--brass)", textTransform: "uppercase" }}>
                  — Founding Partner
                </div>
              </div>
            </div>
          </div>
          <div style={{ display: "grid", gap: 4 }}>
            {t.why.points.map((p, i) => (
              <Reveal key={i} delay={i * 80}>
                <div style={{
                  display: "grid", gridTemplateColumns: "120px 1fr",
                  padding: "28px 0",
                  borderTop: "1px solid var(--line)",
                  alignItems: "start",
                }}>
                  <div style={{ fontFamily: "var(--serif)", fontSize: 44, lineHeight: 1, color: "var(--brand)" }}>{p.n}</div>
                  <div>
                    <h3 style={{ fontFamily: "var(--sans)", fontSize: 18, fontWeight: 500, margin: 0, marginBottom: 8 }}>{p.k}</h3>
                    <p style={{ margin: 0, color: "var(--ink-mid)", fontSize: 14.5, lineHeight: 1.55, maxWidth: 440 }}>{p.d}</p>
                  </div>
                </div>
              </Reveal>
            ))}
            <div style={{ borderTop: "1px solid var(--line)" }} />
          </div>
        </div>
      </div>
    </section>
  );
}

// ────────── HOW IT WORKS ──────────
function HowItWorks({ t }) {
  return (
    <section style={{ padding: "clamp(28px, 3.4vw, 56px) 0" }}>
      <div className="wrap">
        <SectionHead eyebrow={t.how.eyebrow} title={t.how.title} sub={t.how.sub} align="center" maxw={800} />

        <div style={{ marginTop: 40, display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 0, position: "relative" }} className="how-grid">
          {/* Connecting line */}
          <div aria-hidden style={{
            position: "absolute", top: 28, left: "16%", right: "16%", height: 1,
            background: "repeating-linear-gradient(to right, var(--line) 0 6px, transparent 6px 12px)",
            zIndex: 0,
          }} className="how-line" />
          {t.how.steps.map((s, i) => (
            <Reveal key={i} delay={i * 120} style={{ position: "relative", zIndex: 1, padding: "0 24px", textAlign: "center" }}>
              <div style={{
                width: 56, height: 56, margin: "0 auto 24px",
                borderRadius: "50%", background: "var(--surface)",
                border: "1px solid var(--line)",
                display: "grid", placeItems: "center",
                fontFamily: "var(--serif)", fontSize: 22, color: "var(--brand)",
              }}>{s.n}</div>
              <h3 style={{ fontFamily: "var(--serif)", fontWeight: 500, fontSize: 24, letterSpacing: "-0.01em", margin: "0 0 10px" }}>{s.k}</h3>
              <p style={{ margin: 0, color: "var(--ink-mid)", fontSize: 14.5, maxWidth: 280, marginInline: "auto" }}>{s.d}</p>
            </Reveal>
          ))}
        </div>
      </div>
    </section>
  );
}

// ────────── TESTIMONIALS ──────────
function Voices({ t }) {
  return (
    <section style={{ padding: "clamp(80px, 10vw, 140px) 0", background: "var(--bg-soft)" }}>
      <div className="wrap">
        <SectionHead eyebrow={t.voices.eyebrow} title={t.voices.title} />

        <div style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 20, marginTop: 56 }} className="voices-grid">
          {t.voices.items.map((v, i) => (
            <Reveal key={i} delay={i * 100}>
              <div style={{
                background: "var(--surface)", border: "1px solid var(--line)",
                borderRadius: 10, padding: "32px 28px 28px", height: "100%",
                display: "flex", flexDirection: "column",
              }}>
                <div style={{ display: "flex", gap: 4, color: "var(--brass-deep)", marginBottom: 18 }}>
                  {Array.from({ length: 5 }).map((_, j) => <IconStar key={j} />)}
                </div>
                <blockquote style={{
                  fontFamily: "var(--serif)", fontSize: "clamp(20px, 1.8vw, 24px)",
                  margin: 0, lineHeight: 1.35, color: "var(--ink)",
                  letterSpacing: "-0.005em", flex: 1,
                }}>
                  "{v.quote}"
                </blockquote>
                <div style={{ marginTop: 28, paddingTop: 20, borderTop: "1px solid var(--line)" }}>
                  <div style={{ fontWeight: 500, fontSize: 14.5 }}>{v.name}</div>
                  <div style={{ fontFamily: "var(--mono)", fontSize: 11, letterSpacing: "0.06em", color: "var(--ink-soft)", marginTop: 4, textTransform: "uppercase" }}>{v.role}</div>
                  <div style={{ fontSize: 12.5, color: "var(--ink-soft)", marginTop: 6 }}>{v.origin}</div>
                </div>
              </div>
            </Reveal>
          ))}
        </div>
      </div>
    </section>
  );
}

// ────────── FINAL CTA + FORM ──────────
function FinalCTA({ t }) {
  const [step, setStep] = useStateS(1);
  const [form, setForm] = useStateS({ name: "", phone: "", email: "", topic: "", details: "" });
  const [sent, setSent] = useStateS(false);

  const update = (k, v) => setForm((p) => ({ ...p, [k]: v }));

  return (
    <section id="consult" style={{
      background: "var(--bg-deep)", color: "var(--paper)",
      padding: "clamp(48px, 6vw, 88px) 0",
      position: "relative", overflow: "hidden",
    }}>
      <div aria-hidden style={{
        position: "absolute", inset: 0, opacity: 0.4,
        background: "radial-gradient(700px 400px at 90% 110%, oklch(70% 0.11 75 / 0.25), transparent 60%)",
      }} />
      <div className="wrap" style={{ position: "relative" }}>
        <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 80, alignItems: "center" }} className="cta-grid">
          <div>
            {t.finalCta.eyebrow && (
              <div className="eyebrow" style={{ marginBottom: 22, color: "var(--brass)" }}>
                <span style={{ display: "inline-block", width: 22, height: 1, background: "var(--brass)", verticalAlign: "middle", marginRight: 10 }}></span>
                {t.finalCta.eyebrow}
              </div>
            )}
            <h2 className="display" style={{ fontSize: "clamp(40px, 5.5vw, 80px)", margin: 0 }}>
              {t.finalCta.title1}<br/>
              <i style={{ color: "var(--brass)" }}>{t.finalCta.title2}</i>
            </h2>
            <p className="lead" style={{ marginTop: 24, color: "oklch(85% 0.012 80)", maxWidth: 500 }}>{t.finalCta.sub}</p>

            <div style={{ display: "flex", gap: 12, marginTop: 32, flexWrap: "wrap" }}>
              <a href={window.PHONE_TEL} className="btn btn-brass btn-lg">
                <IconPhone size={15} /> {t.finalCta.cta2}
              </a>
            </div>

            <div style={{ marginTop: 32, paddingTop: 24, borderTop: "1px solid rgba(255,255,255,.12)", display: "flex", gap: 18, flexWrap: "wrap" }}>
              {t.finalCta.promise.split(" · ").map((p, i) => (
                <div key={i} style={{ display: "inline-flex", alignItems: "center", gap: 8, fontSize: 13.5, color: "oklch(85% 0.012 80)", whiteSpace: "nowrap" }}>
                  <span style={{ color: "var(--brass)" }}><IconCheck /></span> {p}
                </div>
              ))}
            </div>
          </div>

          {/* Form card */}
          <div style={{
            background: "var(--surface)", color: "var(--ink)",
            borderRadius: 12, padding: "36px 36px 32px",
            boxShadow: "0 30px 80px rgba(0,0,0,.25)",
          }}>
            <div style={{ display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: 22 }}>
              <div className="eyebrow">{sent ? (t.langToggle === 'EN' ? '✓ Recibido' : '✓ Received') : `Step ${step} of 3`}</div>
              <div style={{ display: "flex", gap: 4 }}>
                {[1,2,3].map((n) => (
                  <div key={n} style={{
                    width: 26, height: 3, borderRadius: 2,
                    background: step >= n ? "var(--brand)" : "var(--line)",
                    transition: "background .3s ease",
                  }} />
                ))}
              </div>
            </div>

            {!sent ? (
              <form onSubmit={(e) => { e.preventDefault(); if (step < 3) setStep(step+1); else setSent(true); }}>
                {step === 1 && (
                  <div style={{ display: "grid", gap: 14 }}>
                    <h3 style={{ fontFamily: "var(--serif)", fontSize: 28, margin: 0, marginBottom: 6, letterSpacing: "-0.01em" }}>
                      {t.langToggle === 'EN' ? "Cuéntenos sobre usted" : "Tell us who you are"}
                    </h3>
                    <Input label={t.langToggle === 'EN' ? "Nombre completo" : "Full name"} value={form.name} onChange={(v) => update("name", v)} required />
                    <Input label={t.langToggle === 'EN' ? "Teléfono" : "Phone"} value={form.phone} onChange={(v) => update("phone", v)} type="tel" required />
                    <Input label="Email" value={form.email} onChange={(v) => update("email", v)} type="email" required />
                  </div>
                )}
                {step === 2 && (
                  <div style={{ display: "grid", gap: 14 }}>
                    <h3 style={{ fontFamily: "var(--serif)", fontSize: 28, margin: 0, marginBottom: 6, letterSpacing: "-0.01em" }}>
                      {t.langToggle === 'EN' ? "¿Qué le trae aquí?" : "What brings you here?"}
                    </h3>
                    <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 8 }}>
                      {t.findHelp.services.map((s) => (
                        <button key={s} type="button"
                          onClick={() => update("topic", s)}
                          style={{
                            appearance: "none", cursor: "pointer",
                            background: form.topic === s ? "var(--brand)" : "transparent",
                            color: form.topic === s ? "var(--paper)" : "var(--ink)",
                            border: `1px solid ${form.topic === s ? "var(--brand)" : "var(--line)"}`,
                            borderRadius: 8, padding: "12px 14px", fontSize: 13.5,
                            fontFamily: "inherit", textAlign: "left",
                            transition: "all .18s ease",
                          }}>{s}</button>
                      ))}
                    </div>
                  </div>
                )}
                {step === 3 && (
                  <div style={{ display: "grid", gap: 14 }}>
                    <h3 style={{ fontFamily: "var(--serif)", fontSize: 28, margin: 0, marginBottom: 6, letterSpacing: "-0.01em" }}>
                      {t.langToggle === 'EN' ? "Cuéntenos un poco más" : "Tell us a bit more"}
                    </h3>
                    <Textarea label={t.langToggle === 'EN' ? "Su situación (opcional)" : "Your situation (optional)"} value={form.details} onChange={(v) => update("details", v)} />
                  </div>
                )}

                <div style={{ display: "flex", justifyContent: "space-between", alignItems: "center", marginTop: 26 }}>
                  <button type="button"
                    onClick={() => setStep(Math.max(1, step - 1))}
                    style={{ background: "none", border: 0, color: "var(--ink-soft)", fontFamily: "inherit", cursor: "pointer", fontSize: 13.5, visibility: step === 1 ? "hidden" : "visible" }}>
                    ← Back
                  </button>
                  <button type="submit" className="btn btn-primary">
                    {step < 3
                      ? (t.langToggle === 'EN' ? "Continuar" : "Continue")
                      : t.finalCta.cta1}
                    <IconArrow />
                  </button>
                </div>
              </form>
            ) : (
              <div style={{ textAlign: "center", padding: "20px 0" }}>
                <div style={{
                  width: 56, height: 56, borderRadius: "50%",
                  background: "var(--brand)", color: "var(--paper)",
                  display: "grid", placeItems: "center", margin: "0 auto 18px",
                }}>
                  <IconCheck size={22} />
                </div>
                <h3 style={{ fontFamily: "var(--serif)", fontSize: 30, margin: 0, letterSpacing: "-0.01em" }}>
                  {t.langToggle === 'EN' ? "¡Gracias!" : "Thank you!"}
                </h3>
                <p style={{ color: "var(--ink-mid)", marginTop: 8, marginBottom: 0 }}>
                  {t.langToggle === 'EN'
                    ? "Le llamaremos en menos de una hora. Si es urgente, llame al "
                    : "We'll call you within an hour. For urgent matters, call "}
                  <a href={window.PHONE_TEL} style={{ color: "var(--brand)", fontWeight: 500 }}>{window.PHONE_DISPLAY}</a>.
                </p>
              </div>
            )}
          </div>
        </div>
      </div>
    </section>
  );
}

function Input({ label, value, onChange, type = "text", required }) {
  return (
    <label style={{ display: "block" }}>
      <span style={{ display: "block", fontFamily: "var(--mono)", fontSize: 10.5, letterSpacing: "0.1em", textTransform: "uppercase", color: "var(--ink-soft)", marginBottom: 6 }}>{label}{required && " *"}</span>
      <input
        type={type}
        value={value}
        onChange={(e) => onChange(e.target.value)}
        required={required}
        style={{
          width: "100%", height: 44, padding: "0 14px",
          border: "1px solid var(--line)", borderRadius: 8,
          fontFamily: "inherit", fontSize: 15, background: "var(--bg)",
          color: "var(--ink)", outline: "none",
        }}
      />
    </label>
  );
}

function Textarea({ label, value, onChange }) {
  return (
    <label style={{ display: "block" }}>
      <span style={{ display: "block", fontFamily: "var(--mono)", fontSize: 10.5, letterSpacing: "0.1em", textTransform: "uppercase", color: "var(--ink-soft)", marginBottom: 6 }}>{label}</span>
      <textarea
        value={value}
        onChange={(e) => onChange(e.target.value)}
        rows={4}
        style={{
          width: "100%", padding: "12px 14px",
          border: "1px solid var(--line)", borderRadius: 8,
          fontFamily: "inherit", fontSize: 15, background: "var(--bg)",
          color: "var(--ink)", outline: "none", resize: "vertical",
        }}
      />
    </label>
  );
}

// ────────── FOOTER ──────────
function Footer({ t }) {
  const cols = [t.footer.colServices, t.footer.colFirm, t.footer.colLocations];
  return (
    <footer style={{ background: "var(--bg)", borderTop: "1px solid var(--line)", padding: "80px 0 36px" }}>
      <div className="wrap">
        <div className="footer-grid">
          <div>
            <p style={{ color: "var(--ink-mid)", maxWidth: 320, marginTop: 0 }}>{t.footer.tagline}</p>
            <p style={{ color: "var(--ink-soft)", maxWidth: 320, marginTop: 8, fontSize: 14, display: "inline-flex", alignItems: "center", gap: 8 }}>
              <span style={{ width: 6, height: 6, background: "var(--brass)", borderRadius: "50%", flexShrink: 0 }} />
              Abogado de Inmigración en Miami · Hablamos Español
            </p>
            <div style={{ marginTop: 24, color: "var(--ink-mid)", fontSize: 14, lineHeight: 1.7 }}>
              {t.footer.address.map((l, i) => <div key={i}>{l}</div>)}
            </div>
            <div style={{ marginTop: 18, color: "var(--ink-mid)", fontSize: 14, lineHeight: 1.7 }}>
              {t.footer.hours.map((l, i) => <div key={i}>{l}</div>)}
            </div>
            <a href={window.PHONE_TEL} style={{
              display: "inline-flex", alignItems: "center", gap: 10, marginTop: 22,
              textDecoration: "none", color: "var(--ink)", fontFamily: "var(--serif)",
              fontSize: 26, letterSpacing: "-0.01em", whiteSpace: "nowrap",
            }}>
              <IconPhone size={16} /> {window.PHONE_DISPLAY}
            </a>
          </div>

          {cols.map((c, i) => (
            <div key={i}>
              <div className="eyebrow" style={{ marginBottom: 18 }}>{c.label}</div>
              <ul style={{ listStyle: "none", padding: 0, margin: 0, display: "grid", gap: 12 }}>
                {c.items.map((it) => (
                  <li key={it}><a href="#" style={{ textDecoration: "none", color: "var(--ink-mid)", fontSize: 14.5 }}>{it}</a></li>
                ))}
              </ul>
            </div>
          ))}
        </div>

        <div style={{
          marginTop: 60, paddingTop: 24,
          borderTop: "1px solid var(--line)",
          display: "flex", justifyContent: "space-between", gap: 24, flexWrap: "wrap",
          fontSize: 12.5, color: "var(--ink-soft)", fontFamily: "var(--mono)", letterSpacing: "0.02em",
        }}>
          <div>
            {t.footer.legal}
            {" · "}
            <a href="/privacy" style={{ color: "var(--ink-soft)", textDecoration: "underline" }}>{t.footer.privacy}</a>
          </div>
          <div>{t.footer.disclaimer}</div>
        </div>
      </div>
    </footer>
  );
}

// ────────── MOBILE STICKY ACTION BAR ──────────
function IconWhatsApp({ size = 20 }) {
  return (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
      <path d="M17.5 14.4c-.3-.15-1.77-.87-2.04-.97-.27-.1-.47-.15-.67.15-.2.3-.77.97-.95 1.17-.17.2-.35.22-.65.07-.3-.15-1.26-.46-2.4-1.48-.89-.79-1.49-1.77-1.66-2.07-.17-.3-.02-.46.13-.61.13-.13.3-.35.45-.52.15-.17.2-.3.3-.5.1-.2.05-.37-.02-.52-.07-.15-.67-1.62-.92-2.22-.24-.58-.49-.5-.67-.51l-.57-.01c-.2 0-.52.07-.8.37-.27.3-1.04 1.02-1.04 2.48 0 1.46 1.07 2.88 1.22 3.08.15.2 2.1 3.2 5.08 4.49.71.31 1.26.49 1.69.63.71.23 1.36.19 1.87.12.57-.09 1.77-.72 2.02-1.42.25-.7.25-1.3.17-1.42-.07-.12-.27-.2-.57-.35zM12.05 21.5h-.01a9.4 9.4 0 0 1-4.8-1.32l-.34-.2-3.57.94.95-3.48-.22-.36a9.39 9.39 0 0 1-1.44-5.01c0-5.19 4.23-9.41 9.43-9.41 2.52 0 4.88.98 6.66 2.76a9.34 9.34 0 0 1 2.76 6.66c0 5.19-4.23 9.41-9.41 9.41zm8.01-17.42A11.32 11.32 0 0 0 12.05.75C5.8.75.72 5.83.72 12.08c0 2 .52 3.95 1.52 5.67L.62 23.25l5.65-1.48a11.3 11.3 0 0 0 5.77 1.58h.01c6.24 0 11.32-5.08 11.33-11.33a11.26 11.26 0 0 0-3.32-8.01z"/>
    </svg>
  );
}

function MobileStickyBar() {
  return (
    <div className="mobile-sticky-bar" aria-label="Quick contact">
      <a href={window.PHONE_TEL} className="msb-btn msb-call">
        <IconPhone size={18} /> {window._lang === "es" ? "Llamar" : "Call"}
      </a>
      <a href={window.WHATSAPP_URL} target="_blank" rel="noopener noreferrer" className="msb-btn msb-wa">
        <IconWhatsApp size={20} /> WhatsApp
      </a>
    </div>
  );
}

Object.assign(window, {
  TopBar, Nav, Hero, PhoneBanner, Services, CaseResults, WhyUs, HowItWorks, Voices, FinalCTA, Footer,
  MobileStickyBar,
});
