// FMProject Kft. — Landing page
const { useState, useEffect, useRef } = React;

const COLORS = {
  bg: "#080D1A",
  surface: "#0F1629",
  border: "rgba(255,255,255,0.07)",
  primary: "#2563EB",
  primaryHover: "#3B82F6",
  text: "#F1F5F9",
  muted: "#64748B",
  badgeBg: "rgba(37,99,235,0.12)",
  badgeText: "#60A5FA",
  amber: "#A855F7",
  amberSoft: "#C084FC",
  cyan: "#22D3EE",
  light: "#11182C",
  lightInk: "#F1F5F9",
  lightInkSoft: "rgba(241,245,249,0.62)",
};

const goToSection = (id) => {
  const el = document.getElementById(id);
  if (!el) return;
  const headerOffset = 84;
  const top = el.getBoundingClientRect().top + window.scrollY - headerOffset;
  window.scrollTo({ top, behavior: "smooth" });
};

// ────────────────────────────────────────────────────────────────────
// Reusable bits
// ────────────────────────────────────────────────────────────────────
const SectionLabel = ({ children }) => (
  <div className="text-xs tracking-[0.2em] uppercase font-semibold" style={{ color: "rgba(96,165,250,0.85)" }}>
    {children}
  </div>
);

const Badge = ({ children, icon: Icon }) => (
  <div
    className="inline-flex items-center gap-2 px-3 py-1.5 rounded-full text-xs font-medium"
    style={{ background: COLORS.badgeBg, color: COLORS.badgeText, border: "1px solid rgba(96,165,250,0.18)" }}
  >
    {Icon && <Icon size={14} />}
    {children}
  </div>
);

const PrimaryButton = ({ children, onClick, className = "", icon: Icon }) => (
  <button
    onClick={onClick}
    className={
      "inline-flex items-center gap-2 px-5 py-3 rounded-lg font-semibold text-sm transition-all duration-200 " +
      "shadow-[0_8px_24px_-8px_rgba(37,99,235,0.55)] hover:shadow-[0_12px_28px_-6px_rgba(59,130,246,0.65)] " +
      "active:translate-y-px " + className
    }
    style={{ background: COLORS.primary, color: "white" }}
    onMouseEnter={(e) => (e.currentTarget.style.background = COLORS.primaryHover)}
    onMouseLeave={(e) => (e.currentTarget.style.background = COLORS.primary)}
  >
    {children}
    {Icon && <Icon size={16} />}
  </button>
);

const GhostButton = ({ children, onClick, className = "", icon: Icon }) => (
  <button
    onClick={onClick}
    className={
      "inline-flex items-center gap-2 px-5 py-3 rounded-lg font-semibold text-sm transition-all duration-200 " +
      "border hover:bg-white/[0.04] " + className
    }
    style={{ borderColor: "rgba(255,255,255,0.12)", color: COLORS.text }}
  >
    {children}
    {Icon && <Icon size={16} />}
  </button>
);

// ────────────────────────────────────────────────────────────────────
// Nav
// ────────────────────────────────────────────────────────────────────
const Nav = () => {
  const [open, setOpen] = useState(false);
  const [scrolled, setScrolled] = useState(false);

  useEffect(() => {
    const onScroll = () => setScrolled(window.scrollY > 8);
    onScroll();
    window.addEventListener("scroll", onScroll, { passive: true });
    return () => window.removeEventListener("scroll", onScroll);
  }, []);

  const links = [
    ["Rólunk", "rolunk"],
    ["Miért mi?", "miert-mi"],
    ["Megoldásaink", "asszisztensek"],
    ["Folyamat", "folyamat"],
    ["Megfelelőség", "megfeleles"],
    ["Kapcsolat", "kapcsolat"],
  ];

  return (
    <header
      className="sticky top-0 z-40 transition-all duration-300"
      style={{
        background: "rgba(8,13,26,0.78)",
        backdropFilter: "blur(14px)",
        WebkitBackdropFilter: "blur(14px)",
        borderBottom: `1px solid ${scrolled ? COLORS.border : "transparent"}`,
      }}
    >
      <div className="max-w-7xl mx-auto px-6 md:px-10 h-[68px] flex items-center justify-between">
        <button onClick={() => goToSection("hero")} className="flex items-center group">
          <img
            src="assets/fmproject-logo.png"
            alt="FMProject — AI Powered IT Solutions"
            className="h-7 md:h-8 object-contain fm-logo-nav"
          />
        </button>

        <nav className="hidden min-[1000px]:flex items-center gap-8">
          {links.map(([label, id]) => (
            <button
              key={id}
              onClick={() => goToSection(id)}
              className="text-sm font-medium transition-colors hover:text-white"
              style={{ color: "rgba(241,245,249,0.7)" }}
            >
              {label}
            </button>
          ))}
        </nav>

        <div className="hidden min-[1000px]:block">
          <PrimaryButton onClick={() => goToSection("kapcsolat")}>Kérjen bemutatót</PrimaryButton>
        </div>

        <button
          className="min-[1000px]:hidden p-2 rounded-lg"
          style={{ color: COLORS.text, border: `1px solid ${COLORS.border}` }}
          onClick={() => setOpen(!open)}
          aria-label="Menü"
        >
          {open ? <window.IconX size={20} /> : <window.IconMenu size={20} />}
        </button>
      </div>

      {open && (
        <div
          className="min-[1000px]:hidden border-t"
          style={{ borderColor: COLORS.border, background: "rgba(8,13,26,0.96)" }}
        >
          <div className="px-6 py-4 flex flex-col gap-1">
            {links.map(([label, id]) => (
              <button
                key={id}
                onClick={() => {
                  goToSection(id);
                  setOpen(false);
                }}
                className="text-left py-3 px-2 rounded text-sm font-medium hover:bg-white/[0.04]"
                style={{ color: COLORS.text }}
              >
                {label}
              </button>
            ))}
            <div className="pt-2">
              <PrimaryButton
                onClick={() => {
                  goToSection("kapcsolat");
                  setOpen(false);
                }}
                className="w-full justify-center"
              >
                Kérjen bemutatót
              </PrimaryButton>
            </div>
          </div>
        </div>
      )}
    </header>
  );
};

