/* global React */
const { useState, useEffect, useRef, useMemo } = React;

// Wordmark / brand mark — a quiet "D" mark
const BrandMark = ({ size = 22, color = "currentColor" }) => (
  <svg className="brand-mark" width={size} height={size} viewBox="0 0 22 22" fill="none">
    <rect x="0.5" y="0.5" width="21" height="21" rx="5.5" stroke={color} opacity="0.18"/>
    <path d="M6.5 5.5 H11 a5.5 5.5 0 0 1 5.5 5.5 v0 a5.5 5.5 0 0 1 -5.5 5.5 H6.5 z" fill={color}/>
    <circle cx="11" cy="11" r="1.6" fill="#F6F4EE"/>
  </svg>
);

const Arrow = ({ size = 14 }) => (
  <svg width={size} height={size} viewBox="0 0 14 14" fill="none">
    <path d="M3 11 L11 3 M11 3 H5.5 M11 3 V8.5" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round"/>
  </svg>
);

const ArrowRight = ({ size = 14 }) => (
  <svg width={size} height={size} viewBox="0 0 14 14" fill="none">
    <path d="M2.5 7 H11 M11 7 L7.5 3.5 M11 7 L7.5 10.5" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round"/>
  </svg>
);

const SendIcon = ({ size = 16 }) => (
  <svg width={size} height={size} viewBox="0 0 16 16" fill="none">
    <path d="M3 8 H12.5 M12.5 8 L8.5 4 M12.5 8 L8.5 12" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round"/>
  </svg>
);

const Sparkle = ({ size = 14 }) => (
  <svg width={size} height={size} viewBox="0 0 14 14" fill="none">
    <path d="M7 1 L7.9 5.1 L12 6 L7.9 6.9 L7 11 L6.1 6.9 L2 6 L6.1 5.1 Z" fill="currentColor"/>
    <circle cx="11.5" cy="11" r="1" fill="currentColor"/>
  </svg>
);

// Tiny glyphs for capability tiles
const Glyph = ({ kind, size = 36 }) => {
  const stroke = "currentColor";
  const props = { width: size, height: size, viewBox: "0 0 36 36", fill: "none" };
  switch (kind) {
    case "storefront":
      return (
        <svg {...props}>
          <rect x="5" y="8" width="26" height="22" rx="1" stroke={stroke} strokeWidth="1.2"/>
          <path d="M5 12 H31" stroke={stroke} strokeWidth="1.2"/>
          <circle cx="9" cy="10" r="0.6" fill={stroke}/>
          <circle cx="11.5" cy="10" r="0.6" fill={stroke}/>
          <rect x="9" y="17" width="6" height="9" stroke={stroke} strokeWidth="1.2"/>
          <rect x="18" y="17" width="9" height="4" stroke={stroke} strokeWidth="1.2"/>
          <rect x="18" y="23" width="9" height="3" stroke={stroke} strokeWidth="1.2"/>
        </svg>
      );
    case "catalog":
      return (
        <svg {...props}>
          <rect x="5" y="6" width="11" height="11" rx="1" stroke={stroke} strokeWidth="1.2"/>
          <rect x="20" y="6" width="11" height="11" rx="1" stroke={stroke} strokeWidth="1.2"/>
          <rect x="5" y="21" width="11" height="9" rx="1" stroke={stroke} strokeWidth="1.2"/>
          <rect x="20" y="21" width="11" height="9" rx="1" stroke={stroke} strokeWidth="1.2"/>
          <path d="M9 28 H12 M24 28 H27" stroke={stroke} strokeWidth="1.2" strokeLinecap="round"/>
        </svg>
      );
    case "brand":
      return (
        <svg {...props}>
          <circle cx="13" cy="14" r="6" stroke={stroke} strokeWidth="1.2"/>
          <circle cx="22" cy="14" r="6" stroke={stroke} strokeWidth="1.2"/>
          <path d="M9 26 L27 26" stroke={stroke} strokeWidth="1.2" strokeLinecap="round"/>
          <path d="M11 30 H25" stroke={stroke} strokeWidth="1.2" strokeLinecap="round" strokeDasharray="2 2"/>
        </svg>
      );
    case "checkout":
      return (
        <svg {...props}>
          <rect x="4" y="10" width="28" height="17" rx="2" stroke={stroke} strokeWidth="1.2"/>
          <path d="M4 16 H32" stroke={stroke} strokeWidth="1.2"/>
          <rect x="8" y="20" width="6" height="3" stroke={stroke} strokeWidth="1.2"/>
          <path d="M20 22 H28" stroke={stroke} strokeWidth="1.2" strokeLinecap="round"/>
        </svg>
      );
    case "ops":
      return (
        <svg {...props}>
          <circle cx="18" cy="18" r="11" stroke={stroke} strokeWidth="1.2"/>
          <path d="M18 9 V13 M18 23 V27 M9 18 H13 M23 18 H27 M11.5 11.5 L14.5 14.5 M21.5 21.5 L24.5 24.5 M11.5 24.5 L14.5 21.5 M21.5 14.5 L24.5 11.5" stroke={stroke} strokeWidth="1.2" strokeLinecap="round"/>
          <circle cx="18" cy="18" r="3" stroke={stroke} strokeWidth="1.2"/>
        </svg>
      );
    case "analytics":
      return (
        <svg {...props}>
          <path d="M5 28 H31" stroke={stroke} strokeWidth="1.2" strokeLinecap="round"/>
          <path d="M5 23 L11 18 L16 22 L23 12 L31 7" stroke={stroke} strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round"/>
          <circle cx="11" cy="18" r="1.4" fill={stroke}/>
          <circle cx="16" cy="22" r="1.4" fill={stroke}/>
          <circle cx="23" cy="12" r="1.4" fill={stroke}/>
          <circle cx="31" cy="7" r="1.4" fill={stroke}/>
        </svg>
      );
    case "infra":
      return (
        <svg {...props}>
          <rect x="5" y="7" width="26" height="6" rx="1" stroke={stroke} strokeWidth="1.2"/>
          <rect x="5" y="15" width="26" height="6" rx="1" stroke={stroke} strokeWidth="1.2"/>
          <rect x="5" y="23" width="26" height="6" rx="1" stroke={stroke} strokeWidth="1.2"/>
          <circle cx="9" cy="10" r="0.8" fill={stroke}/>
          <circle cx="9" cy="18" r="0.8" fill={stroke}/>
          <circle cx="9" cy="26" r="0.8" fill={stroke}/>
        </svg>
      );
    default:
      return null;
  }
};

window.BrandMark = BrandMark;
window.Arrow = Arrow;
window.ArrowRight = ArrowRight;
window.SendIcon = SendIcon;
window.Sparkle = Sparkle;
window.Glyph = Glyph;
