// Nav + 3 hero variants

const navStyles = {
  bar: {
    position: "fixed", top: 0, left: 0, right: 0, zIndex: 40,
    transition: "background .3s ease, backdrop-filter .3s ease, border-color .3s ease",
    borderBottom: "1px solid transparent"
  },
  inner: {
    display: "flex", alignItems: "center",
    padding: "20px 24px",
    maxWidth: 1480, margin: "0 auto"
  },
  brand: { display: "flex", alignItems: "center", gap: 10, textDecoration: "none", color: "inherit" },
  brandMark: {
    width: 28, height: 28, borderRadius: 8, background: "var(--ink)", color: "var(--ink)",
    display: "grid", placeItems: "center", fontFamily: "var(--font-sans)", fontWeight: 600, fontSize: 14,
    letterSpacing: "-0.02em"
  },
  links: { display: "flex", gap: 38, alignItems: "center", marginLeft: "auto", marginRight: 28 },
  link: {
    fontSize: 16, color: "inherit", textDecoration: "none", letterSpacing: "-0.005em",
    fontWeight: 400, opacity: .85, transition: "opacity .2s ease"
  }
};

function LangSwitcher({ dark }) {
  const [open, setOpen] = useState(false);
  const { lang, setLang } = useLang();
  const langs = LANGS;

  return (
    <div style={{ position: "relative" }}>
      <button onClick={() => setOpen(!open)} className="cc-hov" style={{
        background: "transparent", border: `1px solid ${dark ? "rgba(0,0,0,.1)" : "var(--line-2)"}`,
        color: "inherit", borderRadius: 999, padding: "9px 15px", fontFamily: "var(--font-mono)",
        fontSize: 11.5, letterSpacing: ".08em", display: "inline-flex", alignItems: "center", gap: 8
      }}>
        <span style={{ width: 6, height: 6, borderRadius: 999, background: "var(--brand)" }} />
        {lang}
        <svg width="8" height="8" viewBox="0 0 8 8"><path d="M1 3l3 3 3-3" stroke="currentColor" fill="none" strokeWidth="1.2" /></svg>
      </button>
      {open &&
      <div style={{
        position: "absolute", top: "calc(100% + 8px)", right: 0,
        background: dark ? "#fafafa" : "#fff", border: `1px solid ${dark ? "rgba(0,0,0,.05)" : "var(--line)"}`,
        borderRadius: 12, padding: 6, minWidth: 180, boxShadow: "var(--shadow-lg)", zIndex: 50
      }}>
          {langs.map((l) =>
        <button key={l.c} onClick={() => {setLang(l.c);setOpen(false);}} style={{
          display: "flex", width: "100%", padding: "8px 12px", justifyContent: "space-between",
          background: l.c === lang ? dark ? "rgba(0,0,0,.03)" : "var(--bg-3)" : "transparent",
          border: 0, borderRadius: 8, color: "inherit", fontFamily: "var(--font-sans)",
          fontSize: 13, alignItems: "center"
        }}>
              <span>{l.n}</span>
              <span className="mono" style={{ fontSize: 10, opacity: .6 }}>{l.c}</span>
            </button>
        )}
        </div>
      }
    </div>);

}

