
// lol-icons.jsx — League of Legends styled SVG icons replacing emoji decoration

// Official Riot position icons rendered directly as inline SVGs (zero network/CORS dependency)
function RoleIcon({ pos, size = 22, color = '#C8AA6E', style = {} }) {
  const p = (pos || '').toString().toUpperCase();
  const normalized = p === 'MIDDLE' ? 'MID' : (p === 'BOT' || p === 'BOTTOM') ? 'ADC' : (p === 'SUP' || p === 'UTILITY') ? 'SUPPORT' : p;
  const s = { width: size, height: size, display: 'inline-block', verticalAlign: 'middle', flexShrink: 0, filter: 'drop-shadow(0 1px 1px rgba(0,0,0,0.3))', ...style };
  const bgFill = '#785a28';

  switch (normalized) {
    case 'TOP':
      return (
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 34 34" style={s}>
          <path opacity="0.5" fill={bgFill} fillRule="evenodd" d="M21,14H14v7h7V14Zm5-3V26L11.014,26l-4,4H30V7.016Z" />
          <polygon fill={color} points="4 4 4.003 28.045 9 23 9 9 23 9 28.045 4.003 4 4" />
        </svg>
      );
    case 'JUNGLE':
      return (
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 34 34" style={s}>
          <path fill={color} fillRule="evenodd" d="M25,3c-2.128,3.3-5.147,6.851-6.966,11.469A42.373,42.373,0,0,1,20,20a27.7,27.7,0,0,1,1-3C21,12.023,22.856,8.277,25,3ZM13,20c-1.488-4.487-4.76-6.966-9-9,3.868,3.136,4.422,7.52,5,12l3.743,3.312C14.215,27.917,16.527,30.451,17,31c4.555-9.445-3.366-20.8-8-28C11.67,9.573,13.717,13.342,13,20Zm8,5a15.271,15.271,0,0,1,0,2l4-4c0.578-4.48,1.132-8.864,5-12C24.712,13.537,22.134,18.854,21,25Z" />
        </svg>
      );
    case 'MID':
      return (
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 34 34" style={s}>
          <path opacity="0.5" fill={bgFill} fillRule="evenodd" d="M30,12.968l-4.008,4L26,26H17l-4,4H30ZM16.979,8L21,4H4V20.977L8,17,8,8h8.981Z" />
          <polygon fill={color} points="25 4 4 25 4 30 9 30 30 9 30 4 25 4" />
        </svg>
      );
    case 'ADC':
      return (
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 34 34" style={s}>
          <path opacity="0.5" fill={bgFill} fillRule="evenodd" d="M13,20h7V13H13v7ZM4,4V26.984l3.955-4L8,8,22.986,8l4-4H4Z" />
          <polygon fill={color} points="29.997 5.955 25 11 25 25 11 25 5.955 29.997 30 30 29.997 5.955" />
        </svg>
      );
    case 'SUPPORT':
      return (
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 34 34" style={s}>
          <path fill={color} fillRule="evenodd" d="M26,13c3.535,0,8-4,8-4H23l-3,3,2,7,5-2-3-4h2ZM22,5L20.827,3H13.062L12,5l5,6Zm-5,9-1-1L13,28l4,3,4-3L18,13ZM11,9H0s4.465,4,8,4h2L7,17l5,2,2-7Z" />
        </svg>
      );
    default:
      return null;
  }
}

