// Inline SVG icon set — 24px viewBox, stroke 2, no fills unless noted.
// Pass props { size, color }.

const Icon = ({ d, size = 18, color = 'currentColor', sw = 2, fill = 'none', vb = 24 }) => (
  <svg width={size} height={size} viewBox={`0 0 ${vb} ${vb}`} fill={fill} stroke={color} strokeWidth={sw} strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
    {d}
  </svg>
);

const ICONS = {
  search:  <Icon d={<><circle cx="11" cy="11" r="7" /><path d="m20 20-3.5-3.5" /></>} />,
  bell:    <Icon d={<><path d="M6 8a6 6 0 0 1 12 0c0 5 2 6 2 8H4c0-2 2-3 2-8" /><path d="M10 20a2 2 0 0 0 4 0" /></>} />,
  plus:    <Icon d={<><path d="M12 5v14M5 12h14" /></>} />,
  close:   <Icon d={<><path d="M6 6l12 12M18 6 6 18" /></>} />,
  back:    <Icon d={<><path d="M15 18 9 12l6-6" /></>} />,
  next:    <Icon d={<><path d="m9 18 6-6-6-6" /></>} />,
  chev:    <Icon d={<><path d="m6 9 6 6 6-6" /></>} />,
  check:   <Icon d={<><path d="M5 12.5 10 17.5 19 7" /></>} />,
  spark:   <Icon d={<><path d="M3 17 9 11l4 4 8-8" /></>} />,
  cube:    <Icon d={<><path d="m12 3 9 5-9 5-9-5 9-5z" /><path d="m3 8 9 5 9-5M3 13l9 5 9-5" /></>} />,
  bolt:    <Icon d={<><path d="M13 3 4 14h7l-1 7 9-11h-7l1-7z" /></>} />,
  scale:   <Icon d={<><path d="M12 4v16M5 8h14M3 14l4-6 4 6M13 14l4-6 4 6" /></>} />,
  shield:  <Icon d={<><path d="M12 3 4 6v6c0 5 3.5 8 8 9 4.5-1 8-4 8-9V6l-8-3z" /></>} />,
  target:  <Icon d={<><circle cx="12" cy="12" r="9" /><circle cx="12" cy="12" r="5" /><circle cx="12" cy="12" r="1.5" fill="currentColor" stroke="none" /></>} />,
  cal:     <Icon d={<><rect x="3" y="5" width="18" height="16" rx="2" /><path d="M3 10h18M8 3v4M16 3v4" /></>} />,
  bookmark:<Icon d={<><path d="M6 3h12v18l-6-4-6 4z" /></>} />,
  cog:     <Icon d={<><circle cx="12" cy="12" r="3" /><path d="M19.4 15a1.7 1.7 0 0 0 .3 1.9l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.9-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1.1-1.6 1.7 1.7 0 0 0-1.9.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.9 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1A1.7 1.7 0 0 0 4.7 9a1.7 1.7 0 0 0-.3-1.9l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.9.3H9A1.7 1.7 0 0 0 10 3.1V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.9-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.9V9a1.7 1.7 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z" /></>} />,
  out:     <Icon d={<><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4M16 17l5-5-5-5M21 12H9" /></>} />,
  copy:    <Icon d={<><rect x="9" y="9" width="11" height="11" rx="2" /><path d="M5 15V5a2 2 0 0 1 2-2h10" /></>} />,
  arrowUp: <Icon d={<><path d="M12 19V5M5 12l7-7 7 7" /></>} />,
  arrowDn: <Icon d={<><path d="M12 5v14M5 12l7 7 7-7" /></>} />,
  layers:  <Icon d={<><path d="m12 2 10 6-10 6L2 8l10-6z" /><path d="M2 14l10 6 10-6" /></>} />,
  flow:    <Icon d={<><path d="M4 7h12M4 12h16M4 17h8" /></>} />,
  walletI: <Icon d={<><path d="M3 7v12a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-8a2 2 0 0 0-2-2H5a2 2 0 0 1 0-4h12" /><circle cx="17" cy="14" r="1.4" fill="currentColor" stroke="none" /></>} />,
  dollar:  <Icon d={<><path d="M12 3v18M8 7h6a3 3 0 0 1 0 6h-4a3 3 0 0 0 0 6h7" /></>} />,
  alertI:  <Icon d={<><circle cx="12" cy="12" r="9" /><path d="M12 7v6M12 17h.01" /></>} />,
  info:    <Icon d={<><circle cx="12" cy="12" r="9" /><path d="M12 11v6M12 7h.01" /></>} />,
};

// === BRAND TICKER LOGOS ===
// Real-feeling brand glyphs as inline SVG. Each renders inside a 32-unit viewBox.

const BRAND_LOGOS = {
  BTC: ({ s = 32 }) => (
    <svg width={s} height={s} viewBox="0 0 32 32" aria-hidden="true">
      <circle cx="16" cy="16" r="16" fill="#F7931A" />
      <path d="M21.4 14.2c.3-1.9-1.2-2.9-3.2-3.6l.7-2.6-1.6-.4-.6 2.5c-.4-.1-.9-.2-1.3-.3l.6-2.5-1.6-.4-.7 2.6c-.4-.1-.7-.2-1.1-.2l-2.2-.6-.4 1.7s1.2.3 1.2.3c.6.2.7.6.7 1l-.7 3-.4 1.7c-.1.1-.3.2-.5.2l-1.2-.3-.8 1.8 2 .5c.4.1.7.2 1.1.3l-.7 2.7 1.6.4.7-2.6c.4.1.9.2 1.3.4l-.7 2.6 1.6.4.7-2.7c2.7.5 4.7.3 5.6-2.2.7-2-.1-3.1-1.5-3.9 1-.3 1.8-.9 2-2.3zm-3.6 5.1c-.5 2-3.9 1-5 .7l.9-3.6c1.1.3 4.6.8 4.1 3zm.5-5.1c-.5 1.8-3.3 1-4.2.7l.8-3.3c.9.2 3.9.7 3.4 2.6z" fill="#fff"/>
    </svg>
  ),
  ETH: ({ s = 32 }) => (
    <svg width={s} height={s} viewBox="0 0 32 32" aria-hidden="true">
      <circle cx="16" cy="16" r="16" fill="#627EEA" />
      <g fill="#fff" fillRule="nonzero">
        <path fillOpacity=".602" d="M16.5 4v8.87l7.5 3.35z"/>
        <path d="M16.5 4 9 16.22l7.5-3.35z"/>
        <path fillOpacity=".602" d="M16.5 21.97v6.03l7.5-10.37z"/>
        <path d="M16.5 28v-6.03L9 17.63z"/>
        <path fillOpacity=".2" d="m16.5 20.57 7.5-4.35-7.5-3.35z"/>
        <path fillOpacity=".602" d="m9 16.22 7.5 4.35v-7.7z"/>
      </g>
    </svg>
  ),
  HYPE: ({ s = 32 }) => (
    <svg width={s} height={s} viewBox="0 0 32 32" aria-hidden="true">
      <rect width="32" height="32" rx="16" fill="#072723" />
      {/* Hyperliquid mark — sine-wave-ish stylized H */}
      <path d="M7 11 C 9 11, 9 16, 11 16 C 13 16, 13 11, 16 11 C 19 11, 19 21, 22 21 C 24 21, 24 16, 26 16"
        stroke="#97FCE4" strokeWidth="2.4" fill="none" strokeLinecap="round" />
    </svg>
  ),
  NVDA: ({ s = 32 }) => (
    <svg width={s} height={s} viewBox="0 0 32 32" aria-hidden="true">
      <rect width="32" height="32" rx="4" fill="#76B900" />
      {/* Stylized NVIDIA "eye" */}
      <path d="M9 11.5 C 12 9, 18 9, 22 12 L 22 20.5 C 18 23, 12 23, 9 20.5 Z"
        fill="none" stroke="#fff" strokeWidth="1.6" />
      <path d="M11.5 13 C 14 11.5, 18 11.5, 20 13.5 L 20 18.5 C 18 20.5, 14 20.5, 11.5 19 Z"
        fill="#fff" />
      <circle cx="16" cy="16" r="2.2" fill="#76B900" />
    </svg>
  ),
  SPX: ({ s = 32 }) => (
    <svg width={s} height={s} viewBox="0 0 32 32" aria-hidden="true">
      <rect width="32" height="32" rx="4" fill="#0A1F44" />
      <text x="16" y="14.5" textAnchor="middle" fontFamily="Georgia, serif" fontSize="9" fontWeight="700" fill="#E8C547" letterSpacing="0.5">S&amp;P</text>
      <text x="16" y="23" textAnchor="middle" fontFamily="Georgia, serif" fontSize="8" fontWeight="700" fill="#fff" letterSpacing="1">500</text>
      <line x1="6" y1="16" x2="11" y2="16" stroke="#E8C547" strokeWidth="0.6" />
      <line x1="21" y1="16" x2="26" y2="16" stroke="#E8C547" strokeWidth="0.6" />
    </svg>
  ),
  AAPL: ({ s = 32 }) => (
    <svg width={s} height={s} viewBox="0 0 32 32" aria-hidden="true">
      <rect width="32" height="32" rx="6" fill="#0F0F0F" />
      <path d="M19.6 16.7c-.02-2.18 1.78-3.22 1.86-3.27-1.02-1.49-2.6-1.69-3.16-1.71-1.34-.13-2.62.79-3.3.79-.69 0-1.74-.78-2.86-.75-1.47.02-2.83.85-3.59 2.16-1.53 2.65-.39 6.58 1.1 8.74.73 1.06 1.59 2.24 2.72 2.2 1.09-.04 1.5-.71 2.83-.71 1.32 0 1.69.71 2.85.69 1.18-.02 1.93-1.07 2.65-2.13.83-1.22 1.18-2.4 1.2-2.46-.03-.01-2.3-.88-2.32-3.55zM17.4 10.3c.6-.73 1-1.74.89-2.74-.86.04-1.91.58-2.54 1.3-.56.64-1.05 1.66-.92 2.65.96.07 1.95-.49 2.57-1.21z" fill="#fff"/>
    </svg>
  ),
  MSFT: ({ s = 32 }) => (
    <svg width={s} height={s} viewBox="0 0 32 32" aria-hidden="true">
      <rect width="32" height="32" rx="4" fill="#0C1014" />
      <rect x="7"  y="7"  width="8" height="8" fill="#F25022" />
      <rect x="17" y="7"  width="8" height="8" fill="#7FBA00" />
      <rect x="7"  y="17" width="8" height="8" fill="#00A4EF" />
      <rect x="17" y="17" width="8" height="8" fill="#FFB900" />
    </svg>
  ),
  TSLA: ({ s = 32 }) => (
    <svg width={s} height={s} viewBox="0 0 32 32" aria-hidden="true">
      <rect width="32" height="32" rx="6" fill="#000" />
      <path d="M16 9 L8.5 9.8 9.5 12 13.2 11.4 13.2 23 18.8 23 18.8 11.4 22.5 12 23.5 9.8z" fill="#E31937"/>
    </svg>
  ),
  GOOGL: ({ s = 32 }) => (
    <svg width={s} height={s} viewBox="0 0 32 32" aria-hidden="true">
      <rect width="32" height="32" rx="6" fill="#fff" />
      <path d="M16 9.6c1.7 0 3.2.6 4.4 1.7l-1.8 1.8c-.7-.7-1.6-1-2.6-1-2.2 0-4 1.8-4 4 0 2.2 1.8 4 4 4 1.9 0 3.2-1.1 3.6-2.8h-3.6V14.6h6c.1.4.1.8.1 1.4 0 4-2.7 6.8-6.5 6.8-3.7 0-6.7-3-6.7-6.7s3-6.5 6.7-6.5z" fill="#4285F4"/>
      <path d="M22 16c0 .6 0 1-.1 1.4h-2.3c.1-.4.1-.9.1-1.4s0-1-.1-1.4h-3.7v2.8h2.1z" fill="#34A853"/>
    </svg>
  ),
  AMZN: ({ s = 32 }) => (
    <svg width={s} height={s} viewBox="0 0 32 32" aria-hidden="true">
      <rect width="32" height="32" rx="6" fill="#131A22" />
      <text x="16" y="17" textAnchor="middle" fontFamily="Georgia, serif" fontSize="9" fontWeight="700" fill="#fff">amazon</text>
      <path d="M9 22 C 14 25, 20 25, 25 21" stroke="#FF9900" strokeWidth="2" fill="none" strokeLinecap="round" />
      <path d="M22.5 19 L 25 21 L 23 23.4" stroke="#FF9900" strokeWidth="2" fill="none" strokeLinecap="round" strokeLinejoin="round"/>
    </svg>
  ),
  GOLD: ({ s = 32 }) => (
    <svg width={s} height={s} viewBox="0 0 32 32" aria-hidden="true">
      <defs>
        <linearGradient id="vd-gold" x1="0" x2="1" y1="0" y2="1">
          <stop offset="0%" stopColor="#F4D03F" />
          <stop offset="50%" stopColor="#D4AC0D" />
          <stop offset="100%" stopColor="#9A7D0A" />
        </linearGradient>
      </defs>
      <circle cx="16" cy="16" r="16" fill="url(#vd-gold)" />
      <text x="16" y="20" textAnchor="middle" fontFamily="Georgia, serif" fontSize="13" fontWeight="700" fill="#5A3E0A" letterSpacing="0">Au</text>
      <circle cx="16" cy="16" r="13" fill="none" stroke="#FCEFB4" strokeWidth="0.6" opacity="0.6"/>
    </svg>
  ),
};

// Asset glyph — uses real brand logo for known tickers, falls back to ticker tile.
const AssetGlyph = ({ sym, size = 28, animate = false }) => {
  const Brand = BRAND_LOGOS[sym];
  const wrapStyle = {
    width: size, height: size,
    display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
    flex: '0 0 auto',
    transition: 'transform 280ms cubic-bezier(.2,1.2,.4,1), filter 240ms var(--ease)',
    transformOrigin: 'center',
  };
  if (Brand) {
    return (
      <div className={animate ? 'vd-glyph' : undefined} style={wrapStyle}>
        <Brand s={size} />
      </div>
    );
  }
  const a = window.VD.VD_ASSETS.find(x => x.sym === sym);
  const c = a ? a.color : '#99A1AA';
  return (
    <div className={animate ? 'vd-glyph' : undefined} style={{
      ...wrapStyle,
      borderRadius: 4,
      background: '#0C1014',
      color: c,
      border: `1px solid ${c}55`,
      fontFamily: 'JetBrains Mono, monospace',
      fontWeight: 700,
      fontSize: 10,
    }}>{sym.slice(0,3)}</div>
  );
};

// Big serif Verdict wordmark for the top-left.
const Logo = ({ size = 26 }) => (
  <svg width={size * 1.15} height={size} viewBox="0 0 36 32" aria-hidden="true">
    {/* Bold "V" mark — wider, more confident, with overlapping inner shape */}
    <path d="M5 6 L18 28 L31 6"
      stroke="#E8FF52" strokeWidth="3.2" fill="none"
      strokeLinecap="square" strokeLinejoin="miter" />
    {/* Inner tick — punched out using page bg so the chisel reads cleanly */}
    <path d="M11.5 6 L18 17 L24.5 6"
      stroke="#07090C" strokeWidth="2.2" fill="none" />
    {/* Punctuation dot at the apex */}
    <rect x="16.5" y="25.5" width="3" height="3" fill="#E8FF52" />
  </svg>
);

window.VDIcons = { ICONS, Icon, Logo, AssetGlyph, BRAND_LOGOS };
