/* venture.jsx — VENTURE / 04 · Live Status Console (stealth)
   Single-viewport editorial dashboard. Most fields redacted; one mission line exposed.
   Interactive layers (zero-to-one-click commitment):
     · Boot sequence on mount (telemetry rows boot in sequence ~1.2s)
     · Live syslog ticker (always running, ambient activity)
     · Click-to-attempt redact bars (single click → animated denial)
     · Cursor radar trail inside the console box
     · Auto-flicker reveals: every 14s a random redact bar briefly shows decoy text
*/

const {
  useState: useStateV, useEffect: useEffectV, useRef: useRefV, useMemo: useMemoV,
} = React;

/* Stealth startup — co-founded Oct 2025, right after discharge */
const VENTURE_T0 = new Date("2025-10-01T00:00:00Z").getTime();
const VENTURE_MISSION = "A personal-optimization engine.";
const VENTURE_SUBLINE = "B2B2C — built first for study and learning environments. Lets an individual see and steer their own decision model.";

const REDUCED_MOTION =
  typeof window !== "undefined" && window.matchMedia &&
  window.matchMedia("(prefers-reduced-motion: reduce)").matches;

/* ---- helpers ---- */

function formatUptime(ms) {
  const totalSec = Math.max(0, Math.floor(ms / 1000));
  const days = Math.floor(totalSec / 86400);
  const h = Math.floor((totalSec % 86400) / 3600);
  const m = Math.floor((totalSec % 3600) / 60);
  const s = totalSec % 60;
  const pad = (n, w = 2) => String(n).padStart(w, "0");
  return `${pad(days, 3)}d ${pad(h)}:${pad(m)}:${pad(s)}`;
}
function utcNow(d = new Date()) {
  const pad = (n) => String(n).padStart(2, "0");
  return `${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())}:${pad(d.getUTCSeconds())} UTC`;
}
function rand(seed) {
  // tiny PRNG so syslog feels stable per-tick
  let x = Math.sin(seed) * 10000;
  return x - Math.floor(x);
}

/* ---- syslog data ---- */
const SYSLOG_TEMPLATES = [
  () => `heartbeat ok`,
  () => `burn nominal`,
  () => `commit ${Math.random().toString(16).slice(2, 9)}`,
  () => `inquiry rcv ${Math.floor(10 + Math.random() * 245)}.${Math.floor(Math.random() * 256)}.*.* — queued`,
  () => `cron · idle-sweep complete`,
  () => `signal lock · 256-bit ok`,
  () => `model-eval · regret ↓ ${(Math.random() * 0.3).toFixed(3)}`,
  () => `auth · candidate ping rejected`,
  () => `disk · snapshot ${(Math.random() * 9 | 0)}h ago`,
  () => `embargo guard · ok`,
];

/* ---- boot timeline ---- */
const TELEMETRY_KEYS = [
  "UPTIME", "STAGE", "SECTOR", "CORE", "TEAM",
  "SIGNAL", "LOCATION", "LAST PING", "INQUIRIES", "NEXT MILESTONE",
];
const BOOT_STEP_MS = 90;          // delay between rows
const BOOT_SETTLE_MS = 200;       // post-fade time
const BOOT_TOTAL_MS = TELEMETRY_KEYS.length * BOOT_STEP_MS + BOOT_SETTLE_MS;

/* ---- redact bar (click → denial) + auto flicker reveal hook ---- */

const FAKE_REVEALS = [
  "REDACTED", "EMBARGO", "ACCESS DENIED", "TRY AT LAUNCH",
  "CLEARANCE INSUFFICIENT", "SEE LAUNCH DAY",
];
const DENIAL_REASONS = [
  "CLEARANCE INSUFFICIENT",
  "EMBARGO ACTIVE",
  "RETRY AT LAUNCH",
  "ACCESS DENIED · 403",
  "QUEUED · WRITE FOR EARLY ACCESS",
];

/* Each RedactBar registers itself with a ref so the parent can trigger an
   auto-flicker. revealText: when set, bar morphs to outlined text briefly.    */