function Nav() {
  const t = useT();
  const [scrolled, setScrolled] = useState(false);
  const [menuOpen, setMenuOpen] = useState(false);
  useEffect(() => {
    const onS = () => setScrolled(window.scrollY > 20);
    window.addEventListener("scroll", onS, { passive: true });
    return () => window.removeEventListener("scroll", onS);
  }, []);
  // Lock body scroll while the mobile drawer is open
  useEffect(() => {
    document.body.style.overflow = menuOpen ? "hidden" : "";
    return () => { document.body.style.overflow = ""; };
  }, [menuOpen]);
  const navBg = scrolled || menuOpen ? "rgba(255,255,255,.92)" : "transparent";

  const links = [
  { href: "#services", label: t("nav.services") },
  { href: "#fleet", label: t("nav.fleet") },
  { href: "#contact", label: t("nav.contact") },
  { href: "#tech", label: t("nav.tech") },
  { href: "#sustainability", label: t("nav.sustainability") },
  { href: "#about", label: t("nav.about") }];


  return (
    <>
      <nav style={{
        ...navStyles.bar,
        background: navBg,
        backdropFilter: scrolled || menuOpen ? "saturate(180%) blur(14px)" : "none",
        WebkitBackdropFilter: scrolled || menuOpen ? "saturate(180%) blur(14px)" : "none",
        borderBottomColor: scrolled || menuOpen ? "var(--line)" : "transparent",
        color: "var(--ink)"
      }}>
        <div style={navStyles.inner}>
          <a href="#" style={navStyles.brand} onClick={() => setMenuOpen(false)}>
            <img
              src="assets/logo.svg?v=15"
              alt="CoolCargo Solutions S.L."
              style={{ height: 54, width: "auto", display: "block" }} />

          </a>

          <div style={navStyles.links} className="cc-nav-links">
            {links.map((l) =>
            <a key={l.href} href={l.href} style={navStyles.link}>{l.label}</a>
            )}
          </div>

          <div style={{ display: "flex", alignItems: "center", gap: 13 }} className="cc-nav-actions">
            <LangSwitcher dark={false} />
            <a href="#contact" className="btn btn-primary cc-nav-cta" style={{ padding: "11px 18px", fontSize: 14.5 }}>
              {t("nav.quote")} <I.arrow />
            </a>
            <button
              className="cc-burger"
              aria-label="Menú"
              aria-expanded={menuOpen}
              onClick={() => setMenuOpen((v) => !v)}
              style={{
                background: "transparent",
                border: "1px solid var(--line-2)",
                borderRadius: 10,
                padding: "10px 12px",
                cursor: "pointer",
                display: "none",
                alignItems: "center",
                justifyContent: "center",
                color: "var(--ink)"
              }}>

              <span className="cc-burger-bars" data-open={menuOpen}>
                <span /><span /><span />
              </span>
            </button>
          </div>
        </div>
      </nav>

      {/* Mobile drawer — rendered OUTSIDE the nav so the nav's backdrop-filter
          (which establishes a containing block) doesn't trap its fixed position. */}
      <div className="cc-mobile-drawer" data-open={menuOpen} style={{
        position: "fixed",
        top: 0, left: 0, right: 0, bottom: 0,
        background: "rgba(255,255,255,0.98)",
        backdropFilter: "saturate(180%) blur(14px)",
        WebkitBackdropFilter: "saturate(180%) blur(14px)",
        borderBottom: "1px solid var(--line)",
        padding: "100px 24px 32px",
        zIndex: 38,
        display: menuOpen ? "block" : "none",
        opacity: menuOpen ? 1 : 0,
        transition: "opacity .25s ease",
        overflowY: "auto"
      }}>
        <div style={{ display: "flex", flexDirection: "column", gap: 4 }}>
          {links.map((l) =>
          <a
            key={l.href}
            href={l.href}
            onClick={() => setMenuOpen(false)}
            style={{
              fontSize: 20,
              fontWeight: 500,
              color: "var(--ink)",
              textDecoration: "none",
              letterSpacing: "-0.018em",
              padding: "16px 4px",
              borderBottom: "1px solid var(--line)"
            }}>

              {l.label}
            </a>
          )}
          <a
            href="#contact"
            onClick={() => setMenuOpen(false)}
            className="btn btn-primary"
            style={{ marginTop: 22, padding: "14px 18px", fontSize: 15, justifyContent: "center" }}>

            {t("nav.quote")} <I.arrow />
          </a>
        </div>
      </div>

      <style>{`
        /* Hamburger bars */
        .cc-burger-bars { position: relative; width: 18px; height: 14px; display: inline-block; }
        .cc-burger-bars span {
          position: absolute; left: 0; right: 0; height: 2px;
          background: currentColor; border-radius: 2px;
          transition: transform .25s ease, opacity .2s ease, top .25s ease;
        }
        .cc-burger-bars span:nth-child(1) { top: 0; }
        .cc-burger-bars span:nth-child(2) { top: 6px; }
        .cc-burger-bars span:nth-child(3) { top: 12px; }
        .cc-burger-bars[data-open="true"] span:nth-child(1) { top: 6px; transform: rotate(45deg); }
        .cc-burger-bars[data-open="true"] span:nth-child(2) { opacity: 0; }
        .cc-burger-bars[data-open="true"] span:nth-child(3) { top: 6px; transform: rotate(-45deg); }

        /* All primary CTAs ("Cotización", "Solicitar cotización", "Pedir
           cotización", "Conocer al equipo"…) — arrow icon rotates 90° to point
           DOWN on hover. The arrow icon is an inline <svg> with no class, so we
           target it directly. */
        .btn-primary svg { transition: transform .28s cubic-bezier(.2,.8,.2,1); }
        .btn-primary:hover svg { transform: rotate(90deg); }

        @media (max-width: 980px) {
          .cc-nav-links { display: none !important; }
          .cc-burger { display: inline-flex !important; }
          .cc-nav-cta { display: none !important; }
          /* En móvil, el grupo "selector idioma + hamburguesa" se ancla a la
             derecha. Sin esto, al ocultarse .cc-nav-links (que llevaba
             margin-left:auto), las acciones quedaban pegadas al logo. */
          .cc-nav-actions { margin-left: auto !important; }
        }
        @media (min-width: 981px) {
          .cc-mobile-drawer { display: none !important; }
        }
      `}</style>
    </>);

}

/* ============================================================ */
/* HERO VARIANT A — Editorial split with REAL truck photo       */
/* ============================================================ */

