// Devleaps — five hero / structure variants modeled on the LQ project,
// rendered with Devleaps fonts, palette tokens, and the real wordmark logo.
// All variants share Sections (Services, Manifesto, Team, Process, Contact)
// and the same V4-style hero copy: manifesto headline + Devleaps lede.

// =============================================================
// SHARED HERO PRIMITIVES — used by all variants
// =============================================================

// Three-line manifesto headline with `//` mono ticks (V4 base)
const ManifestoHeadline = ({ color = "var(--fg-on-dark)", maxFs = 96, cqi = 5 }) =>
<div style={{ containerType: "inline-size", width: "100%", marginBottom: 32 }}>
    <h1 className="dl-display dl-manifesto-headline" style={{
    fontSize: `clamp(16px, ${cqi}cqi, ${maxFs}px)`,
    lineHeight: 1.02, letterSpacing: "-0.035em",
    margin: 0, color, whiteSpace: "nowrap"
  }}>
      <V4Line>one <span style={{ fontStyle: "italic", color: "var(--accent)" }}>TEAM</span></V4Line>
      <V4Line>integrated <span style={{ fontStyle: "italic", color: "var(--accent)" }}>solutions</span></V4Line>
      <V4Line>lasting <span style={{ fontStyle: "italic", color: "var(--accent)" }}>impact</span><span style={{ color: "var(--accent)" }}>.</span></V4Line>
    </h1>
  </div>;


// Reorders the hero: lede first (highlighted), then secondary copy, then the
// manifesto headline last — sized down so it punctuates the story instead of
// dominating it.
const DevleapsLede = ({ tone = "dark" }) => {
  const c1 = tone === "dark" ? "#fff" : "var(--fg)";
  const c2 = tone === "dark" ? "rgba(255,255,255,.78)" : "var(--fg-muted)";
  const c3 = tone === "dark" ? "rgba(255,255,255,.65)" : "var(--fg-subtle)";
  return (
    <div style={{ maxWidth: "60ch", marginBottom: 36 }}>
      <p style={{
        fontFamily: "var(--font-display)", fontWeight: 700,
        fontSize: "clamp(28px, 3.4vw, 44px)", lineHeight: 1.15,
        letterSpacing: "-0.02em", color: c1, margin: "0 0 24px",
        textWrap: "balance"
      }}>
        <b style={{ color: "var(--accent)" }}>DEVLEAPS</b> is your partner in building <span style={{ color: "var(--accent)", fontStyle: "italic" }}>high-performing</span> tech organizations.
      </p>
      <p style={{ fontFamily: "var(--font-body)", fontSize: 18, lineHeight: 1.55, color: c2, margin: "0 0 12px", maxWidth: "60ch" }}>
        Technology becomes a driver of business transformation: faster delivery, better developer experience, real scale across cloud, platforms, data, and AI.
      </p>
      <p style={{ fontFamily: "var(--font-body)", fontSize: 18, lineHeight: 1.55, color: c3, margin: 0, maxWidth: "60ch" }}>
        Engineering excellence at the core. We design, build, integrate, train your engineers, and stay until the transformation actually lands.
      </p>
    </div>);

};

const HeroCTAs = ({ onDark = false }) =>
<div style={{ display: "flex", gap: 12, flexWrap: "wrap" }}>
    <a href="#contact" className="dl-btn dl-btn-primary" onClick={(e) => {e.preventDefault();const el = document.getElementById("contact");el && window.scrollTo({ top: el.offsetTop - 64, behavior: "smooth" });}}>Let's build together <Icon name="arrow-right" size={18} /></a>
    <a href="#services" className="dl-btn dl-btn-ghost" style={onDark ? { color: "#fff", borderColor: "rgba(255,255,255,.3)" } : null} onClick={(e) => {e.preventDefault();const el = document.getElementById("services");el && window.scrollTo({ top: el.offsetTop - 64, behavior: "smooth" });}}>What we do</a>
  </div>;


