/* eslint-disable */
// Intelligence Assist site, shared components & icons

// ---------- Icon (Lucide via CDN) ----------
function Icon({ name, size = 18, color = "currentColor", stroke = 1.75, className, style }) {
  const ref = React.useRef(null);
  React.useEffect(() => {
    if (window.lucide && ref.current) {
      ref.current.innerHTML = "";
      const i = document.createElement("i");
      i.setAttribute("data-lucide", name);
      ref.current.appendChild(i);
      window.lucide.createIcons({
        attrs: { width: size, height: size, "stroke-width": stroke, stroke: color },
      });
    }
  }, [name, size, color, stroke]);
  return (
    <span
      ref={ref}
      className={className}
      style={{ display: "inline-flex", alignItems: "center", justifyContent: "center", width: size, height: size, lineHeight: 0, ...style }}
    />
  );
}

// ---------- Button ----------
function Button({ children, variant = "primary", size = "md", onClick, className = "", style, type = "button" }) {
  const cls = ["btn", `btn--${variant}`, size !== "md" && `btn--${size}`, className].filter(Boolean).join(" ");
  return (
    <button type={type} className={cls} onClick={onClick} style={style}>
      {children}
    </button>
  );
}

// ---------- LinkOut ----------
function LinkOut({ children, onClick, className = "" }) {
  return (
    <button className={`linkout ${className}`} onClick={onClick}>
      {children}
      <Icon name="arrow-right" size={14} className="arrow" />
    </button>
  );
}

// ---------- Tag ----------
function Tag({ tone = "neutral", children, dot = false, className = "", style }) {
  return (
    <span className={`tag tag--${tone} ${className}`} style={style}>
      {dot && <span className="dot" />}
      {children}
    </span>
  );
}

// ---------- Eyebrow ----------
function Eyebrow({ children, plain = false }) {
  return <div className={`eyebrow ${plain ? "eyebrow--plain" : ""}`}>{children}</div>;
}

// ---------- Crumbs ----------
const CRUMB_ROUTES = {
  "Intelligence Assist": "home",
  "Home": "home",
  "About": "about",
  "Services": "services",
  "Build": "build",
  "Custom Builds": "custom-builds",
  "Fixed-Scope Builds": "quick-wins",
  "Foundations": "foundations",
  "How we work": "how-we-work",
  "Work": "work",
  "Blog": "resources",
  "Resources": "resources",
  "Library": "resources",
  "AI Toolbox": "toolbox",
  "Toolbox": "toolbox",
  "Contact": "contact",
};

function Crumbs({ items, go }) {
  const navTo = (route) => {
    if (go) { go(route); return; }
    window.location.hash = route;
    requestAnimationFrame(() => window.scrollTo({ top: 0, behavior: "instant" }));
  };
  return (
    <div className="crumbs">
      {items.map((it, i) => {
        const label = typeof it === "string" ? it : it.label;
        const route = typeof it === "object" ? it.to : CRUMB_ROUTES[it];
        const isLast = i === items.length - 1;
        return (
          <React.Fragment key={i}>
            {isLast ? (
              <strong>{label}</strong>
            ) : route ? (
              <button type="button" className="crumb-link" onClick={() => navTo(route)}>{label}</button>
            ) : (
              <span>{label}</span>
            )}
            {!isLast && <span className="sep">/</span>}
          </React.Fragment>
        );
      })}
    </div>
  );
}

// ---------- Five accelerators data ----------
const ACCELERATORS = [
  { key: "agents",    name: "Agentic AI",     tone: "agents",    dotCls: "acc-dot--agents",    desc: "Multi-step software that orchestrates across your tools, not just answers.", icon: "ia-agentic.png" },
  { key: "knowledge", name: "Knowledge AI",      tone: "knowledge", dotCls: "acc-dot--knowledge", desc: "Make your internal info instantly findable.",    icon: "ia-knowledge.png" },
  { key: "decision",  name: "Data AI", tone: "decision",  dotCls: "acc-dot--decision",  desc: "Turn your data into business decisions.",         icon: "ia-data.png" },
  { key: "conversational", name: "Conversational AI", tone: "conversational", dotCls: "acc-dot--conversational", desc: "Chat and voice assistants that talk to your customers.", icon: "ia-conversation.png" },
  { key: "tool",      name: "Task AI",         tone: "tool",      dotCls: "acc-dot--tool",      desc: "A specific tool, wired into a process and properly adopted.",       icon: "ia-task.png" },
];