function HeroA() {
  // Parallax on scroll for the truck image
  const imgRef = useRef(null);
  useEffect(() => {
    const onScroll = () => {
      if (!imgRef.current) return;
      const y = window.scrollY;
      imgRef.current.style.transform = `translate3d(0, ${y * 0.08}px, 0)`;
    };
    window.addEventListener("scroll", onScroll, { passive: true });
    return () => window.removeEventListener("scroll", onScroll);
  }, []);

  return (
    <section style={{ paddingTop: 120, paddingBottom: 0, position: "relative", overflow: "hidden" }}>
      <div className="wrap">
        <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 48, alignItems: "center", minHeight: "78vh" }} className="cc-hero-grid">
          <div>
            <div className="reveal eyebrow" style={{ marginBottom: 28 }}>
              CoolCargo Solutions S.L. · Operador logístico
            </div>
            <h1 className="reveal d1" style={{ marginBottom: 24 }}>
              Transporte refrigerado<br />
              <em className="serif">internacional</em><br />
              para toda Europa.
            </h1>
            <p className="reveal d2" style={{ fontSize: 18, maxWidth: 480, marginBottom: 36, color: "var(--ink-2)", lineHeight: 1.55 }}>
              Conjuntos Mercedes Actros con remolque frigorífico ATP-FRC.
              Trazabilidad térmica continua, conductores propios y entregas en 20 países.
            </p>
            <div className="reveal d3" style={{ display: "flex", gap: 10, flexWrap: "wrap", marginBottom: 56 }}>
              <a href="#contact" className="btn btn-primary">Solicitar cotización <I.arrow /></a>
              <a href="tel:+34972863031" className="btn btn-ghost"><I.signal /> 972 863 031</a>
            </div>

            <div className="reveal d4" style={{ display: "grid", gridTemplateColumns: "repeat(4, auto)", gap: 28, borderTop: "1px solid var(--line)", paddingTop: 24 }}>
              {[
              ["20", "Países"],
              ["ATP-FRC", "Certificado"],
              ["−20 / +20°", "Rango térmico"],
              ["24/7", "Operación"]].
              map(([k, v], i) =>
              <div key={i}>
                  <div style={{ fontSize: 22, fontWeight: 500, letterSpacing: "-0.02em", color: "var(--ink)" }}>{k}</div>
                  <div className="mono" style={{ fontSize: 10, letterSpacing: ".12em", color: "var(--muted)", textTransform: "uppercase", marginTop: 4, fontWeight: 500 }}>{v}</div>
                </div>
              )}
            </div>
          </div>

          <div className="cc-hero-truck-wrap">
            <TruckPhoto ref={imgRef} />
          </div>
        </div>
      </div>

      {/* Capabilities strip */}
      <div className="reveal" style={{ marginTop: 80, borderTop: "1px solid var(--line)", borderBottom: "1px solid var(--line)", padding: "20px 0" }}>
        <Marquee speed={55}>
          {["ATP-FRC CERTIFIED", "ISO 9001:2015", "GDP COMPLIANT", "TAPA TSR1 · BUREAU VERITAS", "REG. SANITARIO 40.055673/B"].map((b, i) =>
          <span key={i} className="mono" style={{ fontSize: 11, letterSpacing: ".22em", color: "var(--muted)", display: "inline-flex", alignItems: "center", gap: 48, fontWeight: 500 }}>
              {b}<span style={{ width: 3, height: 3, background: "var(--brand)", display: "inline-block" }} />
            </span>
          )}
        </Marquee>
      </div>

      <style>{`
        .cc-hero-truck-wrap {
          position: relative;
          height: 540px;
          display: flex;
          align-items: center;
          justify-content: center;
        }
        @media (max-width: 900px) {
          .cc-hero-grid { grid-template-columns: 1fr !important; gap: 32px !important; }
          .cc-hero-truck-wrap { height: 320px; }
        }
      `}</style>
    </section>);

}

