/* global React */
const { useState } = React;

// ---------------------------------------------------------------------------
// Leaguecast website UI kit — components
// Small, cosmetic recreations. Not production code.
// ---------------------------------------------------------------------------

const LUCIDE_ICONS = {
  // stroke-based icons (currentColor stroke, no fill)
  play: <><polygon points="6 3 20 12 6 21 6 3" fill="currentColor" stroke="none" /></>,
  pause: <><rect x="6" y="4" width="4" height="16" fill="currentColor" stroke="none"/><rect x="14" y="4" width="4" height="16" fill="currentColor" stroke="none"/></>,
  "skip-back": <><polygon points="19 20 9 12 19 4 19 20" fill="currentColor" stroke="none"/><line x1="5" x2="5" y1="19" y2="5"/></>,
  "skip-forward": <><polygon points="5 4 15 12 5 20 5 4" fill="currentColor" stroke="none"/><line x1="19" x2="19" y1="5" y2="19"/></>,
  search: <><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></>,
  image: <><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></>,
  "arrow-down": <><path d="M12 5v14"/><path d="m19 12-7 7-7-7"/></>,
  link: <><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></>,
  loader: <><path d="M12 2v4"/><path d="m16.2 7.8 2.9-2.9"/><path d="M18 12h4"/><path d="m16.2 16.2 2.9 2.9"/><path d="M12 18v4"/><path d="m4.9 19.1 2.9-2.9"/><path d="M2 12h4"/><path d="m4.9 4.9 2.9 2.9"/></>,
  "volume-2": <><polygon points="11 4 6 9 2 9 2 15 6 15 11 20 11 4" fill="currentColor" stroke="none"/><path d="M15.54 8.46a5 5 0 0 1 0 7.07"/><path d="M19.07 4.93a10 10 0 0 1 0 14.14"/></>,
  list: <><line x1="8" x2="21" y1="6" y2="6"/><line x1="8" x2="21" y1="12" y2="12"/><line x1="8" x2="21" y1="18" y2="18"/><line x1="3" x2="3.01" y1="6" y2="6"/><line x1="3" x2="3.01" y1="12" y2="12"/><line x1="3" x2="3.01" y1="18" y2="18"/></>,
  headphones: <><path d="M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H4a1 1 0 0 1-1-1v-6a9 9 0 0 1 18 0v6a1 1 0 0 1-1 1h-2a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3"/></>,
};

const Icon = ({ name, size = 18, stroke = 2, style = {} }) => {
  const content = LUCIDE_ICONS[name];
  if (!content) return null;
  return (
    <svg
      width={size} height={size} viewBox="0 0 24 24"
      fill="none" stroke="currentColor"
      strokeWidth={stroke} strokeLinecap="round" strokeLinejoin="round"
      style={style} aria-hidden="true"
    >
      {content}
    </svg>
  );
};

function Logo({ size = 200 }) {
  return (
    <svg width={size} viewBox="0 0 800 120" role="img" aria-label="Leaguecast" style={{ display: "block" }}>
      <defs>
        <linearGradient id="lcGoldNav" x1="0" y1="0" x2="0" y2="1">
          <stop offset="0" stopColor="#FFE34A" />
          <stop offset="1" stopColor="#D4A637" />
        </linearGradient>
        <linearGradient id="lcBlueNav" x1="0" y1="0" x2="0" y2="1">
          <stop offset="0" stopColor="#35B3E3" />
          <stop offset="1" stopColor="#1B96C8" />
        </linearGradient>
      </defs>
      <text x="400" y="92" textAnchor="middle" style={{
        fontFamily: "var(--font-wordmark)", fontWeight: 900,
        fontSize: 96, letterSpacing: "0px",
      }}>
        <tspan fill="url(#lcGoldNav)">LEAGUE</tspan><tspan fill="url(#lcBlueNav)">CAST</tspan>
      </text>
    </svg>
  );
}