const V4Line = ({ children }) =>
<div style={{ display: "block" }}>
    <span style={{ color: "var(--accent)", fontFamily: "var(--font-mono)", fontWeight: 400, fontSize: "0.42em", letterSpacing: 0, verticalAlign: "0.4em", marginRight: "0.4em" }}>//</span>
    {children}
  </div>;


// =============================================================
// V1 — EDITORIAL ENGINEER  (light · aperture diagram on right)
// Shared content: V4 manifesto headline + Devleaps tagline.
// =============================================================
const V1Hero = () => {
  const [rot, setRot] = React.useState(0);
  React.useEffect(() => {
    const t = setInterval(() => setRot((r) => (r + 0.25) % 360), 32);
    return () => clearInterval(t);
  }, []);
  return (
    <section id="top" className="dl-section" style={{ paddingTop: 64, paddingBottom: 80, position: "relative", overflow: "hidden" }}>
      <div className="dl-grid-bg" style={{ position: "absolute", inset: 0, opacity: .7, pointerEvents: "none" }} />
      <div className="dl-container" style={{ position: "relative", display: "grid", gridTemplateColumns: "1.3fr 1fr", gap: 56, alignItems: "center" }}>
        <div>
          <div style={{ display: "flex", alignItems: "center", gap: 12, marginBottom: 24 }}>
            <span className="dl-pulse" />
            <Eyebrow>devleaps · network online · 75+ engineers · 4 hubs</Eyebrow>
          </div>
          <DevleapsLede tone="light" />
          <ManifestoHeadline color="var(--fg)" maxFs={40} cqi={3} />
          <HeroCTAs />
        </div>
        <V1Aperture rot={rot} />
      </div>
    </section>);

};

const V1Aperture = ({ rot }) =>
<div style={{ position: "relative", aspectRatio: "1/1.05", background: "var(--bg-dark)", padding: 28, color: "var(--fg-on-dark)", overflow: "hidden", border: "1.5px solid var(--accent)", boxShadow: "6px 6px 0 0 var(--accent)" }}>
    <div className="dl-grid-bg" style={{ position: "absolute", inset: 0, opacity: .25 }} />
    <div style={{ position: "relative", zIndex: 1, height: "100%", display: "flex", flexDirection: "column", justifyContent: "space-between" }}>
      <div style={{ display: "flex", justifyContent: "space-between", alignItems: "flex-start" }}>
        <div style={{ fontFamily: "var(--font-mono)", fontSize: 11, color: "var(--accent)", letterSpacing: ".12em" }}>// fig.01 · system unlock</div>
        <div style={{ fontFamily: "var(--font-mono)", fontSize: 11, color: "rgba(255,255,255,.55)" }}>network · 15 nodes</div>
      </div>
      <div style={{ display: "flex", alignItems: "center", justifyContent: "center", flex: 1 }}>
        <svg viewBox="0 0 240 240" style={{ width: "86%", maxWidth: 340 }}>
          <circle cx="120" cy="120" r="100" stroke="rgba(255,255,255,.15)" strokeWidth="1" fill="none" />
          <circle cx="120" cy="120" r="76" stroke="rgba(255,255,255,.20)" strokeWidth="1" fill="none" />
          <circle cx="120" cy="120" r="52" stroke="rgba(255,255,255,.30)" strokeWidth="1.5" fill="none" />
          <g transform={`rotate(${rot} 120 120)`}>
            {[0, 60, 120, 180, 240, 300].map((a) =>
          <g key={a} transform={`rotate(${a} 120 120)`}>
                <line x1="120" y1="120" x2="120" y2="68" stroke="var(--accent)" strokeWidth="1.5" opacity=".55" />
                <circle cx="120" cy="68" r="3" fill="var(--accent)" />
              </g>
          )}
          </g>
          {[30, 90, 150, 210, 270, 330].map((a) =>
        <g key={a} transform={`rotate(${a} 120 120)`}>
              <line x1="120" y1="120" x2="120" y2="44" stroke="rgba(255,255,255,.35)" strokeWidth="1" strokeDasharray="2 4" />
              <circle cx="120" cy="44" r="2" fill="rgba(255,255,255,.6)" />
            </g>
        )}
          <circle cx="120" cy="120" r="10" fill="var(--accent)" />
          <circle cx="120" cy="120" r="18" stroke="var(--accent)" strokeWidth="1" fill="none" opacity=".45" />
        </svg>
      </div>
      <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr 1fr", gap: 12, fontFamily: "var(--font-mono)", fontSize: 10 }}>
        {[["throughput", "+312%"], ["cutover", "0 dt"], ["shipped", "12 wks"]].map(([l, v]) =>
      <div key={l} style={{ borderLeft: "2px solid var(--accent)", paddingLeft: 10 }}>
            <div style={{ color: "rgba(255,255,255,.6)" }}>{l}</div>
            <div style={{ fontSize: 18, color: "#fff", fontFamily: "var(--font-display)", letterSpacing: "-.02em", textTransform: "uppercase" }}>{v}</div>
          </div>
      )}
      </div>
    </div>
  </div>;