// Truck photo component with entrance animation + floating live data badges
const TruckPhoto = React.forwardRef(function TruckPhoto(_, ref) {
  const [tick, setTick] = useState(0);
  const [temp, setTemp] = useState(4.2);
  useEffect(() => {
    const id = setInterval(() => {
      setTick((t) => t + 1);
      setTemp(+(4 + (Math.random() - 0.5) * 0.6).toFixed(1));
    }, 1600);
    return () => clearInterval(id);
  }, []);

  return (
    <div ref={ref} style={{ position: "absolute", inset: 0, willChange: "transform" }}>
      {/* Background plate (subtle grid) */}
      <div style={{
        position: "absolute", inset: "10% -25% 10% -10%",
        background: "radial-gradient(ellipse at 65% 60%, rgba(226,29,36,.05), transparent 60%)"
      }} />
      <svg style={{ position: "absolute", inset: 0, opacity: .5 }} preserveAspectRatio="none" viewBox="0 0 600 540">
        <defs>
          <pattern id="hgrid" width="32" height="32" patternUnits="userSpaceOnUse">
            <path d="M32 0H0V32" fill="none" stroke="var(--line)" strokeWidth=".6" />
          </pattern>
        </defs>
        <rect width="600" height="540" fill="url(#hgrid)" />
      </svg>

      {/* The truck image — animated entrance, slight float */}
      <img
        src="assets/truck.png"
        alt="CoolCargo Solutions S.L. tractor + refrigerated trailer"
        className="cc-truck-img"
        style={{
          position: "absolute",
          right: "-15%",
          top: "50%",
          transform: "translateY(-50%)",
          width: "135%",
          maxWidth: "none",
          height: "auto",
          objectFit: "contain",
          filter: "drop-shadow(0 30px 40px rgba(0,0,0,.08))"
        }} />
      

      {/* Floating live data badge — top right */}
      <div className="reveal d3" style={{
        position: "absolute", left: "4%", top: "10%",
        background: "#fff", border: "1px solid var(--line)",
        padding: "12px 14px", boxShadow: "var(--shadow-md)",
        animation: "cc-float 5s ease-in-out infinite",
        zIndex: 2
      }}>
        <div className="mono" style={{ fontSize: 9, letterSpacing: ".14em", color: "var(--muted)" }}>VEHICLE CC-2418 · LIVE</div>
        <div style={{ display: "flex", alignItems: "baseline", gap: 8, marginTop: 6 }}>
          <span className="mono" style={{ fontSize: 22, fontWeight: 500, color: "var(--ink)" }}>+{temp.toFixed(1)}°C</span>
          <span className="mono" style={{ fontSize: 10, color: "var(--accent-ok)" }}>Δ {(temp - 4).toFixed(1)}°</span>
        </div>
        <div style={{ height: 1, background: "var(--line)", margin: "8px 0" }} />
        <div className="mono" style={{ fontSize: 10, color: "var(--muted)" }}>MAD → MUN · 1.832 km</div>
      </div>

      {/* Bottom-right floating badge */}
      <div className="reveal d4" style={{
        position: "absolute", right: "8%", bottom: "10%",
        background: "var(--ink)", color: "#fff",
        padding: "14px 16px", boxShadow: "var(--shadow-lg)",
        animation: "cc-float 5s ease-in-out infinite reverse",
        zIndex: 2
      }}>
        <div className="mono" style={{ fontSize: 9, letterSpacing: ".14em", opacity: .7 }}>ATP-FRC · 06-2026</div>
        <div style={{ fontSize: 14, fontWeight: 500, marginTop: 4, letterSpacing: "-0.005em" }}>Mercedes Actros</div>
        <div className="mono" style={{ fontSize: 10, opacity: .65, marginTop: 4 }}>Conjunto frigorífico</div>
      </div>

      <style>{`
        .cc-truck-img { animation: cc-truck-in 1.2s cubic-bezier(.2,.8,.2,1) both, cc-truck-bob 7s ease-in-out 1.2s infinite; }
        @keyframes cc-truck-in {
          0% { opacity: 0; transform: translateY(-50%) translateX(60px) scale(.98); }
          100% { opacity: 1; transform: translateY(-50%) translateX(0) scale(1); }
        }
        @keyframes cc-truck-bob {
          0%, 100% { transform: translateY(-50%) translateX(0); }
          50% { transform: translateY(-50%) translateX(-6px); }
        }
        @keyframes cc-float {
          0%, 100% { transform: translateY(0); }
          50% { transform: translateY(-8px); }
        }
        @media (max-width: 900px) {
          .cc-truck-img { width: 110% !important; right: -5% !important; }
        }
      `}</style>
    </div>);

});

// Live IoT panel — animated faux data
function IoTLivePanel() {
  const [t, setT] = useState(0);
  const [trucks, setTrucks] = useState([
  { id: "CC-2418", route: "Madrid → Lyon", temp: 4.2, target: 4, prog: 0.62, eta: "06:14" },
  { id: "CC-3201", route: "Valencia → Hamburg", temp: -19.8, target: -20, prog: 0.31, eta: "21:48" },
  { id: "CC-1907", route: "Sevilla → Milano", temp: 6.1, target: 6, prog: 0.84, eta: "02:55" }]
  );
  useEffect(() => {
    const i = setInterval(() => {
      setT((x) => x + 1);
      setTrucks((ts) => ts.map((t) => ({
        ...t,
        temp: +(t.target + (Math.random() - 0.5) * 0.6).toFixed(1),
        prog: Math.min(1, t.prog + 0.001 + Math.random() * 0.002)
      })));
    }, 1400);
    return () => clearInterval(i);
  }, []);

  return (
    <div style={{
      background: "#fff",
      border: "1px solid var(--line)",
      borderRadius: 18,
      padding: 22,
      boxShadow: "var(--shadow-lg)",
      position: "relative"
    }}>
      <div style={{ display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: 18 }}>
        <div>
          <div className="mono" style={{ fontSize: 10, letterSpacing: ".12em", color: "var(--muted)", textTransform: "uppercase" }}>FleetOps · Live</div>
          <div style={{ fontWeight: 500, fontSize: 16, marginTop: 4 }}>Active shipments</div>
        </div>
        <LiveDot color="var(--accent-ok)" label="STREAMING" />
      </div>

      <div style={{ display: "flex", flexDirection: "column", gap: 10 }}>
        {trucks.map((tr) =>
        <div key={tr.id} style={{
          border: "1px solid var(--line)", borderRadius: 12, padding: "12px 14px",
          background: "var(--bg)"
        }}>
            <div style={{ display: "flex", justifyContent: "space-between", alignItems: "baseline", marginBottom: 8 }}>
              <div>
                <div className="mono" style={{ fontSize: 10, letterSpacing: ".1em", color: "var(--muted)" }}>{tr.id}</div>
                <div style={{ fontSize: 14, fontWeight: 500, marginTop: 2 }}>{tr.route}</div>
              </div>
              <div style={{ textAlign: "right" }}>
                <div className="mono" style={{
                fontSize: 18, fontWeight: 500,
                color: Math.abs(tr.temp - tr.target) < 1 ? "var(--ink)" : "var(--accent-warn)"
              }}>{tr.temp > 0 ? "+" : ""}{tr.temp.toFixed(1)}°</div>
                <div className="mono" style={{ fontSize: 9, color: "var(--muted)", letterSpacing: ".08em" }}>ETA {tr.eta}</div>
              </div>
            </div>
            <div style={{ height: 3, background: "var(--line)", borderRadius: 999, overflow: "hidden", position: "relative" }}>
              <div style={{ position: "absolute", inset: 0, width: `${tr.prog * 100}%`, background: "linear-gradient(90deg, var(--brand), var(--brand-2))" }} />
            </div>
          </div>
        )}
      </div>

      {/* Mini graph */}
      <div style={{ marginTop: 14, paddingTop: 14, borderTop: "1px solid var(--line)" }}>
        <div style={{ display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: 10 }}>
          <div className="mono" style={{ fontSize: 10, color: "var(--muted)", letterSpacing: ".1em" }}>FLEET TEMP · LAST 24H</div>
          <div className="mono" style={{ fontSize: 10, color: "var(--accent-ok)" }}>+0.2° drift</div>
        </div>
        <MiniGraph tick={t} />
      </div>
    </div>);

}

