/*
 * About module.
 *
 * This page is the old marketing site (wms-arka-com/index.html, the page that
 * used to answer https://wms.arka.com) restyled as a module inside the app
 * shell. Its content is that page and nothing else: hero, capabilities, the five
 * optimization engines, beyond optimization, notification workflows, the
 * real-time dashboard, authentication, how it works, integration, platform
 * values, contact, footer — in the original order, with the original wording.
 * Nothing about the audit module lives here; only what the marketing page said.
 *
 * Two things about the port are worth knowing:
 *
 * 1. The old page's two mock-ups are rebuilt as SVG at the same density —
 *    WorkflowVisual keeps the four nodes, the marching-ants connectors and the
 *    pulsing packets; DashboardVisual keeps the three stat tiles with their
 *    rails and the 24-hour throughput curve, whose path data is copied verbatim.
 *    What changed is the palette: cyan/blue-on-slate became this app's neutrals
 *    with green as the single accent. The mock-ups render twice, in the hero and
 *    in their own sections, exactly as they did on the old page.
 * 2. Deliberately dropped, being chrome rather than content: the Privacy and
 *    Terms links (both pointed at a dead `href="#"`), the floating particles,
 *    and the SVG glow filters, which on a white theme only muddy the green.
 *
 * Jump targets are element ids driven by scrollIntoView, not `href="#..."`,
 * because the hash is what ArkaApp routes on — an anchor would change modules.
 *
 * IIFE-wrapped and published on window.AboutModule for the same reason as
 * AppShell.jsx — in-browser Babel gives every .jsx file the same global scope.
 */

