// Avatar.jsx — identity-safe avatar: neon capsule + Spiral-Ring 🌀 + pseudonym.
// No face, no real name. Color derived from a hash of the pseudonym (id-hash).
const GYM_NEON = ['#00ffff', '#ff00aa', '#ff7a00'];
function hashColor(name) {
  let h = 0;
  for (let i = 0; i < name.length; i++) h = (h * 31 + name.charCodeAt(i)) >>> 0;
  return GYM_NEON[h % GYM_NEON.length];
}

function Avatar({ name, speaking, holdingStick, size = 'md', muted }) {
  const col = hashColor(name);
  return (
    <div className={'gy-av gy-av-' + size + (speaking ? ' speaking' : '')}>
      <div className="gy-av-cap" style={{
        background: col,
        boxShadow: speaking ? `0 0 0 3px ${col}, 0 0 26px ${col}` : `0 0 14px ${col}88`,
      }}>
        <img className="gy-av-ring" src="../../assets/spiral.svg" alt="" />
        {holdingStick && <span className="gy-av-stick" title="Redestab">🪄</span>}
      </div>
      <div className="gy-av-label">
        {muted && <span className="gy-av-mic">🔇</span>}
        {speaking && <span className="gy-av-mic" style={{ color: col }}>●</span>}
        {name}
      </div>
    </div>
  );
}
Object.assign(window, { Avatar, hashColor, GYM_NEON });