// ---------- Accelerator strip ----------
function AcceleratorStrip({ title = "The five accelerators", sub }) {
  return (
    <div className="acc-strip-wrap">
      <div className="acc-strip-head">
        <div className="head-title">{title}</div>
        {sub && <div className="head-sub">{sub}</div>}
      </div>
      <div className="acc-strip">
        {ACCELERATORS.map((a, i) => (
          <div
            key={a.key}
            className="acc-tile"
            style={{ "--c": `var(--ac-${a.key}-dot)`, "--cbg": `var(--ac-${a.key}-bg)`, "--cfg": `var(--ac-${a.key}-fg)` }}
          >
            <div className="acc-name"><span className="acc-dot" style={{ background: "var(--c)" }} />{a.name}</div>
            <div className="acc-sub">{a.desc}</div>
          </div>
        ))}
      </div>
    </div>
  );
}

// ---------- Nav ----------
// Rebuild structure (brief v4): two doors top level, Resources group, Playground link.
const NAV_ITEMS = [
  ["ai-foundations", "AI Foundations"],
  ["accelerators", "AI Accelerators"],
  ["how-we-work", "How we work"],
  ["toolbox", "AI Toolbox"],
  ["faqs", "FAQs"],
  ["work", "Our Work"],
  ["resources", "Blog"],
  ["about", "About"],
  ["contact", "Contact"],
];

const MVP = () => document.documentElement.getAttribute("data-mvp") === "on";

function Nav({ current, go }) {
  const mvp = MVP();
  const resRoutes = ["faqs", "work", "resources"];
  const [menuOpen, setMenuOpen] = React.useState(false);
  const [resOpen, setResOpen] = React.useState(false);
  React.useEffect(() => { setMenuOpen(false); setResOpen(false); }, [current]);
  // Real hrefs: middle-click, open-in-new-tab and crawlers all work.
  const link = (id) => ({ href: `#${id}`, onClick: (e) => { e.preventDefault(); go(id); } });
  return (
    <nav className="nav">
      <div className="container nav-inner">
        <a href="#" className="nav-brand" onClick={(e) => { e.preventDefault(); go("home"); }} aria-label="Intelligence Assist, home">
          <img src="assets/logos/web/ia-logo-h-dark-blue.webp" alt="Intelligence Assist" className="nav-logo" />
          <img src="assets/logos/web/ia-mark-navy.webp" alt="" className="nav-mark" aria-hidden="true" />
        </a>
        <div className="nav-links">
          <a {...link("ai-foundations")} className={`nav-link ${current === "ai-foundations" ? "active" : ""}`}>AI Foundations</a>
          <a {...link("accelerators")} className={`nav-link ${current === "accelerators" ? "active" : ""}`}>AI Accelerators</a>
          <a {...link("how-we-work")} className={`nav-link ${current === "how-we-work" ? "active" : ""}`}>How we work</a>
          {!mvp && <a {...link("toolbox")} className={`nav-link ${current === "toolbox" || current === "tool" ? "active" : ""}`}>AI Toolbox</a>}
          {mvp ? (
          <a {...link("faqs")} className={`nav-link ${current === "faqs" ? "active" : ""}`}>FAQs</a>
          ) : (
          <div className={`nav-dropwrap${resOpen ? " is-open" : ""}`} onMouseLeave={() => setResOpen(false)}>
            <button type="button" aria-haspopup="true" aria-expanded={resOpen} className={`nav-link ${resRoutes.includes(current) ? "active" : ""}`} onClick={() => setResOpen(!resOpen)}>
              Resources <Icon name="chevron-down" size={14} className="chev" />
            </button>
            <div className="nav-drop" style={{ gridTemplateColumns: "1fr", minWidth: 320 }}>
              <div className="nav-drop-group">
                <a {...link("faqs")} className="nav-drop-item">
                  <span className="nm">FAQs</span>
                  <span className="ds">The questions we are asked most, answered plainly.</span>
                </a>
                <a {...link("work")} className="nav-drop-item">
                  <span className="nm">Our Work</span>
                  <span className="ds">Case studies and white papers.</span>
                </a>
                <a {...link("resources")} className="nav-drop-item">
                  <span className="nm">Blog</span>
                  <span className="ds">Tool news, observations and write-ups.</span>
                </a>
              </div>
            </div>
          </div>
          )}
          <a {...link("about")} className={`nav-link ${current === "about" ? "active" : ""}`}>About</a>
        </div>
        <button className="nav-burger" aria-label="Menu" aria-expanded={menuOpen} onClick={() => setMenuOpen(!menuOpen)}>
          <Icon name={menuOpen ? "x" : "menu"} size={20} />
        </button>
        <div className="nav-cta">
          <a className="nav-playground" href="https://ia-playground.com.au" target="_blank" rel="noopener" title="For existing clients">
            <Icon name="external-link" size={13} /><span className="np-label">Client Portal</span>
          </a>
          <Button variant="primary" size="sm" onClick={() => go("contact")}>Talk to us</Button>
        </div>
      </div>
      {menuOpen && (
        <div className="nav-panel">
          {(mvp ? NAV_ITEMS.filter(([id]) => ["toolbox", "work", "resources"].indexOf(id) === -1) : NAV_ITEMS).map(([id, label]) => (
            <a key={id} {...link(id)} className={`nav-panel-item ${current === id ? "active" : ""}`}>{label}</a>
          ))}
          <a className="nav-panel-item nav-panel-item--playground" href="https://ia-playground.com.au" target="_blank" rel="noopener"><Icon name="external-link" size={14} />Client Portal</a>
        </div>
      )}
    </nav>
  );
}