function RedactBar({ chars = 12, register }) {
  const [phase, setPhase] = useStateV("idle"); // idle | trying | denied | reveal
  const [denial, setDenial] = useStateV(null);
  const [reveal, setReveal] = useStateV(null);
  const idRef = useRefV(Symbol("bar"));

  useEffectV(() => {
    if (!register) return;
    const handlers = {
      flash: (text) => {
        setReveal(text);
        setPhase("reveal");
        setTimeout(() => { setReveal(null); setPhase("idle"); }, 900);
      },
    };
    register(idRef.current, handlers);
    return () => register(idRef.current, null);
  }, [register]);

  const onClick = (e) => {
    e.preventDefault(); e.stopPropagation();
    if (phase !== "idle") return;
    setPhase("trying");
    setTimeout(() => {
      setDenial(DENIAL_REASONS[Math.floor(Math.random() * DENIAL_REASONS.length)]);
      setPhase("denied");
    }, 420);
    setTimeout(() => {
      setDenial(null); setPhase("idle");
    }, 2200);
  };

  const baseStyle = {
    display: "inline-block",
    minWidth: `${chars * 0.58}ch`,
    height: "1.05em",
    padding: "0 0.3ch",
    verticalAlign: "-0.18em",
    marginInline: 2,
    cursor: "pointer",
    fontFamily: "var(--font-mono)",
    fontSize: "0.78em",
    letterSpacing: "0.04em",
    textAlign: "center",
    lineHeight: "1.05em",
    transition: "background 180ms var(--easing-default), color 180ms var(--easing-default)",
    userSelect: "none",
  };

  if (phase === "reveal") {
    return (
      <span aria-label="auto-revealed decoy" style={{
        ...baseStyle,
        background: "var(--bg)", color: "var(--fg)",
        border: "1px solid var(--fg)",
      }}>{reveal}</span>
    );
  }
  if (phase === "trying") {
    return (
      <span style={{
        ...baseStyle, background: "var(--fg)", color: "var(--bg)",
        animation: REDUCED_MOTION ? "none" : "venture-bar-pulse 0.42s ease-out",
      }}>ACCESSING...</span>
    );
  }
  if (phase === "denied") {
    return (
      <span style={{
        ...baseStyle, background: "var(--bg)", color: "var(--fg)",
        border: "1px dashed var(--fg)",
      }}>{denial}</span>
    );
  }
  // idle
  return (
    <span
      data-cursor="link" data-cursor-label="CLASSIFIED"
      onClick={onClick}
      style={{
        ...baseStyle,
        background: "var(--fg)", color: "transparent",
      }}
    >█</span>
  );
}

/* ---- Telemetry row with boot fade ---- */
function TelemetryRow({ k, children, last, bootIdx, bootProgress }) {
  const visible = bootProgress > bootIdx;
  return (
    <div style={{
      display: "grid",
      gridTemplateColumns: "120px 1fr",
      alignItems: "baseline",
      gap: 18,
      padding: "14px 0",
      borderBottom: last ? "none" : "1px solid var(--line-soft)",
      opacity: visible ? 1 : 0,
      transform: visible ? "translateY(0)" : "translateY(4px)",
      transition: "opacity 320ms var(--easing-default), transform 320ms var(--easing-default)",
    }}>
      <span className="micro" style={{ color: "var(--fg-muted)" }}>{k}</span>
      <span style={{
        fontFamily: "var(--font-mono)",
        fontSize: 13,
        letterSpacing: "0.02em",
        color: "var(--fg)",
      }}>{children}</span>
    </div>
  );
}

/* Mission line — chars emerge left→right in the FINAL font from frame 1.
   No glyph substitution, no font swap: each character holds its final shape and
   width throughout, fading in through a soft leading edge. Subtle parallax tilt
   follows the cursor.                                                            */
