// CyberX Battle Pass — Brand assets: logo, season cover, badges, icons, merch, promo

// ─────────────────────────────────────────────────────────────
// Big Logo: CYBERX BATTLE PASS
// ─────────────────────────────────────────────────────────────
function BPLogo({ width = 360, dark = true, accent = CX.red }) {
  const fg = dark ? CX.white : CX.black;
  return (
    <div style={{
      width, display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 4,
      fontFamily: FONT_DISPLAY, color: fg,
    }}>
      <div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
        <CXMark size={Math.round(width * 0.13)} color={accent} glow={dark} />
        <span style={{
          fontSize: Math.round(width * 0.13),
          letterSpacing: '0.06em', fontWeight: 700, lineHeight: 1,
        }}>CYBER<span style={{ color: accent }}>X</span></span>
      </div>
      <div style={{
        display: 'flex', alignItems: 'center', gap: 8, width: '100%',
        marginTop: 2,
      }}>
        <div style={{ flex: 1, height: 1, background: dark ? 'rgba(255,255,255,0.2)' : 'rgba(0,0,0,0.2)' }} />
        <span style={{
          fontSize: Math.round(width * 0.062),
          letterSpacing: '0.32em', fontWeight: 600,
          color: dark ? CX.textSec : '#444',
        }}>BATTLE PASS</span>
        <div style={{ flex: 1, height: 1, background: dark ? 'rgba(255,255,255,0.2)' : 'rgba(0,0,0,0.2)' }} />
      </div>
    </div>
  );
}

// ─────────────────────────────────────────────────────────────
// Tier Badge (4 variants)
// ─────────────────────────────────────────────────────────────
function TierBadge({ tier = 'recruit', size = 180, label = true }) {
  const t = TIERS[tier];
  const gid = `tb-${tier}-${size}`;
  const symbols = {
    recruit: (
      // Minimalist chevron
      <g>
        <path d="M50 30 L78 56 L66 56 L50 42 L34 56 L22 56 Z" fill="#1a0f06" opacity="0.85"/>
        <path d="M50 50 L78 76 L66 76 L50 62 L34 76 L22 76 Z" fill="#1a0f06" opacity="0.85"/>
      </g>
    ),
    knight: (
      // Shield
      <g>
        <path d="M50 22 L74 30 L74 52 Q74 68 50 80 Q26 68 26 52 L26 30 Z"
              fill="none" stroke="#0c0f17" strokeWidth="3.5" opacity="0.95"/>
        <path d="M50 36 L50 70 M38 50 L62 50" stroke="#0c0f17" strokeWidth="3.5" strokeLinecap="square" opacity="0.95"/>
      </g>
    ),
    champion: (
      // Crown
      <g>
        <path d="M22 64 L26 36 L36 50 L50 28 L64 50 L74 36 L78 64 Z"
              fill="#3a1f00" opacity="0.9" stroke="#3a1f00" strokeWidth="2" strokeLinejoin="round"/>
        <rect x="22" y="64" width="56" height="8" fill="#3a1f00" opacity="0.9"/>
        <circle cx="50" cy="40" r="2.5" fill="#FFE177"/>
        <circle cx="36" cy="50" r="2" fill="#FFE177"/>
        <circle cx="64" cy="50" r="2" fill="#FFE177"/>
      </g>
    ),
    legend: (
      // Star burst
      <g>
        <path d="M50 18 L57 42 L82 42 L62 56 L70 80 L50 65 L30 80 L38 56 L18 42 L43 42 Z"
              fill="#0c0f17" opacity="0.85" stroke="#fff" strokeWidth="0.5" opacity="0.92"/>
        <path d="M50 30 L50 70 M30 50 L70 50" stroke="#fff" strokeWidth="0.8" opacity="0.4"/>
      </g>
    ),
  };

  return (
    <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 10 }}>
      <svg width={size} height={size} viewBox="0 0 100 100" style={{
        filter: `drop-shadow(0 0 ${size * 0.08}px ${t.color}88)`,
      }}>
        <defs>
          <linearGradient id={gid} x1="0.2" y1="0" x2="0.8" y2="1">
            {tier === 'legend' ? (
              <>
                <stop offset="0" stopColor="#A855F7"/>
                <stop offset="0.5" stopColor="#6366F1"/>
                <stop offset="1" stopColor="#22D3EE"/>
              </>
            ) : (
              <>
                <stop offset="0" stopColor={t.color}/>
                <stop offset="1" stopColor={t.hi}/>
              </>
            )}
          </linearGradient>
          <linearGradient id={`${gid}-rim`} x1="0" y1="0" x2="1" y2="1">
            <stop offset="0" stopColor="#fff" stopOpacity="0.4"/>
            <stop offset="0.5" stopColor="#fff" stopOpacity="0"/>
            <stop offset="1" stopColor="#fff" stopOpacity="0.2"/>
          </linearGradient>
        </defs>
        {/* Hex outer */}
        <path d="M50 4 L88 26 L88 74 L50 96 L12 74 L12 26 Z" fill={`url(#${gid})`}/>
        <path d="M50 4 L88 26 L88 74 L50 96 L12 74 L12 26 Z" fill={`url(#${gid}-rim)`}/>
        {/* Inner cut */}
        <path d="M50 12 L80 30 L80 70 L50 88 L20 70 L20 30 Z" fill="none"
              stroke="rgba(0,0,0,0.25)" strokeWidth="1.5"/>
        {symbols[tier]}
      </svg>
      {label && (
        <Display size={Math.round(size * 0.11)} color={t.hi} tracking={0.16}>{t.name}</Display>
      )}
    </div>
  );
}