function TopNav({ active, onNav, onPlay, onDiscord }) {
  const items = ["Episodes", "Hosts", "Contact"];  return (
    <nav style={{
      position: "sticky", top: 0, zIndex: 40,
      display: "flex", alignItems: "center", gap: 28,
      padding: "14px 32px",
      background: "rgba(21,24,27,.78)",
      backdropFilter: "blur(14px)",
      WebkitBackdropFilter: "blur(14px)",
      borderBottom: "1px solid var(--bg-line)",
    }}>
      <a onClick={() => onNav && onNav("Episodes")} style={{ cursor: "pointer", display: "inline-flex" }} aria-label="Go to episodes">
        <Logo size={170} />
      </a>
      <div style={{ display: "flex", gap: 24, marginLeft: 8 }}>
        {items.map((lbl) => (
          <a
            key={lbl}
            onClick={() => onNav && onNav(lbl)}
            style={{
              fontFamily: "var(--font-display)",
              fontWeight: 600, fontSize: 13,
              letterSpacing: ".1em", textTransform: "uppercase",
              color: active === lbl ? "var(--fg-1)" : "var(--fg-2)",
              padding: "8px 0",
              position: "relative",
              cursor: "pointer",
              textDecoration: "none",
            }}
          >
            {lbl}
            {active === lbl && (
              <span style={{
                position: "absolute", left: 0, right: 0, bottom: -2,
                height: 2, background: "var(--lc-yellow)",
              }} />
            )}
          </a>
        ))}
      </div>
      <div style={{ flex: 1 }} />
      <a href="https://discord.gg/cg49fGnJRK" target="_blank" rel="noreferrer" onClick={(e) => { if (onDiscord) { e.preventDefault(); onDiscord(); } }} style={{
        display: "inline-flex", alignItems: "center", gap: 8,
        fontFamily: "var(--font-display)", fontWeight: 700,
        fontSize: 12, letterSpacing: ".12em", textTransform: "uppercase",
        padding: "8px 14px", borderRadius: 4,
        color: "#fff", background: "#5865F2",
        cursor: "pointer", textDecoration: "none",
      }}>
        <svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><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.74 19.74 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.056 19.9 19.9 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028c.462-.63.873-1.295 1.226-1.994a.076.076 0 0 0-.041-.106 13.1 13.1 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.009c.12.098.246.198.373.292a.077.077 0 0 1-.006.127 12.3 12.3 0 0 1-1.873.892.077.077 0 0 0-.041.107c.36.699.772 1.364 1.225 1.993a.076.076 0 0 0 .084.028 19.84 19.84 0 0 0 6.002-3.03.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.548-13.66a.061.061 0 0 0-.03-.028zM8.02 15.331c-1.183 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>
        Discord
      </a>
      <div style={{
        display: "flex", alignItems: "center", gap: 10,
        padding: "6px 12px",
        background: "var(--bg-2)",
        border: "1px solid var(--bg-line)",
        borderRadius: 4,
        color: "var(--fg-3)",
        width: 200,
      }}>
        <Icon name="search" size={14} />
        <span style={{ fontSize: 13, fontFamily: "var(--font-body)" }}>Search the archive…</span>
      </div>
    </nav>
  );
}

