// sport-icons.jsx — Per-sport inline-SVG glyphs.
//
// Monochrome line-art glyphs that inherit color via `currentColor`. Each
// tile in the home/sports lists wraps the glyph in its own gold or dim
// background, so the glyph itself is just stroke-on-transparent.
//
// API: <SportGlyph id="fb" size={18} /> and
//      <SportTile sport={sport} size={40} variant="gold|dim" />.

function SportGlyph({ id, sportId, size = 18, style }) {
  const key = id || sportId;
  const stroke = 'currentColor';
  const sw = 1.6;
  const s = {
    width: size, height: size, display: 'block', flexShrink: 0,
    ...(style || {}),
  };

  switch (key) {
    case 'fb':
      return (
        <svg viewBox="0 0 24 24" style={s} fill="none">
          <ellipse cx="12" cy="12" rx="9" ry="5.4" transform="rotate(-30 12 12)" stroke={stroke} strokeWidth={sw} />
          <path d="M9.5 14.5L14.5 9.5M10.5 10.5L13.5 13.5M11 9L13 11M11 13L13 15" stroke={stroke} strokeWidth={sw - 0.2} strokeLinecap="round" />
        </svg>
      );
    case 'mbb':
    case 'wbb':
      return (
        <svg viewBox="0 0 24 24" style={s} fill="none">
          <circle cx="12" cy="12" r="8.4" stroke={stroke} strokeWidth={sw} />
          <path d="M3.6 12h16.8M12 3.6v16.8M6 6c2.5 2 2.5 10 0 12M18 6c-2.5 2-2.5 10 0 12" stroke={stroke} strokeWidth={sw - 0.2} />
        </svg>
      );
    case 'bsb':
      return (
        <svg viewBox="0 0 24 24" style={s} fill="none">
          <circle cx="12" cy="12" r="8.4" stroke={stroke} strokeWidth={sw} />
          <path d="M5.4 7.5C7.5 9 8.5 12 8.5 14.5M18.6 16.5C16.5 15 15.5 12 15.5 9.5" stroke={stroke} strokeWidth={sw - 0.2} strokeLinecap="round" />
        </svg>
      );
    case 'soc':
    case 'soc_w':
    case 'soc_m':
      return (
        <svg viewBox="0 0 24 24" style={s} fill="none">
          <circle cx="12" cy="12" r="8.4" stroke={stroke} strokeWidth={sw} />
          <path d="M12 7.5l3.5 2.6-1.3 4.1h-4.4L8.5 10.1z" stroke={stroke} strokeWidth={sw - 0.2} strokeLinejoin="round" />
          <path d="M12 7.5V4M15.5 10.1l3-1.7M14.2 14.2l1.8 3M9.8 14.2l-1.8 3M8.5 10.1L5.5 8.4" stroke={stroke} strokeWidth={sw - 0.2} strokeLinecap="round" />
        </svg>
      );
    case 'vb':
      return (
        <svg viewBox="0 0 24 24" style={s} fill="none">
          <circle cx="12" cy="12" r="8.4" stroke={stroke} strokeWidth={sw} />
          <path d="M12 3.6c2 4 2 12-2 16M12 3.6c-4 2-7 8-6 14M20.4 12c-4-1-11 0-14 4" stroke={stroke} strokeWidth={sw - 0.2} strokeLinecap="round" />
        </svg>
      );
    case 'gym':
      return (
        <svg viewBox="0 0 24 24" style={s} fill="none">
          <circle cx="12" cy="6" r="2.2" stroke={stroke} strokeWidth={sw} />
          <path d="M12 8.2v5M8 11l8 0M9 20l3-7 3 7M7 13l5-2 5 2" stroke={stroke} strokeWidth={sw} strokeLinecap="round" strokeLinejoin="round" />
        </svg>
      );
    case 'wr':
      return (
        <svg viewBox="0 0 24 24" style={s} fill="none">
          <circle cx="9" cy="6" r="2" stroke={stroke} strokeWidth={sw} />
          <circle cx="16" cy="8" r="2" stroke={stroke} strokeWidth={sw} />
          <path d="M7 20l3-6 4 1 3 5M9 14l-2-4 4-2 4 4-2 3" stroke={stroke} strokeWidth={sw} strokeLinecap="round" strokeLinejoin="round" />
        </svg>
      );
    case 'rifle':
      return (
        <svg viewBox="0 0 24 24" style={s} fill="none">
          <circle cx="17" cy="7" r="3.2" stroke={stroke} strokeWidth={sw} />
          <path d="M17 3.8v6.4M13.8 7h6.4" stroke={stroke} strokeWidth={sw - 0.2} />
          <path d="M4 18l9-9M5.5 19.5l1.5-1.5M8 17l1.5-1.5" stroke={stroke} strokeWidth={sw} strokeLinecap="round" />
        </svg>
      );
    case 'xc':
    case 'trk':
      return (
        <svg viewBox="0 0 24 24" style={s} fill="none">
          <circle cx="14" cy="5.5" r="1.8" stroke={stroke} strokeWidth={sw} />
          <path d="M7 20l3-5 3-2 3 4 3-1M9 12l3-3 3 1 1 3" stroke={stroke} strokeWidth={sw} strokeLinecap="round" strokeLinejoin="round" />
        </svg>
      );
    case 'swim':
      return (
        <svg viewBox="0 0 24 24" style={s} fill="none">
          <circle cx="7" cy="7" r="1.8" stroke={stroke} strokeWidth={sw} />
          <path d="M3 13c2 1 3 1 5 0s3-1 5 0 3 1 5 0 3-1 5 0M3 17c2 1 3 1 5 0s3-1 5 0 3 1 5 0 3-1 5 0" stroke={stroke} strokeWidth={sw} strokeLinecap="round" />
          <path d="M9 9l4-2 4 4" stroke={stroke} strokeWidth={sw} strokeLinecap="round" />
        </svg>
      );
    case 'row':
      return (
        <svg viewBox="0 0 24 24" style={s} fill="none">
          <path d="M3 17c2 1 3 1 5 0s3-1 5 0 3 1 5 0 3-1 5 0" stroke={stroke} strokeWidth={sw} strokeLinecap="round" />
          <path d="M4 13l16-4M8 11.5l2 4M16 9.5l-2 4" stroke={stroke} strokeWidth={sw} strokeLinecap="round" />
        </svg>
      );
    case 'hky':
      return (
        <svg viewBox="0 0 24 24" style={s} fill="none">
          <path d="M5 4l9 12.5" stroke={stroke} strokeWidth={sw} strokeLinecap="round" />
          <path d="M14 16.5h5" stroke={stroke} strokeWidth={sw + 0.6} strokeLinecap="round" />
          <ellipse cx="6" cy="19" rx="3" ry="1.2" stroke={stroke} strokeWidth={sw} />
        </svg>
      );
    case 'ski':
      return (
        <svg viewBox="0 0 24 24" style={s} fill="none">
          <path d="M5 19L17 5M19 19L7 5" stroke={stroke} strokeWidth={sw} strokeLinecap="round" />
          <path d="M9 5h-3M18 5h-3M16.5 19h-3M7.5 19h-3" stroke={stroke} strokeWidth={sw + 0.4} strokeLinecap="round" />
        </svg>
      );
    default:
      return (
        <svg viewBox="0 0 24 24" style={s} fill="none">
          <circle cx="12" cy="12" r="8.4" stroke={stroke} strokeWidth={sw} />
          <circle cx="12" cy="12" r="2" fill={stroke} />
        </svg>
      );
  }
}

// Wrapper that renders SportGlyph inside a square tile.
function SportTile({ sport, size = 40, variant = 'gold', radius }) {
  const isGold = variant === 'gold';
  const bg = isGold
    ? `linear-gradient(135deg, ${WVU.goldDim}, ${WVU.gold})`
    : WVU.ink3;
  const fg = isGold ? WVU.blueDim : WVU.creamDim;
  const glyphSize = Math.round(size * 0.55);
  return (
    <div style={{
      width: size, height: size,
      borderRadius: radius != null ? radius : DS.r.sm,
      background: bg,
      display: 'flex', alignItems: 'center', justifyContent: 'center',
      flexShrink: 0, color: fg,
      overflow: 'hidden',
    }}>
      <SportGlyph id={sport.id} size={glyphSize} />
    </div>
  );
}

Object.assign(window, { SportGlyph, SportTile });