function MissionLine({ text }) {
  useLang(); // re-render on language toggle
  const isKR = window.__lang === "kr";
  const [progress, setProgress] = useStateV(REDUCED_MOTION ? text.length : 0);
  const [armed, setArmed] = useStateV(REDUCED_MOTION);
  const wrapRef = useRefV(null);

  /* Arm reveal only after the Preloader is gone, so the animation isn't
     wasted behind the overlay. If the preloader is already done (route
     change after first load), arm on next frame.                            */
  useEffectV(() => {
    if (REDUCED_MOTION) return;
    let cancelled = false;
    const arm = () => {
      if (cancelled) return;
      requestAnimationFrame(() => requestAnimationFrame(() => setArmed(true)));
    };
    if (window.__preloaderDone) {
      arm();
      return () => { cancelled = true; };
    }
    const onDone = () => arm();
    window.addEventListener("preloader:done", onDone, { once: true });
    return () => {
      cancelled = true;
      window.removeEventListener("preloader:done", onDone);
    };
  }, []);

  /* Reveal timeline: settle one character every ~38ms */
  useEffectV(() => {
    if (!armed) return;
    let i = 0;
    setProgress(0);
    const settle = setInterval(() => {
      i += 1;
      setProgress(i);
      if (i >= text.length) clearInterval(settle);
    }, 38);
    return () => clearInterval(settle);
  }, [armed, text]);

  /* Parallax tilt — subtle, capped at ~5deg */
  useEffectV(() => {
    if (REDUCED_MOTION) return;
    const el = wrapRef.current;
    if (!el) return;
    let raf = 0;
    let target = { rx: 0, ry: 0, sx: 0, sy: 0 };
    let current = { rx: 0, ry: 0, sx: 0, sy: 0 };
    const onMove = (e) => {
      const r = el.getBoundingClientRect();
      const cx = r.left + r.width / 2;
      const cy = r.top + r.height / 2;
      const nx = (e.clientX - cx) / (window.innerWidth / 2);
      const ny = (e.clientY - cy) / (window.innerHeight / 2);
      target.ry = Math.max(-1, Math.min(1, nx)) * 4;   // deg
      target.rx = -Math.max(-1, Math.min(1, ny)) * 3;  // deg
      target.sx = Math.max(-1, Math.min(1, nx)) * 6;   // px
      target.sy = Math.max(-1, Math.min(1, ny)) * 4;   // px
    };
    const tick = () => {
      const k = 0.08;
      current.rx += (target.rx - current.rx) * k;
      current.ry += (target.ry - current.ry) * k;
      current.sx += (target.sx - current.sx) * k;
      current.sy += (target.sy - current.sy) * k;
      el.style.transform =
        `perspective(900px) rotateX(${current.rx.toFixed(2)}deg) rotateY(${current.ry.toFixed(2)}deg) translate3d(${current.sx.toFixed(2)}px, ${current.sy.toFixed(2)}px, 0)`;
      raf = requestAnimationFrame(tick);
    };
    raf = requestAnimationFrame(tick);
    window.addEventListener("mousemove", onMove);
    return () => { cancelAnimationFrame(raf); window.removeEventListener("mousemove", onMove); };
  }, []);

  /* Render every character in its final glyph from the start. A leading edge
     of ~7 characters ahead of `progress` is partially-faded with a tiny blur so
     the line reads as "materializing" without ever swapping a glyph or font.   */
  const LEAD = 7;
  const chars = text.split("");

  return (
    <h1 ref={wrapRef} className="display-xl" style={{
      fontFamily: isKR ? "var(--font-kr)" : "var(--font-display)",
      fontWeight: 800,
      fontStyle: "normal",
      fontSize: isKR ? "clamp(34px, 4.4vw, 70px)" : "clamp(40px, 5.0vw, 82px)",
      lineHeight: isKR ? 1.22 : 1.02,
      letterSpacing: isKR ? "-0.032em" : "-0.038em",
      wordBreak: isKR ? "keep-all" : "normal",
      overflowWrap: isKR ? "anywhere" : "normal",
      margin: 0,
      transformStyle: "preserve-3d",
      willChange: "transform",
    }}>
      <span>
        {chars.map((c, i) => {
          if (c === " ") return " ";
          // distance: <0 already settled (full opacity); 0..LEAD emerging; >LEAD hidden
          const distance = i - progress;
          let opacity, blur;
          if (distance < 0) {
            opacity = 1; blur = 0;
          } else if (distance < LEAD) {
            const k = distance / LEAD;          // 0 (just emerging) → 1 (still hidden)
            opacity = 1 - k;                    // fade leading edge in
            blur = k * 1.4;                     // tiny blur on far edge only
          } else {
            opacity = 0; blur = 1.6;
          }
          return (
            <span
              key={i}
              style={{
                opacity,
                filter: blur > 0.05 ? `blur(${blur.toFixed(2)}px)` : "none",
                transition: "opacity 260ms var(--easing-default), filter 260ms var(--easing-default)",
              }}
            >{c}</span>
          );
        })}
      </span>
      <span aria-hidden="true" style={{
        display: "inline-block",
        width: "0.55ch", height: "0.85em",
        background: "var(--fg)", verticalAlign: "-0.08em", marginLeft: 6,
        animation: REDUCED_MOTION ? "none" : "venture-caret 1s steps(2, jump-none) infinite",
      }} />
    </h1>
  );
}

