// icons.jsx — Custom-drawn icons for CheapCarrots (no emoji-only chrome)

const Icon = ({ d, size = 22, stroke = 'currentColor', sw = 1.8, fill = 'none', children, vb = 24 }) => (
  <svg width={size} height={size} viewBox={`0 0 ${vb} ${vb}`} fill={fill} stroke={stroke} strokeWidth={sw} strokeLinecap="round" strokeLinejoin="round">
    {d ? <path d={d}/> : children}
  </svg>
);

const IconSearch    = (p) => <Icon {...p}><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></Icon>;
const IconCart      = (p) => <Icon {...p}><path d="M3 4h2l2.5 12h11l2-8H6"/><circle cx="9" cy="20" r="1.6"/><circle cx="17" cy="20" r="1.6"/></Icon>;
const IconHome      = (p) => <Icon {...p}><path d="M3 11.5 12 4l9 7.5"/><path d="M5 10v10h14V10"/></Icon>;
const IconList      = (p) => <Icon {...p}><path d="M8 6h12M8 12h12M8 18h12"/><circle cx="4" cy="6"  r="1.2" fill="currentColor"/><circle cx="4" cy="12" r="1.2" fill="currentColor"/><circle cx="4" cy="18" r="1.2" fill="currentColor"/></Icon>;
const IconUser      = (p) => <Icon {...p}><circle cx="12" cy="8" r="4"/><path d="M4 21c1.5-4 5-6 8-6s6.5 2 8 6"/></Icon>;
const IconBolt      = (p) => <Icon {...p}><path d="M13 2 4 14h7l-1 8 9-12h-7l1-8Z"/></Icon>;
const IconTruck     = (p) => <Icon {...p}><path d="M2 7h11v9H2zM13 10h5l3 3v3h-8"/><circle cx="6" cy="18" r="2"/><circle cx="17" cy="18" r="2"/></Icon>;
const IconBag       = (p) => <Icon {...p}><path d="M5 8h14l-1 12H6L5 8z"/><path d="M9 8a3 3 0 0 1 6 0"/></Icon>;
const IconStar      = (p) => <Icon {...p} fill="currentColor" sw={0}><path d="M12 2.5l2.9 6 6.6.9-4.8 4.6 1.2 6.6L12 17.4 6.1 20.6l1.2-6.6L2.5 9.4l6.6-.9z"/></Icon>;
const IconLeaf      = (p) => <Icon {...p}><path d="M4 20c0-9 7-16 16-16 0 9-7 16-16 16z"/><path d="M4 20c4-4 8-8 16-16"/></Icon>;
const IconPin       = (p) => <Icon {...p}><path d="M12 22s7-7 7-13a7 7 0 0 0-14 0c0 6 7 13 7 13z"/><circle cx="12" cy="9" r="2.5"/></Icon>;
const IconClock     = (p) => <Icon {...p}><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></Icon>;
const IconChevR     = (p) => <Icon {...p}><path d="m9 5 7 7-7 7"/></Icon>;
const IconChevL     = (p) => <Icon {...p}><path d="m15 5-7 7 7 7"/></Icon>;
const IconChevD     = (p) => <Icon {...p}><path d="m5 9 7 7 7-7"/></Icon>;
const IconPlus      = (p) => <Icon {...p}><path d="M12 5v14M5 12h14"/></Icon>;
const IconMinus     = (p) => <Icon {...p}><path d="M5 12h14"/></Icon>;
const IconCheck     = (p) => <Icon {...p}><path d="m4 12 5 5L20 6"/></Icon>;
const IconX         = (p) => <Icon {...p}><path d="m6 6 12 12M18 6 6 18"/></Icon>;
const IconHeart     = (p) => <Icon {...p}><path d="M12 20s-7-4.5-7-10a4 4 0 0 1 7-2.5A4 4 0 0 1 19 10c0 5.5-7 10-7 10z"/></Icon>;
const IconFilter    = (p) => <Icon {...p}><path d="M3 5h18l-7 8v6l-4-2v-4z"/></Icon>;
const IconScan      = (p) => <Icon {...p}><path d="M3 8V5h3M21 8V5h-3M3 16v3h3M21 16v3h-3"/><path d="M7 8v8M11 8v8M15 8v8M19 8v8" sw="1.4"/></Icon>;
const IconSettings  = (p) => <Icon {...p}><circle cx="12" cy="12" r="3"/><path d="M19 12a7 7 0 0 0-.1-1.2l2-1.6-2-3.4-2.4.9a7 7 0 0 0-2-1.2L14 3h-4l-.5 2.5a7 7 0 0 0-2 1.2l-2.4-.9-2 3.4 2 1.6A7 7 0 0 0 5 12c0 .4 0 .8.1 1.2l-2 1.6 2 3.4 2.4-.9c.6.5 1.3.9 2 1.2L10 21h4l.5-2.5c.7-.3 1.4-.7 2-1.2l2.4.9 2-3.4-2-1.6c0-.4.1-.8.1-1.2z"/></Icon>;
const IconSparkle   = (p) => <Icon {...p}><path d="M12 3v6M12 15v6M3 12h6M15 12h6"/><path d="m6 6 4 4M14 14l4 4M18 6l-4 4M10 14l-4 4" sw="1.2"/></Icon>;
const IconBookmark  = (p) => <Icon {...p}><path d="M6 4h12v17l-6-4-6 4z"/></Icon>;
const IconRepeat    = (p) => <Icon {...p}><path d="M3 12V8a3 3 0 0 1 3-3h12l-3-3M21 12v4a3 3 0 0 1-3 3H6l3 3"/></Icon>;
const IconStore     = (p) => <Icon {...p}><path d="M3 9 5 4h14l2 5"/><path d="M3 9v11h18V9"/><path d="M3 9c0 2 1.5 3 3 3s3-1 3-3c0 2 1.5 3 3 3s3-1 3-3c0 2 1.5 3 3 3s3-1 3-3"/></Icon>;
const IconDots      = (p) => <Icon {...p} fill="currentColor" sw={0}><circle cx="6" cy="12" r="1.6"/><circle cx="12" cy="12" r="1.6"/><circle cx="18" cy="12" r="1.6"/></Icon>;
const IconArrowR    = (p) => <Icon {...p}><path d="M5 12h14m-5-5 5 5-5 5"/></Icon>;
const IconBell      = (p) => <Icon {...p}><path d="M6 9a6 6 0 0 1 12 0c0 5 2 7 2 7H4s2-2 2-7z"/><path d="M10 20a2 2 0 0 0 4 0"/></Icon>;
const IconFlame     = (p) => <Icon {...p}><path d="M12 3s5 4 5 9a5 5 0 0 1-10 0c0-2 1-3 1-3s2 1 2 3c0-3 2-5 2-9z"/></Icon>;