function MiniGraph({ tick }) {
  const points = useMemo(() => {
    const arr = [];
    for (let i = 0; i < 40; i++) {
      arr.push(Math.sin((i + tick) * 0.4) * 6 + Math.cos(i * 0.18 + tick * 0.1) * 4 + 20);
    }
    return arr;
  }, [tick]);
  const w = 320,h = 60;
  const max = 32,min = 8;
  const path = points.map((p, i) => {
    const x = i / (points.length - 1) * w;
    const y = h - (p - min) / (max - min) * h;
    return `${i === 0 ? "M" : "L"}${x.toFixed(1)} ${y.toFixed(1)}`;
  }).join(" ");
  return (
    <svg viewBox={`0 0 ${w} ${h}`} style={{ width: "100%", height: 60, display: "block" }}>
      <defs>
        <linearGradient id="gA" x1="0" x2="0" y1="0" y2="1">
          <stop offset="0%" stopColor="var(--brand-2)" stopOpacity=".25" />
          <stop offset="100%" stopColor="var(--brand-2)" stopOpacity="0" />
        </linearGradient>
      </defs>
      <path d={`${path} L${w} ${h} L0 ${h} Z`} fill="url(#gA)" />
      <path d={path} fill="none" stroke="var(--brand)" strokeWidth="1.4" strokeLinejoin="round" strokeLinecap="round" />
    </svg>);

}

/* ============================================================ */
/* HERO — Cinematic (single, final version)                     */
/* ============================================================ */