/* Lombardi-style background graph driven by mouse motion.
   Drops a hairline node every ~35px of movement; connects each new node to its
   1–2 nearest recent neighbours with a gentle bezier arc. Nodes/edges fade over
   ~9s and the buffer caps so the page never feels crowded.                      */
function NodeGraph({ boxRef }) {
  const canvasRef = useRefV(null);
  const nodesRef = useRefV([]);   // {x,y,r,filled,bornAt}
  const edgesRef = useRefV([]);   // {a,b,cx,cy,bornAt}
  const lastRef  = useRefV(null); // last sampled cursor pos
  const rafRef   = useRefV(0);

  const NODE_LIFE = 2200;
  const EDGE_LIFE = 1800;
  const SAMPLE_DIST = 32;       // px
  const MAX_NODES = 90;
  const MAX_EDGES = 140;
  const NEIGHBOUR_RADIUS = 380; // px — wider reach so the graph spreads
  const NEIGHBOUR_K = 4;        // connect new node to up to N recent neighbours

  useEffectV(() => {
    if (REDUCED_MOTION) return;
    const box = boxRef.current;
    const canvas = canvasRef.current;
    if (!box || !canvas) return;
    const ctx = canvas.getContext("2d");

    function size() {
      const r = box.getBoundingClientRect();
      const dpr = window.devicePixelRatio || 1;
      canvas.width = r.width * dpr;
      canvas.height = r.height * dpr;
      canvas.style.width = `${r.width}px`;
      canvas.style.height = `${r.height}px`;
      ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
    }
    size();
    const ro = new ResizeObserver(size);
    ro.observe(box);

    function spawnAt(x, y) {
      const now = performance.now();
      const filled = Math.random() < 0.28;
      const r = filled ? 2.2 + Math.random() * 1.8 : 3 + Math.random() * 3.5;
      const node = { x, y, r, filled, bornAt: now };
      nodesRef.current.push(node);
      if (nodesRef.current.length > MAX_NODES) nodesRef.current.shift();

      // Connect to up to K nearest *recent* nodes within radius
      const recent = nodesRef.current.slice(-40, -1);
      const ranked = recent
        .map(n => ({ n, d: Math.hypot(n.x - x, n.y - y) }))
        .filter(o => o.d > 14 && o.d < NEIGHBOUR_RADIUS)
        .sort((a, b) => a.d - b.d)
        .slice(0, NEIGHBOUR_K);

      for (const { n: other } of ranked) {
        // Perpendicular control point gives a hand-drawn bezier feel
        const mx = (other.x + x) / 2;
        const my = (other.y + y) / 2;
        const dx = x - other.x;
        const dy = y - other.y;
        const len = Math.hypot(dx, dy) || 1;
        const nx = -dy / len;
        const ny = dx / len;
        const sag = (Math.random() - 0.5) * len * 0.35;
        edgesRef.current.push({
          a: other, b: node,
          cx: mx + nx * sag,
          cy: my + ny * sag,
          bornAt: now,
        });
      }
      while (edgesRef.current.length > MAX_EDGES) edgesRef.current.shift();
    }

    function onMove(e) {
      const r = box.getBoundingClientRect();
      const x = e.clientX - r.left;
      const y = e.clientY - r.top;
      if (x < 0 || y < 0 || x > r.width || y > r.height) return;
      const last = lastRef.current;
      if (!last) {
        lastRef.current = { x, y };
        spawnAt(x, y);
        return;
      }
      const d = Math.hypot(x - last.x, y - last.y);
      if (d >= SAMPLE_DIST) {
        // Step along the segment so fast moves still drop nodes evenly
        const steps = Math.min(4, Math.floor(d / SAMPLE_DIST));
        for (let i = 1; i <= steps; i++) {
          const t = i / steps;
          spawnAt(last.x + (x - last.x) * t, last.y + (y - last.y) * t);
        }
        lastRef.current = { x, y };
      }
    }
    window.addEventListener("mousemove", onMove);

    function loop() {
      const r = box.getBoundingClientRect();
      ctx.clearRect(0, 0, r.width, r.height);
      const now = performance.now();

      // Drop dead nodes/edges (compact in place)
      nodesRef.current = nodesRef.current.filter(n => now - n.bornAt < NODE_LIFE);
      edgesRef.current = edgesRef.current.filter(e =>
        now - e.bornAt < EDGE_LIFE &&
        nodesRef.current.includes(e.a) &&
        nodesRef.current.includes(e.b)
      );

      ctx.lineWidth = 1;
      ctx.strokeStyle = "rgba(10,10,10,1)";
      ctx.fillStyle = "rgba(10,10,10,1)";

      // Edges first so nodes sit on top
      for (const e of edgesRef.current) {
        const age = (now - e.bornAt) / EDGE_LIFE;
        const fadeIn = Math.min(1, (now - e.bornAt) / 200);
        const alpha = (1 - age) * 0.18 * fadeIn;
        if (alpha <= 0.01) continue;
        ctx.globalAlpha = alpha;
        ctx.beginPath();
        ctx.moveTo(e.a.x, e.a.y);
        ctx.quadraticCurveTo(e.cx, e.cy, e.b.x, e.b.y);
        ctx.stroke();
      }

      // Nodes — pop-in animation 0→r over 250ms
      for (const n of nodesRef.current) {
        const age = (now - n.bornAt) / NODE_LIFE;
        const pop = Math.min(1, (now - n.bornAt) / 220);
        const alpha = (1 - age) * (n.filled ? 0.5 : 0.38);
        if (alpha <= 0.01) continue;
        const radius = n.r * pop;
        ctx.globalAlpha = alpha;
        ctx.beginPath();
        ctx.arc(n.x, n.y, radius, 0, Math.PI * 2);
        if (n.filled) ctx.fill();
        else ctx.stroke();
      }

      ctx.globalAlpha = 1;
      rafRef.current = requestAnimationFrame(loop);
    }
    rafRef.current = requestAnimationFrame(loop);

    return () => {
      window.removeEventListener("mousemove", onMove);
      ro.disconnect();
      cancelAnimationFrame(rafRef.current);
    };
  }, [boxRef]);

  return (
    <canvas
      ref={canvasRef}
      aria-hidden="true"
      style={{
        position: "absolute", inset: 0,
        pointerEvents: "none",
        mixBlendMode: "multiply",
      }}
    />
  );
}