// ────────────────────────────────────────────────────────────────────
// Hero — with animated SVG node graph
// ────────────────────────────────────────────────────────────────────
const NetworkGraph = () => {
  // A deterministic "neural network / knowledge graph" composition
  const nodes = [
    { id: "c", x: 260, y: 240, r: 26, label: "AI", core: true },
    // ring 1
    { id: "n1", x: 110, y: 110, r: 10 },
    { id: "n2", x: 410, y: 100, r: 12 },
    { id: "n3", x: 460, y: 250, r: 9 },
    { id: "n4", x: 360, y: 400, r: 11 },
    { id: "n5", x: 130, y: 380, r: 10 },
    { id: "n6", x: 60, y: 250, r: 9 },
    // outer
    { id: "n7", x: 220, y: 60, r: 7 },
    { id: "n8", x: 320, y: 60, r: 6 },
    { id: "n9", x: 480, y: 170, r: 6 },
    { id: "n10", x: 480, y: 340, r: 7 },
    { id: "n11", x: 220, y: 440, r: 6 },
    { id: "n12", x: 50, y: 170, r: 7 },
    { id: "n13", x: 50, y: 340, r: 6 },
  ];

  const edgesCenter = ["n1", "n2", "n3", "n4", "n5", "n6"];
  const edgesOuter = [
    ["n1", "n7"], ["n1", "n12"], ["n2", "n8"], ["n2", "n9"], ["n3", "n9"], ["n3", "n10"],
    ["n4", "n10"], ["n4", "n11"], ["n5", "n11"], ["n5", "n13"], ["n6", "n12"], ["n6", "n13"],
    ["n1", "n2"], ["n5", "n4"],
  ];

  const node = (id) => nodes.find((n) => n.id === id);

  return (
    <svg viewBox="0 0 520 480" className="w-full h-full" role="img" aria-label="AI hálózati ábra">
      <defs>
        <radialGradient id="coreGlow" cx="50%" cy="50%" r="50%">
          <stop offset="0%" stopColor="#60A5FA" stopOpacity="0.55" />
          <stop offset="60%" stopColor="#2563EB" stopOpacity="0.18" />
          <stop offset="100%" stopColor="#2563EB" stopOpacity="0" />
        </radialGradient>
        <radialGradient id="bgFade" cx="50%" cy="50%" r="60%">
          <stop offset="0%" stopColor="#1E3A8A" stopOpacity="0.25" />
          <stop offset="100%" stopColor="#080D1A" stopOpacity="0" />
        </radialGradient>
        <linearGradient id="edge" x1="0" y1="0" x2="1" y2="1">
          <stop offset="0%" stopColor="#3B82F6" stopOpacity="0.9" />
          <stop offset="100%" stopColor="#2563EB" stopOpacity="0.25" />
        </linearGradient>
        <filter id="soft" x="-30%" y="-30%" width="160%" height="160%">
          <feGaussianBlur stdDeviation="2.5" />
        </filter>
      </defs>

      <rect x="0" y="0" width="520" height="480" fill="url(#bgFade)" />
      <circle cx="260" cy="240" r="180" fill="url(#coreGlow)" />

      {/* Concentric rings */}
      {[80, 130, 190].map((r, i) => (
        <circle
          key={r}
          cx="260"
          cy="240"
          r={r}
          fill="none"
          stroke="rgba(96,165,250,0.12)"
          strokeWidth="1"
          strokeDasharray={i === 1 ? "2 6" : "1 4"}
        />
      ))}

      {/* Edges from center */}
      {edgesCenter.map((id) => {
        const n = node(id);
        return (
          <line
            key={"ec-" + id}
            x1={260}
            y1={240}
            x2={n.x}
            y2={n.y}
            stroke="url(#edge)"
            strokeWidth="1.4"
            opacity="0.9"
          />
        );
      })}

      {/* Outer edges */}
      {edgesOuter.map(([a, b], i) => {
        const A = node(a);
        const B = node(b);
        return (
          <line
            key={"eo-" + i}
            x1={A.x}
            y1={A.y}
            x2={B.x}
            y2={B.y}
            stroke="rgba(96,165,250,0.35)"
            strokeWidth="1"
          />
        );
      })}

      {/* Travelling pulses on selected edges */}
      {["n2", "n4", "n6"].map((id, i) => {
        const n = node(id);
        return (
          <circle key={"p-" + id} r="2.5" fill="#93C5FD">
            <animateMotion
              dur={`${3 + i * 0.6}s`}
              repeatCount="indefinite"
              path={`M260,240 L${n.x},${n.y}`}
            />
            <animate attributeName="opacity" values="0;1;1;0" dur={`${3 + i * 0.6}s`} repeatCount="indefinite" />
          </circle>
        );
      })}

      {/* Nodes */}
      {nodes.map((n) => {
        if (n.core) {
          return (
            <g key={n.id}>
              <circle cx={n.x} cy={n.y} r={n.r + 14} fill="#2563EB" opacity="0.18" filter="url(#soft)" />
              <circle cx={n.x} cy={n.y} r={n.r} fill="#0F1629" stroke="#3B82F6" strokeWidth="1.5" />
              <circle cx={n.x} cy={n.y} r={n.r - 8} fill="#3B82F6" />
              <text
                x={n.x}
                y={n.y + 4}
                textAnchor="middle"
                fontSize="11"
                fontWeight="700"
                fill="#F1F5F9"
                style={{ letterSpacing: "0.05em" }}
              >
                {n.label}
              </text>
              <circle cx={n.x} cy={n.y} r={n.r}>
                <animate attributeName="r" from={n.r} to={n.r + 18} dur="3s" repeatCount="indefinite" />
                <animate attributeName="opacity" from="0.5" to="0" dur="3s" repeatCount="indefinite" />
                <animate attributeName="stroke" values="#3B82F6;#3B82F6" dur="3s" repeatCount="indefinite" />
                <animate attributeName="fill" values="none;none" dur="3s" repeatCount="indefinite" />
              </circle>
            </g>
          );
        }
        return (
          <g key={n.id}>
            <circle cx={n.x} cy={n.y} r={n.r + 4} fill="#3B82F6" opacity="0.12" />
            <circle cx={n.x} cy={n.y} r={n.r} fill="#0F1629" stroke="#3B82F6" strokeWidth="1.4" />
            <circle cx={n.x} cy={n.y} r={Math.max(2, n.r - 5)} fill="#60A5FA" opacity="0.85" />
          </g>
        );
      })}
    </svg>
  );
};

const CountStat = ({ end, prefix = "", suffix = "", small, accent }) => {
  const [ref, val] = window.useCountUp(end, { duration: 1400 });
  return (
    <div ref={ref} className="flex flex-col gap-1 md:px-6">
      <div
        className="text-3xl md:text-4xl font-bold tracking-tight"
        style={
          accent
            ? {
                fontVariantNumeric: "tabular-nums",
                backgroundImage: "linear-gradient(135deg, #22D3EE 0%, #A855F7 100%)",
                WebkitBackgroundClip: "text",
                backgroundClip: "text",
                WebkitTextFillColor: "transparent",
                color: "transparent",
              }
            : { color: COLORS.text, fontVariantNumeric: "tabular-nums" }
        }
      >
        {prefix}{val}{suffix}
      </div>
      <div className="text-sm" style={{ color: COLORS.muted }}>
        {small}
      </div>
    </div>
  );
};