// ─────────────────────────────────────────────────────────────
// Task icons (12) — both outline + filled
// ─────────────────────────────────────────────────────────────
function TaskIcon({ kind = 'time', size = 24, active = false, color }) {
  const c = active ? (color || CX.amber) : CX.textSec;
  const w = active ? 2.2 : 1.8;
  const fill = active ? c : 'none';
  const glow = active ? `drop-shadow(0 0 4px ${c}66)` : 'none';
  const ICONS = {
    time: (
      <g>
        <circle cx="12" cy="13" r="8" stroke={c} strokeWidth={w} fill={active ? `${c}33` : 'none'}/>
        <path d="M12 8.5 L12 13 L15 15.5" stroke={c} strokeWidth={w} strokeLinecap="round" fill="none"/>
        <path d="M9 3 L15 3" stroke={c} strokeWidth={w} strokeLinecap="round"/>
      </g>
    ),
    challenge: (
      <g>
        <circle cx="12" cy="12" r="9" stroke={c} strokeWidth={w} fill={active ? `${c}22` : 'none'}/>
        <circle cx="12" cy="12" r="5" stroke={c} strokeWidth={w} fill="none"/>
        <circle cx="12" cy="12" r="1.5" fill={c}/>
      </g>
    ),
    referral: (
      <g>
        <circle cx="9" cy="9" r="3.5" stroke={c} strokeWidth={w} fill={active ? `${c}22` : 'none'}/>
        <path d="M3 20 Q3 14 9 14 Q15 14 15 20" stroke={c} strokeWidth={w} fill="none" strokeLinecap="round"/>
        <circle cx="17" cy="10" r="2.5" stroke={c} strokeWidth={w} fill="none"/>
        <path d="M13 19 Q13 16 17 16 Q21 16 21 19" stroke={c} strokeWidth={w} fill="none" strokeLinecap="round"/>
      </g>
    ),
    bar: (
      <g>
        <path d="M4 6 L20 6 L17 13 L7 13 Z" stroke={c} strokeWidth={w} fill={active ? `${c}22` : 'none'} strokeLinejoin="round"/>
        <path d="M12 13 L12 19 M8 19 L16 19" stroke={c} strokeWidth={w} strokeLinecap="round"/>
        <path d="M14 3 L16 5 L18 3" stroke={c} strokeWidth={w} fill="none" strokeLinecap="round"/>
      </g>
    ),
    tournament: (
      <g>
        <path d="M7 4 L17 4 L17 9 Q17 13 12 13 Q7 13 7 9 Z" stroke={c} strokeWidth={w} fill={active ? `${c}22` : 'none'}/>
        <path d="M7 5 L4 5 L4 8 Q4 10 7 10 M17 5 L20 5 L20 8 Q20 10 17 10" stroke={c} strokeWidth={w} fill="none"/>
        <path d="M12 13 L12 17 M8 20 L16 20 L15 17 L9 17 Z" stroke={c} strokeWidth={w} strokeLinejoin="round" fill={active ? `${c}22` : 'none'}/>
      </g>
    ),
    steam: (
      <g>
        <circle cx="12" cy="12" r="9" stroke={c} strokeWidth={w} fill={active ? `${c}22` : 'none'}/>
        <circle cx="15" cy="9" r="2.8" stroke={c} strokeWidth={w} fill="none"/>
        <circle cx="9" cy="14" r="2" stroke={c} strokeWidth={w} fill="none"/>
        <path d="M11 14 L14 11" stroke={c} strokeWidth={w * 0.8}/>
      </g>
    ),
    night: (
      <path d="M19 14 A8 8 0 1 1 10 5 A6 6 0 0 0 19 14 Z"
        stroke={c} strokeWidth={w} fill={active ? `${c}33` : 'none'} strokeLinejoin="round"/>
    ),
    morning: (
      <g>
        <circle cx="12" cy="13" r="4" stroke={c} strokeWidth={w} fill={active ? `${c}33` : 'none'}/>
        <path d="M12 5 L12 7 M5 13 L7 13 M17 13 L19 13 M7 8 L8.5 9.5 M16 9.5 L17.5 8 M3 19 L21 19" stroke={c} strokeWidth={w} strokeLinecap="round"/>
      </g>
    ),
    social: (
      <g>
        <rect x="4" y="6" width="16" height="13" rx="2" stroke={c} strokeWidth={w} fill={active ? `${c}22` : 'none'}/>
        <circle cx="12" cy="12.5" r="3.5" stroke={c} strokeWidth={w} fill="none"/>
        <rect x="14" y="4" width="4" height="3" stroke={c} strokeWidth={w} fill="none"/>
      </g>
    ),
    review: (
      <path d="M12 4 L14.5 9.5 L20 10 L16 14 L17 19.5 L12 17 L7 19.5 L8 14 L4 10 L9.5 9.5 Z"
        stroke={c} strokeWidth={w} fill={active ? `${c}55` : 'none'} strokeLinejoin="round"/>
    ),
    birthday: (
      <g>
        <path d="M4 12 L20 12 L20 18 Q20 20 18 20 L6 20 Q4 20 4 18 Z" stroke={c} strokeWidth={w} fill={active ? `${c}22` : 'none'}/>
        <path d="M4 12 Q4 10 6 10 L18 10 Q20 10 20 12" stroke={c} strokeWidth={w} fill="none"/>
        <path d="M12 10 L12 5 M12 5 Q14 5 14 3 Q14 5 12 5 Q10 5 10 3 Q10 5 12 5" stroke={c} strokeWidth={w} fill="none"/>
      </g>
    ),
    topup: (
      <g>
        <rect x="3" y="7" width="18" height="12" rx="2" stroke={c} strokeWidth={w} fill={active ? `${c}22` : 'none'}/>
        <path d="M3 11 L21 11" stroke={c} strokeWidth={w}/>
        <path d="M12 14 L12 17 M10.5 15.5 L13.5 15.5" stroke={c} strokeWidth={w} strokeLinecap="round"/>
      </g>
    ),
  };
  return (
    <svg width={size} height={size} viewBox="0 0 24 24" style={{ filter: glow }}>
      {ICONS[kind]}
    </svg>
  );
}