/* Live syslog ticker — generates fake events every 1.6s, keeps last 4 */
function SyslogTicker() {
  const [events, setEvents] = useStateV(() => {
    // seed with 3 events so it doesn't appear empty on first paint
    const now = Date.now();
    return [0, 1, 2].map(i => ({
      t: utcNow(new Date(now - (3 - i) * 1800)),
      msg: SYSLOG_TEMPLATES[i % SYSLOG_TEMPLATES.length](),
      id: now - (3 - i) * 1800,
    }));
  });

  useEffectV(() => {
    const id = setInterval(() => {
      const tmpl = SYSLOG_TEMPLATES[Math.floor(Math.random() * SYSLOG_TEMPLATES.length)];
      setEvents(prev => {
        const next = [...prev, { t: utcNow(), msg: tmpl(), id: Date.now() }];
        return next.slice(-4);
      });
    }, 1800);
    return () => clearInterval(id);
  }, []);

  return (
    <div style={{
      borderTop: "1px solid var(--line-soft)",
      marginTop: 24,
      paddingTop: 14,
    }}>
      <div className="micro" style={{ color: "var(--fg-muted)", marginBottom: 8 }}>{t("SYSLOG · LIVE")}</div>
      <div style={{
        fontFamily: "var(--font-mono)",
        fontSize: 11.5,
        lineHeight: 1.7,
        color: "var(--fg-muted)",
        height: `${1.7 * 4}em`,
        overflow: "hidden",
        position: "relative",
      }}>
        {events.map((e, i) => (
          <div key={e.id} style={{
            opacity: (i + 1) / events.length, // older = fainter
            transition: "opacity 600ms var(--easing-default)",
          }}>
            <span style={{ color: "var(--fg)" }}>[{e.t}]</span> {e.msg}
          </div>
        ))}
      </div>
    </div>
  );
}