function Hero({ onListen }) {
  return (
    <section style={{
      position: "relative",
      minHeight: 480,
      padding: "96px 32px 120px",
      background: `
        radial-gradient(ellipse at 25% 40%, rgba(21,24,27,.4), rgba(21,24,27,.95) 70%),
        radial-gradient(ellipse at 30% 20%, rgba(255,255,255,.05), transparent 60%),
        radial-gradient(ellipse at 70% 80%, rgba(0,0,0,.35), transparent 55%),
        linear-gradient(180deg, #3a3f44 0%, #23272b 100%)
      `,
      overflow: "hidden",
    }}>
      <div aria-hidden style={{
        position: "absolute", inset: 0, pointerEvents: "none",
        backgroundImage:
          "repeating-linear-gradient(115deg, rgba(255,255,255,.04) 0 1px, transparent 1px 3px)," +
          "repeating-linear-gradient(75deg, rgba(0,0,0,.08) 0 1px, transparent 1px 5px)",
        mixBlendMode: "overlay",
      }} />
      <div aria-hidden style={{
        position: "absolute", right: -80, bottom: -60, width: 560, height: 560,
        borderRadius: 999,
        background: "radial-gradient(circle, rgba(238,213,54,.18), transparent 60%)",
        filter: "blur(20px)", pointerEvents: "none",
      }} />
      <div style={{ maxWidth: 1200, margin: "0 auto", position: "relative" }}>
        <div style={{
          fontFamily: "var(--font-display)", fontWeight: 600,
          fontSize: 14, letterSpacing: ".2em", textTransform: "uppercase",
          color: "var(--lc-yellow)", marginBottom: 18,
        }}>
          The unofficial League of Legends podcast · Est. 2014
        </div>
        <h1 style={{
          fontFamily: "var(--font-display)", fontWeight: 900,
          fontSize: "clamp(56px, 9vw, 132px)", lineHeight: 0.92,
          letterSpacing: "-.01em", textTransform: "uppercase",
          margin: "0 0 28px", maxWidth: 960,
        }}>
          Ten years of <span style={{ color: "var(--lc-yellow)" }}>builds</span>,<br/>
          <span style={{ color: "var(--lc-blue-hot)" }}>lore</span>, and listener mail.
        </h1>
        <p style={{
          fontFamily: "var(--font-body)", fontSize: 19, lineHeight: 1.55,
          color: "var(--fg-2)", maxWidth: 620, margin: "0 0 36px",
        }}>
          Pull up a chair. We're a couple of friends who've been talking League
          every week since forever — patches, champions, tangents, all of it.
        </p>
        <div style={{ display: "flex", gap: 12, flexWrap: "wrap" }}>
          <button onClick={onListen} style={{
            fontFamily: "var(--font-display)", fontWeight: 700,
            fontSize: 15, letterSpacing: ".08em", textTransform: "uppercase",
            padding: "14px 26px",
            background: "var(--lc-yellow)", color: "var(--lc-ink)",
            border: 0, borderRadius: 4, cursor: "pointer",
            display: "inline-flex", alignItems: "center", gap: 10,
            boxShadow: "0 0 0 1px rgba(238,213,54,.6), 0 0 24px rgba(238,213,54,.35)",
          }}>
            <Icon name="play" size={16} />
            Listen to Ep 247
          </button>
          <button style={{
            fontFamily: "var(--font-display)", fontWeight: 700,
            fontSize: 15, letterSpacing: ".08em", textTransform: "uppercase",
            padding: "14px 26px",
            background: "transparent", color: "var(--fg-1)",
            border: "1px solid var(--bg-line)", borderRadius: 4, cursor: "pointer",
          }}>
            Browse the archive →
          </button>
        </div>
      </div>
    </section>
  );
}

function EpisodeCard({ ep, onPlay, featured }) {
  const [hover, setHover] = useState(false);
  return (
    <article
      onMouseEnter={() => setHover(true)}
      onMouseLeave={() => setHover(false)}
      style={{
        background: "var(--bg-2)",
        border: `1px solid ${hover ? "rgba(238,213,54,.35)" : "var(--bg-line)"}`,
        borderRadius: 8,
        padding: 18,
        display: "flex", gap: 16, alignItems: "center",
        boxShadow: hover ? "0 16px 40px rgba(0,0,0,.55)" : "0 4px 14px rgba(0,0,0,.45)",
        transform: hover ? "translateY(-2px)" : "translateY(0)",
        transition: "all 180ms cubic-bezier(.22,.61,.36,1)",
        cursor: "pointer",
      }}
    >
      <div style={{
        width: featured ? 108 : 80, height: featured ? 108 : 80,
        borderRadius: 6,
        backgroundImage: "url('./assets/leaguecast-podcast-cover.jpg')",
        backgroundSize: "cover", flex: "none",
      }} />
      <div style={{ flex: 1, minWidth: 0 }}>
        <div style={{
          fontFamily: "var(--font-display)", fontWeight: 600,
          fontSize: 11, letterSpacing: ".18em", textTransform: "uppercase",
          color: "var(--lc-yellow)", marginBottom: 6,
        }}>
          Ep {ep.num} · {ep.date}
        </div>
        <h3 style={{
          fontFamily: "var(--font-display)", fontWeight: 700,
          fontSize: featured ? 24 : 19, lineHeight: 1.1,
          textTransform: "uppercase", margin: "0 0 6px", color: "var(--fg-1)",
        }}>
          {ep.title}
        </h3>
        <p style={{
          fontFamily: "var(--font-body)", fontSize: 14, lineHeight: 1.4,
          color: "var(--fg-3)", margin: 0,
          display: "-webkit-box", WebkitLineClamp: 2, WebkitBoxOrient: "vertical",
          overflow: "hidden",
        }}>
          {ep.blurb}
        </p>
        <div style={{ display: "flex", gap: 8, marginTop: 10, flexWrap: "wrap" }}>
          {ep.tags.map((t) => (
            <span key={t} style={{
              fontFamily: "var(--font-display)", fontWeight: 700,
              fontSize: 10, letterSpacing: ".14em", textTransform: "uppercase",
              padding: "4px 9px", borderRadius: 999,
              background: "rgba(27,150,200,.15)",
              color: "var(--lc-blue-hot)",
              border: "1px solid rgba(27,150,200,.35)",
            }}>{t}</span>
          ))}
          <span style={{
            fontFamily: "var(--font-body)", fontSize: 11,
            color: "var(--fg-3)", alignSelf: "center",
            textTransform: "uppercase", letterSpacing: ".08em",
          }}>
            {ep.duration}
          </span>
        </div>
      </div>
      <button onClick={(e) => { e.stopPropagation(); onPlay(ep); }} style={{
        width: 48, height: 48, borderRadius: 999,
        background: "var(--lc-yellow)", color: "var(--lc-ink)",
        border: 0, cursor: "pointer", flex: "none",
        display: "flex", alignItems: "center", justifyContent: "center",
        boxShadow: hover ? "0 0 0 1px rgba(238,213,54,.6), 0 0 24px rgba(238,213,54,.35)" : "none",
        transition: "box-shadow 180ms",
      }}>
        <Icon name="play" size={18} stroke={2.5} />
      </button>
    </article>
  );
}