// ─────────────────────────────────────────────────────────────
// Reward icon (placeholder gaming items)
// ─────────────────────────────────────────────────────────────
function RewardIcon({ kind, size = 48, tier = CX.bronze }) {
  const ICONS = {
    hoodie: (
      <g>
        <path d="M16 18 Q16 8 32 8 Q48 8 48 18 L52 24 L48 28 L48 54 Q48 56 46 56 L18 56 Q16 56 16 54 L16 28 L12 24 Z" fill={tier} opacity="0.92"/>
        <path d="M26 16 Q32 22 38 16 L38 28 Q32 34 26 28 Z" fill="#0D0F14"/>
        <text x="32" y="46" textAnchor="middle" fontFamily="Bebas Neue,sans-serif" fontSize="9" letterSpacing="1" fill="#0D0F14" fontWeight="700">CYBERX</text>
      </g>
    ),
    coins: (
      <g>
        <circle cx="22" cy="40" r="14" fill={tier} stroke="#0D0F14" strokeWidth="1.5"/>
        <circle cx="42" cy="28" r="16" fill={tier} stroke="#0D0F14" strokeWidth="1.5"/>
        <text x="42" y="34" textAnchor="middle" fontFamily="Bebas Neue,sans-serif" fontSize="18" fontWeight="700" fill="#0D0F14">X</text>
        <text x="22" y="46" textAnchor="middle" fontFamily="Bebas Neue,sans-serif" fontSize="14" fontWeight="700" fill="#0D0F14">X</text>
      </g>
    ),
    mousepad: (
      <g>
        <rect x="6" y="20" width="52" height="28" rx="3" fill={tier}/>
        <rect x="6" y="20" width="52" height="28" rx="3" fill="none" stroke="#0D0F14" strokeWidth="1"/>
        <text x="32" y="38" textAnchor="middle" fontFamily="Bebas Neue,sans-serif" fontSize="10" fill="#0D0F14" letterSpacing="2">CYBERX</text>
      </g>
    ),
    sticker: (
      <g>
        <path d="M32 8 L40 18 L52 20 L44 30 L46 42 L34 40 L26 50 L22 38 L12 32 L22 24 L20 12 Z" fill={tier}/>
        <text x="32" y="33" textAnchor="middle" fontFamily="Bebas Neue,sans-serif" fontSize="10" fontWeight="700" fill="#0D0F14" letterSpacing="1">CX</text>
      </g>
    ),
    cup: (
      <g>
        <path d="M14 20 L46 20 L44 52 Q44 56 40 56 L20 56 Q16 56 16 52 Z" fill={tier} stroke="#0D0F14" strokeWidth="1.5"/>
        <path d="M46 26 Q54 26 54 34 Q54 42 46 42" fill="none" stroke="#0D0F14" strokeWidth="2"/>
        <text x="30" y="42" textAnchor="middle" fontFamily="Bebas Neue,sans-serif" fontSize="14" fontWeight="700" fill="#0D0F14">CX</text>
      </g>
    ),
    hours: (
      <g>
        <circle cx="32" cy="32" r="22" fill="none" stroke={tier} strokeWidth="3"/>
        <path d="M32 18 L32 32 L42 38" stroke={tier} strokeWidth="3" strokeLinecap="round"/>
        <text x="32" y="52" textAnchor="middle" fontFamily="Bebas Neue,sans-serif" fontSize="9" fill={tier} letterSpacing="1.5">HOURS</text>
      </g>
    ),
    avatar: (
      <g>
        <circle cx="32" cy="26" r="11" fill={tier}/>
        <path d="M14 56 Q14 40 32 40 Q50 40 50 56 Z" fill={tier}/>
        <circle cx="32" cy="26" r="11" fill="none" stroke="#0D0F14" strokeWidth="1.5"/>
      </g>
    ),
    boost: (
      <g>
        <path d="M22 8 L48 8 L42 34 L52 34 L26 60 L34 38 L20 38 Z" fill={tier} stroke="#0D0F14" strokeWidth="1.5" strokeLinejoin="round"/>
      </g>
    ),
    tshirt: (
      <g>
        <path d="M14 18 L24 12 Q28 18 32 18 Q36 18 40 12 L50 18 L46 26 L42 24 L42 56 L22 56 L22 24 L18 26 Z" fill={tier}/>
        <path d="M14 18 L24 12 Q28 18 32 18 Q36 18 40 12 L50 18 L46 26 L42 24 L42 56 L22 56 L22 24 L18 26 Z" fill="none" stroke="#0D0F14" strokeWidth="1"/>
      </g>
    ),
    cake: (
      <g>
        <rect x="14" y="32" width="36" height="20" fill={tier} stroke="#0D0F14" strokeWidth="1.5"/>
        <rect x="18" y="24" width="28" height="10" fill={tier} stroke="#0D0F14" strokeWidth="1.5"/>
        <path d="M32 16 L32 24 M32 16 Q34 14 32 12 Q30 14 32 16" stroke="#FFD700" strokeWidth="1.5" fill="#FFD700"/>
      </g>
    ),
    key: (
      <g>
        <circle cx="20" cy="32" r="10" fill="none" stroke={tier} strokeWidth="3.5"/>
        <path d="M28 32 L50 32 L50 38 M44 32 L44 38" stroke={tier} strokeWidth="3.5" strokeLinecap="square" fill="none"/>
      </g>
    ),
    title: (
      <g>
        <rect x="8" y="22" width="48" height="20" rx="2" fill={tier}/>
        <text x="32" y="36" textAnchor="middle" fontFamily="Bebas Neue,sans-serif" fontSize="10" fontWeight="700" fill="#0D0F14" letterSpacing="2">LEGEND</text>
      </g>
    ),
  };
  return (
    <svg width={size} height={size} viewBox="0 0 64 64" style={{ filter: `drop-shadow(0 4px 8px ${tier}55)` }}>
      {ICONS[kind] || ICONS.coins}
    </svg>
  );
}

Object.assign(window, { BPLogo, TierBadge, TaskIcon, RewardIcon });