function HeroCinematic() {
  const t = useT();
  const [activeHub, setActiveHub] = useState(null);
  const [tick, setTick] = useState(0);
  useEffect(() => {
    const id = setInterval(() => setTick((t) => t + 1), 80);
    return () => clearInterval(id);
  }, []);

  return (
    <section id="coverage" style={{ paddingTop: 170, paddingBottom: 80, position: "relative", overflow: "hidden" }}>
      <RouteGridBg />

      <div className="wrap" style={{ position: "relative", zIndex: 2 }}>
        <div className="cc-hero-grid" style={{ display: "grid", gridTemplateColumns: "1.25fr 1fr", gap: 56, alignItems: "start" }}>
          <div>
          <div className="reveal eyebrow" style={{ marginBottom: 30 }}>

          </div>
          <h1 className="reveal d1" style={{ marginBottom: 28, letterSpacing: "-0.04em", lineHeight: 0.98 }}>
            <span style={{ whiteSpace: "nowrap", display: "block" }}>{t("hero.title.line1")}</span>
            <span style={{ display: "block" }}><em className="serif">{t("hero.title.italic")}</em> {t("hero.title.line2.rest")}</span>
          </h1>
          <p className="reveal d2" style={{ fontSize: 19, maxWidth: 620, marginBottom: 36, color: "var(--ink-2)", lineHeight: 1.55 }}>{t("hero.subtitle")}</p>
          <div className="reveal d3" style={{ display: "flex", gap: 10, flexWrap: "wrap", marginBottom: 56 }}>
            <a href="#contact" className="btn btn-primary">{t("hero.cta.quote")} <I.arrow /></a>
            <a href="tel:+34972863031" className="btn btn-ghost"><I.signal /> +34 972 863 031</a>
          </div>

          {/* Stats row — hvalai-style, sits below buttons inside the text column */}
          <div className="reveal d4 cc-cine-stats" style={{ paddingTop: 28, display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: 20, borderTop: "1px solid var(--line)" }}>
            {[
            { k: "20", s: t("hero.stat.countries") },
            { k: "ATP-FRC", s: t("hero.stat.certified") },
            { k: "−20 / +20 °C", s: t("hero.stat.range") },
            { k: "24/7", s: t("hero.stat.ops") }].
            map((m, i) =>
            <div key={i}>
                <div style={{ display: "flex", alignItems: "center", gap: 7, marginBottom: 10 }}>
                  <span className="mono" style={{ fontSize: 10, letterSpacing: ".14em", color: "var(--muted)", fontWeight: 600 }}>{String(i + 1).padStart(2, "0")}</span>
                  <span style={{
                  width: 6, height: 6, borderRadius: 999,
                  background: i === 0 ? "var(--brand)" : "var(--ink)",
                  boxShadow: i === 0 ? "0 0 0 3px rgba(226,29,36,.12)" : "none"
                }} />
                </div>
                <div style={{ fontSize: 26, fontWeight: 500, letterSpacing: "-0.025em", color: "var(--ink)", lineHeight: 1 }}>{m.k}</div>
                <div className="mono" style={{ fontSize: 9, color: "var(--muted)", letterSpacing: ".14em", marginTop: 10, fontWeight: 500 }}>{m.s.toUpperCase()}</div>
              </div>
            )}
          </div>
          </div>

          <div className="reveal d2 cc-hero-map" style={{
            position: "relative",
            aspectRatio: "5 / 6",
            width: "100%",
            maxWidth: 540,
            marginLeft: "auto"
          }}>
            <MapSVG tick={tick} activeHub={activeHub} setActiveHub={setActiveHub} />

            {/* Stylish caption — refers to the 82 trucks animating across the map */}
            <div className="cc-fleet-caption" style={{
              position: "absolute",
              right: 14, bottom: 14,
              display: "inline-flex", alignItems: "center", gap: 12,
              padding: "10px 16px 10px 14px",
              background: "rgba(255,255,255,0.78)",
              backdropFilter: "blur(18px) saturate(160%)",
              WebkitBackdropFilter: "blur(18px) saturate(160%)",
              border: "1px solid rgba(255,255,255,0.7)",
              borderRadius: 999,
              boxShadow: "0 16px 40px -14px rgba(20,20,40,.22), 0 1px 0 rgba(255,255,255,.7) inset",
              zIndex: 7,
              pointerEvents: "none",
            }}>
              <span style={{ position: "relative", width: 10, height: 10, display: "inline-block" }}>
                <span style={{
                  position: "absolute", inset: 0, borderRadius: 999,
                  background: "var(--brand)",
                  boxShadow: "0 0 0 4px rgba(226,29,36,.18)"
                }} />
                <span style={{
                  position: "absolute", inset: -3, borderRadius: 999,
                  border: "1.5px solid rgba(226,29,36,.55)",
                  animation: "cc-fleet-ping 1.8s ease-out infinite"
                }} />
              </span>
              <span style={{ display: "inline-flex", flexDirection: "column", lineHeight: 1.05 }}>
                <span className="mono" style={{
                  fontSize: 9, letterSpacing: ".18em",
                  color: "rgba(0,0,0,.55)", fontWeight: 600, textTransform: "uppercase"
                }}>
                  82 conjuntos
                </span>
                <span style={{
                  fontFamily: "var(--font-serif)",
                  fontStyle: "italic", fontSize: 17,
                  color: "var(--ink)", marginTop: 4, letterSpacing: "-0.005em",
                  lineHeight: 1.1
                }}>
                  nuestra flota un lunes por la mañana
                </span>
              </span>
            </div>
          </div>
        </div>
      </div>

      <style>{`
        /* Slightly bigger gap and column ratio on mid-narrow viewports */
        @media (min-width: 901px) and (max-width: 1200px) {
          .cc-hero-grid { gap: 72px !important; padding-top: 24px; }
          .cc-cine-stats { gap: 28px !important; }
        }
        @media (max-width: 900px) {
          .cc-hero-grid { grid-template-columns: 1fr !important; gap: 32px !important; }
          .cc-cine-stats { grid-template-columns: 1fr 1fr !important; gap: 24px !important; }
        }
        @keyframes cc-fleet-ping {
          0%   { transform: scale(0.9); opacity: 0.9; }
          80%  { transform: scale(2.1); opacity: 0; }
          100% { transform: scale(2.1); opacity: 0; }
        }
        @media (max-width: 600px) {
          .cc-fleet-caption { right: 8px !important; bottom: 8px !important; padding: 8px 12px 8px 11px !important; }
          .cc-fleet-caption span span:last-child { font-size: 14px !important; }
        }
      `}</style>
    </section>);

}