// ────────────────────────────────────────────────────────────────────
// Timeline — "How it works" — LIGHT section for contrast
// ────────────────────────────────────────────────────────────────────
const Timeline = () => {
  const steps = [
    ["Felmérés", "Üzleti folyamatok, kockázatok, jogszabályi környezet feltérképezése."],
    ["Tervezés", "Use case-ek, ROI becslés, megfelelőségi keret rögzítése."],
    ["Bevezetés", "Integráció a meglévő rendszerekkel: webchat, IVR, CRM, e-mail."],
    ["Audit", "Független felülvizsgálat — adatkezelés, biztonság, AI Act szempontok."],
    ["Üzemeltetés", "Folyamatos finomhangolás, riportálás, oktatás, support."],
  ];

  return (
    <section
      id="folyamat"
      className="relative"
      style={{
        background: "linear-gradient(180deg, #0B1224 0%, #11182C 50%, #0B1224 100%)",
        color: COLORS.lightInk,
        borderTop: `1px solid ${COLORS.border}`,
        borderBottom: `1px solid ${COLORS.border}`,
      }}
    >
      <div
        aria-hidden="true"
        className="absolute inset-0 pointer-events-none"
        style={{
          backgroundImage:
            "radial-gradient(ellipse 50% 40% at 15% 20%, rgba(168,85,247,0.10), transparent 60%)," +
            "radial-gradient(ellipse 60% 50% at 85% 80%, rgba(37,99,235,0.10), transparent 60%)",
        }}
      />
      <div className="relative max-w-7xl mx-auto px-6 md:px-10 py-24 md:py-28">
        <div>
          <div className="text-xs tracking-[0.2em] uppercase font-semibold" style={{ color: COLORS.amberSoft }}>
            Folyamat
          </div>
          <h2
            className="mt-3 font-bold tracking-tight max-w-3xl"
            style={{
              fontSize: "clamp(1.75rem, 3.5vw, 2.5rem)",
              lineHeight: 1.15,
              letterSpacing: "-0.02em",
              textWrap: "balance",
              color: COLORS.lightInk,
            }}
          >
            A koncepciótól az üzemeltetésig — egy csapatban
          </h2>
          <p className="mt-4 max-w-2xl" style={{ color: COLORS.lightInkSoft, fontSize: "1.0625rem", lineHeight: 1.65, textWrap: "pretty" }}>
            Öt fókuszált fázis, jogi és biztonsági ellenőrzéssel végig a folyamaton. Minden szakaszban világos átadási pontok és mérhető eredmények.
          </p>
        </div>

        {/* Desktop: horizontal rail */}
        <div className="mt-14 hidden md:block">
          <div className="relative">
            <div className="absolute left-0 right-0 top-[18px] h-px" style={{ background: "linear-gradient(90deg, transparent, rgba(168,85,247,0.40) 8%, rgba(96,165,250,0.35) 92%, transparent)" }} />
            <div className="grid grid-cols-5 gap-4">
              {steps.map(([title, desc], i) => (
                <window.Reveal key={i} delay={i * 110}>
                  <div className="flex flex-col items-start">
                    <div
                      className="relative w-9 h-9 rounded-full flex items-center justify-center font-bold text-sm"
                      style={{
                        background: i === 0 ? COLORS.amber : "#0F1629",
                        color: i === 0 ? "#FFFFFF" : COLORS.text,
                        border: `2px solid ${i === 0 ? COLORS.amber : "rgba(96,165,250,0.30)"}`,
                        boxShadow: i === 0 ? "0 0 0 6px rgba(168,85,247,0.20)" : "none",
                        fontVariantNumeric: "tabular-nums",
                      }}
                    >
                      {i + 1}
                    </div>
                    <div className="mt-5">
                      <h3 className="font-semibold text-base mb-1.5" style={{ color: COLORS.text, letterSpacing: "-0.01em" }}>
                        {title}
                      </h3>
                      <p className="text-sm leading-relaxed" style={{ color: COLORS.lightInkSoft }}>
                        {desc}
                      </p>
                    </div>
                  </div>
                </window.Reveal>
              ))}
            </div>
          </div>
        </div>

        {/* Mobile: vertical rail */}
        <div className="mt-10 md:hidden relative">
          <div className="absolute left-[17px] top-2 bottom-2 w-px" style={{ background: "rgba(96,165,250,0.25)" }} />
          <div className="space-y-7">
            {steps.map(([title, desc], i) => (
              <div key={i} className="relative pl-12">
                <div
                  className="absolute left-0 top-0 w-9 h-9 rounded-full flex items-center justify-center font-bold text-sm"
                  style={{
                    background: i === 0 ? COLORS.amber : "#0F1629",
                    color: i === 0 ? "#FFFFFF" : COLORS.text,
                    border: `2px solid ${i === 0 ? COLORS.amber : "rgba(96,165,250,0.30)"}`,
                    fontVariantNumeric: "tabular-nums",
                  }}
                >
                  {i + 1}
                </div>
                <h3 className="font-semibold text-base mb-1" style={{ color: COLORS.text }}>
                  {title}
                </h3>
                <p className="text-sm leading-relaxed" style={{ color: COLORS.lightInkSoft }}>
                  {desc}
                </p>
              </div>
            ))}
          </div>
        </div>
      </div>
    </section>
  );
};

