// Shared header for all page mockups
const CZFHeader = ({ active, headerStyle }) => {
  // Pull live season info from config (auto-fetch if not cached)
  const [cfg, setCfg] = React.useState(() => window.__CZF_CONFIG__ || null);
  React.useEffect(() => {
    if (cfg) return;
    if (!window.CZF || !CZF.USE_LIVE_DATA) return;
    fetch(`${CZF.API_BASE}/public/config`)
      .then(r => r.json())
      .then(c => { window.__CZF_CONFIG__ = c; setCfg(c); })
      .catch(() => {});
  }, []);
  const season = cfg?.season || { number: 4, state: 'EN COURS' };
  const links = [
    { id: 'home', label: 'Accueil' },
    { id: 'joueurs', label: 'Joueurs' },
    { id: 'equipes', label: 'Équipes' },
    { id: 'cast', label: 'Cast' },
    { id: 'matchs', label: 'Matchs' },
    { id: 'scrims', label: 'Scrims' },
    { id: 'prono', label: 'Pronostics' },
    { id: 'tierlist', label: 'Tierlist' },
    { id: 'awards', label: 'Awards' },
  ];
  return (
    <header style={{
      display: 'flex', alignItems: 'center', gap: '1.5rem',
      padding: '0 2.5rem', height: 60,
      background: 'linear-gradient(180deg, #110D08 0%, #0B0805 100%)',
      borderBottom: '1px solid var(--border)',
      position: 'relative', zIndex: 10,
    }}>
      {/* Logo image */}
      <div style={{
        width: 44, height: 44, borderRadius: 6,
        background: '#000', flexShrink: 0, overflow: 'hidden',
        border: '1px solid var(--border-2)',
        display: 'flex', alignItems: 'center', justifyContent: 'center',
      }}>
        <img src="assets/logo-czf.webp" alt="CZF" style={{ width: '120%', height: '120%', objectFit: 'cover' }} />
      </div>
      <div style={{ display: 'flex', flexDirection: 'column', lineHeight: 1 }}>
        <span style={{ fontFamily: 'var(--fd)', fontSize: '1.4rem', color: 'var(--bone)', letterSpacing: '.08em' }}>CZF</span>
        <span style={{ fontFamily: 'var(--fc)', fontSize: '.55rem', fontWeight: 600, letterSpacing: '.2em', textTransform: 'uppercase', color: 'var(--cream-2)', marginTop: 2 }}>
          Clash des Zéros de la Faille
        </span>
      </div>
      <nav style={{ display: 'flex', gap: 0, marginLeft: '1.5rem' }}>
        {links.map(l => (
          <a key={l.id} href={`#${l.id}`} data-nav={l.id} style={{
            fontFamily: 'var(--fc)', fontSize: '.78rem', fontWeight: 700,
            letterSpacing: '.14em', textTransform: 'uppercase',
            color: active === l.id ? 'var(--bone)' : 'var(--cream)',
            padding: '.4rem 1rem', textDecoration: 'none',
            position: 'relative', opacity: active === l.id ? 1 : .78,
          }}>
            {l.label}
            {active === l.id && <span style={{
              position: 'absolute', left: '1rem', right: '1rem', bottom: -2,
              height: 2, background: 'var(--gold)',
            }} />}
          </a>
        ))}
      </nav>
      <div style={{ marginLeft: 'auto', display: 'flex', alignItems: 'center', gap: '1rem' }}>
        <span style={{ fontFamily: 'var(--fc)', fontSize: '.65rem', color: 'var(--cream-2)', letterSpacing: '.1em', opacity: .8 }}>
          <span className="dot dot-live" style={{ marginRight: 6 }}></span>
          SAISON {season.number} · {season.state}
        </span>
      </div>
    </header>
  );
};