// Floating live-data card — pinned on top of the hero truck
function HeroLiveCard() {
  const [temp, setTemp] = useState(4.0);
  const [km, setKm] = useState(1832);
  useEffect(() => {
    const id = setInterval(() => {
      setTemp(+(4 + (Math.random() - 0.5) * 0.5).toFixed(1));
      setKm((k) => k - 1);
    }, 1400);
    return () => clearInterval(id);
  }, []);
  return (
    <div style={{
      position: "absolute",
      left: "2%", top: "6%",
      background: "#fff", border: "1px solid var(--line)",
      padding: "14px 16px", boxShadow: "var(--shadow-md)",
      minWidth: 200, zIndex: 3,
      animation: "cc-card-in 1.6s ease 0.6s both"
    }}>
      <div style={{ display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: 10 }}>
        <div className="mono" style={{ fontSize: 9, letterSpacing: ".14em", color: "var(--muted)", fontWeight: 500 }}>CC-2418 · LIVE</div>
        <LiveDot color="var(--accent-ok)" label="" />
      </div>
      <div style={{ display: "flex", alignItems: "baseline", gap: 8 }}>
        <span className="mono" style={{ fontSize: 26, fontWeight: 500, color: "var(--ink)", letterSpacing: "-0.01em" }}>+{temp.toFixed(1)}°C</span>
      </div>
      <div className="mono" style={{ fontSize: 10, color: "var(--muted)", marginTop: 4 }}>Target +4.0° · Δ {(temp - 4).toFixed(1)}°</div>
      <div style={{ height: 1, background: "var(--line)", margin: "10px 0" }} />
      <div className="mono" style={{ fontSize: 10, color: "var(--muted)" }}>MAD → MUN</div>
      <div className="mono" style={{ fontSize: 12, color: "var(--ink)", marginTop: 2, fontWeight: 500 }}>{km.toLocaleString("es-ES")} km restantes</div>
      <style>{`@keyframes cc-card-in { 0% { opacity: 0; transform: translateY(-8px); } 100% { opacity: 1; transform: translateY(0); } }`}</style>
    </div>);

}

function RouteGridBg() {
  return (
    <div style={{ position: "absolute", inset: 0, opacity: .6, pointerEvents: "none" }}>
      <svg width="100%" height="100%" preserveAspectRatio="none" style={{ position: "absolute", inset: 0 }}>
        <defs>
          <pattern id="gridA" width="80" height="80" patternUnits="userSpaceOnUse">
            <path d="M80 0H0V80" fill="none" stroke="rgba(0,0,0,.03)" strokeWidth="1" />
          </pattern>
          <radialGradient id="vign" cx="50%" cy="40%" r="65%">
            <stop offset="0%" stopColor="rgba(226,29,36,.18)" />
            <stop offset="100%" stopColor="transparent" />
          </radialGradient>
        </defs>
        <rect width="100%" height="100%" fill="url(#gridA)" />
        <rect width="100%" height="100%" fill="url(#vign)" />
      </svg>
      {/* Animated route lines */}
      <svg width="100%" height="100%" preserveAspectRatio="none" style={{ position: "absolute", inset: 0 }} viewBox="0 0 1400 700">
        {[
        "M0,420 C300,420 380,200 700,200 C1020,200 1100,520 1400,520",
        "M0,300 C200,300 280,580 600,580 C920,580 1000,300 1400,300",
        "M0,580 C260,580 340,360 720,360 C1100,360 1180,150 1400,150"].
        map((d, i) =>
        <g key={i}>
            <path d={d} fill="none" stroke="rgba(0,0,0,.07)" strokeWidth="1" />
            <circle r="3" fill="var(--brand-2)">
              <animateMotion dur={`${10 + i * 3}s`} repeatCount="indefinite" path={d} />
            </circle>
            <circle r="3" fill="var(--brand-2)" opacity=".4">
              <animateMotion dur={`${10 + i * 3}s`} repeatCount="indefinite" begin={`${-3 - i}s`} path={d} />
            </circle>
          </g>
        )}
      </svg>
    </div>);

}

/* ============================================================ */
/* HERO VARIANT C — Big number reveal + side specs              */
/* ============================================================ */