// TikTok is not in the Lucide set, so its mark is drawn to match the 15px icons.
function TikTokMark() {
  return (
    <svg width="15" height="15" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
      <path d="M16.6 5.82A4.28 4.28 0 0 1 15.54 3h-3.09v12.4a2.59 2.59 0 1 1-1.79-2.46V9.79a5.77 5.77 0 1 0 4.88 5.71V9.01a7.35 7.35 0 0 0 4.29 1.38V7.3a4.28 4.28 0 0 1-3.23-1.48Z" />
    </svg>);
}

// ---------- Footer ----------
function Footer({ go }) {
  const mvp = MVP();
  return (
    <footer className="footer">
      <div className="container">
        <div className="footer-top">
          <div>
            <div className="footer-lockup">
              <img src="assets/logos/web/ia-logo-h-light-blue.webp" alt="Intelligence Assist" />
              <p className="footer-tag">Your AI journey, simplified and supported.</p>
            </div>
            <div className="footer-social">
              <a href="https://au.linkedin.com/company/intelligence-assist" target="_blank" rel="noopener" aria-label="LinkedIn">
                <Icon name="linkedin" size={17} />
              </a>
              <a href="https://www.facebook.com/IntelligenceAssist.au" target="_blank" rel="noopener" aria-label="Facebook">
                <Icon name="facebook" size={17} />
              </a>
              <a href="https://www.youtube.com/@IntelligenceAssist" target="_blank" rel="noopener" aria-label="YouTube">
                <Icon name="youtube" size={17} />
              </a>
              <a href="https://www.instagram.com/intelligenceassist/" target="_blank" rel="noopener" aria-label="Instagram">
                <Icon name="instagram" size={17} />
              </a>
              <a href="https://www.tiktok.com/@intelligenceassist" target="_blank" rel="noopener" aria-label="TikTok">
                <TikTokMark />
              </a>
            </div>
          </div>
          <div>
            <span className="footer-h5">Services</span>
            <button onClick={() => go("ai-foundations")}>AI Foundations</button>
            <button onClick={() => go("accelerators")}>AI Accelerators</button>
            <button onClick={() => go("how-we-work")}>How we work</button>
          </div>
          <div>
            <span className="footer-h5">Resources</span>
            {!mvp && <button onClick={() => go("toolbox")}>AI Toolbox</button>}
            <button onClick={() => go("faqs")}>FAQs</button>
            {!mvp && <button onClick={() => go("work")}>Our Work</button>}
            {!mvp && <button onClick={() => go("resources")}>Blog</button>}
          </div>
          <div>
            <span className="footer-h5">Company</span>
            <button onClick={() => go("about")}>About</button>
            <button onClick={() => go("contact")}>Contact</button>
            <a href="https://ia-playground.com.au" target="_blank" rel="noopener">Client Portal</a>
          </div>
          <div>
            <span className="footer-h5">Get in touch</span>
            <a href="tel:1300059625">1300 059 625</a>
            <a href="mailto:info@intelligenceassist.com.au">info@<br/>intelligenceassist.com.au</a>
          </div>
        </div>
        <div className="footer-bottom">
          <div>© 2026 Intelligence Assist Pty Ltd</div>
          <div className="legal">
            <a href="#privacy" onClick={(e) => { e.preventDefault(); go("privacy"); }}>Privacy</a>
            <a href="#terms" onClick={(e) => { e.preventDefault(); go("terms"); }}>Terms</a>
          </div>
        </div>
      </div>
    </footer>
  );
}