(function () {
  const { cn, PageContainer, PageHeader, Section, IconTile, Icons } = window.Shell;

  /* The old page's nav, in its order. "Platform" is the values grid, as there. */
  const SECTION_INDEX = [
    { id: 'capabilities', label: 'Capabilities' },
    { id: 'optimization', label: 'Optimization' },
    { id: 'beyond', label: 'Beyond' },
    { id: 'workflows', label: 'Workflows' },
    { id: 'dashboard', label: 'Dashboard' },
    { id: 'security', label: 'Security' },
    { id: 'how', label: 'How It Works' },
    { id: 'integration', label: 'Integration' },
    { id: 'platform', label: 'Platform' },
    { id: 'contact', label: 'Contact' },
  ];

  const CAPABILITIES = [
    {
      icon: Icons.Warehouse,
      title: 'Multi-warehouse support',
      metric: 'Multi-site ready',
      quote: 'One command layer across sites.',
      desc: 'Operate multiple warehouses with unified visibility, consistent controls, and clean cross-site reporting.',
    },
    {
      icon: Icons.Box,
      title: 'Product & inventory tracking',
      metric: 'Inventory control',
      quote: 'Know what you have and where it is.',
      desc: 'Track SKUs, bins, and inventory states with accuracy-focused tools built for speed at the edge.',
    },
    {
      icon: Icons.Bolt,
      title: 'Custom package management',
      metric: 'Faster pack',
      quote: 'Standardize pack-out quality.',
      desc: 'Define packaging rules and handling constraints to reduce waste, improve speed, and keep ops consistent.',
    },
    {
      icon: Icons.Bell,
      title: 'Visual notification workflows',
      metric: 'Workflow builder',
      quote: 'Triggers + channels, no bottlenecks.',
      desc: 'Build workflows visually: triggers, rules, and channels (email, Slack, webhooks) with audit trails.',
    },
    {
      icon: Icons.Users,
      title: 'User & admin management',
      metric: 'RBAC',
      quote: 'Right access, right scope.',
      desc: 'Role-based access with admin tools and guardrails for teams that scale across warehouses.',
    },
    {
      icon: Icons.Chart,
      title: 'Real-time dashboard metrics',
      metric: 'Live KPIs',
      quote: 'Run the floor with live truth.',
      desc: 'Utilization, throughput, accuracy, and exception queues—so teams act before issues cascade.',
    },
    {
      icon: Icons.Lock,
      title: 'Full authentication system',
      metric: 'Auth built-in',
      quote: 'Secure by default.',
      desc: 'Authentication and session controls designed for operational environments and compliance needs.',
    },
    {
      icon: Icons.Sparkle,
      title: 'Light theme',
      metric: 'Shift-ready',
      quote: 'Comfort for long shifts.',
      desc: 'A modern, clean interface optimized for both office and floor use.',
    },
  ];

  const OPTIMIZATION_ENGINES = [
    {
      title: 'CardStack Optimization',
      desc: 'Groups items with similar dimensions so they can be safely stacked together. Reduces wasted vertical space without compromising item safety.',
    },
    {
      title: 'Size Standardization',
      desc: 'Categorizes inventory by weight and size class, then reorganizes zones so similar-sized goods stay together.',
    },
    {
      title: 'Value Density Sorting',
      desc: 'Moves highest-value inventory into secure, climate-controlled, or high-visibility zones while bulk goods go to open storage.',
    },
    {
      title: 'Bin Packing',
      desc: 'First-fit-decreasing packing that treats the warehouse like a puzzle, maximizing space while respecting weight and zone limits.',
    },
    {
      title: 'Name Consolidation',
      desc: 'Groups items with similar descriptions into the same zones so teams find what they need faster.',
    },
  ];

  const BEYOND_OPTIMIZATION = [
    {
      title: 'Multi-site inventory visibility',
      desc: 'See stock levels across all locations in one view and spot shortages instantly.',
    },
    {
      title: 'Capacity forecasting',
      desc: '30-day utilization projections with alerts at 80% and 95% thresholds.',
    },
    {
      title: 'Smart rebalancing',
      desc: 'AI recommendations to redistribute inventory across sites with one-click approval and tracking.',
    },
    {
      title: 'Priority transfer queue',
      desc: 'Route urgent transfers ahead of routine ones with escalation controls and queue tracking.',
    },
    {
      title: 'Aging alerts',
      desc: 'Configurable thresholds flag inventory sitting too long to reduce spoilage and obsolescence.',
    },
    {
      title: 'Site benchmarking',
      desc: 'Daily metric snapshots, leaderboards, and trends to compare location performance.',
    },
    {
      title: 'Transport calendar',
      desc: 'Schedule cross-site shipments with conflict detection and consolidation tools.',
    },
    {
      title: 'Version control',
      desc: 'Every optimization run creates a snapshot with one-click rollback.',
    },
  ];

  const WORKFLOW_PIECES = [
    'Triggers: low stock, SLA breach, receiving delays, anomalies',
    'Rules: warehouse scope, product class, priority thresholds',
    'Channels: email, Slack, webhooks, in-app alerts',
    'Actions: create tasks, draft POs, escalate exceptions',
  ];

  const DASHBOARD_METRICS = [
    { title: 'Utilization', desc: 'Capacity by warehouse, zone, and bin class.' },
    { title: 'Throughput', desc: 'Pick/pack/ship performance and SLA tracking.' },
    { title: 'Exceptions', desc: 'Backorders, mismatches, damaged goods, holds.' },
    { title: 'Inventory health', desc: 'Aging stock, cycle counts, accuracy deltas.' },
  ];

  const SECURITY = [
    {
      icon: Icons.Lock,
      title: 'Authentication',
      desc: 'Secure sessions and consistent identity across modules.',
    },
    {
      icon: Icons.Users,
      title: 'Role-based access',
      desc: 'Operators, managers, admins—scoped per warehouse and workflow.',
    },
    {
      icon: Icons.Shield,
      title: 'Auditability',
      desc: 'Action logs and workflow history for traceability.',
    },
  ];

  const HOW_IT_WORKS = [
    {
      title: 'Import your inventory',
      desc: 'Upload CSV or Excel files. We validate and map everything automatically.',
    },
    {
      title: 'Configure your zones',
      desc: 'Define storage areas by type with capacity limits: bulk, rack, cold storage, hazmat, outdoor.',
    },
    {
      title: 'Run optimization',
      desc: 'Pick one algorithm or run all five in sequence. Preview every move before applying.',
    },
    {
      title: 'Monitor & adapt',
      desc: 'Real-time dashboards, utilization charts, and automated alerts keep you ahead of problems.',
    },
  ];

  const INTEGRATION = [
    'Full REST API with standard JSON responses.',
    'Connect ERP, TMS, or order management systems.',
    'User-scoped data isolation so every client sees only their operations.',
  ];

  const VALUES = [
    { title: 'Operational clarity', desc: 'Every view drives a decision.' },
    { title: 'Automation first', desc: 'Humans approve; systems execute.' },
    { title: 'Auditability', desc: 'Trace every event end-to-end.' },
    { title: 'Extensible by design', desc: 'APIs and integrations with no lock-in.' },
    { title: 'Performance', desc: 'Fast UI, fast workflows, fast outcomes.' },
    { title: 'Secure defaults', desc: 'RBAC + auth and least privilege.' },
    { title: 'Multi-site reality', desc: 'Built for distributed operations.' },
    { title: 'Modern UX', desc: 'Light theme and clean flows.' },
  ];

  const CONTACT_CHANNELS = [
    { label: 'General inquiries', value: 'wms@arka.com', href: 'mailto:wms@arka.com' },
    { label: 'Platform access', value: 'support@arka.com', href: 'mailto:support@arka.com' },
    { label: 'Headquarters', value: 'Austin, Texas' },
  ];

  /* ---------- small pieces ---------- */

  function Tile({ title, children }) {
    return (
      <div className="rounded-2xl border border-border bg-card p-5">
        <div className="text-sm font-semibold text-foreground">{title}</div>
        <p className="mt-2 text-sm leading-relaxed text-muted-foreground">{children}</p>
      </div>
    );
  }

  const PILL =
    'inline-flex items-center gap-2 rounded-full border border-border bg-card px-3.5 py-1.5 text-sm font-medium text-foreground transition-colors hover:bg-card-raised';

  const EYEBROW = 'text-2xs font-bold uppercase tracking-widest';

  /* ---------- the two mock-ups ---------- */

  /**
   * The chrome both mock-ups sit in.
   *
   * The old page framed each one as an application window — a titlebar carrying a
   * name on the left and a scope on the right, over a darker body. Same frame
   * here, with the titlebar as the raised step and the body as the plain card, so
   * the mock reads as a screenshot of something rather than as another panel.
   * `lights` draws the three window dots the workflow builder had; they are the
   * one place the status tones appear purely as decoration.
   */
  function MockWindow({ label, tag, lights, children }) {
    return (
      <div className="overflow-hidden rounded-2xl border border-border bg-card">
        <div className="flex items-center gap-2 border-b border-border bg-card-raised px-4 py-3">
          {lights && (
            <span className="flex items-center gap-1.5 pr-1" aria-hidden="true">
              <span className="h-2 w-2 rounded-full bg-danger/50" />
              <span className="h-2 w-2 rounded-full bg-warning/50" />
              <span className="h-2 w-2 rounded-full bg-success/50" />
            </span>
          )}
          <span className="truncate text-xs font-semibold text-foreground">{label}</span>
          <span className={cn('ml-auto shrink-0 text-muted-foreground', EYEBROW)}>{tag}</span>
        </div>
        <div className="p-4 sm:p-5">{children}</div>
      </div>
    );
  }

  /** One of the dashboard's three stat tiles: label, figure, rail, caption. */
  function MockStat({ label, value, percent, delta, caption }) {
    return (
      <div className="rounded-xl border border-border bg-card-raised p-4">
        <div className={cn('text-muted-foreground', EYEBROW)}>{label}</div>
        <div className="mt-2 text-3xl font-semibold leading-none tracking-tight tabular-nums text-foreground">
          {value}
        </div>
        <div className="mt-3 flex items-center gap-2">
          {/* The rail is drawn on foreground/10 rather than on the border token,
              which is a hairline colour and disappears as a filled track. */}
          <div className="h-1.5 w-full overflow-hidden rounded-full bg-foreground/10">
            <div className="h-full rounded-full bg-foreground" style={{ width: `${percent}%` }} />
          </div>
          {delta && (
            <span className="shrink-0 text-2xs font-semibold tabular-nums text-success">{delta}</span>
          )}
        </div>
        <div className="mt-2 text-2xs leading-relaxed text-muted-foreground">{caption}</div>
      </div>
    );
  }

  /* The old throughput curve, copied verbatim so the shape is the same one —
     an early climb, two dips, and a strong close. */
  const THROUGHPUT_PATH =
    'M10 95 C 80 35, 140 80, 210 55 C 280 30, 340 70, 410 50 C 480 30, 540 60, 610 35 C 680 10, 740 40, 820 22 C 860 14, 885 18, 890 20';

  /**
   * The throughput chart.
   *
   * Two passes over one path: a wide translucent green halo (the old version's
   * glow, done with opacity rather than a blur filter, which on white smears into
   * grey) and the readable ink-green line on top. No area fill — the old chart was
   * a bare line, and a wash under it only dulls the one green element in the mock.
   * The ten baseline ticks are the old hour markers.
   */
  function ThroughputChart() {
    return (
      <svg viewBox="0 0 900 120" className="h-auto w-full" aria-hidden="true">
        <path d={THROUGHPUT_PATH} fill="none" strokeWidth="9" className="stroke-primary/30" />
        <path
          d={THROUGHPUT_PATH}
          fill="none"
          strokeWidth="2.5"
          strokeLinecap="round"
          className="stroke-primary-ink"
        />
        {Array.from({ length: 10 }, (_, i) => (
          <circle key={i} cx={90 * i + 10} cy="112" r="1.6" className="fill-foreground/30" />
        ))}
      </svg>
    );
  }

  /**
   * The real-time dashboard mock — the old page's hero visual, and the visual of
   * its dashboard section. Same three figures (12 warehouses at 78% capacity,
   * 4,218 orders in motion at +9%, 99.2% accuracy from 92% coverage) and the same
   * 24-hour throughput panel beneath them.
   */
  function DashboardVisual() {
    return (
      <MockWindow label="Real-time dashboard" tag="Multi-warehouse">
        <div className="grid gap-3 sm:grid-cols-3">
          <MockStat label="Active warehouses" value="12" percent={78} caption="78% capacity utilization" />
          <MockStat
            label="Orders in motion"
            value="4,218"
            percent={64}
            delta="+9%"
            caption="Pick/pack SLA trending up"
          />
          <MockStat
            label="Inventory accuracy"
            value="99.2%"
            percent={92}
            caption="Cycle counts + barcode scans"
          />
        </div>

        <div className="mt-3 rounded-xl border border-border bg-card-raised p-4">
          <div className="flex items-baseline justify-between gap-3">
            <span className={cn('text-muted-foreground', EYEBROW)}>Throughput</span>
            <span className="text-2xs text-muted-foreground">last 24h</span>
          </div>
          <div className="mt-2">
            <ThroughputChart />
          </div>
        </div>
      </MockWindow>
    );
  }

  /** One node of the workflow diagram. Coordinates are in the 900×360 viewBox. */
  function FlowNode({ x, y, w, h, eyebrow, title, sub, accent }) {
    const cx = x + w / 2;
    return (
      <g>
        <rect
          x={x}
          y={y}
          width={w}
          height={h}
          rx="16"
          strokeWidth={accent ? 2 : 1.5}
          className={accent ? 'fill-primary/15 stroke-primary' : 'fill-card-raised stroke-foreground/20'}
        />
        <text
          x={cx}
          y={y + 30}
          textAnchor="middle"
          fontSize="13"
          fontWeight="700"
          letterSpacing="1.8"
          className={accent ? 'fill-primary-ink' : 'fill-muted-foreground'}
        >
          {eyebrow}
        </text>
        <text
          x={cx}
          y={y + 62}
          textAnchor="middle"
          fontSize="19"
          fontWeight="600"
          className="fill-foreground"
        >
          {title}
        </text>
        {sub && (
          <text x={cx} y={y + 88} textAnchor="middle" fontSize="15" className="fill-muted-foreground">
            {sub}
          </text>
        )}
      </g>
    );
  }

  /* Packets travelling a connector: a run of dots that pulse in sequence, which
     is what the old page's animated dots along the trigger line did. `at` is the
     fixed coordinate — the y of a horizontal run, the x of a vertical one. */
  function FlowPackets({ from, to, at, vertical, step = 12, delay = 0 }) {
    const dots = [];
    for (let p = from, i = 0; p <= to; p += step, i++) {
      dots.push(
        <circle
          key={p}
          cx={vertical ? at : p}
          cy={vertical ? p : at}
          r="2.4"
          className="fill-primary arka-pulse"
          style={{ animationDelay: `${delay + i * 0.11}s` }}
        />
      );
    }
    return <g aria-hidden="true">{dots}</g>;
  }

  /**
   * The notification workflow builder.
   *
   * The original: TRIGGER → RULE → CHANNELS across the top, the rule branching
   * down to the ACTION it fires, joined by marching-ants connectors with packets
   * running along them. All of it is here; what changed is that the nodes are
   * neutral cards with green reserved for the action they end at, and the glow
   * filter is gone — on white it only smears the ink.
   */
  function WorkflowVisual() {
    return (
      <MockWindow lights label="Notification workflow builder" tag="Triggers • Rules • Channels">
        <svg
          viewBox="0 0 900 360"
          className="h-auto w-full"
          role="img"
          aria-label="A low-stock trigger passes through a warehouse A+B rule to email and Slack channels, and fires an action that auto-creates a PO draft and notifies managers."
        >
          {/* Connectors first, so the nodes cover their ends. */}
          <path
            d="M246 88 H344"
            fill="none"
            strokeWidth="2.5"
            strokeDasharray="10 10"
            className="stroke-primary/50 arka-ants"
          />
          <path
            d="M556 88 H654"
            fill="none"
            strokeWidth="2.5"
            strokeDasharray="10 10"
            className="stroke-primary/50 arka-ants"
          />
          <path
            d="M450 130 V226"
            fill="none"
            strokeWidth="2.5"
            strokeDasharray="10 10"
            className="stroke-primary/50 arka-ants-b"
          />

          <polygon points="346,88 334,82 334,94" className="fill-primary-ink/60" />
          <polygon points="656,88 644,82 644,94" className="fill-primary-ink/60" />
          <polygon points="450,230 444,218 456,218" className="fill-primary-ink/60" />

          <FlowPackets from={258} to={332} at={88} />
          <FlowPackets from={568} to={642} at={88} delay={0.4} />
          <FlowPackets from={146} to={206} at={450} vertical delay={0.2} />

          <FlowNode x={40} y={46} w={200} h={84} eyebrow="TRIGGER" title="Low stock" />
          <FlowNode x={350} y={46} w={200} h={84} eyebrow="RULE" title="Warehouse A+B" />
          <FlowNode x={660} y={46} w={200} h={84} eyebrow="CHANNELS" title="Email + Slack" />
          <FlowNode
            accent
            x={300}
            y={232}
            w={300}
            h={104}
            eyebrow="ACTION"
            title="Auto-create PO draft"
            sub="Notify managers"
          />
        </svg>

        <div className="mt-4 grid gap-3 sm:grid-cols-3">
          {[
            { label: 'Triggers', value: 'Inventory' },
            { label: 'Channels', value: 'Email / Slack' },
            { label: 'Audit', value: 'Every event' },
          ].map(t => (
            <div
              key={t.label}
              className="rounded-xl border border-border bg-card-raised p-3 text-center"
            >
              <div className={cn('text-muted-foreground', EYEBROW)}>{t.label}</div>
              <div className="mt-1 text-sm font-semibold text-foreground">{t.value}</div>
            </div>
          ))}
        </div>
      </MockWindow>
    );
  }

  /* ---------- hero backdrop ---------- */

  /**
   * The old hero's technical grid. Drawn in foreground alphas rather than the
   * border token, which is too faint to read as a pattern, and kept under 10%
   * so it stays a texture instead of becoming graph paper.
   */
  function HeroGrid() {
    return (
      <svg className="absolute inset-0 h-full w-full text-foreground" aria-hidden="true">
        <defs>
          <pattern id="about-hero-grid" width="56" height="56" patternUnits="userSpaceOnUse">
            <path d="M56 0H0v56" fill="none" stroke="currentColor" strokeOpacity="0.045" />
            {[
              [0, 0],
              [56, 0],
              [0, 56],
              [56, 56],
            ].map(([cx, cy]) => (
              <circle key={`${cx}-${cy}`} cx={cx} cy={cy} r="1.1" fill="currentColor" fillOpacity="0.11" />
            ))}
          </pattern>
        </defs>
        <rect width="100%" height="100%" fill="url(#about-hero-grid)" />
      </svg>
    );
  }

  /* ---------- section index ---------- */

  /**
   * The old page's nav. It highlighted whichever section you were in, so this one
   * does too — the bottom margin keeps the marker on the heading you are reading
   * rather than on the one about to enter from below.
   */
  function SectionIndex() {
    const [activeId, setActiveId] = React.useState(SECTION_INDEX[0].id);

    React.useEffect(() => {
      const els = SECTION_INDEX.map(s => document.getElementById(s.id)).filter(Boolean);
      if (!els.length || typeof IntersectionObserver !== 'function') return;
      const observer = new IntersectionObserver(
        entries => {
          const visible = entries
            .filter(e => e.isIntersecting)
            .sort((a, b) => a.boundingClientRect.top - b.boundingClientRect.top);
          if (visible.length) setActiveId(visible[0].target.id);
        },
        { rootMargin: '-72px 0px -55% 0px' }
      );
      els.forEach(el => observer.observe(el));
      return () => observer.disconnect();
    }, []);

    return (
      <nav aria-label="On this page" className="flex flex-wrap gap-2">
        {SECTION_INDEX.map(s => (
          <button
            key={s.id}
            onClick={() => jumpTo(s.id)}
            aria-current={s.id === activeId ? 'true' : undefined}
            className={cn(
              'rounded-full border px-3 py-1.5 text-xs font-medium transition-colors',
              s.id === activeId
                ? 'border-foreground bg-foreground text-background'
                : 'border-border bg-card text-muted-foreground hover:bg-card-raised hover:text-foreground'
            )}
          >
            {s.label}
          </button>
        ))}
      </nav>
    );
  }

  function jumpTo(id) {
    const el = document.getElementById(id);
    if (el) el.scrollIntoView({ behavior: 'smooth', block: 'start' });
  }

  /* ---------- the page ---------- */

  function AboutModule() {
    return (
      <PageContainer>
        <PageHeader
          title="About"
          actions={
            <a href="mailto:wms@arka.com" className={PILL}>
              Contact
              <Icons.Mail className="h-4 w-4" />
            </a>
          }
        />

        {/* HERO — copy left, the dashboard mock right, as on the old page. */}
        <div className="relative overflow-hidden rounded-2xl border border-border bg-card p-6 sm:p-8">
          <HeroGrid />

          <div className="relative grid gap-8 lg:grid-cols-2 lg:items-center">
            <div>
              <div className="inline-flex flex-wrap items-center gap-x-2 gap-y-1 rounded-full border border-primary/30 bg-primary/10 px-3.5 py-1.5">
                <span className={cn('text-primary-ink', EYEBROW)}>Warehouse management system</span>
                <span className="text-2xs text-muted-foreground">
                  multi-warehouse • workflows • auth
                </span>
              </div>

              <h2 className="mt-5 text-2xl font-semibold leading-tight tracking-tight text-foreground sm:text-4xl">
                Multi-warehouse
                <br />
                command &amp; control
              </h2>

              <p className="mt-4 max-w-xl text-sm leading-relaxed text-muted-foreground sm:text-base">
                Full-scale WMS with smart optimization engines, inventory tracking, package
                management, admin tooling, and visual notification workflows—delivered in a modern,
                clean interface built for long shifts.
              </p>

              <div className="mt-6 flex flex-wrap items-center gap-2">
                <button
                  onClick={() => jumpTo('capabilities')}
                  className="inline-flex items-center gap-2 rounded-full bg-primary px-4 py-2 text-sm font-semibold text-primary-foreground transition-colors hover:bg-primary/90"
                >
                  Explore capabilities
                  <Icons.ChevronRight className="h-4 w-4 rotate-90" />
                </button>
                <a href="mailto:get-demo@arka.com" className={PILL}>
                  Request a demo
                  <Icons.Mail className="h-4 w-4" />
                </a>
              </div>
            </div>

            <DashboardVisual />
          </div>

          <div className="relative mt-8 flex justify-center">
            <button
              onClick={() => jumpTo('capabilities')}
              className="flex flex-col items-center gap-1 text-2xs font-semibold uppercase tracking-widest text-muted-foreground transition-colors hover:text-foreground"
            >
              Scroll to explore
              {/* The bounce and the quarter-turn have to sit on different
                  elements: animate-bounce animates `transform`, so on one node it
                  overwrites the rotation and the chevron points sideways. */}
              <span className="motion-safe:animate-bounce" aria-hidden="true">
                <Icons.ChevronRight className="h-5 w-5 rotate-90 text-primary-ink" />
              </span>
            </button>
          </div>
        </div>

        <div className="mt-6">
          <SectionIndex />
        </div>

        <Section
          id="capabilities"
          title="Capabilities"
          description="Multi-warehouse operations, inventory control, workflows, admin tools, dashboards, and auth."
        >
          <div className="grid gap-4 md:grid-cols-2">
            {CAPABILITIES.map(c => (
              <div key={c.title} className="rounded-2xl border border-border bg-card p-5">
                <div className="flex items-start gap-3.5">
                  <IconTile icon={c.icon} size="lg" />
                  <div className="min-w-0 flex-1">
                    <div className="flex flex-wrap items-start justify-between gap-2">
                      <div className="text-base font-semibold text-foreground">{c.title}</div>
                      <span className={cn('text-primary-ink', EYEBROW)}>{c.metric}</span>
                    </div>
                    <p className="mt-1.5 text-sm italic text-muted-foreground">“{c.quote}”</p>
                    <p className="mt-2 text-sm leading-relaxed text-muted-foreground">{c.desc}</p>
                  </div>
                </div>
              </div>
            ))}
          </div>
        </Section>

        <Section
          id="optimization"
          title="Smart warehouse optimization"
          description="A platform that goes beyond inventory tracking. It actively analyzes operations and recommends actions to reduce waste, improve space utilization, and speed up fulfillment."
        >
          <div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
            {OPTIMIZATION_ENGINES.map(o => (
              <Tile key={o.title} title={o.title}>
                {o.desc}
              </Tile>
            ))}
          </div>
        </Section>

        <Section
          id="beyond"
          title="Beyond optimization"
          description="Visibility, forecasting, and orchestration across every site."
        >
          <div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-4">
            {BEYOND_OPTIMIZATION.map(b => (
              <Tile key={b.title} title={b.title}>
                {b.desc}
              </Tile>
            ))}
          </div>
        </Section>

        <Section
          id="workflows"
          title="Visual notification workflows"
          description="Build automation with triggers, rules, and channels—audited end-to-end."
        >
          <div className="grid gap-4 lg:grid-cols-[minmax(0,2fr)_minmax(0,3fr)]">
            {/* Bare in the column, not in a card — on the old page these sat as
                plain text beside the diagram, and a card this tall around four
                lines reads as an empty box. */}
            <div className="flex flex-col justify-center px-1 py-2">
              <ul className="space-y-3">
                {WORKFLOW_PIECES.map(piece => (
                  <li key={piece} className="flex items-baseline gap-2.5">
                    <span className="text-primary-ink">•</span>
                    <span className="text-sm leading-relaxed text-muted-foreground">{piece}</span>
                  </li>
                ))}
              </ul>
            </div>
            <WorkflowVisual />
          </div>
        </Section>

        <Section
          id="dashboard"
          title="Real-time dashboard metrics"
          description="Utilization, throughput, accuracy, and exception queues across warehouses."
        >
          {/* Mock left, the four metric families right — the old page's order. */}
          <div className="grid gap-4 lg:grid-cols-2 lg:items-start">
            <DashboardVisual />
            <div className="grid gap-4 sm:grid-cols-2">
              {DASHBOARD_METRICS.map(m => (
                <Tile key={m.title} title={m.title}>
                  {m.desc}
                </Tile>
              ))}
            </div>
          </div>
        </Section>

        <Section
          id="security"
          title="Authentication & admin controls"
          description="Full authentication system, RBAC, and admin tooling—built for operations."
        >
          <div className="grid gap-4 lg:grid-cols-3">
            {SECURITY.map(s => (
              <div key={s.title} className="rounded-2xl border border-border bg-card p-5">
                <IconTile icon={s.icon} size="lg" />
                <div className="mt-4 text-sm font-semibold text-foreground">{s.title}</div>
                <p className="mt-2 text-sm leading-relaxed text-muted-foreground">{s.desc}</p>
              </div>
            ))}
          </div>
        </Section>

        <Section id="how" title="How it works" description="Configure once, optimize continuously.">
          <div className="grid gap-4 md:grid-cols-2">
            {HOW_IT_WORKS.map((step, i) => (
              <div key={step.title} className="rounded-2xl border border-border bg-card p-5">
                <div className={cn('text-primary-ink', EYEBROW)}>Step {i + 1}</div>
                <div className="mt-2 text-base font-semibold text-foreground">{step.title}</div>
                <p className="mt-2 text-sm leading-relaxed text-muted-foreground">{step.desc}</p>
              </div>
            ))}
          </div>
        </Section>

        <Section
          id="integration"
          title="Built for integration"
          description="Connect to your existing stack without replatforming."
        >
          <div className="grid gap-4 sm:grid-cols-3">
            {INTEGRATION.map(point => (
              <div
                key={point}
                className="rounded-2xl border border-border bg-card p-5 text-sm leading-relaxed text-muted-foreground"
              >
                {point}
              </div>
            ))}
          </div>
        </Section>

        {/* The old page's values grid — its nav called this section "Platform". */}
        <Section id="platform" title="Platform">
          <div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-4">
            {VALUES.map(v => (
              <Tile key={v.title} title={v.title}>
                {v.desc}
              </Tile>
            ))}
          </div>
        </Section>

        <Section
          id="contact"
          title="Contact"
          description="Partnerships, contracts, or a walkthrough of Arka WMS."
        >
          <div className="rounded-2xl border border-border bg-card p-5 sm:p-6">
            <div className="grid gap-4 sm:grid-cols-3">
              {CONTACT_CHANNELS.map(c => (
                <div key={c.label}>
                  <div className={cn('text-primary-ink', EYEBROW)}>{c.label}</div>
                  {c.href ? (
                    <a
                      href={c.href}
                      className="mt-1.5 block text-sm font-semibold text-foreground underline decoration-foreground/25 underline-offset-4 hover:decoration-primary-ink"
                    >
                      {c.value}
                    </a>
                  ) : (
                    <div className="mt-1.5 text-sm font-semibold text-foreground">{c.value}</div>
                  )}
                </div>
              ))}
            </div>

            <div className="mt-5 border-t border-border pt-5">
              <a
                href="mailto:wms@arka.com"
                className="inline-flex items-center gap-2 rounded-full bg-primary px-4 py-2 text-sm font-semibold text-primary-foreground transition-colors hover:bg-primary/90"
              >
                Email us
                <Icons.External className="h-4 w-4" />
              </a>
            </div>
          </div>
        </Section>

        {/* The old footer, minus its duplicate wordmark and its links. The
            wms.arka.com link is deliberately gone: that domain now serves this
            app, so the link pointed the reader back at the page they are on. */}
        <footer className="mt-2 flex flex-wrap items-center justify-between gap-3 border-t border-border pb-8 pt-6">
          <div>
            <div className="text-sm font-black tracking-tight text-foreground">ARKA</div>
            <div className={cn('text-muted-foreground', EYEBROW)}>WMS platform</div>
          </div>
          <div className="text-xs text-muted-foreground">© 2026 Arka. All rights reserved.</div>
        </footer>
      </PageContainer>
    );
  }

  window.AboutModule = AboutModule;
})();