const Hero = () => {

  return (
    <section id="hero" className="relative overflow-hidden">
      {/* ambient bg */}
      <div
        aria-hidden="true"
        className="absolute inset-0 pointer-events-none"
        style={{
          background:
            "radial-gradient(ellipse 70% 50% at 80% 20%, rgba(37,99,235,0.18), transparent 60%)," +
            "radial-gradient(ellipse 50% 40% at 10% 90%, rgba(37,99,235,0.10), transparent 60%)",
        }}
      />
      <div
        aria-hidden="true"
        className="absolute inset-0 pointer-events-none opacity-[0.35]"
        style={{
          backgroundImage:
            "linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px)",
          backgroundSize: "56px 56px",
          maskImage: "radial-gradient(ellipse 70% 60% at 50% 30%, black, transparent 75%)",
          WebkitMaskImage: "radial-gradient(ellipse 70% 60% at 50% 30%, black, transparent 75%)",
        }}
      />

      <div className="relative max-w-7xl mx-auto px-6 md:px-10 pt-20 md:pt-28 pb-12 md:pb-20">
        <div className="grid grid-cols-1 lg:grid-cols-5 gap-12 lg:gap-10 items-center">
          <div className="lg:col-span-3">
            <Badge icon={window.IconShieldCheck}>EU AI Act · GDPR · NIS2 ready</Badge>

            <h1
              className="mt-6 font-bold tracking-tight"
              style={{
                color: COLORS.text,
                fontSize: "clamp(2.25rem, 5vw, 3.75rem)",
                lineHeight: 1.05,
                letterSpacing: "-0.025em",
                textWrap: "balance",
              }}
            >
              Megbízható mesterséges intelligencia —{" "}
              <span
                style={{
                  background: "linear-gradient(120deg, #60A5FA 0%, #3B82F6 60%, #93C5FD 100%)",
                  WebkitBackgroundClip: "text",
                  WebkitTextFillColor: "transparent",
                  backgroundClip: "text",
                }}
              >
                Compliance-el a fókuszban
              </span>
            </h1>

            <p
              className="mt-6 max-w-xl"
              style={{ color: "rgba(241,245,249,0.7)", fontSize: "1.0625rem", lineHeight: 1.65, textWrap: "pretty" }}
            >
              Az FMProject Kft. innovatív, AI-alapú ügyfélszolgálati rendszereket szállít, amelyek a jogszabályoknak teljes mértékben megfelelnek. Segítünk hatékonyabb működést elérni, miközben ügyfelei elégedettsége is növekszik.
            </p>

            <div className="mt-8 flex flex-wrap gap-3">
              <PrimaryButton onClick={() => goToSection("kapcsolat")} icon={window.IconArrowRight}>
                Kérjen bemutatót
              </PrimaryButton>
              <GhostButton onClick={() => goToSection("megfeleles")} icon={window.IconArrowRight}>
                Megfelelőség és biztonság
              </GhostButton>
            </div>
          </div>

          <div className="lg:col-span-2">
            <div
              className="relative rounded-2xl overflow-hidden aspect-square max-w-md mx-auto"
              style={{
                background: `linear-gradient(160deg, ${COLORS.surface} 0%, ${COLORS.bg} 100%)`,
                border: `1px solid ${COLORS.border}`,
                boxShadow: "0 30px 80px -30px rgba(37,99,235,0.35), inset 0 1px 0 rgba(255,255,255,0.04)",
              }}
            >
              <NetworkGraph />
              <div
                className="absolute top-3 left-3 right-3 flex items-center justify-between text-[10px] uppercase tracking-[0.2em]"
                style={{ color: "rgba(96,165,250,0.7)" }}
              >
                <span>// neural-graph.fmp</span>
                <span className="flex items-center gap-1.5">
                  <span className="w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse" />
                  live
                </span>
              </div>
            </div>
          </div>
        </div>
      </div>

      {/* Stat bar */}
      <div className="relative" style={{ borderTop: `1px solid ${COLORS.border}`, borderBottom: `1px solid ${COLORS.border}` }}>
        <div className="max-w-7xl mx-auto px-6 md:px-10 py-8 grid grid-cols-1 md:grid-cols-3 gap-8 md:gap-4">
          <CountStat end={60} prefix=">" suffix=" év" small="összesített szakértői tapasztalat" accent />
          <div className="flex flex-col gap-1 md:px-6 md:border-l" style={{ borderColor: COLORS.border }}>
            <div className="text-3xl md:text-4xl font-bold tracking-tight" style={{ color: COLORS.text }}>
              Compliance-first
            </div>
            <div className="text-sm" style={{ color: COLORS.muted }}>
              EU AI Act · GDPR · NIS2
            </div>
          </div>
          <div className="flex flex-col gap-1 md:px-6 md:border-l" style={{ borderColor: COLORS.border }}>
            <div className="text-3xl md:text-4xl font-bold tracking-tight" style={{ color: COLORS.text }}>
              24/7
            </div>
            <div className="text-sm" style={{ color: COLORS.muted }}>
              folyamatos digitális ügyfélkiszolgálás
            </div>
          </div>
        </div>
      </div>

      {/* Trust marquee */}
      <div className="py-5" style={{ borderBottom: `1px solid ${COLORS.border}` }}>
        <window.Marquee
          speed={55}
          items={[
            { icon: window.IconShieldCheck, label: "EU AI Act" },
            { icon: window.IconShieldCheck, label: "GDPR" },
            { icon: window.IconShieldCheck, label: "NIS2" },
            { icon: window.IconAward,       label: "Sirius Award" },
            { icon: window.IconAward,       label: "Privacy Oscar" },
            { icon: window.IconWifi,        label: "Telekommunikáció" },
            { icon: window.IconHeart,       label: "Egészségügy" },
            { icon: window.IconBuilding2,   label: "Közigazgatás" },
            { icon: window.IconZap,         label: "Energetika" },
            { icon: window.IconShoppingCart,label: "Kiskereskedelem" },
          ]}
        />
      </div>
    </section>
  );
};

// ────────────────────────────────────────────────────────────────────
// Section header
// ────────────────────────────────────────────────────────────────────
const SectionHeader = ({ label, title, lead, align = "left", maxLeadWidth = "max-w-3xl" }) => (
  <div className={align === "center" ? "text-center mx-auto " + maxLeadWidth : ""}>
    <SectionLabel>{label}</SectionLabel>
    <h2
      className="mt-3 font-bold tracking-tight"
      style={{
        color: COLORS.text,
        fontSize: "clamp(1.75rem, 3.5vw, 2.5rem)",
        lineHeight: 1.15,
        letterSpacing: "-0.02em",
        textWrap: "balance",
      }}
    >
      {title}
    </h2>
    {lead && (
      <p
        className={"mt-4 " + (align === "center" ? "" : maxLeadWidth)}
        style={{ color: "rgba(241,245,249,0.7)", fontSize: "1.0625rem", lineHeight: 1.65, textWrap: "pretty" }}
      >
        {lead}
      </p>
    )}
  </div>
);

// ────────────────────────────────────────────────────────────────────
// Rólunk (2x2 grid)
// ────────────────────────────────────────────────────────────────────
const Rolunk = () => {
  const items = [
    [window.IconUsers, "Tapasztalt szakértői csapat", "Nemzetközi nagyvállalati IT, ügyfélkiszolgálási és információbiztonsági projektek vezetése."],
    [window.IconAward, "Díjakkal igazolt teljesítmény", "Sirius Award, Privacy Oscar, Advisor of the Year, Energy Executive of the Year, Manager of the Year."],
    [window.IconZap, "Transzformációs szakértelem", "Nagyvállalati transzformációs projektek — Vodafone, Vantage Towers és egyéb multinacionális környezetek."],
    [window.IconLayers, "Átfogó multidiszciplináris tudás", "Üzleti folyamatmenedzsment, jog, informatika és IT biztonság — egy csapaton belül."],
  ];

  return (
    <section id="rolunk" className="relative">
      <div className="max-w-7xl mx-auto px-6 md:px-10 py-24 md:py-28">
        <SectionHeader
          label="Rólunk"
          title="Tapasztalat, amelyre hosszú távon építhet"
          lead="Csapatunk több mint hat évtizednyi összesített tapasztalattal rendelkezik komplex projektek tervezésében, főként multinacionális és nagyvállalati környezetben. A távközlési, pénzügyi, energiaipari és tanácsadói szektorban szerzett tudásunkat AI-alapú ügyfélszolgálati megoldásokra fókuszálva hasznosítjuk."
        />

        <div className="mt-14 grid grid-cols-1 md:grid-cols-2 gap-5">
          {items.map(([Icon, title, desc], i) => (
            <window.Reveal
              key={i}
              delay={i * 80}
              className="group relative rounded-xl p-7 transition-all duration-300 hover:-translate-y-0.5"
              style={{
                background: COLORS.surface,
                border: `1px solid ${COLORS.border}`,
              }}
            >
              <div className="flex items-start gap-5">
                <div
                  className="flex-shrink-0 w-12 h-12 rounded-lg flex items-center justify-center"
                  style={{
                    background: "rgba(37,99,235,0.12)",
                    color: COLORS.badgeText,
                    border: "1px solid rgba(96,165,250,0.18)",
                  }}
                >
                  <Icon size={22} />
                </div>
                <div className="flex-1">
                  <h3 className="font-semibold text-lg mb-2" style={{ color: COLORS.text, letterSpacing: "-0.01em" }}>
                    {title}
                  </h3>
                  <p className="text-sm leading-relaxed" style={{ color: "rgba(241,245,249,0.65)" }}>
                    {desc}
                  </p>
                </div>
              </div>
            </window.Reveal>
          ))}
        </div>
      </div>
    </section>
  );
};