// ---------- CtaStrip ----------
function CtaStrip({ headline, sub, primaryLabel = "Book a Blueprint", secondaryLabel, onPrimary, onSecondary, dark = true }) {
  if (dark) {
    return (
      <div className="cta-strip">
        <div style={{ position: "relative" }}>
          <Eyebrow>Take the next step</Eyebrow>
          <h2 className="h-section" style={{ color: "#fff", marginTop: 8 }}>{headline}</h2>
          {sub && <p className="lede" style={{ color: "rgba(255,255,255, .7)", marginTop: 14 }}>{sub}</p>}
        </div>
        <div className="actions" style={{ position: "relative" }}>
          <Button variant="on-dark-primary" size="lg" onClick={onPrimary}>
            {primaryLabel} <Icon name="arrow-right" size={16} className="arrow" />
          </Button>
          {secondaryLabel && (
            <Button variant="on-dark-secondary" size="lg" onClick={onSecondary}>{secondaryLabel}</Button>
          )}
        </div>
      </div>
    );
  }
  return (
    <div className="cta-strip" style={{ background: "#fff", color: "var(--ink)", border: "1px solid var(--hairline)" }}>
      <div>
        <Eyebrow>Take the next step</Eyebrow>
        <h2 className="h-section" style={{ marginTop: 8 }}>{headline}</h2>
        {sub && <p className="lede" style={{ marginTop: 14 }}>{sub}</p>}
      </div>
      <div className="actions">
        <Button variant="primary" size="lg" onClick={onPrimary}>{primaryLabel} <Icon name="arrow-right" size={16} className="arrow" /></Button>
        {secondaryLabel && <Button variant="secondary" size="lg" onClick={onSecondary}>{secondaryLabel}</Button>}
      </div>
    </div>
  );
}

// ---------- OffRamp ----------
function OffRamp({ label = "Off-ramp", title, cta, onCta, variant }) {
  const cls = "offramp" + (variant === "primary" ? " offramp--primary" : "");
  const btnVariant = variant === "primary" ? "on-dark-primary" : "secondary";
  return (
    <div className={cls}>
      <div className="copy">
        <span className="lbl">{label}</span>
        <span>{title}</span>
      </div>
      <Button variant={btnVariant} size="md" onClick={onCta}>{cta} <Icon name="arrow-right" size={14} className="arrow" /></Button>
    </div>
  );
}