// Generic LoL-styled glyphs replacing common UI emoji
function LolIcon({ name, size = 18, color = '#C8AA6E' }) {
  const s = { width: size, height: size, display: 'inline-block', verticalAlign: 'middle', flexShrink: 0 };
  switch (name) {
    case 'home': // hextech crystal
      return (
        <svg viewBox="0 0 24 24" style={s}>
          <polygon points="12,2 20,8 18,18 6,18 4,8" fill="none" stroke={color} strokeWidth="1.8" strokeLinejoin="round" />
          <polygon points="12,6 16,9 14,15 10,15 8,9" fill={color} opacity="0.45" />
        </svg>
      );
    case 'pool': // championship cup
      return (
        <svg viewBox="0 0 24 24" style={s} fill="none" stroke={color} strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round">
          <path d="M7 4 L17 4 L17 10 C17 13 15 15 12 15 C9 15 7 13 7 10 Z" fill={color} fillOpacity="0.3" />
          <path d="M7 6 L4 6 L4 9 C4 11 6 12 7 12" />
          <path d="M17 6 L20 6 L20 9 C20 11 18 12 17 12" />
          <path d="M10 15 L10 19 L14 19 L14 15 M8 19 L16 19" />
        </svg>
      );
    case 'comp': // crossed swords
      return (
        <svg viewBox="0 0 24 24" style={s} fill="none" stroke={color} strokeWidth="1.8" strokeLinecap="round">
          <path d="M4 4 L14 14 M16 16 L20 20" />
          <path d="M20 4 L10 14 M8 16 L4 20" />
          <circle cx="14" cy="14" r="1.5" fill={color} />
        </svg>
      );
    case 'draft': // pick bracket
      return (
        <svg viewBox="0 0 24 24" style={s} fill="none" stroke={color} strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round">
          <rect x="3" y="5" width="6" height="4" rx="0.5" />
          <rect x="3" y="15" width="6" height="4" rx="0.5" />
          <rect x="15" y="10" width="6" height="4" rx="0.5" />
          <path d="M9 7 L12 7 L12 12 L15 12 M9 17 L12 17 L12 12" />
        </svg>
      );
    case 'scout': // eye
      return (
        <svg viewBox="0 0 24 24" style={s} fill="none" stroke={color} strokeWidth="1.8">
          <path d="M2 12 C5 6 9 4 12 4 C15 4 19 6 22 12 C19 18 15 20 12 20 C9 20 5 18 2 12 Z" />
          <circle cx="12" cy="12" r="3.5" fill={color} fillOpacity="0.35" />
          <circle cx="12" cy="12" r="1.4" fill={color} />
        </svg>
      );
    case 'learn': // tome
      return (
        <svg viewBox="0 0 24 24" style={s} fill="none" stroke={color} strokeWidth="1.8" strokeLinejoin="round">
          <path d="M4 5 C7 4 10 4 12 6 C14 4 17 4 20 5 L20 19 C17 18 14 18 12 20 C10 18 7 18 4 19 Z" />
          <path d="M12 6 L12 20" />
        </svg>
      );
    case 'vod': // play
      return (
        <svg viewBox="0 0 24 24" style={s} stroke={color} strokeWidth="1.8" fill="none">
          <rect x="3" y="5" width="18" height="14" rx="2" />
          <polygon points="10,9 16,12 10,15" fill={color} />
        </svg>
      );
    case 'patch': // shard
      return (
        <svg viewBox="0 0 24 24" style={s} fill="none" stroke={color} strokeWidth="1.8" strokeLinejoin="round">
          <polygon points="12,3 19,9 16,21 8,21 5,9" />
          <path d="M12 3 L12 21 M5 9 L19 9" />
        </svg>
      );
    case 'star':
      return (
        <svg viewBox="0 0 24 24" style={s} fill={color}>
          <polygon points="12,2 14.6,9 22,9.5 16.3,14.1 18.2,21 12,17 5.8,21 7.7,14.1 2,9.5 9.4,9" />
        </svg>
      );
    case 'check':
      return (
        <svg viewBox="0 0 24 24" style={s} fill="none" stroke={color} strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round">
          <path d="M4 12 L10 18 L20 6" />
        </svg>
      );
    case 'flame':
      return (
        <svg viewBox="0 0 24 24" style={s} fill={color}>
          <path d="M12 2 C9 7 6 8 6 13 C6 17 9 21 12 21 C15 21 18 17 18 13 C18 10 16 9 15 7 C14 9 13 10 12 10 C11 8 12 5 12 2 Z" />
        </svg>
      );
    case 'sparkle':
      return (
        <svg viewBox="0 0 24 24" style={s} fill={color}>
          <path d="M12 2 L13.5 10.5 L22 12 L13.5 13.5 L12 22 L10.5 13.5 L2 12 L10.5 10.5 Z" />
        </svg>
      );
    default:
      return <span style={{ display: 'inline-block', width: size }} />;
  }
}

Object.assign(window, { RoleIcon, LolIcon });