// =============================================================
// V2 — TERMINAL  (dark · live terminal log on right)
// =============================================================
const V2Hero = () => {
  const [tick, setTick] = React.useState(0);
  React.useEffect(() => {
    const t = setInterval(() => setTick((x) => x + 1), 1200);
    return () => clearInterval(t);
  }, []);
  const dot = tick % 4 === 0 ? "●" : tick % 4 === 1 ? "○" : tick % 4 === 2 ? "●" : "○";
  return (
    <section id="top" style={{ background: "var(--bg-dark)", color: "var(--fg-on-dark)", padding: "80px 0 72px", position: "relative", overflow: "hidden" }}>
      <div className="dl-grid-bg" style={{ position: "absolute", inset: 0, opacity: .4 }} />
      <div className="dl-container" style={{ position: "relative", display: "grid", gridTemplateColumns: "1.2fr 1fr", gap: 48, alignItems: "center" }}>
        <div>
          <div style={{ fontFamily: "var(--font-mono)", fontSize: 12, color: "var(--accent)", letterSpacing: ".12em", marginBottom: 20, display: "flex", alignItems: "center", gap: 10 }}>
            <span>{dot}</span>
            <span>// devleaps · network online · 75+ engineers · 4 hubs</span>
          </div>
          <DevleapsLede tone="dark" />
          <ManifestoHeadline maxFs={36} cqi={2.6} />
          <HeroCTAs onDark />
        </div>
        <Terminal />
      </div>
    </section>);

};