// ---------- Page-level FAQ section ----------
// Renders the FAQs tagged for a given page id, with a compact accordion.
// Pass title / eyebrow to override the defaults.
function PageFAQ({
  pageId,
  go,
  eyebrow = "Common questions",
  title = "Questions clients ask",
  viewAllLink = true,
}) {
  const items = (window.getFAQsForPage ? window.getFAQsForPage(pageId) : [])
    .filter(Boolean);
  const [open, setOpen] = React.useState(null);
  if (!items.length) return null;
  return (
    <div>
      <div className="section-head section-head--row" style={{ marginBottom: 28, gap: 24, alignItems: "flex-end" }}>
        <div className="head-left">
          <Eyebrow>{eyebrow}</Eyebrow>
          <h2 className="h-section">{title}</h2>
        </div>
        {viewAllLink && go ? (
          <LinkOut onClick={() => go("faqs")}>See all FAQs</LinkOut>
        ) : null}
      </div>
      <div className="faq-list">
        {items.map((f, i) => (
          <div key={f.id || i} className={`faq-item ${open === i ? "is-open" : ""}`}>
            <button className="faq-q" onClick={() => setOpen(open === i ? null : i)}>
              <span>{f.q}</span>
              <Icon name={open === i ? "minus" : "plus"} size={20} color="var(--ia-blue)" />
            </button>
            {open === i && <div className="faq-a">{f.a}</div>}
          </div>
        ))}
      </div>
    </div>
  );
}

// ---------- EnablementSequence ----------
// Repeated across the three Foundations service pages. Foundations is communicated
// as an ordered sequence the client moves through: 1) AI Setup → 2) AI Governance
// → 3) AI Literacy. The current page's step is marked "You are here"; the others
// are clickable. Reuses the site stepper so it reads as native process language.
const ENABLEMENT_STEPS = [
  { key: "ai-setup",   name: "AI Setup",      desc: "Get the right everyday assistants in place, chosen, configured, and rolled out for how your team actually works." },
  { key: "governance", name: "AI Governance", desc: "Set clear rules and guardrails around those tools, so they're used safely and responsibly." },
  { key: "literacy",   name: "AI Literacy",   desc: "Build the confidence and skill to get real, daily value from the tools." },
];

function EnablementSequence({ active, go }) {
  return (
    <section className="section section--paper" style={{ paddingTop: 56, paddingBottom: 56 }}>
      <div className="container">
        <div className="section-head section-head--center" style={{ marginBottom: 40 }}>
          <Eyebrow>The foundations sequence</Eyebrow>
          <h2 className="h-section" style={{ textAlign: "center", maxWidth: "24ch", marginInline: "auto" }}>
            Foundations work best in order.
          </h2>
          <p className="lede" style={{ textAlign: "center" }}>
            First the tools, then the rules, then the skills. Each step makes the next one
            land, so AI is set up properly, used safely, and actually adopted.
          </p>
        </div>

        <div className="stepper stepper--three">
          {ENABLEMENT_STEPS.map((s, i) => {
            const isActive = s.key === active;
            return (
              <div
                key={s.key}
                className={"step" + (isActive ? " step--active" : " step--link")}
                onClick={isActive ? undefined : () => go(s.key)}
                role={isActive ? undefined : "button"}
                tabIndex={isActive ? undefined : 0}
              >
                <div className="step-num">{String(i + 1).padStart(2, "0")}</div>
                <div className="step-eyebrow">Step 0{i + 1}</div>
                <div className="step-name">{s.name}</div>
                <div className="step-desc">{s.desc}</div>
                {isActive ? (
                  <span className="cat-chip" style={{ marginTop: 2, alignSelf: "flex-start" }}>You are here</span>
                ) : (
                  <span className="linkout step-cta" style={{ marginTop: 2, fontSize: 14 }}>
                    See {s.name}
                    <Icon name="arrow-right" size={14} className="arrow" />
                  </span>
                )}
              </div>
            );
          })}
        </div>
      </div>
    </section>
  );
}

// ---------- EnablementTriangle ----------
// The deck's triangle motif, reused across the three Foundations pages. Foundations
// has three sides, tools (AI Setup), rules (AI Governance), skills (AI Literacy).
// On each page the relevant side is LIT and the other two are dimmed, exactly like
// the deck. The numbered order (1→2→3) is preserved in the legend.
const TRI_SIDES = [
  { key: "ai-setup",   n: "01", name: "AI Setup",      side: "Tools",  blurb: "The right everyday AI assistants, set up and rolled out.",          color: "var(--ia-dark-blue)" },
  { key: "governance", n: "02", name: "AI Governance", side: "Rules",  blurb: "Policies and guardrails for safe, responsible use.",            color: "var(--ia-blue)" },
  { key: "literacy",   n: "03", name: "AI Literacy",   side: "Skills", blurb: "The confidence and capability to use it all well.",             color: "var(--ia-light-blue)" },
];
const TRI_COPY = {
  "ai-setup":   { side: "the tools" },
  "governance": { side: "the rules" },
  "literacy":   { side: "the skills" },
};