// Social icons — exported globally for reuse
const Icon = {
  Twitch: (props) => (
    <svg viewBox="0 0 24 24" fill="currentColor" width="16" height="16" {...props}>
      <path d="M11.571 4.714h1.715v5.143H11.57zm4.715 0H18v5.143h-1.714zM6 0L1.714 4.286v15.428h5.143V24l4.286-4.286h3.428L22.286 12V0zm14.571 11.143l-3.428 3.428h-3.429l-3 3v-3H6.857V1.714h13.714z"/>
    </svg>
  ),
  YouTube: (props) => (
    <svg viewBox="0 0 24 24" fill="currentColor" width="16" height="16" {...props}>
      <path d="M23.495 6.205a3.007 3.007 0 0 0-2.088-2.088c-1.87-.501-9.396-.501-9.396-.501s-7.507-.01-9.396.501A3.007 3.007 0 0 0 .527 6.205a31.247 31.247 0 0 0-.522 5.805 31.247 31.247 0 0 0 .522 5.783 3.007 3.007 0 0 0 2.088 2.088c1.868.502 9.396.502 9.396.502s7.506 0 9.396-.502a3.007 3.007 0 0 0 2.088-2.088 31.247 31.247 0 0 0 .5-5.783 31.247 31.247 0 0 0-.5-5.805zM9.609 15.601V8.408l6.264 3.602z"/>
    </svg>
  ),
  Discord: (props) => (
    <svg viewBox="0 0 24 24" fill="currentColor" width="16" height="16" {...props}>
      <path d="M20.317 4.37a19.79 19.79 0 0 0-4.885-1.515.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0 12.64 12.64 0 0 0-.617-1.25.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057 19.9 19.9 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028 14.09 14.09 0 0 0 1.226-1.994.076.076 0 0 0-.041-.106 13.107 13.107 0 0 1-1.872-.892.077.077 0 0 1-.008-.128 10.2 10.2 0 0 0 .372-.292.074.074 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127 12.299 12.299 0 0 1-1.873.892.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028 19.839 19.839 0 0 0 6.002-3.03.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.03zM8.02 15.33c-1.182 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z"/>
    </svg>
  ),
  Opgg: (props) => (
    <svg viewBox="0 0 24 24" width="16" height="16" {...props}>
      <circle cx="12" cy="12" r="9" fill="none" stroke="currentColor" strokeWidth="2"/>
      <text x="12" y="15" textAnchor="middle" fontSize="7" fontWeight="900" fontFamily="Arial" fill="currentColor">OP</text>
    </svg>
  ),
  Trophy: (props) => (
    <svg viewBox="0 0 24 24" fill="currentColor" width="16" height="16" {...props}>
      <path d="M7 3h10v2h3v3a4 4 0 0 1-4 4h-.4a5 5 0 0 1-4.6 3v3h3v2H10v-2h3v-3a5 5 0 0 1-4.6-3H8a4 4 0 0 1-4-4V5h3V3zm0 4H6v1a2 2 0 0 0 1 1.7V7zm10 0v2.7A2 2 0 0 0 18 8V7h-1z"/>
    </svg>
  ),
  Sword: (props) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" width="16" height="16" {...props}>
      <polyline points="14.5 17.5 3 6 3 3 6 3 17.5 14.5"/>
      <line x1="13" y1="19" x2="19" y2="13"/>
      <line x1="16" y1="16" x2="20" y2="20"/>
      <line x1="19" y1="21" x2="21" y2="19"/>
    </svg>
  ),
  Live: (props) => (
    <svg viewBox="0 0 24 24" fill="currentColor" width="14" height="14" {...props}>
      <circle cx="12" cy="12" r="4"/>
    </svg>
  ),
  Calendar: (props) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" width="14" height="14" {...props}>
      <rect x="3" y="4" width="18" height="18" rx="2"/>
      <line x1="16" y1="2" x2="16" y2="6"/>
      <line x1="8" y1="2" x2="8" y2="6"/>
      <line x1="3" y1="10" x2="21" y2="10"/>
    </svg>
  ),
  ChevronR: (props) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" width="14" height="14" {...props}>
      <polyline points="9 18 15 12 9 6"/>
    </svg>
  ),
  Mic: (props) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" width="14" height="14" {...props}>
      <path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3z"/>
      <path d="M19 10v2a7 7 0 0 1-14 0v-2M12 19v3"/>
    </svg>
  ),
};

Object.assign(window, { CZFHeader, Icon });
