/* eslint-disable */
/* global React */
const { useState, useEffect, useRef } = React;

/* ============================================================
   Shared primitives + small components
   ============================================================ */

// -------- Tick ruler decorative element
function Ruler({ count = 40 }) {
  return (
    <div className="ruler">
      {Array.from({ length: count }).map((_, i) => (
        <span key={i} className={i % 5 === 0 ? "tall" : ""} />
      ))}
    </div>
  );
}

// -------- Eyebrow label (mono uppercase)
function Eyebrow({ children }) {
  return <span className="eyebrow">{children}</span>;
}

// -------- Section wrapper
function Section({ id, eyebrow, title, children, fluid }) {
  return (
    <section id={id} className="section">
      <div className={fluid ? "" : "wrap"}>
        {eyebrow || title ? (
          <div className="section-head">
            {eyebrow ? <Eyebrow>{eyebrow}</Eyebrow> : null}
            {title ? <h2 className="h2">{title}</h2> : null}
          </div>
        ) : null}
        {children}
      </div>
    </section>
  );
}

// -------- Number cell
function NumCell({ figure, unit, caption, tag, tone }) {
  return (
    <div className="num-cell">
      <div className="tag">{tag}</div>
      <div className={"figure " + (tone || "")}>
        {figure}
        {unit ? <span className="unit">{unit}</span> : null}
      </div>
      <div className="caption">{caption}</div>
    </div>
  );
}

// -------- Stat cluster cell
function StatCell({ figure, lbl, tone }) {
  return (
    <div className="cell">
      <div className={"figure " + (tone || "")}>{figure}</div>
      <div className="lbl">{lbl}</div>
    </div>
  );
}

// -------- Stack icon cell (SVG iconography for stack)
function StackCell({ name, cat, tone, icon }) {
  return (
    <div className={"stack-cell " + (tone || "")}>
      <div className="icon">{icon || <DotIcon />}</div>
      <div>
        <div className="name">{name}</div>
        <div className="cat">{cat}</div>
      </div>
    </div>
  );
}

// -------- Generic icon glyphs (simple geometric, brand-neutral)
function DotIcon() {
  return (
    <svg viewBox="0 0 24 24" width="22" height="22" fill="currentColor"><circle cx="12" cy="12" r="5" /></svg>
  );
}
function SquareIcon() {
  return <svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" strokeWidth="2"><rect x="5" y="5" width="14" height="14" /></svg>;
}
function CircleIcon() {
  return <svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" strokeWidth="2"><circle cx="12" cy="12" r="7" /></svg>;
}
function DiamondIcon() {
  return <svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" strokeWidth="2"><polygon points="12,3 21,12 12,21 3,12" /></svg>;
}
function TriIcon() {
  return <svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" strokeWidth="2"><polygon points="12,4 21,20 3,20" /></svg>;
}
function CrossIcon() {
  return <svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" strokeWidth="2"><line x1="6" y1="6" x2="18" y2="18" /><line x1="18" y1="6" x2="6" y2="18" /></svg>;
}
function HexIcon() {
  return <svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" strokeWidth="2"><polygon points="6,4 18,4 22,12 18,20 6,20 2,12" /></svg>;
}
function BarsIcon() {
  return <svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" strokeWidth="2"><line x1="6" y1="20" x2="6" y2="10" /><line x1="12" y1="20" x2="12" y2="4" /><line x1="18" y1="20" x2="18" y2="14" /></svg>;
}
function DbIcon() {
  return <svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" strokeWidth="2"><ellipse cx="12" cy="6" rx="8" ry="2.5" /><path d="M4 6 V12 C 4 13.4 7.6 14.5 12 14.5 S 20 13.4 20 12 V6" /><path d="M4 12 V18 C 4 19.4 7.6 20.5 12 20.5 S 20 19.4 20 18 V12" /></svg>;
}
function CloudIcon() {
  return <svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" strokeWidth="2"><path d="M7 18 a 4 4 0 0 1 -1 -7.9 a 5 5 0 0 1 9.6 -1 a 4 4 0 0 1 0.9 7.9 z" /></svg>;
}
function BoltIcon() {
  return <svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" strokeWidth="2"><polygon points="13,3 4,14 11,14 9,21 20,10 13,10" /></svg>;
}
function LockIcon() {
  return <svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" strokeWidth="2"><rect x="5" y="11" width="14" height="10" /><path d="M8 11 V7 a 4 4 0 0 1 8 0 V11" /></svg>;
}
function GearIcon() {
  return <svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" strokeWidth="2"><circle cx="12" cy="12" r="3" /><path d="M12 2 V5 M12 19 V22 M2 12 H5 M19 12 H22 M5 5 L7 7 M17 17 L19 19 M5 19 L7 17 M17 7 L19 5" /></svg>;
}
function TermIcon() {
  return <svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" strokeWidth="2"><rect x="3" y="5" width="18" height="14" /><polyline points="7,10 10,12 7,14" /><line x1="12" y1="15" x2="17" y2="15" /></svg>;
}
function PuzzleIcon() {
  return <svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" strokeWidth="2"><path d="M3 8 H8 V5 a 2 2 0 0 1 4 0 V8 H17 V13 a 2 2 0 0 0 0 4 H17 V21 H12 a 2 2 0 0 1 -4 0 V17 a 2 2 0 0 1 -4 0 a 2 2 0 0 1 0 -4 V8 z" /></svg>;
}
function StreamIcon() {
  return <svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" strokeWidth="2"><path d="M3 6 Q 9 12 15 6 Q 21 0 21 12" /><path d="M3 18 Q 9 12 15 18 Q 21 24 21 12" /></svg>;
}

// Export to window for use across other Babel scripts
Object.assign(window, {
  Ruler, Eyebrow, Section, NumCell, StatCell, StackCell,
  DotIcon, SquareIcon, CircleIcon, DiamondIcon, TriIcon, CrossIcon, HexIcon,
  BarsIcon, DbIcon, CloudIcon, BoltIcon, LockIcon, GearIcon, TermIcon, PuzzleIcon, StreamIcon,
});