// ────────────────────────────────────────────────────────────────────
// Miért mi (3-col)
// ────────────────────────────────────────────────────────────────────
const MiertMi = () => {
  const items = [
    [window.IconTarget, "Üzleti fókuszú megközelítés", "Először az üzleti folyamatokat, célokat és kockázatokat értjük meg. Use case-alapú tervezés, ROI és megtérülési idő becsléssel."],
    [window.IconRefreshCw, "Teljes szolgáltatási életciklus", "Konzultációtól az üzemeltetésig. Felmérés, design, bevezetés, oktatás, folyamatos finomhangolás auditokkal kombinálva."],
    [window.IconShieldCheck, "Beépített jogi megfelelés", "Minden projektünkbe beépül a compliance — EU AI Act, GDPR, NIS2 — így Ön a növekedésre koncentrálhat."],
  ];

  return (
    <section id="miert-mi" className="relative" style={{ borderTop: `1px solid ${COLORS.border}` }}>
      <div className="max-w-7xl mx-auto px-6 md:px-10 py-24 md:py-28">
        <SectionHeader
          label="Miért válasszon minket?"
          title="Üzleti problémák, technológiai megoldások"
          lead="Nem 'dobozos' technológiát értékesítünk. Az Ön konkrét üzleti kihívásait elemezzük, majd ehhez igazítjuk az AI eszköztárát — teljes körű jogi megfeleléssel. A technológia nálunk eszköz, nem cél."
        />

        <div className="mt-14 grid grid-cols-1 md:grid-cols-3 gap-8 md:gap-6">
          {items.map(([Icon, title, desc], i) => (
            <window.Reveal key={i} delay={i * 110} className="relative">
              <div
                className="w-14 h-14 rounded-full flex items-center justify-center mb-5"
                style={{
                  background: "rgba(37,99,235,0.12)",
                  color: COLORS.badgeText,
                  border: "1px solid rgba(96,165,250,0.22)",
                  boxShadow: "0 0 0 6px rgba(37,99,235,0.04)",
                }}
              >
                <Icon size={24} />
              </div>
              <h3 className="font-semibold text-xl mb-3" style={{ color: COLORS.text, letterSpacing: "-0.015em" }}>
                {title}
              </h3>
              <p className="text-sm leading-relaxed" style={{ color: "rgba(241,245,249,0.65)" }}>
                {desc}
              </p>
            </window.Reveal>
          ))}
        </div>
      </div>
    </section>
  );
};

// ────────────────────────────────────────────────────────────────────
// Megoldások — horizontal cards
// ────────────────────────────────────────────────────────────────────
const Megoldasok = () => {
  const items = [
    [window.IconMessageSquare, "Természetes nyelvi párbeszéd", "LLM-alapú megoldások, amelyek emberközeli stílusban reagálnak. Integráció webchat, mobilapp, telefonos IVR és e-mail csatornákkal."],
    [window.IconClipboardCheck, "Automatizált audit és minőségbiztosítás", "Szabályzatok, SLA-k és belső eljárások szerinti folyamatos ellenőrzés. Riportok a megfelelőségi és üzleti döntéshozatalhoz."],
    [window.IconPackage, "Teljes körű szolgáltatási csomag", "A koncepciótól az üzemeltetésig végigkísérjük a megoldást. Konzultáció, bevezetés, oktatás, üzemeltetési és támogatási folyamatok."],
  ];

  return (
    <section id="asszisztensek" className="relative" style={{ borderTop: `1px solid ${COLORS.border}` }}>
      <window.TerminalDecor className="hidden lg:block absolute top-10 right-8 z-0" style={{ opacity: 0.7 }} />
      <div className="relative max-w-7xl mx-auto px-6 md:px-10 py-24 md:py-28" style={{ zIndex: 1 }}>
        <SectionHeader
          label="Megoldásaink"
          title="FMProject digitális asszisztensek"
          lead="Természetes nyelvi kommunikációval, automatizált auditokkal és átfogó szolgáltatási csomaggal segítik ügyfélszolgálatát — kevesebb manuális teher, gyorsabb válaszadás, stabilabb minőség."
        />

        <div className="mt-14 flex flex-col gap-4">
          {items.map(([Icon, title, desc], i) => (
            <window.Reveal
              key={i}
              delay={i * 90}
              className="group relative rounded-xl p-6 md:p-7 transition-all duration-300"
              style={{
                background: COLORS.surface,
                border: `1px solid ${COLORS.border}`,
              }}
            >
              <div
                className="flex flex-col md:flex-row items-start gap-5 md:gap-7"
                onMouseEnter={(e) => (e.currentTarget.parentElement.style.borderColor = "rgba(59,130,246,0.35)")}
                onMouseLeave={(e) => (e.currentTarget.parentElement.style.borderColor = COLORS.border)}
              >
                <div className="flex-shrink-0 md:w-[260px] flex md:justify-center md:items-center w-full">
                  {i === 0 ? (
                    <window.ChatPreview />
                  ) : (
                    <div
                      className="w-14 h-14 rounded-xl flex items-center justify-center"
                      style={{
                        background: "linear-gradient(135deg, rgba(59,130,246,0.20), rgba(37,99,235,0.08))",
                        color: COLORS.badgeText,
                        border: "1px solid rgba(96,165,250,0.22)",
                      }}
                    >
                      <Icon size={26} />
                    </div>
                  )}
                </div>
                <div className="flex-1 min-w-0">
                  <div className="flex items-center gap-3 mb-2">
                    <span
                      className="text-xs font-mono"
                      style={{ color: "rgba(96,165,250,0.55)" }}
                    >
                      0{i + 1}
                    </span>
                    <h3 className="font-semibold text-xl" style={{ color: COLORS.text, letterSpacing: "-0.015em" }}>
                      {title}
                    </h3>
                  </div>
                  <p className="text-sm md:text-[0.95rem] leading-relaxed" style={{ color: "rgba(241,245,249,0.68)" }}>
                    {desc}
                  </p>
                </div>
                <div
                  className="hidden md:flex flex-shrink-0 self-center w-10 h-10 rounded-full items-center justify-center transition-all"
                  style={{
                    color: "rgba(96,165,250,0.6)",
                    border: `1px solid ${COLORS.border}`,
                  }}
                >
                  <window.IconArrowRight size={16} />
                </div>
              </div>
            </window.Reveal>
          ))}
        </div>
      </div>
    </section>
  );
};