// Quality-mark badge (for organic, etc.)
const Pill = ({ children, bg = '#eee', color = '#333', size = 11, weight = 600, style = {} }) => (
  <span style={{
    display: 'inline-flex', alignItems: 'center', gap: 4,
    padding: '3px 8px', borderRadius: 999, background: bg, color,
    fontSize: size, fontWeight: weight, letterSpacing: 0.1,
    whiteSpace: 'nowrap', ...style
  }}>{children}</span>
);

// Star-row helper (uses IconStar)
const Stars = ({ rating, color = '#F2A035', size = 12 }) => (
  <span style={{ display: 'inline-flex', gap: 1, color }}>
    {[1,2,3,4,5].map(i => (
      <span key={i} style={{ opacity: i <= Math.round(rating) ? 1 : 0.22 }}>
        <IconStar size={size}/>
      </span>
    ))}
  </span>
);

// Logo placeholder per store (rounded square w/ first letter, store color)
const StoreMark = ({ store, size = 36, radius = 10 }) => (
  <div style={{
    width: size, height: size, borderRadius: radius,
    background: store.color, color: '#fff',
    display: 'flex', alignItems: 'center', justifyContent: 'center',
    fontFamily: '"DM Serif Display", Georgia, serif', fontWeight: 400,
    fontSize: size * 0.5, lineHeight: 1, letterSpacing: -0.5,
    boxShadow: '0 1px 0 rgba(0,0,0,0.06)',
  }}>{store.name[0]}</div>
);

Object.assign(window, {
  IconSearch, IconCart, IconHome, IconList, IconUser, IconBolt, IconTruck,
  IconBag, IconStar, IconLeaf, IconPin, IconClock, IconChevR, IconChevL, IconChevD,
  IconPlus, IconMinus, IconCheck, IconX, IconHeart, IconFilter, IconScan,
  IconSettings, IconSparkle, IconBookmark, IconRepeat, IconStore, IconDots,
  IconArrowR, IconBell, IconFlame,
  Pill, Stars, StoreMark,
});