const Terminal = () => {
  const [lines, setLines] = React.useState([]);
  const script = React.useMemo(() => [
  { t: "$ ", c: "devleaps scope --client=northbank", col: "#fff" },
  { t: "", c: "→ authenticating...", col: "rgba(255,255,255,.55)" },
  { t: "", c: "✓ network handshake · 4 hubs reachable", col: "var(--accent)" },
  { t: "", c: "→ provisioning engineers: 6", col: "rgba(255,255,255,.55)" },
  { t: "", c: "✓ cloud · devex · data · ai · transform", col: "var(--accent)" },
  { t: "", c: "→ estimated cutover: 12 weeks · zero downtime", col: "rgba(255,255,255,.55)" },
  { t: "", c: "✓ scope v1 ready for review", col: "var(--accent)" },
  { t: "$ ", c: "devleaps ship", col: "#fff" }],
  []);
  React.useEffect(() => {
    let i = 0;
    const t = setInterval(() => {
      setLines((prev) => {
        if (i >= script.length) {clearInterval(t);return prev;}
        const next = [...prev, script[i]];
        i++;
        return next;
      });
    }, 650);
    return () => clearInterval(t);
  }, [script]);
  return (
    <div style={{ background: "var(--bg-elev)", color: "var(--fg)", border: "1.5px solid var(--accent)", overflow: "hidden", boxShadow: "8px 8px 0 0 var(--accent)" }}>
      <div style={{ padding: "10px 14px", background: "var(--bg-inset)", borderBottom: "1px solid var(--line)", display: "flex", alignItems: "center", gap: 8, fontFamily: "var(--font-mono)", fontSize: 11, color: "var(--fg-muted)" }}>
        <span style={{ width: 10, height: 10, borderRadius: 999, background: "#FF6158" }} />
        <span style={{ width: 10, height: 10, borderRadius: 999, background: "#FFBD2E" }} />
        <span style={{ width: 10, height: 10, borderRadius: 999, background: "var(--accent)" }} />
        <span style={{ marginLeft: 12, letterSpacing: ".1em" }}>devleaps@engineer · ~/scope</span>
      </div>
      <div style={{ padding: "24px 20px", minHeight: 340, fontFamily: "var(--font-mono)", fontSize: 13, lineHeight: 1.7 }}>
        {lines.map((ln, i) =>
        <div key={i} style={{ color: ln.col, whiteSpace: "pre" }}>
            <span style={{ color: "var(--accent)" }}>{ln.t}</span>{ln.c}
          </div>
        )}
        <div style={{ display: "inline-block", width: 8, height: 15, background: "var(--accent)", verticalAlign: "middle", animation: "dl-blink 1s steps(2) infinite" }} />
      </div>
      <style>{`@keyframes dl-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }`}</style>
    </div>);

};

// =============================================================
// V3 — EDITORIAL CONTRAST  (full-bleed dark · centered manifesto)
// =============================================================
const V3Hero = () =>
<section id="top" style={{ background: "var(--bg-dark)", color: "var(--fg-on-dark)", padding: "72px 0 0", position: "relative", overflow: "hidden", minHeight: "88vh", display: "flex", flexDirection: "column", justifyContent: "space-between" }}>
    <div className="dl-grid-bg" style={{ position: "absolute", inset: 0, opacity: .35 }} />
    <div className="dl-container" style={{ position: "relative", paddingTop: 40, flex: 1, display: "flex", flexDirection: "column", justifyContent: "center" }}>
      <div style={{ fontFamily: "var(--font-mono)", fontSize: 12, color: "var(--accent)", letterSpacing: ".12em", marginBottom: 32 }}>
        <span style={{ opacity: .55 }}>// </span>devleaps · network online · 75+ engineers · 4 hubs
      </div>
      <DevleapsLede tone="dark" />
      <ManifestoHeadline maxFs={64} cqi={4.2} />
      <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 64, alignItems: "flex-end", marginTop: 24 }}>
        <div/>
        <div style={{ display: "flex", gap: 12, justifyContent: "flex-end", flexWrap: "wrap" }}>
          <HeroCTAs onDark />
        </div>
      </div>
    </div>
    <V3Stats />
  </section>;


const V3Stats = () =>
<div style={{ position: "relative", borderTop: "1px solid rgba(255,255,255,.12)", padding: "20px 0", marginTop: 48 }}>
    <div className="dl-container" style={{ display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: 24, fontFamily: "var(--font-mono)", fontSize: 12, color: "rgba(255,255,255,.78)" }}>
      {[
    ["// ENGINEERS", "75+"],
    ["// HUBS", "4 · NL / PL / SR / ID"],
    ["// DELIVERED IMPACT", "50+ projects"],
    ["// FOUNDED", "2023"]].
    map(([l, v]) =>
    <div key={l} style={{ minWidth: 0 }}>
          <div style={{ color: "var(--accent)", marginBottom: 4, fontSize: 10, letterSpacing: ".12em" }}>{l}</div>
          <div style={{
        fontSize: "clamp(16px, 1.6vw, 28px)",
        fontFamily: "var(--font-display)", color: "#fff", fontWeight: 700,
        letterSpacing: "-0.02em", textTransform: "uppercase",
        whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis"
      }}>{v}</div>
        </div>
    )}
    </div>
  </div>;