function EnablementTriangle({ active, go }) {
  const copy = TRI_COPY[active] || TRI_COPY["ai-setup"];
  // geometry
  const apex = [300, 100], bl = [115, 385], br = [485, 385];
  const sw = 74;
  const dim = 0.16;
  const op = (k) => (k === active ? 1 : dim);
  return (
    <section className="section section--paper" style={{ paddingTop: 60, paddingBottom: 60 }}>
      <div className="container">
        <div className="section-head section-head--center" style={{ marginBottom: 36 }}>
          <Eyebrow>The foundations triangle</Eyebrow>
          <h2 className="h-section" style={{ textAlign: "center", maxWidth: "26ch", marginInline: "auto" }}>
            Foundations have three sides. This page is <em style={{ fontStyle: "normal", color: "var(--ia-blue)" }}>{copy.side}.</em>
          </h2>
          <p className="lede" style={{ textAlign: "center" }}>
            Tools, rules, and skills, the three sides of getting AI adoption right. Each
            one holds the others up, and we deliver all three.
          </p>
        </div>

        <div className="tri-grid">
          <div className="tri-stage">
            <svg viewBox="0 0 600 450" role="img" aria-label={`Foundations triangle, ${active} side emphasised`} style={{ width: "100%", height: "auto", display: "block" }}>
              {/* Left leg, AI Setup (navy) */}
              <g opacity={op("ai-setup")} style={{ transition: "opacity .3s" }}>
                <line x1={apex[0]} y1={apex[1]} x2={bl[0]} y2={bl[1]} stroke="var(--ia-dark-blue)" strokeWidth={sw} strokeLinecap="round" />
                <text x="207" y="242" textAnchor="middle" dominantBaseline="central" transform="rotate(-57 207 242)" fill="#fff" fontFamily="var(--font-display)" fontWeight="700" fontSize="25" letterSpacing="3">SETUP</text>
              </g>
              {/* Right leg, AI Governance (blue) */}
              <g opacity={op("governance")} style={{ transition: "opacity .3s" }}>
                <line x1={apex[0]} y1={apex[1]} x2={br[0]} y2={br[1]} stroke="var(--ia-blue)" strokeWidth={sw} strokeLinecap="round" />
                <text x="393" y="242" textAnchor="middle" dominantBaseline="central" transform="rotate(57 393 242)" fill="#fff" fontFamily="var(--font-display)" fontWeight="700" fontSize="25" letterSpacing="2">GOVERNANCE</text>
              </g>
              {/* Base, AI Literacy (cyan), on top */}
              <g opacity={op("literacy")} style={{ transition: "opacity .3s" }}>
                <line x1={bl[0]} y1={bl[1]} x2={br[0]} y2={br[1]} stroke="var(--ia-light-blue)" strokeWidth={sw + 6} strokeLinecap="round" />
                <text x="300" y="385" textAnchor="middle" dominantBaseline="central" fill="var(--ia-dark-blue)" fontFamily="var(--font-display)" fontWeight="700" fontSize="25" letterSpacing="3">LITERACY</text>
              </g>
            </svg>
          </div>

          <div className="tri-legend">
            {TRI_SIDES.map((s) => {
              const isActive = s.key === active;
              return (
                <div
                  key={s.key}
                  className={"tri-row" + (isActive ? " tri-row--active" : "")}
                  onClick={isActive ? undefined : () => go(s.key)}
                  role={isActive ? undefined : "button"}
                  tabIndex={isActive ? undefined : 0}
                  style={isActive ? { ["--tri-accent"]: s.color } : { ["--tri-accent"]: s.color }}
                >
                  <span className="tri-swatch" style={{ background: s.color }}></span>
                  <div className="tri-body">
                    <div className="tri-name">
                      <span className="tri-n">{s.n}</span>
                      {s.name}
                      <span className="tri-side">{s.side}</span>
                    </div>
                    <div className="tri-blurb">{s.blurb}</div>
                  </div>
                  {isActive ? (
                    <span className="cat-chip">You are here</span>
                  ) : (
                    <span className="linkout tri-cta">See it<Icon name="arrow-right" size={14} className="arrow" /></span>
                  )}
                </div>
              );
            })}
          </div>
        </div>
      </div>
    </section>
  );
}

