<!-- RACING BIAS — WEC SERIES PAGE -->
<!-- Paste this entire block into the WordPress Code block on the WEC page -->
<!-- Your AI agent should POST articles to the #rb-wec-feed container via the data format below -->

<style>
  @import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@400;600;700;900&family=Barlow:wght@300;400;500&display=swap');

  .rb-wec-wrap * { box-sizing: border-box; margin: 0; padding: 0; }

  .rb-wec-wrap {
    font-family: 'Barlow', sans-serif;
    background: #0a0a0a;
    color: #fff;
    padding: 0;
    margin: 0 -20px;
    width: calc(100% + 40px);
  }

  /* ── HERO BANNER ── */
  .rb-wec-hero {
    position: relative;
    background: #0a0a0a;
    padding: 48px 40px 36px;
    border-bottom: 3px solid #00AEEF;
    overflow: hidden;
  }
  .rb-wec-hero::before {
    content: 'WEC';
    position: absolute;
    right: -10px;
    top: -20px;
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 160px;
    font-weight: 900;
    color: rgba(0,174,239,0.05);
    letter-spacing: -4px;
    pointer-events: none;
    line-height: 1;
  }
  .rb-wec-hero-eyebrow {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 4px;
    color: #00AEEF;
    text-transform: uppercase;
    margin-bottom: 10px;
  }
  .rb-wec-hero-title {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 52px;
    font-weight: 900;
    line-height: 1;
    letter-spacing: -1px;
    text-transform: uppercase;
    color: #fff;
    margin-bottom: 12px;
  }
  .rb-wec-hero-title span { color: #00AEEF; }
  .rb-wec-hero-desc {
    font-size: 14px;
    font-weight: 300;
    color: #888;
    max-width: 540px;
    line-height: 1.6;
    margin-bottom: 20px;
  }
  .rb-wec-hero-meta {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
  }
  .rb-wec-hero-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .rb-wec-hero-stat-num {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 22px;
    font-weight: 700;
    color: #00AEEF;
  }
  .rb-wec-hero-stat-label {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #555;
  }

  /* ── LIVE INDICATOR ── */
  .rb-wec-live-bar {
    background: #111;
    border-bottom: 1px solid #1a1a1a;
    padding: 10px 40px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 11px;
    letter-spacing: 1px;
    color: #555;
    text-transform: uppercase;
    font-weight: 500;
  }
  .rb-wec-live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #00AEEF;
    animation: rb-pulse 2s infinite;
    flex-shrink: 0;
  }
  @keyframes rb-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.8); }
  }
  #rb-wec-last-updated { color: #00AEEF; }

  /* ── FILTER BAR ── */
  .rb-wec-filters {
    padding: 16px 40px;
    background: #0d0d0d;
    border-bottom: 1px solid #1a1a1a;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
  }
  .rb-wec-filter-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 2px;
    color: #444;
    text-transform: uppercase;
    margin-right: 4px;
  }
  .rb-filter-btn {
    background: none;
    border: 1px solid #222;
    color: #666;
    padding: 5px 14px;
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 2px;
  }
  .rb-filter-btn:hover, .rb-filter-btn.active {
    background: #00AEEF;
    border-color: #00AEEF;
    color: #000;
  }

  /* ── FEED LAYOUT ── */
  .rb-wec-feed-wrap { padding: 32px 40px 48px; background: #0a0a0a; }

  /* Featured (first article — big) */
  .rb-wec-featured {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    background: #111;
    border: 1px solid #1e1e1e;
    margin-bottom: 28px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s;
    cursor: pointer;
  }
  .rb-wec-featured:hover { border-color: #00AEEF; }
  .rb-wec-featured-img {
    width: 100%;
    aspect-ratio: 16/10;
    object-fit: cover;
    display: block;
    background: #1a1a1a;
  }
  .rb-wec-featured-img-placeholder {
    width: 100%;
    aspect-ratio: 16/10;
    background: linear-gradient(135deg, #0d1a22 0%, #0a1520 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 32px;
    font-weight: 900;
    color: rgba(0,174,239,0.2);
    letter-spacing: 2px;
  }
  .rb-wec-featured-body {
    padding: 28px 28px 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }
  .rb-wec-tag {
    display: inline-block;
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    padding: 3px 10px;
    background: #00AEEF;
    color: #000;
    margin-bottom: 14px;
    width: fit-content;
  }
  .rb-wec-tag.breaking { background: #e63946; color: #fff; }
  .rb-wec-tag.opinion { background: #f4a261; color: #000; }
  .rb-wec-featured-headline {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 26px;
    font-weight: 700;
    line-height: 1.2;
    color: #fff;
    margin-bottom: 12px;
    flex-grow: 1;
  }
  .rb-wec-featured-excerpt {
    font-size: 13px;
    font-weight: 300;
    color: #777;
    line-height: 1.6;
    margin-bottom: 20px;
  }
  .rb-wec-article-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
  }
  .rb-wec-source {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #00AEEF;
  }
  .rb-wec-dot { color: #333; font-size: 10px; }
  .rb-wec-time {
    font-size: 11px;
    color: #444;
  }
  .rb-wec-ext-icon {
    font-size: 10px;
    color: #333;
    margin-left: auto;
  }

  /* Grid cards */
  .rb-wec-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 28px;
  }
  .rb-wec-card {
    background: #111;
    border: 1px solid #1e1e1e;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s, transform 0.2s;
    display: flex;
    flex-direction: column;
    cursor: pointer;
  }
  .rb-wec-card:hover { border-color: #00AEEF; transform: translateY(-2px); }
  .rb-wec-card-img {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    background: #1a1a1a;
    display: block;
  }
  .rb-wec-card-img-placeholder {
    width: 100%;
    aspect-ratio: 16/9;
    background: #111;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(0,174,239,0.15);
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 18px;
    font-weight: 900;
    letter-spacing: 2px;
  }
  .rb-wec-card-body { padding: 16px; flex-grow: 1; display: flex; flex-direction: column; }
  .rb-wec-card-headline {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.25;
    color: #e8e8e8;
    margin-bottom: 10px;
    flex-grow: 1;
  }

  /* List articles (below the grid) */
  .rb-wec-list { display: flex; flex-direction: column; gap: 1px; }
  .rb-wec-list-item {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 0;
    background: #111;
    border: 1px solid #1a1a1a;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s;
    cursor: pointer;
    margin-bottom: 8px;
  }
  .rb-wec-list-item:hover { border-color: #00AEEF; }
  .rb-wec-list-img {
    width: 100px;
    height: 70px;
    object-fit: cover;
    display: block;
    background: #1a1a1a;
  }
  .rb-wec-list-img-placeholder {
    width: 100px;
    height: 70px;
    background: #131313;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(0,174,239,0.12);
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 12px;
    font-weight: 900;
  }
  .rb-wec-list-body {
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
  }
  .rb-wec-list-headline {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.25;
    color: #ddd;
  }

  /* Load more */
  .rb-load-more-wrap { text-align: center; padding-top: 16px; }
  .rb-load-more-btn {
    background: none;
    border: 1px solid #333;
    color: #555;
    padding: 12px 36px;
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s;
  }
  .rb-load-more-btn:hover { border-color: #00AEEF; color: #00AEEF; }

  /* Empty state */
  .rb-wec-empty {
    text-align: center;
    padding: 60px 20px;
    color: #333;
  }
  .rb-wec-empty-icon {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 48px;
    font-weight: 900;
    color: rgba(0,174,239,0.1);
    margin-bottom: 12px;
  }
  .rb-wec-empty p { font-size: 13px; color: #444; }

  /* Hidden articles for filtering */
  .rb-article-item[data-hidden="true"] { display: none !important; }

  /* Responsive */
  @media (max-width: 768px) {
    .rb-wec-wrap { margin: 0 -16px; width: calc(100% + 32px); }
    .rb-wec-hero { padding: 32px 20px 24px; }
    .rb-wec-hero-title { font-size: 36px; }
    .rb-wec-filters { padding: 12px 20px; }
    .rb-wec-feed-wrap { padding: 24px 20px 36px; }
    .rb-wec-featured { grid-template-columns: 1fr; }
    .rb-wec-grid { grid-template-columns: 1fr 1fr; }
    .rb-wec-live-bar { padding: 10px 20px; }
  }
  @media (max-width: 500px) {
    .rb-wec-grid { grid-template-columns: 1fr; }
  }
</style>

<div class="rb-wec-wrap" id="rb-wec-page">

  <!-- HERO -->
  <div class="rb-wec-hero">
    <div class="rb-wec-hero-eyebrow">Racing Bias // Series Coverage</div>
    <h1 class="rb-wec-hero-title">FIA World<br><span>Endurance</span><br>Championship</h1>
    <p class="rb-wec-hero-desc">The pinnacle of endurance racing. Le Mans. Spa. Fuji. Bahrain. Breaking news, results, and analysis from every round of the WEC season — all in one place.</p>
    <div class="rb-wec-hero-meta">
      <div class="rb-wec-hero-stat">
        <span class="rb-wec-hero-stat-num" id="rb-wec-article-count">—</span>
        <span class="rb-wec-hero-stat-label">Articles</span>
      </div>
      <div class="rb-wec-hero-stat">
        <span class="rb-wec-hero-stat-num">Hypercar</span>
        <span class="rb-wec-hero-stat-label">Top Class</span>
      </div>
      <div class="rb-wec-hero-stat">
        <span class="rb-wec-hero-stat-num">24h</span>
        <span class="rb-wec-hero-stat-label">Le Mans</span>
      </div>
    </div>
  </div>

  <!-- LIVE BAR -->
  <div class="rb-wec-live-bar">
    <div class="rb-wec-live-dot"></div>
    <span>Live feed</span>
    <span style="color:#333">•</span>
    <span>Last updated: <span id="rb-wec-last-updated">—</span></span>
    <span style="margin-left:auto;font-size:10px;color:#333;">racingbias.com</span>
  </div>

  <!-- FILTER BAR -->
  <div class="rb-wec-filters">
    <span class="rb-wec-filter-label">Filter:</span>
    <button class="rb-filter-btn active" onclick="rbFilter('all', this)">All</button>
    <button class="rb-filter-btn" onclick="rbFilter('breaking', this)">Breaking</button>
    <button class="rb-filter-btn" onclick="rbFilter('results', this)">Results</button>
    <button class="rb-filter-btn" onclick="rbFilter('hypercar', this)">Hypercar</button>
    <button class="rb-filter-btn" onclick="rbFilter('lmp2', this)">LMP2</button>
    <button class="rb-filter-btn" onclick="rbFilter('le-mans', this)">Le Mans</button>
    <button class="rb-filter-btn" onclick="rbFilter('opinion', this)">Bias Take</button>
  </div>

  <!-- FEED -->
  <div class="rb-wec-feed-wrap">
    <div id="rb-wec-feed">
      <!-- Articles injected here by JS or your AI agent -->
    </div>
    <div class="rb-load-more-wrap" id="rb-load-more-wrap" style="display:none;">
      <button class="rb-load-more-btn" onclick="rbLoadMore()">Load More Stories</button>
    </div>
  </div>

</div>

<script>
(function() {

  // ─────────────────────────────────────────────
  // CONFIG — update these to match your AI agent
  // ─────────────────────────────────────────────
  var RB_WEC_CONFIG = {
    // If your AI agent posts to a JSON endpoint, set this URL.
    // Leave as null to use the demo articles below.
    feedUrl: null,

    // How often to auto-refresh (ms). 0 = disabled.
    refreshInterval: 120000, // 2 minutes

    // Articles shown per page before "Load More"
    articlesPerPage: 9,
  };

  // ─────────────────────────────────────────────
  // STATE
  // ─────────────────────────────────────────────
  var allArticles = [];
  var filteredArticles = [];
  var currentFilter = 'all';
  var currentPage = 1;

  // ─────────────────────────────────────────────
  // DEMO ARTICLES
  // Replace with your live feed, or let your AI
  // agent call window.rbInjectArticles(articles)
  // ─────────────────────────────────────────────
  var demoArticles = [
    {
      id: 1,
      headline: "Toyota Claims Pole Position Ahead of WEC Opener in Qatar",
      excerpt: "The GR010 Hypercar secures front-row lockout as Porsche and Ferrari fight for second row grid positions in sweltering Doha heat.",
      source: "Autosport",
      time: "2h ago",
      url: "#",
      image: null,
      tags: ["hypercar","results"],
      type: "featured"
    },
    {
      id: 2,
      headline: "Ferrari 499P Running in Top 3 After Six Hours at Spa",
      excerpt: "The Italian manufacturer's Hypercar showing remarkable consistency in Belgian endurance test.",
      source: "Motorsport.com",
      time: "4h ago",
      url: "#",
      image: null,
      tags: ["hypercar","results"],
      type: "card"
    },
    {
      id: 3,
      headline: "Porsche Confirms Updated 963 Aero Package for Le Mans",
      excerpt: "New front splitter and rear diffuser combination expected to close gap to Toyota on straights.",
      source: "The Race",
      time: "6h ago",
      url: "#",
      image: null,
      tags: ["hypercar","le-mans"],
      type: "card"
    },
    {
      id: 4,
      headline: "JOTA Expands to Three LMP2 Entries for Full WEC Season",
      excerpt: "British team announces additional Oreca 07 entry as LMP2 grid builds ahead of season opener.",
      source: "WEC Official",
      time: "8h ago",
      url: "#",
      image: null,
      tags: ["lmp2"],
      type: "card"
    },
    {
      id: 5,
      headline: "WEC Stewards Penalise Alpine A424 After Qualifying Irregularity",
      excerpt: "Five-place grid drop handed to Alpine following post-qualifying technical inspection.",
      source: "Motorsport Week",
      time: "10h ago",
      url: "#",
      image: null,
      tags: ["breaking","results"],
      type: "list"
    },
    {
      id: 6,
      headline: "Le Mans 24 Hours Entry List Confirms Record 62-Car Field",
      excerpt: "FIA and ACO confirm the biggest Le Mans grid in over a decade including six Hypercar manufacturers.",
      source: "RaceFans",
      time: "12h ago",
      url: "#",
      image: null,
      tags: ["le-mans"],
      type: "list"
    },
    {
      id: 7,
      headline: "Racing Bias Take: Is Toyota's WEC Dominance Hurting the Championship?",
      excerpt: "We argue the case for and against manufacturer balance — and why the ACO must act before Le Mans.",
      source: "Racing Bias",
      time: "1d ago",
      url: "#",
      image: null,
      tags: ["opinion"],
      type: "list"
    },
    {
      id: 8,
      headline: "BMW M Hybrid V8 Posts Fastest WEC Test Time in Prologue",
      excerpt: "German manufacturer stuns rivals with benchmark lap in pre-season Prologue at Sebring.",
      source: "Autosport",
      time: "1d ago",
      url: "#",
      image: null,
      tags: ["hypercar"],
      type: "list"
    },
    {
      id: 9,
      headline: "Cadillac V-Series.R Set for Full WEC Campaign in 2026 Season",
      excerpt: "American marque joins full-season programme after successful partial entries in recent seasons.",
      source: "Sportscar365",
      time: "2d ago",
      url: "#",
      image: null,
      tags: ["hypercar"],
      type: "list"
    }
  ];

  // ─────────────────────────────────────────────
  // PUBLIC API — your AI agent calls these
  // ─────────────────────────────────────────────

  // Your AI agent can call: window.rbWEC.injectArticles(articles)
  // Articles format:
  // [{
  //   id: unique_id,
  //   headline: "string",
  //   excerpt: "string (optional)",
  //   source: "Source Name",
  //   time: "2h ago",
  //   url: "https://original-source.com/article",
  //   image: "https://image-url.com/img.jpg" or null,
  //   tags: ["breaking","hypercar","results","lmp2","le-mans","opinion"],
  //   type: "featured" | "card" | "list"  (first article auto-becomes featured)
  // }]

  window.rbWEC = {
    injectArticles: function(articles) {
      allArticles = articles;
      // Auto-promote first article to featured
      if (allArticles.length > 0) allArticles[0].type = 'featured';
      rbApplyFilter();
      rbUpdateMeta();
    },
    addArticle: function(article) {
      allArticles.unshift(article);
      allArticles[0].type = 'featured';
      if (allArticles[1]) allArticles[1].type = 'card';
      rbApplyFilter();
      rbUpdateMeta();
    }
  };

  // ─────────────────────────────────────────────
  // FILTER
  // ─────────────────────────────────────────────
  window.rbFilter = function(filter, btn) {
    currentFilter = filter;
    currentPage = 1;
    document.querySelectorAll('.rb-filter-btn').forEach(function(b){ b.classList.remove('active'); });
    if (btn) btn.classList.add('active');
    rbApplyFilter();
  };

  function rbApplyFilter() {
    if (currentFilter === 'all') {
      filteredArticles = allArticles.slice();
    } else {
      filteredArticles = allArticles.filter(function(a){
        return a.tags && a.tags.indexOf(currentFilter) > -1;
      });
    }
    rbRender();
  }

  // ─────────────────────────────────────────────
  // LOAD MORE
  // ─────────────────────────────────────────────
  window.rbLoadMore = function() {
    currentPage++;
    rbRender();
  };

  // ─────────────────────────────────────────────
  // RENDER
  // ─────────────────────────────────────────────
  function rbRender() {
    var feed = document.getElementById('rb-wec-feed');
    var loadMoreWrap = document.getElementById('rb-load-more-wrap');
    var visible = filteredArticles.slice(0, currentPage * RB_WEC_CONFIG.articlesPerPage);

    if (filteredArticles.length === 0) {
      feed.innerHTML = '<div class="rb-wec-empty"><div class="rb-wec-empty-icon">WEC</div><p>No stories yet. Check back soon.</p></div>';
      loadMoreWrap.style.display = 'none';
      return;
    }

    var featured = visible.filter(function(a){ return a.type === 'featured'; });
    var cards = visible.filter(function(a){ return a.type === 'card'; });
    var listItems = visible.filter(function(a){ return a.type === 'list'; });

    var html = '';

    // Featured
    featured.forEach(function(a){
      html += '<a class="rb-wec-featured rb-article-item" href="' + a.url + '" target="_blank" rel="noopener" data-tags="' + (a.tags||[]).join(',') + '">';
      html += rbImageOrPlaceholder(a.image, 'rb-wec-featured-img', 'rb-wec-featured-img-placeholder', 'WEC');
      html += '<div class="rb-wec-featured-body">';
      html += '<div>';
      html += rbTag(a);
      html += '<div class="rb-wec-featured-headline">' + rbEscape(a.headline) + '</div>';
      if (a.excerpt) html += '<div class="rb-wec-featured-excerpt">' + rbEscape(a.excerpt) + '</div>';
      html += '</div>';
      html += rbMeta(a);
      html += '</div></a>';
    });

    // Cards grid
    if (cards.length > 0) {
      html += '<div class="rb-wec-grid">';
      cards.forEach(function(a){
        html += '<a class="rb-wec-card rb-article-item" href="' + a.url + '" target="_blank" rel="noopener" data-tags="' + (a.tags||[]).join(',') + '">';
        html += rbImageOrPlaceholder(a.image, 'rb-wec-card-img', 'rb-wec-card-img-placeholder', 'WEC');
        html += '<div class="rb-wec-card-body">';
        html += rbTag(a);
        html += '<div class="rb-wec-card-headline">' + rbEscape(a.headline) + '</div>';
        html += rbMeta(a);
        html += '</div></a>';
      });
      html += '</div>';
    }

    // List items
    if (listItems.length > 0) {
      html += '<div class="rb-wec-list">';
      listItems.forEach(function(a){
        html += '<a class="rb-wec-list-item rb-article-item" href="' + a.url + '" target="_blank" rel="noopener" data-tags="' + (a.tags||[]).join(',') + '">';
        html += rbListImage(a.image);
        html += '<div class="rb-wec-list-body">';
        html += rbTag(a);
        html += '<div class="rb-wec-list-headline">' + rbEscape(a.headline) + '</div>';
        html += rbMeta(a);
        html += '</div></a>';
      });
      html += '</div>';
    }

    feed.innerHTML = html;

    // Load more button
    if (visible.length < filteredArticles.length) {
      loadMoreWrap.style.display = 'block';
    } else {
      loadMoreWrap.style.display = 'none';
    }
  }

  // ─────────────────────────────────────────────
  // HELPERS
  // ─────────────────────────────────────────────
  function rbImageOrPlaceholder(url, imgClass, placeholderClass, label) {
    if (url) {
      return '<img class="' + imgClass + '" src="' + url + '" alt="" loading="lazy" onerror="this.style.display=\'none\'">';
    }
    return '<div class="' + placeholderClass + '">' + label + '</div>';
  }

  function rbListImage(url) {
    if (url) {
      return '<img class="rb-wec-list-img" src="' + url + '" alt="" loading="lazy" onerror="this.style.display=\'none\'">';
    }
    return '<div class="rb-wec-list-img-placeholder">WEC</div>';
  }

  function rbTag(a) {
    if (!a.tags || a.tags.length === 0) return '';
    var t = a.tags[0];
    var cls = t === 'breaking' ? 'breaking' : t === 'opinion' ? 'opinion' : '';
    var label = t === 'breaking' ? 'Breaking' : t === 'results' ? 'Results' : t === 'hypercar' ? 'Hypercar' : t === 'lmp2' ? 'LMP2' : t === 'le-mans' ? 'Le Mans' : t === 'opinion' ? 'Bias Take' : t;
    return '<span class="rb-wec-tag ' + cls + '">' + label + '</span>';
  }

  function rbMeta(a) {
    return '<div class="rb-wec-article-meta"><span class="rb-wec-source">' + rbEscape(a.source) + '</span><span class="rb-wec-dot">•</span><span class="rb-wec-time">' + rbEscape(a.time) + '</span><span class="rb-wec-ext-icon">↗</span></div>';
  }

  function rbEscape(str) {
    if (!str) return '';
    return String(str).replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,'&quot;');
  }

  function rbUpdateMeta() {
    var el = document.getElementById('rb-wec-article-count');
    if (el) el.textContent = allArticles.length;
    var ts = document.getElementById('rb-wec-last-updated');
    if (ts) {
      var now = new Date();
      ts.textContent = now.toLocaleTimeString([], {hour:'2-digit', minute:'2-digit'});
    }
  }

  // ─────────────────────────────────────────────
  // FETCH FROM FEED URL (if configured)
  // ─────────────────────────────────────────────
  function rbFetchFeed() {
    if (!RB_WEC_CONFIG.feedUrl) return;
    fetch(RB_WEC_CONFIG.feedUrl)
      .then(function(r){ return r.json(); })
      .then(function(data){
        if (data && Array.isArray(data.articles)) {
          window.rbWEC.injectArticles(data.articles);
        }
      })
      .catch(function(e){ console.warn('Racing Bias WEC feed error:', e); });
  }

  // ─────────────────────────────────────────────
  // INIT
  // ─────────────────────────────────────────────
  function rbInit() {
    if (RB_WEC_CONFIG.feedUrl) {
      rbFetchFeed();
      if (RB_WEC_CONFIG.refreshInterval > 0) {
        setInterval(rbFetchFeed, RB_WEC_CONFIG.refreshInterval);
      }
    } else {
      // Load demo articles until your live feed is connected
      window.rbWEC.injectArticles(demoArticles);
    }
  }

  if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', rbInit);
  } else {
    rbInit();
  }

})();
</script>
<!-- END RACING BIAS WEC PAGE -->