function HostCard({ host }) {
  return (
    <div style={{
      background: "var(--bg-2)",
      border: "1px solid var(--bg-line)",
      borderRadius: 8, padding: 20,
      textAlign: "center",
    }}>
      <div style={{
        width: 88, height: 88, borderRadius: 999,
        margin: "0 auto 14px",
        background: `linear-gradient(135deg, ${host.bg1}, ${host.bg2})`,
        display: "flex", alignItems: "center", justifyContent: "center",
        fontFamily: "var(--font-display)", fontWeight: 900, fontSize: 32,
        color: "var(--lc-ink)",
        border: "2px solid rgba(238,213,54,.4)",
      }}>
        {host.initials}
      </div>
      <div style={{
        fontFamily: "var(--font-display)", fontWeight: 800, fontSize: 18,
        textTransform: "uppercase", color: "var(--fg-1)", marginBottom: 4,
      }}>{host.name}</div>
      <div style={{
        fontFamily: "var(--font-display)", fontWeight: 600, fontSize: 11,
        letterSpacing: ".18em", textTransform: "uppercase",
        color: "var(--lc-yellow)", marginBottom: 10,
      }}>{host.role}</div>
      <div style={{
        fontFamily: "var(--font-body)", fontSize: 13, lineHeight: 1.5,
        color: "var(--fg-3)",
      }}>{host.main}</div>
    </div>
  );
}