// ---------- EnablementWhere ----------
// Combines BOTH devices the user wants: the deck triangle (structure + per-page
// emphasis, the active side lit, others dimmed) AND the numbered 1-2-3 step
// process (the order: tools → rules → skills, current step "You are here").
function EnablementWhere({ active, go }) {
  const isOverview = !active;
  const copy = TRI_COPY[active] || TRI_COPY["ai-setup"];
  const apex = [300, 100], bl = [115, 385], br = [485, 385];
  const sw = 74, dim = 0.16;
  const op = (k) => (isOverview ? 1 : (k === active ? 1 : dim));
  return (
    <section className="section section--paper" style={{ paddingTop: 60, paddingBottom: 60 }}>
      <div className="container">
        <div className="section-head section-head--center" style={{ marginBottom: 40 }}>
          <Eyebrow>{isOverview ? "How Foundations work" : "Where it fits"}</Eyebrow>
          <h2 className="h-section" style={{ textAlign: "center", maxWidth: "26ch", marginInline: "auto" }}>
            {isOverview ? (
              <>Three sides, <em style={{ fontStyle: "normal", color: "var(--ia-blue)" }}>one path.</em></>
            ) : (
              <>Three parts, one path. This page is <em style={{ fontStyle: "normal", color: "var(--ia-blue)" }}>{copy.side}.</em></>
            )}
          </h2>
        </div>

        <div className="enb-grid">
          {/* Triangle, structure + emphasis */}
          <div className="tri-stage">
            <svg viewBox="0 0 600 450" role="img" aria-label={`Foundations triangle, ${active} side emphasised`} style={{ width: "100%", height: "auto", display: "block" }}>
              <g opacity={op("ai-setup")} style={{ transition: "opacity .3s" }}>
                <line x1={apex[0]} y1={apex[1]} x2={bl[0]} y2={bl[1]} stroke="var(--ia-dark-blue)" strokeWidth={sw} strokeLinecap="round" />
                <text x="207" y="242" textAnchor="middle" dominantBaseline="central" transform="rotate(-57 207 242)" fill="#fff" fontFamily="var(--font-display)" fontWeight="700" fontSize="25" letterSpacing="3">SETUP</text>
              </g>
              <g opacity={op("governance")} style={{ transition: "opacity .3s" }}>
                <line x1={apex[0]} y1={apex[1]} x2={br[0]} y2={br[1]} stroke="var(--ia-blue)" strokeWidth={sw} strokeLinecap="round" />
                <text x="393" y="242" textAnchor="middle" dominantBaseline="central" transform="rotate(57 393 242)" fill="#fff" fontFamily="var(--font-display)" fontWeight="700" fontSize="25" letterSpacing="2">GOVERNANCE</text>
              </g>
              <g opacity={op("literacy")} style={{ transition: "opacity .3s" }}>
                <line x1={bl[0]} y1={bl[1]} x2={br[0]} y2={br[1]} stroke="var(--ia-light-blue)" strokeWidth={sw + 6} strokeLinecap="round" />
                <text x="300" y="385" textAnchor="middle" dominantBaseline="central" fill="var(--ia-dark-blue)" fontFamily="var(--font-display)" fontWeight="700" fontSize="25" letterSpacing="3">LITERACY</text>
              </g>
            </svg>
          </div>

          {/* Numbered 1-2-3 step process, the sequence */}
          <div className="enb-steps">
            {TRI_SIDES.map((s, i) => {
              const isActive = s.key === active;
              return (
                <div
                  key={s.key}
                  className={"enb-step" + (isActive ? " enb-step--active" : " enb-step--link")}
                  onClick={isActive ? undefined : () => go(s.key)}
                  role={isActive ? undefined : "button"}
                  tabIndex={isActive ? undefined : 0}
                  style={{ ["--enb-accent"]: s.color }}
                >
                  <div className="enb-rail"><span className="enb-n">{i + 1}</span></div>
                  <div className="enb-content">
                    <div className="enb-name">{s.name}</div>
                    <div className="enb-desc">{s.blurb}</div>
                    {isActive ? (
                      <span className="cat-chip" style={{ marginTop: 10, display: "inline-flex", alignSelf: "flex-start" }}>You are here</span>
                    ) : (
                      <span className="linkout enb-cta" style={{ marginTop: 10, fontSize: 14 }}>
                        See {s.name}<Icon name="arrow-right" size={14} className="arrow" />
                      </span>
                    )}
                  </div>
                </div>
              );
            })}
          </div>
        </div>
      </div>
    </section>
  );
}