// =============================================================
// V4 — HYBRID  (manifesto headline · full-bleed dark — the canonical layout)
// =============================================================
const V4Hero = () =>
<section id="top" style={{ background: "var(--bg-dark)", color: "var(--fg-on-dark)", padding: "72px 0 0", position: "relative", overflow: "hidden", minHeight: "92vh", display: "flex", flexDirection: "column", justifyContent: "space-between" }}>
    <div className="dl-grid-bg" style={{ position: "absolute", inset: 0, opacity: .35 }} />
    <div className="dl-container" style={{ position: "relative", paddingTop: 56, flex: 1, display: "flex", flexDirection: "column", justifyContent: "center" }}>
      <DevleapsLede tone="dark" />
      <ManifestoHeadline maxFs={60} cqi={3.8} />
      <div style={{ display: "grid", gridTemplateColumns: "1.2fr 1fr", gap: 64, alignItems: "flex-end" }}>
        <div/>
        <div style={{ display: "flex", gap: 12, justifyContent: "flex-end", flexWrap: "wrap" }}>
          <HeroCTAs onDark />
        </div>
      </div>
    </div>
    <V3Stats />
  </section>;


// Animated client marquee — wordmarks scrolling on a strip
const ClientMarquee = ({ reverse = false, items, label = "trusted by teams at", inset = false }) => {
  const list = items || CLIENTS;
  const loop = [...list, ...list];
  return (
    <section className={inset ? "dl-paper" : "dl-paper"} style={{ padding: "36px 0", overflow: "hidden", borderTop: "1px solid var(--line)", borderBottom: "1px solid var(--line)", position: "relative" }}>
      <div className="dl-container" style={{ marginBottom: 20 }}>
        <Eyebrow>{label}</Eyebrow>
      </div>
      <div className="dl-marquee">
        <div className={`dl-marquee-track ${reverse ? "dl-marquee-rev" : ""}`}>
          {loop.map((n, i) => {
            const logo = (typeof CLIENT_LOGOS !== "undefined") && CLIENT_LOGOS[n];
            return (
              <span key={i} className="dl-marquee-item">
                {logo
                  ? <img src={logo} alt={n} style={{ height: 36, width: "auto", maxWidth: 180, objectFit: "contain", filter: "grayscale(1) contrast(1.05)", opacity: .78 }} />
                  : <span style={{ fontFamily: "var(--font-display)", fontWeight: 700, fontSize: 28, letterSpacing: "-0.03em", color: "var(--fg)", textTransform: "uppercase" }}>{n}</span>
                }
              </span>
            );
          })}
        </div>
      </div>
      <style>{`
        .dl-marquee { overflow: hidden; width: 100%; mask-image: linear-gradient(90deg, transparent, #000 5%, #000 95%, transparent); -webkit-mask-image: linear-gradient(90deg, transparent, #000 5%, #000 95%, transparent); }
        .dl-marquee-track { display: flex; gap: 64px; animation: dl-scroll 50s linear infinite; white-space: nowrap; width: max-content; }
        .dl-marquee-rev { animation-direction: reverse; }
        .dl-marquee-item { display: inline-flex; align-items: center; gap: 14px; flex-shrink: 0; }
        .dl-marquee:hover .dl-marquee-track { animation-play-state: paused; }
        @keyframes dl-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }
        @media (prefers-reduced-motion: reduce) { .dl-marquee-track { animation: none; } }
      `}</style>
    </section>);

};