function Footer() {
  const links = [
    { label: "Apple Podcasts", href: "https://podcasts.apple.com/us/podcast/leaguecast-a-league-of-legends-podcast/id503300852", icon: (
      <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 0C5.373 0 0 5.373 0 12s5.373 12 12 12 12-5.373 12-12S18.627 0 12 0zm0 4.5a3.75 3.75 0 1 1 0 7.5 3.75 3.75 0 0 1 0-7.5zm-.02 8.76c1.75 0 3.17.3 3.17 2.13 0 1.4-.68 2.24-1.5 2.76l-.35 1.93c-.11.6-.58 1.03-1.15 1.03h-.3c-.57 0-1.04-.43-1.15-1.03l-.35-1.93c-.82-.52-1.5-1.36-1.5-2.76 0-1.83 1.42-2.13 3.13-2.13zM7.6 14.08a.9.9 0 0 1 .9.9c0 1.26.4 2.44 1.1 3.4.25.35.2.84-.12 1.14l-.02.02a.88.88 0 0 1-1.28-.06A7.45 7.45 0 0 1 6.7 15c0-.5.4-.92.9-.92zm8.8 0c.5 0 .9.41.9.92a7.45 7.45 0 0 1-1.48 4.48.88.88 0 0 1-1.28.06l-.02-.02a.87.87 0 0 1-.12-1.14 5.76 5.76 0 0 0 1.1-3.4c0-.5.4-.9.9-.9z"/></svg>
    ) },
    { label: "Spotify", href: "https://open.spotify.com/show/6sW5H8VZuncKg1Qr01NYX1", icon: (
      <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 0C5.4 0 0 5.4 0 12s5.4 12 12 12 12-5.4 12-12S18.66 0 12 0zm5.52 17.34c-.24.36-.66.48-1.02.24-2.82-1.74-6.36-2.1-10.56-1.14-.42.12-.78-.18-.9-.54-.12-.42.18-.78.54-.9 4.56-1.02 8.52-.6 11.64 1.32.42.18.48.66.3 1.02zm1.44-3.3c-.3.42-.84.6-1.26.3-3.24-1.98-8.16-2.58-11.94-1.38-.48.12-1.02-.12-1.14-.6-.12-.48.12-1.02.6-1.14 4.38-1.32 9.78-.66 13.5 1.62.36.18.54.78.24 1.2zm.12-3.36C15.24 8.4 8.82 8.16 5.1 9.3c-.6.18-1.2-.18-1.38-.72-.18-.6.18-1.2.72-1.38 4.32-1.32 11.34-1.02 15.78 1.62.54.3.72 1.02.42 1.56-.3.42-1.02.6-1.56.3z"/></svg>
    ) },
    { label: "YouTube", href: "https://www.youtube.com/c/Leaguecast", icon: (
      <svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z"/></svg>
    ) },
    { label: "RSS", href: "https://anchor.fm/s/10da1cb84/podcast/rss", icon: (
      <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M6.18 15.64a2.18 2.18 0 0 1 2.18 2.18C8.36 19 7.38 20 6.18 20A2.18 2.18 0 0 1 4 17.82a2.18 2.18 0 0 1 2.18-2.18zM4 4.44A15.56 15.56 0 0 1 19.56 20h-2.83A12.73 12.73 0 0 0 4 7.27V4.44zm0 5.66a9.9 9.9 0 0 1 9.9 9.9h-2.83A7.07 7.07 0 0 0 4 12.93V10.1z"/></svg>
    ) },
    { label: "Discord", href: "https://discord.gg/cg49fGnJRK", icon: <DiscordIcon size={18} /> },
    { label: "Contact us", href: "#", icon: (
      <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"/><path d="m22 6-10 7L2 6"/></svg>
    ) },
  ];
  return (
    <footer style={{
      padding: "28px 32px",
      background: "var(--bg-3)",
      borderTop: "1px solid var(--bg-line)",
    }}>
      <div style={{
        maxWidth: 1200, margin: "0 auto",
        display: "flex", alignItems: "center", justifyContent: "space-between",
        gap: 24, flexWrap: "wrap",
      }}>
        <div style={{
          fontFamily: "var(--font-body)", fontSize: 12, color: "var(--fg-3)",
        }}>© 2009–2026 Leaguecast</div>
        <div style={{ display: "flex", alignItems: "center", gap: 6 }}>
          {links.map((l) => (
            <a key={l.label} href={l.href || "#"} target={l.href && l.href !== "#" ? "_blank" : undefined} rel={l.href && l.href !== "#" ? "noreferrer" : undefined} title={l.label} aria-label={l.label} style={{
              display: "inline-flex", alignItems: "center", justifyContent: "center",
              width: 36, height: 36, borderRadius: 4,
              color: "var(--fg-2)", textDecoration: "none",
              transition: "color 160ms, background 160ms",
            }}
            onMouseEnter={(e) => { e.currentTarget.style.color = "var(--lc-yellow)"; e.currentTarget.style.background = "var(--bg-2)"; }}
            onMouseLeave={(e) => { e.currentTarget.style.color = "var(--fg-2)"; e.currentTarget.style.background = "transparent"; }}>
              {l.icon}
            </a>
          ))}
        </div>
      </div>
    </footer>
  );
}