function HeroC() {
  return (
    <section style={{ paddingTop: 130, paddingBottom: 90, background: "var(--bg-2)" }}>
      <div className="wrap">
        <div className="reveal eyebrow" style={{ marginBottom: 24 }}>CoolCargo · Cold chain logistics</div>
        <div style={{ display: "grid", gridTemplateColumns: "1fr 420px", gap: 64, alignItems: "start" }} className="cc-hero-grid">
          <div>
            <h1 className="reveal d1" style={{ marginBottom: 28, letterSpacing: "-0.04em" }}>
              <span style={{ display: "block" }}>Logística refrigerada</span>
              <span style={{ display: "block" }}>para Europa. <em className="serif" style={{ color: "var(--brand)" }}>Sin compromisos.</em></span>
            </h1>
            <p className="reveal d2" style={{ fontSize: 19, maxWidth: 600, marginBottom: 36 }}>
              Operamos uno de los corredores frigoríficos más fiables del sur de Europa:
              29 años de experiencia, flota propia ATP, registros térmicos auditables y un
              modelo de servicio diseñado para cargas sensibles de alto valor.
            </p>
            <div className="reveal d3" style={{ display: "flex", gap: 12, flexWrap: "wrap" }}>
              <a href="#contact" className="btn btn-primary">Pedir cotización <I.arrow /></a>
              <a href="#services" className="btn btn-ghost">Conocer servicios</a>
            </div>
          </div>

          <div className="reveal d2" style={{ background: "var(--bg)", border: "1px solid var(--line)", borderRadius: 18, padding: 24 }}>
            <div className="mono" style={{ fontSize: 10, letterSpacing: ".12em", color: "var(--muted)", marginBottom: 18, textTransform: "uppercase" }}>Capacidad operativa · 2026</div>
            {[
            ["Países en cobertura activa", "20"],
            ["Conjuntos en flota", "+82"],
            ["Rango térmico ATP", "−20 a +20°C"],
            ["Cumplimiento SLA", "98,4%"],
            ["Certificaciones activas", "5"]].
            map(([k, v], i) =>
            <div key={i} style={{ display: "flex", justifyContent: "space-between", alignItems: "baseline", padding: "12px 0", borderTop: i ? "1px solid var(--line)" : 0 }}>
                <span style={{ fontSize: 13, color: "var(--muted)" }}>{k}</span>
                <span className="mono" style={{ fontSize: 14, fontWeight: 500, color: "var(--ink)" }}>{v}</span>
              </div>
            )}
          </div>
        </div>

        {/* Camera/IoT preview */}
        <div className="reveal d3" style={{ marginTop: 80 }}>
          <BigVisualStrip />
        </div>
      </div>
    </section>);

}

function BigVisualStrip() {
  // 3 placeholder visuals with technical overlays
  return (
    <div style={{ display: "grid", gridTemplateColumns: "1.6fr 1fr 1fr", gap: 14, height: 360 }} className="cc-strip">
      <div style={{ position: "relative", borderRadius: 16, overflow: "hidden", background: "var(--bg-3)" }}>
        <StripedPlaceholder label="DOCK · MADRID HUB · CAM 03" />
        <div style={{ position: "absolute", left: 16, top: 16 }}><LiveDot color="#ef4444" label="LIVE" /></div>
        <div style={{ position: "absolute", left: 16, bottom: 16, color: "var(--ink)" }}>
          <div className="mono" style={{ fontSize: 10, opacity: .8, letterSpacing: ".12em" }}>MAD-HUB-03 · 14:22:08 UTC</div>
          <div style={{ fontSize: 22, fontWeight: 500, marginTop: 4 }}>Loading bay 7 · 38 units</div>
        </div>
      </div>
      <div style={{ position: "relative", borderRadius: 16, overflow: "hidden", background: "var(--ink)" }}>
        <div style={{ padding: 22, color: "var(--ink)", height: "100%" }}>
          <div className="mono" style={{ fontSize: 10, opacity: .6, letterSpacing: ".12em", marginBottom: 12 }}>VEHICLE CC-2418</div>
          <div style={{ fontSize: 60, fontWeight: 400, letterSpacing: "-0.03em" }}>+4.2°<span style={{ fontSize: 22, opacity: .5 }}> C</span></div>
          <div className="mono" style={{ fontSize: 11, color: "var(--brand-2)", marginTop: 4 }}>Target +4.0°  ·  Δ +0.2°</div>
          <div style={{ marginTop: 24 }}><MiniGraph tick={0} /></div>
          <div className="mono" style={{ fontSize: 10, color: "var(--muted)", marginTop: 10, letterSpacing: ".1em" }}>STABLE  ·  LAST 24H</div>
        </div>
      </div>
      <div style={{ position: "relative", borderRadius: 16, overflow: "hidden", background: "var(--bg-3)" }}>
        <StripedPlaceholder label="TRAILER · INTERIOR · CAM 12" />
        <div style={{ position: "absolute", inset: 16, display: "flex", flexDirection: "column", justifyContent: "space-between", color: "var(--ink)" }}>
          <div><LiveDot color="#ef4444" label="LIVE" /></div>
          <div>
            <div className="mono" style={{ fontSize: 10, opacity: .8, letterSpacing: ".12em" }}>CC-3201 · Valencia → Hamburg</div>
            <div style={{ fontSize: 22, fontWeight: 500, marginTop: 4 }}>−19.8°C · 6,4t</div>
          </div>
        </div>
      </div>
      <style>{`
        @media (max-width: 900px) {
          .cc-strip { grid-template-columns: 1fr !important; height: auto !important; }
          .cc-strip > div { height: 240px; }
        }
      `}</style>
    </div>);

}

function StripedPlaceholder({ label }) {
  return (
    <div style={{ position: "absolute", inset: 0, background:
      "repeating-linear-gradient(135deg, #f4f4f5 0 2px, #0f1c33 2px 14px)",
      display: "grid", placeItems: "center"
    }}>
      <div className="mono" style={{ fontSize: 10, letterSpacing: ".18em", color: "rgba(0,0,0,.3)" }}>{label}</div>
    </div>);

}

Object.assign(window, { Nav, HeroCinematic, HeroA, HeroC, MiniGraph, LangSwitcher });