const TechMarquee = () =>
<section style={{ background: "var(--bg)", padding: "64px 0", borderTop: "1px solid var(--line)", borderBottom: "1px solid var(--line)" }}>
    <div className="dl-container" style={{ marginBottom: 24, display: "grid", gridTemplateColumns: "1fr 2fr", gap: 32 }}>
      <div>
        <Eyebrow>tech we love</Eyebrow>
        <h3 className="dl-h3" style={{ fontFamily: "var(--font-display)", marginTop: 12, textTransform: "uppercase", letterSpacing: "-0.02em" }}>The stack we bet on.</h3>
      </div>
      <p className="dl-body" style={{ maxWidth: "48ch", alignSelf: "flex-end", margin: 0 }}>
        Innovative where it earns its keep, stable where it counts. The tech choices that unlock your team's potential without leaving them stranded.
      </p>
    </div>
    <div className="dl-marquee">
      <div className="dl-marquee-track dl-marquee-rev">
        {[...TECH, ...TECH].map((t, i) =>
      <span key={i} className="dl-marquee-item">
            <span style={{ width: 6, height: 6, borderRadius: 999, background: "var(--accent)" }} />
            <span style={{ fontFamily: "var(--font-mono)", fontSize: 15, color: "var(--fg)", fontWeight: 500 }}>{t}</span>
          </span>
      )}
      </div>
    </div>
  </section>;


// =============================================================
// V5 — TERMINAL x EDITORIAL  (manifesto + terminal log on right)
// =============================================================
const V5Hero = () => {
  const [tick, setTick] = React.useState(0);
  React.useEffect(() => {
    const t = setInterval(() => setTick((x) => x + 1), 1200);
    return () => clearInterval(t);
  }, []);
  const dot = tick % 2 === 0 ? "●" : "○";
  return (
    <section id="top" style={{ background: "var(--bg-dark)", color: "var(--fg-on-dark)", padding: "88px 0 72px", position: "relative", overflow: "hidden", minHeight: "92vh", display: "flex", flexDirection: "column", justifyContent: "space-between" }}>
      <div className="dl-grid-bg" style={{ position: "absolute", inset: 0, opacity: .45 }} />
      <div className="dl-container" style={{ position: "relative", display: "grid", gridTemplateColumns: "1.2fr 1fr", gap: 48, alignItems: "center", flex: 1 }}>
        <div>
          <div style={{ fontFamily: "var(--font-mono)", fontSize: 12, color: "var(--accent)", letterSpacing: ".12em", marginBottom: 22, display: "flex", alignItems: "center", gap: 10 }}>
            <span>{dot}</span>
            <span>// devleaps · network online · 75+ engineers · 4 hubs</span>
          </div>
          <DevleapsLede tone="dark" />
          <ManifestoHeadline maxFs={34} cqi={2.4} />
          <HeroCTAs onDark />
        </div>
        <Terminal />
      </div>
      <V3Stats />
    </section>);

};

// =============================================================
// PAGE COMPOSITIONS — all share the same content order. Hero differs only.
// Block sequence: Hero → ClientMarquee → Network → Manifesto →
// QuickStart → Team → LifeGallery → HumanQuote (promise) → TechMarquee → ProductsTeaser → Contact.
// =============================================================
const buildPage = (Hero, useMarquee = false) => () => {
  const joost = TEAM.find(m => m.name === "Joost");
  return (
  <>
    <Hero />
    {useMarquee ? <ClientMarquee /> : <ClientStrip />}
    <Network />
    <Manifesto />
    <QuickStart />
    <Team />
    <LifeGallery />
    <HumanQuote
      photo={joost?.photo}
      name="Joost"
      role="AIEx · CTO · practice lead"
      eyebrow="// our promise"
      quote="One team. One network. Lasting impact. We work alongside our partners to engineer solutions at our customers that keep delivering, long after we've gone."
    />
    {useMarquee ? <TechMarquee /> : <TechStrip />}
    <ProductsTeaser />
    <Contact />
  </>);

};

const V1Page = buildPage(V1Hero, true);
const V2Page = buildPage(V2Hero, true);
const V3Page = buildPage(V3Hero, true);
const V4Page = buildPage(V4Hero, true);
const V5Page = buildPage(V5Hero, true);

Object.assign(window, { V1Hero, V2Hero, V3Hero, V4Hero, V5Hero, Terminal, ClientMarquee, TechMarquee, V1Page, V2Page, V3Page, V4Page, V5Page });