function PlayerBar({ ep, playing, currentTime, duration, rate = 1, onPlayPause, onSeek, onSkip, onCycleRate, thumb }) {
  if (!ep) return null;
  const pct = duration ? Math.min(100, (currentTime / duration) * 100) : 0;
  const fmt = (s) => {
    s = Math.floor(s || 0);
    if (s < 0 || !isFinite(s)) return "0:00";
    const h = Math.floor(s / 3600);
    const m = Math.floor((s % 3600) / 60);
    const sec = String(s % 60).padStart(2, "0");
    if (h > 0) return `${h}:${String(m).padStart(2, "0")}:${sec}`;
    return `${m}:${sec}`;
  };
  const handleScrub = (e) => {
    if (!duration) return;
    const rect = e.currentTarget.getBoundingClientRect();
    const ratio = Math.max(0, Math.min(1, (e.clientX - rect.left) / rect.width));
    onSeek(ratio * duration);
  };
  return (
    <div style={{
      position: "fixed", left: 0, right: 0, bottom: 0, zIndex: 60,
      background: "var(--bg-3)",
      borderTop: "1px solid var(--bg-line)",
      padding: "12px 24px",
      display: "flex", alignItems: "center", gap: 18,
      boxShadow: "0 -8px 24px rgba(0,0,0,.45)",
    }}>
      <div style={{
        width: 56, height: 56, borderRadius: 4,
        backgroundImage: `url('${thumb || "./assets/leaguecast-podcast-cover.jpg"}')`,
        backgroundSize: "cover", backgroundPosition: "center", flex: "none",
        border: "1px solid var(--bg-line)",
      }} />
      <div style={{ minWidth: 0, flex: "0 1 260px" }}>
        <div style={{
          fontFamily: "var(--font-display)", fontWeight: 700, fontSize: 14,
          textTransform: "uppercase", color: "var(--fg-1)",
          whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis",
        }}>{ep.title}</div>
        <div style={{
          fontFamily: "var(--font-body)", fontSize: 11, color: "var(--fg-3)",
          whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis",
        }}>{ep.bonus ? "Bonus episode" : `Episode ${ep.num}`} · Leaguecast</div>
      </div>
      <div style={{ display: "flex", alignItems: "center", gap: 8, flex: "none" }}>
        <button onClick={() => onSkip(-15)} title="Back 15s" style={iconBtn()}>
          <Icon name="skip-back" size={16} />
        </button>
        <button onClick={onPlayPause} title={playing ? "Pause" : "Play"} style={{
          width: 44, height: 44, borderRadius: 999,
          background: "var(--lc-yellow)", color: "var(--lc-ink)",
          border: 0, cursor: "pointer",
          display: "flex", alignItems: "center", justifyContent: "center",
          boxShadow: "0 0 0 1px rgba(238,213,54,.5), 0 0 16px rgba(238,213,54,.25)",
        }}>
          <Icon name={playing ? "pause" : "play"} size={18} stroke={2.5} />
        </button>
        <button onClick={() => onSkip(15)} title="Forward 15s" style={iconBtn()}>
          <Icon name="skip-forward" size={16} />
        </button>
      </div>
      <div style={{ flex: 1, display: "flex", alignItems: "center", gap: 10, minWidth: 200 }}>
        <div style={{ fontFamily: "var(--font-mono)", fontSize: 11, color: "var(--fg-3)", minWidth: 44, textAlign: "right" }}>{fmt(currentTime)}</div>
        <div onClick={handleScrub}
          style={{ flex: 1, height: 16, display: "flex", alignItems: "center", cursor: "pointer" }}>
          <div style={{ flex: 1, height: 4, background: "var(--bg-line)", borderRadius: 999, position: "relative" }}>
            <div style={{
              position: "absolute", left: 0, top: 0, bottom: 0, width: pct + "%",
              background: "var(--lc-yellow)", borderRadius: 999, transition: "width 100ms linear",
            }} />
            <div style={{
              position: "absolute", left: pct + "%", top: "50%",
              transform: "translate(-50%,-50%)",
              width: 12, height: 12, borderRadius: 999,
              background: "var(--lc-yellow)",
              boxShadow: "0 0 0 3px rgba(238,213,54,.2)",
            }} />
          </div>
        </div>
        <div style={{ fontFamily: "var(--font-mono)", fontSize: 11, color: "var(--fg-3)", minWidth: 44 }}>{fmt(duration)}</div>
      </div>
      {onCycleRate && (
        <button onClick={onCycleRate} title="Playback speed (click to cycle)" style={{
          flex: "none",
          height: 32, minWidth: 50, padding: "0 12px",
          borderRadius: 999,
          background: rate === 1 ? "transparent" : "var(--lc-yellow)",
          color: rate === 1 ? "var(--fg-2)" : "var(--lc-ink)",
          border: "1px solid " + (rate === 1 ? "var(--bg-line)" : "var(--lc-yellow)"),
          cursor: "pointer",
          fontFamily: "var(--font-display)", fontWeight: 700,
          fontSize: 13,
          display: "inline-flex", alignItems: "center", justifyContent: "center",
          transition: "all 120ms cubic-bezier(.22,.61,.36,1)",
        }}>
          {rate}×
        </button>
      )}
    </div>
  );
}

function iconBtn() {
  return {
    width: 32, height: 32, borderRadius: 999,
    background: "transparent", color: "var(--fg-2)",
    border: 0, cursor: "pointer",
    display: "flex", alignItems: "center", justifyContent: "center",
  };
}

Object.assign(window, { Logo, TopNav, Hero, EpisodeCard, HostCard, Footer, PlayerBar, Icon });