// ---------- EnablementMiniTriangle ----------
// Compact version of the triangle for the hero of each Foundations page, the
// active side lit, others dimmed (like the deck's per-slide pillar indicator).
function EnablementMiniTriangle({ active, width = 76 }) {
  const dim = 0.2;
  const op = (k) => (k === active ? 1 : dim);
  return (
    <svg viewBox="0 0 100 90" width={width} height={width * 0.9} style={{ display: "block", flex: "none" }} aria-hidden="true">
      <line x1="50" y1="16" x2="16" y2="74" stroke="var(--ia-dark-blue)" strokeWidth="14" strokeLinecap="round" opacity={op("ai-setup")} />
      <line x1="50" y1="16" x2="84" y2="74" stroke="var(--ia-blue)" strokeWidth="14" strokeLinecap="round" opacity={op("governance")} />
      <line x1="16" y1="74" x2="84" y2="74" stroke="var(--ia-light-blue)" strokeWidth="15" strokeLinecap="round" opacity={op("literacy")} />
    </svg>
  );
}

// ---------- Cursor-follow stage ----------
// Publishes normalised pointer position as --mx / --my (-1..1) on itself, so any
// child can read them in a transform. Resets to centre on leave.
function TiltStage({ className = "", children, strength = 1, style, ariaHidden, innerRef }) {
  const own = React.useRef(null);
  const ref = innerRef || own;
  const set = (x, y) => {
    const el = ref.current;
    if (!el) return;
    el.style.setProperty("--mx", (x * strength).toFixed(3));
    el.style.setProperty("--my", (y * strength).toFixed(3));
  };
  return (
    <div
      ref={ref}
      className={`tilt-stage ${className}`}
      style={style}
      aria-hidden={ariaHidden ? "true" : undefined}
      onPointerMove={(e) => {
        const r = ref.current.getBoundingClientRect();
        set(((e.clientX - r.left) / r.width) * 2 - 1, ((e.clientY - r.top) / r.height) * 2 - 1);
      }}
      onPointerLeave={() => set(0, 0)}
    >
      {children}
    </div>);
}

/* ---------- Long-form legal documents (Terms, Privacy Policy) ----------
   Shared so each policy page reads like the document it reproduces, and so the
   pages cannot drift apart typographically. */
const LP = ({ children }) => <p className="legal-p">{children}</p>;
const LClause = ({ children, className = "" }) =>
  <p className={`legal-clause ${className}`}>{children}</p>;
const LDef = ({ term, children }) => (
  <p className="legal-def"><span className="legal-term">{term}</span> {children}</p>
);
const LH2 = ({ n, children }) => (
  <h2 className="legal-h2"><span className="legal-num">{n}</span>{children}</h2>
);
const LH3 = ({ children }) => <h3 className="legal-h3">{children}</h3>;

// Share everything to global scope
Object.assign(window, {
  IA_MVP: MVP,
  Icon, Button, LinkOut, Tag, Eyebrow, Crumbs, TiltStage,
  ACCELERATORS, AcceleratorStrip,
  LP, LClause, LDef, LH2, LH3,
  Nav, Footer, CtaStrip, OffRamp, PageFAQ, EnablementSequence, EnablementTriangle, EnablementWhere, EnablementMiniTriangle,
});