/* ---- Main ---- */
function Venture() {
  const { go } = useRouter();
  useLang(); // re-render on language toggle
  const [now, setNow] = useStateV(Date.now());
  const [bootProgress, setBootProgress] = useStateV(REDUCED_MOTION ? 99 : 0);
  const consoleRef = useRefV(null);

  // Bar registry (id → handlers) for auto-flicker
  const barsRef = useRefV(new Map());
  const registerBar = (id, handlers) => {
    if (handlers === null) barsRef.current.delete(id);
    else barsRef.current.set(id, handlers);
  };

  /* tick clock + uptime */
  useEffectV(() => {
    const id = setInterval(() => setNow(Date.now()), 1000);
    return () => clearInterval(id);
  }, []);

  /* boot sequence */
  useEffectV(() => {
    if (REDUCED_MOTION) return;
    let i = 0;
    const id = setInterval(() => {
      i++;
      setBootProgress(i);
      if (i > TELEMETRY_KEYS.length) clearInterval(id);
    }, BOOT_STEP_MS);
    return () => clearInterval(id);
  }, []);

  /* auto flicker reveals — every 14s, pick a random registered bar and flash */
  useEffectV(() => {
    if (REDUCED_MOTION) return;
    const id = setInterval(() => {
      const ids = Array.from(barsRef.current.keys());
      if (ids.length === 0) return;
      const pick = ids[Math.floor(Math.random() * ids.length)];
      const text = FAKE_REVEALS[Math.floor(Math.random() * FAKE_REVEALS.length)];
      barsRef.current.get(pick)?.flash(text);
    }, 14000);
    return () => clearInterval(id);
  }, []);

  const uptime = formatUptime(now - VENTURE_T0);
  const ping = utcNow(new Date(now));

  return (
    <div className="page" style={{ paddingTop: 140, position: "relative" }}>
      <div className="page-eyebrow">
        <span className="micro">{t("Index")} 04</span>
        <span style={{ width: 24, height: 1, background: "var(--fg)" }} />
        <span className="micro micro-fg">{t("Venture · Stealth startup · pre-launch")}</span>
      </div>

      {/* Two-column heading row — mirrors the projects page: quote clustered
          on the left, supporting visual + description on the right. */}
      <div ref={consoleRef} className="responsive-stack" style={{
        display: "grid", gridTemplateColumns: "1fr 1fr",
        gap: 64, marginBottom: 64, alignItems: "end",
      }}>
        {/* LEFT — quote, hugged to its column (max-width keeps glyphs clustered) */}
        <div>
          <div className="micro" style={{ color: "var(--fg-muted)", marginBottom: 16 }}>
            {t("STEALTH · MISSION · DECRYPTED")}
          </div>
          <div style={{ maxWidth: 520 }}>
            <MissionLine text={t(VENTURE_MISSION)} />
            <p style={{
              marginTop: 18,
              fontFamily: "var(--font-mono)",
              fontSize: 13,
              lineHeight: 1.6,
              letterSpacing: "0.01em",
              color: "var(--fg-muted)",
              maxWidth: 460,
            }}>
              {t(VENTURE_SUBLINE)}
            </p>
          </div>
        </div>

        {/* RIGHT — zigzag node trace (redacted-bar variation) + body copy */}
        <div style={{ display: "flex", flexDirection: "column", gap: 18 }}>
          <svg viewBox="0 0 600 96" preserveAspectRatio="none"
               style={{ width: "100%", height: 96, display: "block", overflow: "visible" }}>
            {/* Faint horizon — quiet axis the trajectory rides on */}
            <line x1="0" y1="78" x2="560" y2="78"
                  stroke="var(--fg)" strokeWidth="1"
                  vectorEffect="non-scaling-stroke"
                  strokeDasharray="1 5" opacity="0.35" />
            {/* Trajectory — ascending arc toward target */}
            <polyline
              points="-10,82 60,70 120,76 190,52 260,60 330,34 400,42 470,18 540,24"
              fill="none" stroke="var(--fg)" strokeWidth="1.2"
              vectorEffect="non-scaling-stroke"
              strokeDasharray="4 4"
              strokeLinecap="round" strokeLinejoin="round"
            />
            {/* Cross/tick waypoint markers */}
            {[
              [60, 70], [120, 76], [190, 52], [260, 60], [330, 34], [400, 42], [470, 18],
            ].map(([cx, cy], i) => (
              <g key={i} stroke="var(--fg)" strokeWidth="1"
                 vectorEffect="non-scaling-stroke">
                <line x1={cx - 3.5} y1={cy} x2={cx + 3.5} y2={cy} />
                <line x1={cx} y1={cy - 3.5} x2={cx} y2={cy + 3.5} />
              </g>
            ))}
            {/* Origin — solid launch dot */}
            <circle cx="-10" cy="82" r="3.4" fill="var(--fg)" />
            {/* Terminal — concentric crosshair / target acquired */}
            <g transform="translate(540, 24)" stroke="var(--fg)"
               vectorEffect="non-scaling-stroke" fill="none">
              <circle r="13" strokeWidth="0.8" opacity="0.55" />
              <circle r="7" strokeWidth="1.2" />
              <circle r="2" fill="var(--fg)" stroke="none" />
              <line x1="-18" y1="0" x2="-9" y2="0" strokeWidth="1" />
              <line x1="9" y1="0" x2="18" y2="0" strokeWidth="1" />
              <line x1="0" y1="-18" x2="0" y2="-9" strokeWidth="1" />
              <line x1="0" y1="9" x2="0" y2="18" strokeWidth="1" />
            </g>
          </svg>
          <div className="body-lg" style={{ color: "var(--fg-muted)" }}>
            {t("Further detail withheld until launch. Strategic partners, candidates, and press: write — replies sent under embargo.")}
          </div>
        </div>
      </div>

      {/* Hairline meta strip — essentials only (boot/ping/role/since/sector) */}
      <div className="venture-meta-strip" style={{
        display: "grid",
        gridTemplateColumns: "repeat(3, 1fr)",
        gap: 24,
        padding: "20px 0",
        borderTop: "1px solid var(--line)",
        borderBottom: "1px solid var(--line-soft)",
        marginBottom: 80,
        alignItems: "baseline",
      }}>
        <div>
          <div className="micro" style={{ color: "var(--fg-muted)", marginBottom: 6 }}>{t("ROLE")}</div>
          <div style={{ fontSize: 14 }}>{t("Co-Founder · CEO")}</div>
        </div>
        <div>
          <div className="micro" style={{ color: "var(--fg-muted)", marginBottom: 6 }}>{t("SINCE")}</div>
          <div style={{ fontSize: 14 }}>{t("2025 · 10 — present")}</div>
        </div>
        <div>
          <div className="micro" style={{ color: "var(--fg-muted)", marginBottom: 6 }}>{t("SECTOR")}</div>
          <div style={{ fontSize: 14 }}>B2B2C · {t("Personal Optimization")} &nbsp;<span style={{ color: "var(--fg-muted)" }}>· {t("pre-launch")}</span></div>
        </div>
      </div>

      {/* Interest CTA — black inverted card, jumps to contact */}
      <a
        href="#contact"
        onClick={(e) => { e.preventDefault(); go("contact"); }}
        data-cursor="link" data-cursor-label="Contact →"
        className="venture-cta"
        style={{
          display: "block",
          background: "var(--fg)",
          color: "var(--bg)",
          padding: "clamp(36px, 4.5vw, 64px) clamp(28px, 4vw, 56px)",
          marginBottom: 56,
          textDecoration: "none",
          position: "relative",
          overflow: "hidden",
          transition: "transform 320ms var(--easing-default)",
        }}
      >
        <div className="venture-cta-grid" style={{
          display: "grid",
          gridTemplateColumns: "1fr auto",
          gap: 32,
          alignItems: "center",
        }}>
          <div>
            <div className="micro" style={{
              color: "rgba(255,255,255,0.55)",
              marginBottom: 18,
            }}>{t("INTERESTED?")}</div>
            <h2 className="display-lg" style={{
              fontFamily: "var(--font-display)",
              fontWeight: 800, fontStyle: "normal",
              fontSize: "clamp(32px, 4.0vw, 62px)",
              lineHeight: 1.02, letterSpacing: "-0.034em",
              margin: 0,
              color: "var(--bg)",
            }}>
              {t("If any of this resonates,")}<br />
              {t("we should talk.")}
            </h2>
            <p style={{
              fontFamily: "var(--font-mono)",
              fontSize: 13,
              lineHeight: 1.6,
              letterSpacing: "0.01em",
              color: "rgba(255,255,255,0.65)",
              margin: "20px 0 0",
              maxWidth: 560,
            }}>
              {t("Investors, candidates, or fellow builders — open a line. Replies sent under embargo until launch.")}
            </p>
          </div>
          <div className="venture-cta-arrow" style={{
            display: "flex", alignItems: "center", gap: 14,
            fontFamily: "var(--font-mono)",
            fontSize: 12, letterSpacing: "0.12em",
            textTransform: "uppercase",
            color: "var(--bg)",
            borderBottom: "1px solid var(--bg)",
            paddingBottom: 6,
            whiteSpace: "nowrap",
          }}>
            {t("Contact")} <span aria-hidden="true">→</span>
          </div>
        </div>
      </a>

      {/* Footer band */}
      <div className="venture-footer three-col" style={{
        display: "grid",
        gridTemplateColumns: "1fr 1fr 1fr",
        gap: 24,
        padding: "32px 0",
        borderTop: "1px solid var(--line)",
        alignItems: "center",
      }}>
        <a className="link-arrow" href="https://github.com/TaewoooPark" target="_blank" rel="noopener"
           data-cursor="link" data-cursor-label="Open">github.com/TaewoooPark ↗</a>
        <a className="link-arrow" href="mailto:ptw5446@gmail.com?subject=Stealth%20venture%20%E2%80%94%20inquiry"
           data-cursor="link" data-cursor-label={t("Contact")} style={{ justifySelf: "center" }}>
          {t("If you can help — write ✉")}
        </a>
        <span className="micro" style={{
          color: "var(--fg-muted)", justifySelf: "end",
          fontFamily: "var(--font-mono)",
        }}>
          KST · {new Date(now).toLocaleString("en-GB", { timeZone: "Asia/Seoul", hour12: false }).replace(",", "")}
        </span>
      </div>

      <style>{`
        @keyframes venture-caret { 50% { opacity: 0; } }
        @keyframes venture-pulse {
          0%, 100% { opacity: 0.35; transform: scale(1); }
          50% { opacity: 1; transform: scale(1.4); }
        }
        @keyframes venture-bar-pulse {
          0% { transform: scaleX(0.85); opacity: 0.7; }
          100% { transform: scaleX(1); opacity: 1; }
        }
        .venture-cta:hover .venture-cta-arrow { gap: 22px !important; }
        .venture-cta-arrow { transition: gap 200ms var(--easing-default); }
        @media (max-width: 900px) {
          .venture-grid { grid-template-columns: 1fr !important; }
          .venture-footer { grid-template-columns: 1fr !important; gap: 16px !important; text-align: left; }
          .venture-footer > * { justify-self: start !important; }
          .venture-cta-grid { grid-template-columns: 1fr !important; gap: 24px !important; }
        }
      `}</style>
    </div>
  );
}

Object.assign(window, { Venture });