// ────────────────────────────────────────────────────────────────────
// Megfelelőség — Venn diagram
// ────────────────────────────────────────────────────────────────────
const VennDiagram = () => {
  // 3 overlapping circles
  return (
    <svg viewBox="0 0 480 440" className="w-full h-full" role="img" aria-label="Compliance Venn diagram">
      <defs>
        <radialGradient id="vennC1" cx="40%" cy="40%" r="60%">
          <stop offset="0%" stopColor="#60A5FA" stopOpacity="0.40" />
          <stop offset="100%" stopColor="#2563EB" stopOpacity="0.10" />
        </radialGradient>
        <radialGradient id="vennC2" cx="60%" cy="40%" r="60%">
          <stop offset="0%" stopColor="#3B82F6" stopOpacity="0.40" />
          <stop offset="100%" stopColor="#1D4ED8" stopOpacity="0.10" />
        </radialGradient>
        <radialGradient id="vennC3" cx="50%" cy="60%" r="60%">
          <stop offset="0%" stopColor="#93C5FD" stopOpacity="0.40" />
          <stop offset="100%" stopColor="#2563EB" stopOpacity="0.10" />
        </radialGradient>
      </defs>

      {/* subtle grid */}
      <g opacity="0.18">
        {[0.25, 0.5, 0.75].map((p) => (
          <line key={"h" + p} x1="40" x2="440" y1={40 + 360 * p} y2={40 + 360 * p} stroke="rgba(96,165,250,0.25)" strokeDasharray="2 6" />
        ))}
      </g>

      {/* Circles */}
      <g style={{ mixBlendMode: "screen" }}>
        <circle cx="170" cy="180" r="120" fill="url(#vennC1)" stroke="#3B82F6" strokeWidth="1.5" />
        <circle cx="310" cy="180" r="120" fill="url(#vennC2)" stroke="#60A5FA" strokeWidth="1.5" />
        <circle cx="240" cy="290" r="120" fill="url(#vennC3)" stroke="#93C5FD" strokeWidth="1.5" />
      </g>

      {/* Center label */}
      <g>
        <circle cx="240" cy="217" r="38" fill="#0F1629" stroke="#3B82F6" strokeWidth="1.5" />
        <circle cx="240" cy="217" r="38" fill="none" stroke="rgba(96,165,250,0.18)" strokeWidth="10" />
        <text x="240" y="213" textAnchor="middle" fontSize="11" fontWeight="700" fill="#F1F5F9" style={{ letterSpacing: "0.04em" }}>
          BIZTONSÁGOS
        </text>
        <text x="240" y="228" textAnchor="middle" fontSize="11" fontWeight="700" fill="#60A5FA" style={{ letterSpacing: "0.04em" }}>
          AI
        </text>
      </g>

      {/* Outer labels */}
      <g fontSize="13" fontWeight="700" fill="#F1F5F9">
        <text x="100" y="100" textAnchor="middle">EU AI Act</text>
        <text x="380" y="100" textAnchor="middle">GDPR</text>
        <text x="240" y="395" textAnchor="middle">NIS2</text>
      </g>

      {/* Sub-labels */}
      <g fontSize="9" fontWeight="500" fill="rgba(96,165,250,0.85)" style={{ letterSpacing: "0.08em", textTransform: "uppercase" }}>
        <text x="100" y="116" textAnchor="middle">Risk-based</text>
        <text x="380" y="116" textAnchor="middle">Data privacy</text>
        <text x="240" y="411" textAnchor="middle">Network security</text>
      </g>

      {/* Floating dots / pulse */}
      {[
        [170, 180], [310, 180], [240, 290],
      ].map(([x, y], i) => (
        <circle key={i} cx={x} cy={y} r="3" fill="#93C5FD">
          <animate attributeName="opacity" values="0.3;1;0.3" dur={`${2 + i * 0.4}s`} repeatCount="indefinite" />
        </circle>
      ))}
    </svg>
  );
};

const Megfeleles = () => {
  const Bullet = ({ children }) => (
    <li className="flex gap-3 items-start text-sm leading-relaxed" style={{ color: "rgba(241,245,249,0.78)" }}>
      <span
        className="flex-shrink-0 mt-0.5 w-5 h-5 rounded-md flex items-center justify-center"
        style={{ background: "rgba(37,99,235,0.18)", color: "#60A5FA" }}
      >
        <window.IconCheck size={12} stroke={3} />
      </span>
      <span>{children}</span>
    </li>
  );

  return (
    <section id="megfeleles" className="relative" style={{ background: COLORS.surface, borderTop: `1px solid ${COLORS.border}`, borderBottom: `1px solid ${COLORS.border}` }}>
      <div className="max-w-7xl mx-auto px-6 md:px-10 py-24 md:py-28">
        <SectionHeader
          label="Megfelelőség és biztonság"
          title="Jogszabálykövető, biztonságos AI keretrendszer"
          lead="Kiemelt hangsúlyt fektetünk a jogszabályi megfelelésre és az adattal történő felelős gazdálkodásra."
        />

        <div className="mt-14 grid grid-cols-1 lg:grid-cols-2 gap-12 lg:gap-16 items-start">
          <div className="space-y-10">
            <div>
              <h3 className="font-semibold text-lg mb-4" style={{ color: COLORS.text, letterSpacing: "-0.01em" }}>
                EU AI Act, GDPR, NIS2
              </h3>
              <ul className="space-y-3">
                <Bullet>Az EU AI Act elvárásaihoz igazodó kockázatalapú megközelítés</Bullet>
                <Bullet>GDPR-konform adatkezelési gyakorlatok, hangfelvételek kezelésére is</Bullet>
                <Bullet>NIS2-nek megfelelő informatikai és hálózatbiztonsági kontrollok</Bullet>
              </ul>
            </div>

            <div>
              <h3 className="font-semibold text-lg mb-4" style={{ color: COLORS.text, letterSpacing: "-0.01em" }}>
                Auditált, biztonságos működés
              </h3>
              <ul className="space-y-3">
                <Bullet>Dokumentált, rendszeresen felülvizsgált folyamatok az átláthatóság érdekében</Bullet>
                <Bullet>Naprakész adatbiztonsági keretrendszer: behatolásvédelem, naplózás, hozzáférés-ellenőrzés</Bullet>
                <Bullet>Igény szerint független audit, penetrációs teszt és megfelelőségi jelentés</Bullet>
              </ul>
            </div>
          </div>

          <div
            className="relative rounded-2xl aspect-[4/3.6] max-w-lg mx-auto w-full"
            style={{
              background: COLORS.bg,
              border: `1px solid ${COLORS.border}`,
              boxShadow: "0 20px 60px -20px rgba(37,99,235,0.30), inset 0 1px 0 rgba(255,255,255,0.04)",
            }}
          >
            <VennDiagram />
          </div>
        </div>
      </div>
    </section>
  );
};

