{
  "id": 43,
  "slug": "empirical-data-atlas",
  "name": "Empirical Data Atlas",
  "kind": "style",
  "family": "Scientific & Data Journalism",
  "sourceSite": {
    "name": "Our World in Data",
    "url": "https://ourworldindata.org/",
    "verifiedStatus": 200
  },
  "tagline": "Institutional empirical research portal with multi-series longitudinal charts, linear/log switches, and data tables.",
  "whyUnique": "Prioritizes transparent empirical evidence by pairing authoritative Oxford-navy editorial framing with interactive chart/table explorers that cite methodology directly beneath each plot.",
  "theme": "light",
  "mobileStrength": "high",
  "tags": [
    "data-dense",
    "charts",
    "research",
    "institutional",
    "editorial-data",
    "light-mode"
  ],
  "bestFor": [
    "Public policy and longitudinal research portals",
    "Climate, energy, and demographic open-data explorers",
    "Annual transparency and impact reports"
  ],
  "palette": [
    {
      "role": "canvas",
      "hex": "#F7F9FB",
      "name": "Research Paper"
    },
    {
      "role": "surface",
      "hex": "#FFFFFF",
      "name": "Chart Sheet"
    },
    {
      "role": "ink",
      "hex": "#0F2744",
      "name": "Oxford Navy"
    },
    {
      "role": "accent",
      "hex": "#1D5B9B",
      "name": "Cobalt Series"
    },
    {
      "role": "muted",
      "hex": "#5C6F82",
      "name": "Citation Steel"
    }
  ],
  "typography": {
    "display": "Playfair Display",
    "body": "Lato",
    "mono": "IBM Plex Mono",
    "googleFontsUrl": "https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=Lato:wght@400;700&family=Playfair+Display:wght@600;700&display=swap",
    "scaleNotes": "Editorial serif titles (28-38px) paired with clean humanist sans UI controls (13-15px) and tabular monospace axis labels."
  },
  "layoutNotes": "Institutional top bar in Oxford navy above a centered interactive grapher card with bottom Chart/Table mode tabs, source footer, and country legend chips.",
  "interactionNotes": "Toggle individual series visibility, switch between Linear and Logarithmic Y-axis scales, and flip seamlessly between SVG time-series chart and sortable tabular data.",
  "mobileNotes": "Country legend wraps into scrollable 44px touch chips and the data table scrolls cleanly inside its card container with zero page overflow.",
  "agentGuardrails": {
    "do": [
      "Include explicit units, source attribution, and axis labels on every chart",
      "Provide both visual chart and structured table views for the same underlying dataset",
      "Use distinct, colorblind-conscious series hues against crisp white chart surfaces"
    ],
    "dont": [
      "Do not omit zero-baseline or scale indicators when toggling Linear vs Log modes",
      "Do not clutter the grapher with decorative 3D effects or unlabelled sparklines"
    ]
  },
  "demoFile": "demos/empirical-data-atlas.html",
  "thumbDesktop": "thumbs/empirical-data-atlas-desktop.webp",
  "thumbMobile": "thumbs/empirical-data-atlas-mobile.webp",
  "urls": {
    "page": "https://templates.michaelpitts.net/t/empirical-data-atlas",
    "markdown": "https://templates.michaelpitts.net/t/empirical-data-atlas.md",
    "api": "https://templates.michaelpitts.net/api/templates/empirical-data-atlas",
    "demo": "https://templates.michaelpitts.net/demos/empirical-data-atlas.html",
    "thumbDesktop": "https://templates.michaelpitts.net/thumbs/empirical-data-atlas-desktop.webp",
    "thumbMobile": "https://templates.michaelpitts.net/thumbs/empirical-data-atlas-mobile.webp"
  },
  "agentPrompt": "Design & build using template #043 \"Empirical Data Atlas\" (style / Scientific & Data Journalism, light theme).\nFull AI blueprint & standalone starter code: https://templates.michaelpitts.net/t/empirical-data-atlas.md\nLive demo: https://templates.michaelpitts.net/demos/empirical-data-atlas.html\nReal-world inspiration: Our World in Data (https://ourworldindata.org/)\n\nCore aesthetic: Prioritizes transparent empirical evidence by pairing authoritative Oxford-navy editorial framing with interactive chart/table explorers that cite methodology directly beneath each plot.\nPalette: canvas: #F7F9FB (Research Paper), surface: #FFFFFF (Chart Sheet), ink: #0F2744 (Oxford Navy), accent: #1D5B9B (Cobalt Series), muted: #5C6F82 (Citation Steel)\nTypography: Display=\"Playfair Display\", Body=\"Lato\", Mono=\"IBM Plex Mono\"\nLayout: Institutional top bar in Oxford navy above a centered interactive grapher card with bottom Chart/Table mode tabs, source footer, and country legend chips.\nInteractions: Toggle individual series visibility, switch between Linear and Logarithmic Y-axis scales, and flip seamlessly between SVG time-series chart and sortable tabular data.\nMobile: Country legend wraps into scrollable 44px touch chips and the data table scrolls cleanly inside its card container with zero page overflow.\n\nGuardrails:\n- DO: Include explicit units, source attribution, and axis labels on every chart\n- DO: Provide both visual chart and structured table views for the same underlying dataset\n- DO: Use distinct, colorblind-conscious series hues against crisp white chart surfaces\n- DON'T: Do not omit zero-baseline or scale indicators when toggling Linear vs Log modes\n- DON'T: Do not clutter the grapher with decorative 3D effects or unlabelled sparklines",
  "sourceCode": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"UTF-8\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n  <title>Global Empirical Atlas — Share of Electricity from Renewables (1990–2025)</title>\n  <link rel=\"preconnect\" href=\"https://fonts.googleapis.com\">\n  <link rel=\"preconnect\" href=\"https://fonts.gstatic.com\" crossorigin>\n  <link href=\"https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=Playfair+Display:wght@600;700&family=Source+Sans+3:wght@400;500;600;700&display=swap\" rel=\"stylesheet\">\n  <style>\n    :root {\n      --canvas: #F7F9FB;\n      --surface: #FFFFFF;\n      --ink: #0F2744;\n      --accent: #1D5B9B;\n      --accent-soft: #EBF3FA;\n      --muted: #5C6F82;\n      --border: #DCE4EC;\n      --serif: 'Playfair Display', Georgia, serif;\n      --sans: 'Source Sans 3', system-ui, -apple-system, sans-serif;\n      --mono: 'IBM Plex Mono', ui-monospace, monospace;\n    }\n\n    *, *::before, *::after {\n      box-sizing: border-box;\n    }\n\n    body {\n      margin: 0;\n      background: var(--canvas);\n      color: var(--ink);\n      font-family: var(--sans);\n      line-height: 1.55;\n      overflow-x: hidden;\n    }\n\n    /* Institutional Header */\n    .inst-header {\n      background: var(--ink);\n      color: #FFFFFF;\n      border-bottom: 3px solid var(--accent);\n    }\n\n    .inst-inner {\n      max-width: 1180px;\n      margin: 0 auto;\n      padding: 0 20px;\n      min-height: 62px;\n      display: flex;\n      align-items: center;\n      justify-content: space-between;\n      gap: 16px;\n    }\n\n    .inst-brand {\n      display: flex;\n      align-items: center;\n      gap: 12px;\n      text-decoration: none;\n      color: #FFFFFF;\n    }\n\n    .inst-mark {\n      width: 34px;\n      height: 34px;\n      border-radius: 4px;\n      background: var(--accent);\n      display: grid;\n      place-items: center;\n      font-family: var(--serif);\n      font-weight: 700;\n      font-size: 1.05rem;\n      flex-shrink: 0;\n    }\n\n    .inst-title {\n      font-weight: 700;\n      font-size: 1rem;\n      letter-spacing: 0.01em;\n      line-height: 1.15;\n    }\n\n    .inst-sub {\n      display: block;\n      font-size: 0.72rem;\n      color: #A9BFD4;\n      font-weight: 400;\n    }\n\n    .inst-nav {\n      display: flex;\n      align-items: center;\n      gap: 20px;\n      font-size: 0.9rem;\n    }\n\n    .inst-nav a {\n      color: #D7E4F0;\n      text-decoration: none;\n      font-weight: 500;\n    }\n\n    .inst-nav a:hover {\n      color: #FFFFFF;\n      text-decoration: underline;\n    }\n\n    .nav-menu-btn {\n      display: none;\n      min-width: 44px;\n      min-height: 44px;\n      padding: 0 12px;\n      background: rgba(255, 255, 255, 0.12);\n      border: 1px solid rgba(255, 255, 255, 0.25);\n      border-radius: 5px;\n      color: #FFFFFF;\n      font-family: var(--sans);\n      font-weight: 600;\n      cursor: pointer;\n    }\n\n    .mobile-nav-drawer {\n      display: none;\n      background: #133154;\n      padding: 8px 20px 16px;\n      border-top: 1px solid rgba(255, 255, 255, 0.12);\n    }\n\n    .mobile-nav-drawer.open {\n      display: block;\n    }\n\n    .mobile-nav-drawer a {\n      display: flex;\n      align-items: center;\n      min-height: 44px;\n      color: #E4EEF7;\n      text-decoration: none;\n      border-bottom: 1px solid rgba(255, 255, 255, 0.08);\n      font-size: 0.95rem;\n    }\n\n    /* Main Container */\n    .page-shell {\n      max-width: 1180px;\n      margin: 0 auto;\n      padding: 28px 20px 64px;\n    }\n\n    .breadcrumb {\n      font-size: 0.82rem;\n      color: var(--muted);\n      margin-bottom: 10px;\n    }\n\n    .page-head h1 {\n      font-family: var(--serif);\n      font-size: clamp(1.7rem, 3.2vw, 2.45rem);\n      line-height: 1.18;\n      margin: 0 0 10px;\n      color: var(--ink);\n    }\n\n    .page-lead {\n      max-width: 74ch;\n      color: var(--muted);\n      font-size: 1.04rem;\n      margin: 0 0 24px;\n    }\n\n    /* KPI Summary Strip */\n    .kpi-strip {\n      display: grid;\n      grid-template-columns: repeat(4, minmax(0, 1fr));\n      gap: 14px;\n      margin-bottom: 24px;\n    }\n\n    .kpi-card {\n      background: var(--surface);\n      border: 1px solid var(--border);\n      border-radius: 6px;\n      padding: 14px 16px;\n    }\n\n    .kpi-label {\n      font-size: 0.76rem;\n      text-transform: uppercase;\n      letter-spacing: 0.06em;\n      color: var(--muted);\n      font-weight: 600;\n    }\n\n    .kpi-value {\n      font-family: var(--mono);\n      font-size: 1.45rem;\n      font-weight: 500;\n      color: var(--ink);\n      margin: 4px 0 2px;\n    }\n\n    .kpi-delta {\n      font-size: 0.8rem;\n      color: var(--accent);\n      font-weight: 600;\n    }\n\n    /* Grapher Card */\n    .grapher-card {\n      background: var(--surface);\n      border: 1px solid var(--border);\n      border-radius: 8px;\n      box-shadow: 0 4px 18px rgba(15, 39, 68, 0.05);\n      overflow: hidden;\n    }\n\n    .grapher-top {\n      padding: 20px 22px 14px;\n      border-bottom: 1px solid var(--border);\n      display: flex;\n      flex-wrap: wrap;\n      align-items: flex-start;\n      justify-content: space-between;\n      gap: 14px;\n    }\n\n    .grapher-title {\n      font-family: var(--serif);\n      font-size: 1.28rem;\n      margin: 0 0 4px;\n    }\n\n    .grapher-sub {\n      font-size: 0.88rem;\n      color: var(--muted);\n      margin: 0;\n    }\n\n    .grapher-controls {\n      display: flex;\n      flex-wrap: wrap;\n      align-items: center;\n      gap: 8px;\n    }\n\n    .seg-group {\n      display: inline-flex;\n      background: var(--canvas);\n      border: 1px solid var(--border);\n      border-radius: 6px;\n      padding: 2px;\n    }\n\n    .seg-btn {\n      min-height: 40px;\n      padding: 0 13px;\n      border: none;\n      background: transparent;\n      color: var(--muted);\n      font-family: var(--sans);\n      font-size: 0.84rem;\n      font-weight: 600;\n      border-radius: 4px;\n      cursor: pointer;\n    }\n\n    .seg-btn.active {\n      background: var(--surface);\n      color: var(--accent);\n      box-shadow: 0 1px 3px rgba(15, 39, 68, 0.12);\n    }\n\n    /* Country Filter Chips */\n    .country-bar {\n      padding: 12px 22px;\n      background: #FAFCFE;\n      border-bottom: 1px solid var(--border);\n      display: flex;\n      flex-wrap: wrap;\n      align-items: center;\n      gap: 8px;\n    }\n\n    .country-bar-label {\n      font-size: 0.78rem;\n      font-weight: 700;\n      text-transform: uppercase;\n      letter-spacing: 0.05em;\n      color: var(--muted);\n      margin-right: 4px;\n    }\n\n    .country-chip {\n      min-height: 40px;\n      padding: 0 12px;\n      border-radius: 99px;\n      border: 1px solid var(--border);\n      background: var(--surface);\n      color: var(--ink);\n      font-family: var(--sans);\n      font-size: 0.84rem;\n      font-weight: 600;\n      display: inline-flex;\n      align-items: center;\n      gap: 7px;\n      cursor: pointer;\n      transition: opacity 0.15s, border-color 0.15s;\n    }\n\n    .country-chip.inactive {\n      opacity: 0.42;\n    }\n\n    .swatch {\n      width: 10px;\n      height: 10px;\n      border-radius: 50%;\n      flex-shrink: 0;\n    }\n\n    /* Chart & Table Body */\n    .grapher-body {\n      padding: 18px 22px 22px;\n    }\n\n    .chart-wrap {\n      position: relative;\n      width: 100%;\n    }\n\n    #atlasSvg {\n      width: 100%;\n      height: auto;\n      display: block;\n    }\n\n    .hover-readout {\n      margin-top: 12px;\n      padding: 10px 14px;\n      background: var(--canvas);\n      border: 1px solid var(--border);\n      border-radius: 6px;\n      display: flex;\n      flex-wrap: wrap;\n      align-items: center;\n      justify-content: space-between;\n      gap: 10px;\n      font-size: 0.86rem;\n    }\n\n    .hover-year {\n      font-family: var(--mono);\n      font-weight: 600;\n      color: var(--accent);\n    }\n\n    .hover-values {\n      display: flex;\n      flex-wrap: wrap;\n      gap: 14px;\n      font-family: var(--mono);\n      font-size: 0.8rem;\n    }\n\n    .table-wrap {\n      display: none;\n      width: 100%;\n      overflow-x: auto;\n    }\n\n    .table-wrap.active {\n      display: block;\n    }\n\n    .chart-panel.hidden {\n      display: none;\n    }\n\n    table {\n      width: 100%;\n      border-collapse: collapse;\n      font-size: 0.9rem;\n    }\n\n    th, td {\n      padding: 11px 12px;\n      text-align: right;\n      border-bottom: 1px solid var(--border);\n      font-variant-numeric: tabular-nums;\n    }\n\n    th:first-child, td:first-child {\n      text-align: left;\n      font-weight: 600;\n    }\n\n    thead th {\n      background: var(--canvas);\n      color: var(--muted);\n      font-size: 0.78rem;\n      text-transform: uppercase;\n      letter-spacing: 0.05em;\n    }\n\n    .grapher-footer {\n      padding: 14px 22px;\n      background: var(--canvas);\n      border-top: 1px solid var(--border);\n      font-size: 0.8rem;\n      color: var(--muted);\n      display: flex;\n      flex-wrap: wrap;\n      justify-content: space-between;\n      gap: 8px;\n    }\n\n    /* Methodology Notes */\n    .notes-grid {\n      margin-top: 28px;\n      display: grid;\n      grid-template-columns: repeat(2, minmax(0, 1fr));\n      gap: 18px;\n    }\n\n    .note-box {\n      background: var(--surface);\n      border: 1px solid var(--border);\n      border-radius: 6px;\n      padding: 18px 20px;\n    }\n\n    .note-box h2 {\n      font-family: var(--serif);\n      font-size: 1.12rem;\n      margin: 0 0 8px;\n    }\n\n    .note-box p {\n      margin: 0;\n      font-size: 0.92rem;\n      color: var(--muted);\n    }\n\n    @media (max-width: 820px) {\n      .inst-nav {\n        display: none;\n      }\n\n      .nav-menu-btn {\n        display: inline-flex;\n        align-items: center;\n        justify-content: center;\n      }\n\n      .kpi-strip {\n        grid-template-columns: repeat(2, minmax(0, 1fr));\n      }\n\n      .notes-grid {\n        grid-template-columns: 1fr;\n      }\n\n      .seg-btn, .country-chip {\n        min-height: 44px;\n      }\n\n      .grapher-top, .country-bar, .grapher-body, .grapher-footer {\n        padding-left: 14px;\n        padding-right: 14px;\n      }\n    }\n  </style>\n</head>\n<body>\n  <header class=\"inst-header\">\n    <div class=\"inst-inner\">\n      <a class=\"inst-brand\" href=\"#top\">\n        <span class=\"inst-mark\" aria-hidden=\"true\">E</span>\n        <div>\n          <span class=\"inst-title\">Empirical Data Atlas</span>\n          <span class=\"inst-sub\">Institute for Global Quantitative Research</span>\n        </div>\n      </a>\n      <nav class=\"inst-nav\" aria-label=\"Primary portal navigation\">\n        <a href=\"#explorer\">Data Explorer</a>\n        <a href=\"#methodology\">Methodology</a>\n        <a href=\"#sources\">Sources</a>\n      </nav>\n      <button class=\"nav-menu-btn\" id=\"menuToggle\" type=\"button\" aria-expanded=\"false\" aria-controls=\"mobileDrawer\">Menu</button>\n    </div>\n    <nav class=\"mobile-nav-drawer\" id=\"mobileDrawer\" aria-label=\"Mobile navigation\">\n      <a href=\"#explorer\">Data Explorer</a>\n      <a href=\"#methodology\">Methodology</a>\n      <a href=\"#sources\">Sources &amp; Citations</a>\n    </nav>\n  </header>\n\n  <main class=\"page-shell\" id=\"top\">\n    <div class=\"breadcrumb\">Energy &amp; Environment / Electricity Mix / Renewable Generation</div>\n    <section class=\"page-head\">\n      <h1>Share of Electricity Generation from Renewables, 1990–2025</h1>\n      <p class=\"page-lead\">\n        Percentage of total gross electricity generated from hydropower, solar photovoltaic, onshore and offshore wind, geothermal, and bioenergy across major economies.\n      </p>\n    </section>\n\n    <section class=\"kpi-strip\" aria-label=\"Headline global statistics\">\n      <div class=\"kpi-card\">\n        <div class=\"kpi-label\">World Share (2025)</div>\n        <div class=\"kpi-value\">34.8%</div>\n        <div class=\"kpi-delta\">+15.6 pp since 2000</div>\n      </div>\n      <div class=\"kpi-card\">\n        <div class=\"kpi-label\">Denmark (2025)</div>\n        <div class=\"kpi-value\">86.4%</div>\n        <div class=\"kpi-delta\">Wind-led grid leader</div>\n      </div>\n      <div class=\"kpi-card\">\n        <div class=\"kpi-label\">Germany (2025)</div>\n        <div class=\"kpi-value\">58.2%</div>\n        <div class=\"kpi-delta\">+54.6 pp since 1990</div>\n      </div>\n      <div class=\"kpi-card\">\n        <div class=\"kpi-label\">China (2025)</div>\n        <div class=\"kpi-value\">36.9%</div>\n        <div class=\"kpi-delta\">Largest absolute TWh</div>\n      </div>\n    </section>\n\n    <section class=\"grapher-card\" id=\"explorer\" aria-label=\"Interactive renewable electricity explorer\">\n      <div class=\"grapher-top\">\n        <div>\n          <h2 class=\"grapher-title\">Renewable Share of Electricity Production (%)</h2>\n          <p class=\"grapher-sub\">Annual series, 1990 to 2025 · Hover or tap year columns to inspect exact values</p>\n        </div>\n        <div class=\"grapher-controls\">\n          <div class=\"seg-group\" role=\"group\" aria-label=\"Vertical axis scale\">\n            <button class=\"seg-btn active\" type=\"button\" data-scale=\"linear\">Linear</button>\n            <button class=\"seg-btn\" type=\"button\" data-scale=\"log\">Log</button>\n          </div>\n          <div class=\"seg-group\" role=\"group\" aria-label=\"Data view mode\">\n            <button class=\"seg-btn active\" type=\"button\" data-view=\"chart\">Chart</button>\n            <button class=\"seg-btn\" type=\"button\" data-view=\"table\">Table</button>\n          </div>\n        </div>\n      </div>\n\n      <div class=\"country-bar\" id=\"countryBar\" role=\"group\" aria-label=\"Toggle countries in chart\">\n        <span class=\"country-bar-label\">Entities:</span>\n      </div>\n\n      <div class=\"grapher-body\">\n        <div class=\"chart-panel\" id=\"chartPanel\">\n          <div class=\"chart-wrap\">\n            <svg id=\"atlasSvg\" viewBox=\"0 0 860 390\" role=\"img\" aria-label=\"Multi-country renewable electricity share time series from 1990 to 2025\"></svg>\n          </div>\n          <div class=\"hover-readout\" aria-live=\"polite\">\n            <span class=\"hover-year\" id=\"hoverYear\">YEAR: 2025</span>\n            <div class=\"hover-values\" id=\"hoverValues\"></div>\n          </div>\n        </div>\n\n        <div class=\"table-wrap\" id=\"tablePanel\">\n          <table>\n            <thead>\n              <tr>\n                <th>Entity</th>\n                <th>1990</th>\n                <th>2000</th>\n                <th>2010</th>\n                <th>2020</th>\n                <th>2025</th>\n                <th>Change (pp)</th>\n              </tr>\n            </thead>\n            <tbody id=\"atlasTableBody\"></tbody>\n          </table>\n        </div>\n      </div>\n\n      <div class=\"grapher-footer\" id=\"sources\">\n        <span><strong>Data source:</strong> Ember Global Electricity Review &amp; Energy Institute Statistical Review (2026 release)</span>\n        <span>CC BY 4.0 · Empirical Data Atlas</span>\n      </div>\n    </section>\n\n    <section class=\"notes-grid\" id=\"methodology\">\n      <div class=\"note-box\">\n        <h2>Measurement Definition</h2>\n        <p>\n          Renewables include hydropower, wind, solar PV, concentrated solar power, geothermal, wave/tidal, and modern biomass electricity. Nuclear power is excluded from this indicator and tracked separately under low-carbon generation.\n        </p>\n      </div>\n      <div class=\"note-box\">\n        <h2>Interpreting Logarithmic Scale</h2>\n        <p>\n          Switching to the logarithmic Y-axis highlights exponential early-stage adoption—such as Denmark and Germany expanding from under 4% renewable electricity in 1990 to majority-renewable grids within three decades.\n        </p>\n      </div>\n    </section>\n  </main>\n\n  <script>\n    (() => {\n      const YEARS = [1990, 1995, 2000, 2005, 2010, 2015, 2020, 2025];\n      const SERIES = [\n        { id: 'DNK', name: 'Denmark', color: '#1D5B9B', values: [3.2, 5.8, 16.4, 27.1, 31.9, 65.4, 81.2, 86.4], active: true },\n        { id: 'BRA', name: 'Brazil', color: '#1B8A5A', values: [93.4, 92.8, 89.6, 86.2, 84.8, 75.5, 84.1, 88.9], active: true },\n        { id: 'DEU', name: 'Germany', color: '#D97706', values: [3.6, 4.9, 6.6, 10.4, 17.1, 29.5, 44.6, 58.2], active: true },\n        { id: 'CHN', name: 'China', color: '#C0392B', values: [20.4, 19.0, 16.6, 16.0, 18.4, 24.1, 28.4, 36.9], active: true },\n        { id: 'USA', name: 'United States', color: '#6D28D9', values: [11.4, 10.7, 9.2, 8.8, 10.3, 13.4, 19.8, 25.6], active: true },\n        { id: 'WLD', name: 'World', color: '#334155', values: [19.5, 19.3, 19.2, 18.4, 19.9, 23.1, 28.6, 34.8], active: true }\n      ];\n\n      let scaleMode = 'linear';\n      let viewMode = 'chart';\n      let selectedYearIdx = YEARS.length - 1;\n\n      const svg = document.getElementById('atlasSvg');\n      const countryBar = document.getElementById('countryBar');\n      const hoverYear = document.getElementById('hoverYear');\n      const hoverValues = document.getElementById('hoverValues');\n      const tableBody = document.getElementById('atlasTableBody');\n\n      function buildChips() {\n        SERIES.forEach((s) => {\n          const btn = document.createElement('button');\n          btn.type = 'button';\n          btn.className = 'country-chip';\n          btn.innerHTML = `<span class=\"swatch\" style=\"background:${s.color}\"></span><span>${s.name}</span>`;\n          btn.addEventListener('click', () => {\n            s.active = !s.active;\n            btn.classList.toggle('inactive', !s.active);\n            renderChart();\n            renderReadout();\n          });\n          countryBar.appendChild(btn);\n        });\n      }\n\n      function yToPx(val, top, bottom) {\n        if (scaleMode === 'log') {\n          const minL = Math.log10(2);\n          const maxL = Math.log10(100);\n          const clamped = Math.max(2, Math.min(100, val));\n          const norm = (Math.log10(clamped) - minL) / (maxL - minL);\n          return bottom - norm * (bottom - top);\n        }\n        return bottom - (val / 100) * (bottom - top);\n      }\n\n      function renderChart() {\n        const ns = 'http://www.w3.org/2000/svg';\n        svg.innerHTML = '';\n\n        const padL = 52;\n        const padR = 112;\n        const padT = 22;\n        const padB = 42;\n        const W = 860;\n        const H = 390;\n        const plotW = W - padL - padR;\n\n        const yTicks = scaleMode === 'log' ? [2, 5, 10, 25, 50, 100] : [0, 20, 40, 60, 80, 100];\n\n        // Horizontal grid & Y labels\n        yTicks.forEach((tick) => {\n          const y = yToPx(tick, padT, H - padB);\n          const line = document.createElementNS(ns, 'line');\n          line.setAttribute('x1', padL);\n          line.setAttribute('x2', W - padR);\n          line.setAttribute('y1', y);\n          line.setAttribute('y2', y);\n          line.setAttribute('stroke', '#E5ECF3');\n          line.setAttribute('stroke-dasharray', tick === 0 ? '' : '3 3');\n          svg.appendChild(line);\n\n          const txt = document.createElementNS(ns, 'text');\n          txt.setAttribute('x', padL - 10);\n          txt.setAttribute('y', y + 4);\n          txt.setAttribute('text-anchor', 'end');\n          txt.setAttribute('font-size', '12');\n          txt.setAttribute('fill', '#5C6F82');\n          txt.setAttribute('font-family', 'IBM Plex Mono, monospace');\n          txt.textContent = `${tick}%`;\n          svg.appendChild(txt);\n        });\n\n        // X-axis labels & interactive year hit columns\n        YEARS.forEach((yr, idx) => {\n          const x = padL + (idx / (YEARS.length - 1)) * plotW;\n          if (idx === selectedYearIdx) {\n            const guide = document.createElementNS(ns, 'line');\n            guide.setAttribute('x1', x);\n            guide.setAttribute('x2', x);\n            guide.setAttribute('y1', padT);\n            guide.setAttribute('y2', H - padB);\n            guide.setAttribute('stroke', '#1D5B9B');\n            guide.setAttribute('stroke-opacity', '0.35');\n            guide.setAttribute('stroke-width', '1.5');\n            svg.appendChild(guide);\n          }\n\n          const lbl = document.createElementNS(ns, 'text');\n          lbl.setAttribute('x', x);\n          lbl.setAttribute('y', H - 14);\n          lbl.setAttribute('text-anchor', 'middle');\n          lbl.setAttribute('font-size', '12');\n          lbl.setAttribute('fill', idx === selectedYearIdx ? '#0F2744' : '#5C6F82');\n          lbl.setAttribute('font-weight', idx === selectedYearIdx ? '700' : '400');\n          lbl.setAttribute('font-family', 'IBM Plex Mono, monospace');\n          lbl.textContent = yr;\n          svg.appendChild(lbl);\n        });\n\n        // Series polylines and end-labels\n        const activeSeries = SERIES.filter((s) => s.active);\n        activeSeries.forEach((s) => {\n          const pts = s.values.map((v, idx) => {\n            const x = padL + (idx / (YEARS.length - 1)) * plotW;\n            const y = yToPx(v, padT, H - padB);\n            return [x, y];\n          });\n\n          const path = document.createElementNS(ns, 'polyline');\n          path.setAttribute('fill', 'none');\n          path.setAttribute('stroke', s.color);\n          path.setAttribute('stroke-width', s.id === 'WLD' ? '2.2' : '2.7');\n          if (s.id === 'WLD') path.setAttribute('stroke-dasharray', '6 4');\n          path.setAttribute('points', pts.map((p) => `${p[0].toFixed(1)},${p[1].toFixed(1)}`).join(' '));\n          svg.appendChild(path);\n\n          // Highlight dot on selected year\n          const [sx, sy] = pts[selectedYearIdx];\n          const dot = document.createElementNS(ns, 'circle');\n          dot.setAttribute('cx', sx);\n          dot.setAttribute('cy', sy);\n          dot.setAttribute('r', '4.6');\n          dot.setAttribute('fill', s.color);\n          dot.setAttribute('stroke', '#FFFFFF');\n          dot.setAttribute('stroke-width', '1.8');\n          svg.appendChild(dot);\n\n          // End label\n          const [lx, ly] = pts[pts.length - 1];\n          const endLbl = document.createElementNS(ns, 'text');\n          endLbl.setAttribute('x', lx + 8);\n          endLbl.setAttribute('y', ly + 4);\n          endLbl.setAttribute('font-size', '12');\n          endLbl.setAttribute('font-weight', '600');\n          endLbl.setAttribute('fill', s.color);\n          endLbl.textContent = `${s.name} ${s.values[s.values.length - 1]}%`;\n          svg.appendChild(endLbl);\n        });\n\n        // Transparent interactive hover/tap bands\n        const colW = plotW / (YEARS.length - 1);\n        YEARS.forEach((yr, idx) => {\n          const x = padL + idx * colW - colW / 2;\n          const rect = document.createElementNS(ns, 'rect');\n          rect.setAttribute('x', Math.max(padL, x));\n          rect.setAttribute('y', padT);\n          rect.setAttribute('width', colW);\n          rect.setAttribute('height', H - padT - padB);\n          rect.setAttribute('fill', 'transparent');\n          rect.style.cursor = 'pointer';\n          rect.addEventListener('mouseenter', () => {\n            selectedYearIdx = idx;\n            renderChart();\n            renderReadout();\n          });\n          rect.addEventListener('click', () => {\n            selectedYearIdx = idx;\n            renderChart();\n            renderReadout();\n          });\n          svg.appendChild(rect);\n        });\n      }\n\n      function renderReadout() {\n        hoverYear.textContent = `YEAR: ${YEARS[selectedYearIdx]}`;\n        hoverValues.innerHTML = SERIES.filter((s) => s.active)\n          .map((s) => `<span style=\"color:${s.color}\"><strong>${s.id}</strong> ${s.values[selectedYearIdx].toFixed(1)}%</span>`)\n          .join('');\n      }\n\n      function renderTable() {\n        tableBody.innerHTML = SERIES.map((s) => {\n          const delta = (s.values[7] - s.values[0]).toFixed(1);\n          const sign = Number(delta) >= 0 ? '+' : '';\n          return `\n            <tr>\n              <td><span class=\"swatch\" style=\"display:inline-block;background:${s.color};margin-right:8px;\"></span>${s.name}</td>\n              <td>${s.values[0].toFixed(1)}%</td>\n              <td>${s.values[2].toFixed(1)}%</td>\n              <td>${s.values[4].toFixed(1)}%</td>\n              <td>${s.values[6].toFixed(1)}%</td>\n              <td><strong>${s.values[7].toFixed(1)}%</strong></td>\n              <td style=\"color:${Number(delta) >= 0 ? '#1B8A5A' : '#C0392B'}\">${sign}${delta} pp</td>\n            </tr>`;\n        }).join('');\n      }\n\n      document.querySelectorAll('[data-scale]').forEach((btn) => {\n        btn.addEventListener('click', () => {\n          document.querySelectorAll('[data-scale]').forEach((b) => b.classList.remove('active'));\n          btn.classList.add('active');\n          scaleMode = btn.dataset.scale;\n          renderChart();\n        });\n      });\n\n      document.querySelectorAll('[data-view]').forEach((btn) => {\n        btn.addEventListener('click', () => {\n          document.querySelectorAll('[data-view]').forEach((b) => b.classList.remove('active'));\n          btn.classList.add('active');\n          viewMode = btn.dataset.view;\n          document.getElementById('chartPanel').classList.toggle('hidden', viewMode === 'table');\n          document.getElementById('tablePanel').classList.toggle('active', viewMode === 'table');\n        });\n      });\n\n      const menuToggle = document.getElementById('menuToggle');\n      const mobileDrawer = document.getElementById('mobileDrawer');\n      menuToggle.addEventListener('click', () => {\n        const open = mobileDrawer.classList.toggle('open');\n        menuToggle.setAttribute('aria-expanded', String(open));\n      });\n\n      buildChips();\n      renderChart();\n      renderReadout();\n      renderTable();\n    })();\n  </script>\n</body>\n</html>\n"
}