// ────────────────────────────────────────────────────────────────────
// Iparágak
// ────────────────────────────────────────────────────────────────────
const Iparagak = () => {
  const items = [
    [window.IconWifi, "Telekommunikáció", "Gyors és hatékony ügyfélkezelés szolgáltatók számára."],
    [window.IconHeart, "Egészségügy", "Páciens-információk és időpontfoglalás automatizálása."],
    [window.IconBuilding2, "Közigazgatás", "Panaszbejelentések és ügyféltájékoztatás kezelése."],
    [window.IconZap, "Energetika", "Fogyasztói adatok és szolgáltatási kérdések kezelése."],
    [window.IconShoppingCart, "Kiskereskedelem", "Vásárlói kérdések, termékkereség, készletinformáció."],
  ];

  return (
    <section id="iparagak" className="relative">
      <window.DotMatrixDecor className="hidden lg:block absolute top-16 left-6" />
      <window.BlueprintDecor className="hidden lg:block absolute bottom-10 right-10" />
      <div className="max-w-7xl mx-auto px-6 md:px-10 py-24 md:py-28">
        <SectionHeader
          label="Iparági megoldások"
          title="Fókuszban az ügyfél — minden szektorban"
          lead="Megoldásaink rugalmasan illeszkednek a telekommunikáció, egészségügy, közigazgatás, energetika és kiskereskedelem speciális igényeihez."
        />

        <div className="mt-14 grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-5 gap-4">
          {items.map(([Icon, title, desc], i) => (
            <window.Reveal
              key={i}
              delay={i * 70}
              className="rounded-xl p-6 transition-all duration-300 hover:-translate-y-0.5"
              style={{
                background: COLORS.surface,
                border: `1px solid ${COLORS.border}`,
              }}
            >
              <div
                className="w-11 h-11 rounded-lg flex items-center justify-center mb-4"
                style={{
                  background: "rgba(37,99,235,0.12)",
                  color: COLORS.badgeText,
                  border: "1px solid rgba(96,165,250,0.18)",
                }}
              >
                <Icon size={20} />
              </div>
              <h3 className="font-semibold text-base mb-1.5" style={{ color: COLORS.text, letterSpacing: "-0.01em" }}>
                {title}
              </h3>
              <p className="text-sm leading-relaxed" style={{ color: "rgba(241,245,249,0.62)" }}>
                {desc}
              </p>
            </window.Reveal>
          ))}
        </div>
      </div>
    </section>
  );
};

// ────────────────────────────────────────────────────────────────────
// Kapcsolat
// ────────────────────────────────────────────────────────────────────
const ContactField = ({ label, error, children }) => (
  <label className="block">
    <div className="text-xs font-semibold mb-2 tracking-wide" style={{ color: "rgba(241,245,249,0.75)" }}>
      {label}
    </div>
    {children}
    {error && <div className="text-xs mt-1.5" style={{ color: "#F87171" }}>{error}</div>}
  </label>
);

const Kapcsolat = () => {
  const [form, setForm] = useState({ name: "", email: "", message: "" });
  const [errors, setErrors] = useState({});
  const [submitting, setSubmitting] = useState(false);
  const turnstileInitialized = useRef(false);
  const pendingData = useRef(null);
  const mountedRef = useRef(true);

  const backendUrl = (window.AppConfig && window.AppConfig.backendUrl) || "/";

  useEffect(() => {
    return () => { mountedRef.current = false; };
  }, []);

  const validate = () => {
    const e = {};
    if (!form.name.trim()) e.name = "Adja meg a nevét";
    if (!form.email.trim()) e.email = "Adja meg az e-mail címét";
    else if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(form.email)) e.email = "Érvénytelen e-mail cím";
    if (!form.message.trim()) e.message = "Üzenete tartalma kötelező";
    return e;
  };

  const sanitizeForm = (raw) => {
    const S = window.Sanitize;
    if (!S) return { ok: false, error: "Sanitizer not available" };
    const data = {
      name: S.sanitizeInput(raw.name, "name"),
      email: S.sanitizeInput(raw.email, "email"),
      message: S.sanitizeInput(raw.message, "message"),
    };
    if (!S.isValidEmail(data.email)) {
      return { ok: false, error: window.i18n?.t("validation.invalidEmail") || "Érvénytelen e-mail cím" };
    }
    if (S.detectSuspiciousPatterns(data.name) || S.detectSuspiciousPatterns(data.email) || S.detectSuspiciousPatterns(data.message)) {
      return { ok: false, error: window.i18n?.t("validation.suspiciousContent") || "Az üzenet gyanús tartalmat tartalmaz." };
    }
    return { ok: true, data };
  };

  const postToWorker = async (data, token) => {
    setSubmitting(true);
    try {
      const resp = await fetch(backendUrl, {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({ ...data, turnstileToken: token }),
      });
      window.UI?.closeCaptchaModal();
      if (resp.ok) {
        window.UI?.showMessageModal(window.i18n?.t("submission.success") || "Üzenet sikeresen elküldve");
        if (mountedRef.current) setForm({ name: "", email: "", message: "" });
        window.TurnstileClient?.reset();
        turnstileInitialized.current = false;
        setTimeout(() => window.UI?.closeMessageModal(), 2000);
      } else {
        window.UI?.showMessageModal(window.i18n?.t("submission.failure") || "Sikertelen küldés.");
      }
    } catch (err) {
      console.error("Contact form submission error:", err);
      window.UI?.closeCaptchaModal();
      window.UI?.showMessageModal(window.i18n?.t("submission.failure") || "Sikertelen küldés.");
    } finally {
      if (mountedRef.current) setSubmitting(false);
    }
  };

  useEffect(() => {
    window._formHandlerTurnstileSuccess = (token) => {
      const data = pendingData.current;
      if (!data) return;
      pendingData.current = null;
      postToWorker(data, token);
    };
    window._formHandlerTurnstileError = (errorMessage) => {
      window.UI?.closeCaptchaModal();
      window.UI?.showMessageModal(errorMessage);
    };
    return () => {
      try { delete window._formHandlerTurnstileSuccess; } catch (e) { window._formHandlerTurnstileSuccess = undefined; }
      try { delete window._formHandlerTurnstileError; } catch (e) { window._formHandlerTurnstileError = undefined; }
    };
  }, []);

  const onSubmit = (ev) => {
    ev.preventDefault();
    if (submitting) return;

    const e = validate();
    setErrors(e);
    if (Object.keys(e).length) return;

    const result = sanitizeForm(form);
    if (!result.ok) {
      window.UI?.showMessageModal(result.error);
      return;
    }

    if (!turnstileInitialized.current) {
      pendingData.current = result.data;
      turnstileInitialized.current = true;
      window.UI?.showCaptchaModal();
      window.TurnstileClient?.init(backendUrl);
      return;
    }

    const token = window.TurnstileClient?.getToken();
    if (!token) {
      window.UI?.showMessageModal(window.i18n?.t("captcha.required") || "Kérjük, igazolja, hogy nem robot.");
      return;
    }
    postToWorker(result.data, token);
  };

  const inputClass =
    "w-full px-4 py-3 rounded-lg text-sm outline-none transition-colors focus:border-blue-500/60";
  const inputStyle = {
    background: COLORS.bg,
    border: `1px solid ${COLORS.border}`,
    color: COLORS.text,
  };

  return (
    <section id="kapcsolat" className="relative" style={{ borderTop: `1px solid ${COLORS.border}` }}>
      <div className="max-w-3xl mx-auto px-6 md:px-10 py-24 md:py-28 text-center">
        <SectionHeader
          label="Kapcsolat"
          title="Kérjen személyes konzultációt"
          lead="Érdekli, hogyan illeszkedhet egy jogilag védhető, AI-alapú ügyfélszolgálati megoldás az Ön szervezetéhez? Vegye fel velünk a kapcsolatot — online vagy személyes workshop formájában megmutatjuk a lehetőségeket."
          align="center"
        />

        <div className="mt-8 flex flex-wrap justify-center gap-3">
          <a
            href="mailto:info@fmproject.hu"
            className="inline-flex items-center gap-2 px-4 py-2.5 rounded-lg text-sm font-medium transition-colors"
            style={{ background: COLORS.surface, border: `1px solid ${COLORS.border}`, color: COLORS.text }}
          >
            <window.IconMail size={16} style={{ color: COLORS.badgeText }} />
            info@fmproject.hu
          </a>
          <a
            href="tel:+3670442 2434"
            className="inline-flex items-center gap-2 px-4 py-2.5 rounded-lg text-sm font-medium transition-colors"
            style={{ background: COLORS.surface, border: `1px solid ${COLORS.border}`, color: COLORS.text }}
          >
            <window.IconPhone size={16} style={{ color: COLORS.badgeText }} />
            +36 70 4422-434
          </a>
        </div>

        <form
          onSubmit={onSubmit}
          className="mt-10 text-left rounded-2xl p-6 md:p-8 space-y-5"
          style={{ background: COLORS.surface, border: `1px solid ${COLORS.border}` }}
          noValidate
        >
          <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
            <ContactField label="Név" error={errors.name}>
              <input
                type="text"
                value={form.name}
                onChange={(e) => setForm({ ...form, name: e.target.value })}
                className={inputClass}
                style={inputStyle}
                placeholder="Pl. Kovács Anna"
              />
            </ContactField>
            <ContactField label="E-mail" error={errors.email}>
              <input
                type="email"
                value={form.email}
                onChange={(e) => setForm({ ...form, email: e.target.value })}
                className={inputClass}
                style={inputStyle}
                placeholder="anna@vallalat.hu"
              />
            </ContactField>
          </div>
          <ContactField label="Üzenet" error={errors.message}>
            <textarea
              value={form.message}
              onChange={(e) => setForm({ ...form, message: e.target.value })}
              rows={5}
              className={inputClass + " resize-none"}
              style={inputStyle}
              placeholder="Mondja el röviden, milyen kihívásra keresnek megoldást..."
            />
          </ContactField>
          <div className="flex justify-end pt-2">
            <PrimaryButton onClick={undefined}>
              <span className="flex items-center gap-2">
                {submitting ? "Küldés…" : "Üzenet küldése"}
                <window.IconSend size={16} />
              </span>
            </PrimaryButton>
          </div>
          {/* the inner button needs to act as submit */}
          <button type="submit" style={{ display: "none" }} aria-hidden="true" />
        </form>
      </div>
    </section>
  );
};

// HTML wordmark used in the footer so individual letters can stagger on hover.
// (Image-based logo can't be animated per-letter.)
const FmWordmark = () => {
  const row1 = [
    { ch: "F", cls: "fm-fm" },
    { ch: "M", cls: "fm-fm" },
    { ch: "P", cls: "fm-project" },
    { ch: "r", cls: "fm-project" },
    { ch: "o", cls: "fm-project" },
    { ch: "j", cls: "fm-project" },
    { ch: "e", cls: "fm-project" },
    { ch: "c", cls: "fm-project" },
    { ch: "t", cls: "fm-project" },
  ];
  const row2 = "AI POWERED IT SOLUTIONS".split("");
  let r2idx = 0;

  return (
    <div className="fm-wordmark" aria-label="FMProject — AI Powered IT Solutions">
      <div className="fm-row1">
        {row1.map((l, i) => (
          <span key={i} className={`fm-letter ${l.cls}`} style={{ animationDelay: `${i * 45}ms` }}>
            {l.ch}
          </span>
        ))}
      </div>
      <div className="fm-row2">
        {row2.map((ch, i) => {
          const isAI = i === 0 || i === 1;
          const isIT = i === 11 || i === 12;
          const cls = isAI ? "fm-ai" : isIT ? "fm-it" : "";
          const isLetter = ch !== " ";
          if (isLetter) r2idx += 1;
          return (
            <span
              key={i}
              className={`fm-letter ${cls}`}
              style={{
                animationDelay: `${(row1.length + (isLetter ? r2idx : 0)) * 35 + 80}ms`,
                width: ch === " " ? "0.45em" : "auto",
              }}
            >
              {ch === " " ? "\u00A0" : ch}
            </span>
          );
        })}
      </div>
    </div>
  );
};

window.FmWordmark = FmWordmark;

// ────────────────────────────────────────────────────────────────────
// Footer
// ────────────────────────────────────────────────────────────────────
const Footer = () => (
  <footer style={{ borderTop: `1px solid ${COLORS.border}` }}>
    <div className="max-w-7xl mx-auto px-6 md:px-10 py-6 flex flex-col md:flex-row items-center justify-between gap-6">
      <FmWordmark />
      <div className="flex flex-col md:items-end items-center gap-2">
        <div className="text-sm" style={{ color: COLORS.muted }}>
          © 2025 FMProject Kft. Minden jog fenntartva.
        </div>
        <a
          href="adatkezeles.html"
          target="_blank"
          rel="noopener noreferrer"
          className="text-sm transition-colors hover:text-blue-400"
          style={{ color: COLORS.muted }}
        >
          Adatkezelési tájékoztató
        </a>
      </div>
    </div>
  </footer>
);

// ────────────────────────────────────────────────────────────────────
// Root
// ────────────────────────────────────────────────────────────────────
function App() {
  // Tweak the contact form's "PrimaryButton" workaround:
  // since PrimaryButton is just <button>, intercept its click to submit form.
  useEffect(() => {
    const form = document.querySelector("#kapcsolat form");
    if (!form) return;
    const handler = (e) => {
      const t = e.target;
      if (t.tagName === "BUTTON" && !t.matches('[type="submit"]') && form.contains(t)) {
        // synthesize a submit
        e.preventDefault();
        form.dispatchEvent(new Event("submit", { cancelable: true, bubbles: true }));
      }
    };
    form.addEventListener("click", handler);
    return () => form.removeEventListener("click", handler);
  }, []);

  return (
    <div style={{ color: COLORS.text, minHeight: "100vh", position: "relative" }}>
      <window.ScrollProgress />
      <window.PageBackdrop />
      <Nav />
      <window.CursorGlow targetSelector="#hero" />
      <main style={{ position: "relative", zIndex: 1 }}>
        <Hero />
        <Rolunk />
        <MiertMi />
        <Megoldasok />
        <Timeline />
        <Megfeleles />
        <Iparagak />
        <Kapcsolat />
      </main>
      <Footer />
    </div>
  );
}

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