/**
 * styles.css — Visual Climate Tableau Extension
 *
 * Design System:
 *   Tokens: brand → semantic → component (tailwind-design-system pattern)
 *   Colors: OKLCH-informed perceptually balanced palette, tinted neutrals
 *   Shadows: layered for realistic depth
 *   Motion: ease-out-quart/expo, 150-300ms, staggered reveals
 *   Typography: Inter (UI) + JetBrains Mono (data)
 *   Grid: 8px spatial rhythm
 */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,500;0,9..144,600;0,9..144,700;0,9..144,900;1,9..144,400;1,9..144,600&family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

/* ================================================================
   DESIGN TOKENS
   ================================================================ */
:root {
  /* ---- Brand (warm editorial) ---- */
  --vc-primary: #C2410C;
  --vc-primary-hover: #9A3410;
  --vc-primary-active: #7C2D12;
  --vc-primary-subtle: rgba(194, 65, 12, 0.08);
  --vc-primary-glow: rgba(194, 65, 12, 0.18);

  --vc-changer: #0B6B3A;
  --vc-starter: #B45309;
  --vc-talker: #8B1C1C;
  --vc-critical: #7F1D1D;
  --vc-purple: #6D28D9;

  /* ---- Semantic neutrals (warm-tinted, never pure gray) ---- */
  --vc-bg: #FAFAF7;
  --vc-surface: #F5F5F0;
  --vc-surface-raised: #FFFFFF;
  --vc-surface-hover: #EFEFE8;
  --vc-section-bg: #F0EFE8;
  --vc-text: #0E0E0E;
  --vc-text-secondary: #555555;
  --vc-text-muted: #9A9A9A;
  --vc-border: rgba(14, 14, 14, 0.12);
  --vc-border-hover: rgba(14, 14, 14, 0.22);
  --vc-missing: #C4C4BC;

  /* ---- Domain colors (functional, from shared.js) ---- */
  --vc-emissions: #E5484D;
  --vc-energy: #0066FF;
  --vc-economy: #8B5CF6;
  --vc-responsibility: #F59E0B;
  --vc-resilience: #00A67E;

  /* ---- Layered shadows (warm-tinted) ---- */
  --shadow-xs: 0 1px 2px rgba(14, 14, 14, 0.04);
  --shadow-sm: 0 1px 3px rgba(14, 14, 14, 0.06),
               0 1px 2px rgba(14, 14, 14, 0.03);
  --shadow-md: 0 4px 8px -2px rgba(14, 14, 14, 0.06),
               0 2px 4px -2px rgba(14, 14, 14, 0.03);
  --shadow-lg: 0 12px 20px -4px rgba(14, 14, 14, 0.08),
               0 4px 8px -4px rgba(14, 14, 14, 0.04);
  --shadow-xl: 0 20px 32px -8px rgba(14, 14, 14, 0.10),
               0 8px 16px -6px rgba(14, 14, 14, 0.05);
  --shadow-glow-primary: 0 0 0 3px var(--vc-primary-glow);
  --shadow-glow-green: 0 0 0 3px rgba(11, 107, 58, 0.15);

  /* ---- Motion ---- */
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 150ms;
  --dur-normal: 220ms;
  --dur-slow: 350ms;

  /* ---- Spacing (8px grid) ---- */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;

  /* ---- Radius ---- */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
}

/* ================================================================
   RESET & BASE
   ================================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--vc-bg);
  color: var(--vc-text);
  font-size: 13px;
  line-height: 1.55;
  padding: 0;
  margin: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(14,14,14,0.04) 1px, transparent 1px);
  background-size: 3px 3px;
  mix-blend-mode: multiply;
  opacity: 0.55;
  z-index: 0;
}

/* ================================================================
   SETUP SCREEN
   ================================================================ */
.setup-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  padding: var(--sp-6);
  text-align: center;
}
.setup-screen h2 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: var(--sp-4);
  color: var(--vc-text);
}
.setup-screen input {
  width: 100%;
  max-width: 400px;
  padding: 10px 14px;
  border: 1px solid var(--vc-border);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-family: inherit;
  margin-bottom: 10px;
  background: var(--vc-surface);
  color: var(--vc-text);
  transition: border-color var(--dur-fast) ease,
              box-shadow var(--dur-fast) ease;
}
.setup-screen input:focus {
  outline: none;
  border-color: var(--vc-primary);
  box-shadow: var(--shadow-glow-primary);
}
.setup-screen button {
  padding: 10px 28px;
  background: var(--vc-primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--dur-fast) ease,
              transform var(--dur-fast) var(--ease-out-quart),
              box-shadow var(--dur-fast) ease;
  box-shadow: var(--shadow-sm);
}
.setup-screen button:hover {
  background: var(--vc-primary-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.setup-screen button:active {
  background: var(--vc-primary-active);
  transform: translateY(0);
  box-shadow: var(--shadow-xs);
}

/* ================================================================
   LOADING / EMPTY STATE
   ================================================================ */
.loading, .empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 200px;
  color: var(--vc-text-muted);
  font-size: 13px;
}
.spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid var(--vc-border);
  border-top-color: var(--vc-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-bottom: var(--sp-3);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ================================================================
   ANIMATIONS
   ================================================================ */

/* Card entry */
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.climate-card,
.ndc-card,
#ts-main {
  animation: fadeSlideIn 0.5s var(--ease-out-expo);
}

/* Score pop */
@keyframes scoreReveal {
  from { opacity: 0; transform: scale(0.85) translateY(4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.score-animate {
  animation: scoreReveal 0.5s var(--ease-out-quart);
}

/* Staggered bar entry */
@keyframes barSlideIn {
  from { opacity: 0; transform: translateX(-16px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Subtle pulse for badges */
@keyframes subtlePulse {
  0%, 100% { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); }
  50%      { box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22), 0 0 0 4px rgba(0, 0, 0, 0.04); }
}

/* Shine sweep for domain bars */
@keyframes shine {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ================================================================
   CLIMATE CARD (Extension 1)
   ================================================================ */
.climate-card {
  padding: var(--sp-5);
  max-width: 100%;
  margin: 0 auto;
}

/* ---- Card Header ---- */
.card-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--vc-border);
}
.card-flag { font-size: 36px; line-height: 1; }
.card-country-name {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--vc-text);
  line-height: 1.2;
}
.card-meta {
  font-size: 11px;
  color: var(--vc-text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
  margin-top: 2px;
}

/* ---- Score Hero (blue gradient) ---- */
.score-hero {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-5);
  background: var(--vc-surface);
  border-radius: var(--radius-lg);
  margin-bottom: var(--sp-4);
  border: 1px solid var(--vc-border);
  color: var(--vc-text);
  position: relative;
  overflow: hidden;
}
.score-hero::before {
  display: none;
}

.score-big {
  font-family: 'Fraunces', Georgia, 'Times New Roman', serif;
  font-optical-sizing: auto;
  font-size: 48px;
  font-weight: 900;
  line-height: 1;
  color: var(--vc-text);
  position: relative;
}
.score-unit {
  font-size: 16px;
  color: var(--vc-text-muted);
  font-weight: 500;
  font-family: 'Fraunces', Georgia, serif;
}

.grade-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  font-size: 22px;
  font-weight: 800;
  box-shadow: var(--shadow-md);
  flex-shrink: 0;
  transition: transform var(--dur-fast) var(--ease-out-quart),
              box-shadow var(--dur-fast) ease;
}
.grade-badge:hover {
  transform: scale(1.08);
  box-shadow: var(--shadow-lg);
}

.class-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  color: white;
  letter-spacing: 0.01em;
}
.rank-text {
  font-size: 12px;
  color: var(--vc-text-secondary);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
}

/* ---- View Toggle Buttons ---- */
.view-toggle {
  display: flex;
  gap: 2px;
  margin-bottom: var(--sp-3);
  background: var(--vc-section-bg);
  border-radius: var(--radius-md);
  padding: 2px;
}
.view-toggle-btn {
  padding: 6px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background: transparent;
  color: var(--vc-text-secondary);
  transition: background var(--dur-fast) ease,
              color var(--dur-fast) ease,
              box-shadow var(--dur-fast) ease;
}
.view-toggle-btn:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--vc-text);
}
.view-toggle-btn.active {
  background: var(--vc-surface);
  color: var(--vc-primary);
  box-shadow: var(--shadow-sm);
}
.view-toggle-btn:active {
  transform: scale(0.97);
}

/* ---- Domain Bars ---- */
.domain-section {
  margin-bottom: var(--sp-4);
}
.domain-section h3 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  margin-bottom: var(--sp-2);
  color: var(--vc-text);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.domain-bar-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: 5px;
  cursor: default;
  position: relative;
  padding: 5px 6px;
  border-radius: var(--radius-sm);
  transition: background var(--dur-fast) ease;
  /* Staggered entry: set by JS */
  opacity: 0;
  animation: barSlideIn 0.45s var(--ease-out-expo) forwards;
}
.domain-bar-row:nth-child(1) { animation-delay: 0ms; }
.domain-bar-row:nth-child(2) { animation-delay: 60ms; }
.domain-bar-row:nth-child(3) { animation-delay: 120ms; }
.domain-bar-row:nth-child(4) { animation-delay: 180ms; }
.domain-bar-row:nth-child(5) { animation-delay: 240ms; }

.domain-bar-row:hover {
  background: var(--vc-surface-hover);
}

.domain-label {
  width: 96px;
  font-size: 11px;
  font-weight: 600;
  color: var(--vc-text-secondary);
  text-align: right;
  flex-shrink: 0;
  line-height: 1.3;
}

.domain-bar-track {
  flex: 1;
  height: 24px;
  background: var(--vc-section-bg);
  border-radius: var(--radius-sm);
  position: relative;
  overflow: visible;
}

.domain-bar-fill {
  height: 100%;
  border-radius: var(--radius-sm);
  position: relative;
  overflow: hidden;
  transition: width 0.9s var(--ease-out-expo);
  transform-origin: left center;
}

/* Shine effect on hover */
.domain-bar-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: -60%;
  width: 40%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.35) 50%,
    transparent 100%
  );
  pointer-events: none;
  opacity: 0;
}
.domain-bar-row:hover .domain-bar-fill::after {
  opacity: 1;
  animation: shine 0.7s var(--ease-out-quart) forwards;
}

/* Scale nudge on hover */
.domain-bar-row:hover .domain-bar-fill {
  filter: brightness(1.08);
}

.domain-bar-avg {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  background: var(--vc-text);
  opacity: 0.18;
  border-radius: 1px;
}

.domain-bar-value {
  width: 42px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  text-align: right;
  flex-shrink: 0;
  transition: transform var(--dur-fast) var(--ease-out-quart);
}
.domain-bar-row:hover .domain-bar-value {
  transform: translateX(2px);
}

/* ---- Domain Bar Hover Tooltip ---- */
.domain-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  /* Solid warm dark bg as fallback for Tableau CEF */
  background: rgba(42, 36, 30, 0.94);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: #F5F0E8;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  z-index: 200;
  pointer-events: none;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.06);
  letter-spacing: 0.01em;
}
.domain-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(42, 36, 30, 0.94);
}
.domain-bar-row:hover .domain-tooltip { display: block; }

/* ---- Radar Container ---- */
.radar-container {
  display: flex;
  justify-content: center;
  margin-bottom: var(--sp-4);
}

/* ---- Key Insights ---- */
.insights {
  padding: var(--sp-3) var(--sp-4);
  background: var(--vc-surface);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--vc-primary);
  font-size: 12px;
  color: var(--vc-text-secondary);
  line-height: 1.65;
  margin-bottom: var(--sp-3);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--dur-normal) ease,
              transform var(--dur-normal) var(--ease-out-quart);
}
.insights:hover {
  box-shadow: var(--shadow-sm);
}
.insights strong {
  color: var(--vc-text);
  font-weight: 700;
}

/* ================================================================
   TIMESERIES (Extension 2)
   ================================================================ */
.ts-controls {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-bottom: var(--sp-3);
  padding: 0 var(--sp-4);
}
.ts-controls select,
.ts-controls button {
  padding: 7px 14px;
  border: 1px solid var(--vc-border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
  background: var(--vc-surface);
  color: var(--vc-text);
  cursor: pointer;
  transition: border-color var(--dur-fast) ease,
              box-shadow var(--dur-fast) ease,
              background var(--dur-fast) ease,
              color var(--dur-fast) ease,
              transform var(--dur-fast) var(--ease-out-quart);
}
.ts-controls select:hover,
.ts-controls button:hover {
  border-color: var(--vc-border-hover);
  box-shadow: var(--shadow-xs);
}
.ts-controls select:focus,
.ts-controls button:focus {
  outline: none;
  border-color: var(--vc-primary);
  box-shadow: var(--shadow-glow-primary);
}
.ts-controls button.active {
  background: var(--vc-primary);
  color: white;
  border-color: var(--vc-primary);
  box-shadow: var(--shadow-sm);
}
.ts-controls button:active {
  transform: scale(0.97);
}

.ts-chart-area {
  padding: 0 var(--sp-4);
  height: calc(100vh - 120px);
  min-height: 300px;
}
.ts-chart-area svg { width: 100%; height: 100%; }

/* ================================================================
   NDC TRACKER (Extension 3)
   ================================================================ */
.ndc-card {
  padding: var(--sp-4);
  max-width: 520px;
  margin: 0 auto;
}
.ndc-header {
  margin-bottom: var(--sp-3);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--vc-border);
}

.ndc-kpi-row {
  display: flex;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}

.ndc-kpi {
  flex: 1;
  padding: var(--sp-3);
  background: var(--vc-surface);
  border-radius: var(--radius-md);
  text-align: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--vc-border);
  transition: transform var(--dur-normal) var(--ease-out-quart),
              box-shadow var(--dur-normal) var(--ease-out-quart),
              border-color var(--dur-normal) ease;
  cursor: default;
}
.ndc-kpi:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg), var(--shadow-glow-primary);
  border-color: rgba(194, 65, 12, 0.25);
}

.ndc-kpi-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.ndc-kpi-label {
  font-size: 10px;
  color: var(--vc-text-muted);
  margin-top: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ndc-gap-badge {
  display: inline-block;
  padding: 8px 20px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 700;
  color: white;
  letter-spacing: 0.01em;
  animation: subtlePulse 2.8s ease-in-out infinite;
}

.ndc-chart-area {
  margin-bottom: var(--sp-4);
  border-radius: var(--radius-md);
  background: var(--vc-surface);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.ndc-detail {
  font-size: 11px;
  color: var(--vc-text-secondary);
}
.ndc-detail td {
  padding: 5px var(--sp-2);
  border-bottom: 1px solid rgba(226, 232, 240, 0.5);
}
.ndc-detail tr:last-child td {
  border-bottom: none;
}

/* NDC 3.0 Info panel */
.ndc3-info-panel {
  padding: var(--sp-2) var(--sp-3);
  background: var(--vc-section-bg);
  border-radius: var(--radius-sm);
  margin-bottom: var(--sp-3);
  font-size: 11px;
  border-left: 3px solid var(--vc-primary);
  color: var(--vc-text-secondary);
}

/* ================================================================
   SVG CHART INTERACTIONS
   ================================================================ */
.chart-dot {
  cursor: pointer;
  transition: r 0.15s var(--ease-out-quart);
}
.chart-dot:hover { r: 6; }

/* ---- Chart Tooltip (glassmorphism dark) ---- */
.chart-tooltip {
  display: none;
  position: fixed;
  z-index: 500;
  /* Solid warm dark fallback for Tableau Desktop CEF */
  background: rgba(42, 36, 30, 0.94);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  color: #F5F0E8;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 12px;
  pointer-events: none;
  box-shadow: var(--shadow-xl);
  border: 1px solid rgba(255, 255, 255, 0.06);
  min-width: 80px;
  transition: opacity 0.1s ease;
}
.chart-tooltip .tt-year {
  font-size: 10px;
  font-weight: 600;
  color: rgba(245, 240, 232, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 3px;
}
.chart-tooltip .tt-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  font-weight: 700;
  color: #FFFFFF;
  letter-spacing: -0.01em;
}
.chart-tooltip .tt-label {
  font-size: 10px;
  color: rgba(245, 240, 232, 0.5);
  margin-top: 2px;
}

/* ================================================================
   FOOTER
   ================================================================ */
.vc-footer {
  margin-top: var(--sp-4);
  padding: var(--sp-2) var(--sp-4);
  font-size: 10px;
  color: var(--vc-text-muted);
  text-align: right;
  border-top: 1px solid var(--vc-border);
}
.vc-footer a {
  color: var(--vc-primary);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--dur-fast) ease;
}
.vc-footer a:hover {
  color: var(--vc-primary-hover);
}

/* ================================================================
   COMPARISON GRID (multi-country)
   ================================================================ */
.comparison-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--sp-3);
  padding: var(--sp-4);
}
.comparison-mini-card {
  padding: var(--sp-3);
  background: var(--vc-surface);
  border: 1px solid var(--vc-border);
  border-radius: var(--radius-md);
  text-align: center;
  box-shadow: var(--shadow-xs);
  transition: transform var(--dur-normal) var(--ease-out-quart),
              box-shadow var(--dur-normal) ease;
}
.comparison-mini-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.comparison-mini-card .card-flag { font-size: 24px; }
.comparison-mini-card .card-country-name { font-size: 14px; font-weight: 700; }

.mini-domain-row {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  margin: 2px 0;
}
.mini-domain-label {
  width: 24px;
  font-size: 9px;
  color: var(--vc-text-muted);
  text-align: right;
}
.mini-bar-track {
  flex: 1;
  height: 6px;
  background: var(--vc-section-bg);
  border-radius: 3px;
}
.mini-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s var(--ease-out-expo);
}
.mini-bar-value {
  width: 28px;
  font-size: 9px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
}

/* ================================================================
   TIMESERIES DATA TABLE
   ================================================================ */
#ts-table table {
  border-collapse: collapse;
}
#ts-table th {
  font-size: 10px;
  font-weight: 700;
  color: var(--vc-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 6px 6px;
  border-bottom: 2px solid var(--vc-border);
}
#ts-table td {
  padding: 5px 6px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.5);
  font-size: 10px;
}
#ts-table tr:hover td {
  background: var(--vc-surface-hover);
}

/* ================================================================
   TIMESERIES HEADER BAR
   ================================================================ */
.ts-header {
  padding: var(--sp-3) var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  border-bottom: 1px solid var(--vc-border);
  background: var(--vc-surface);
}
.ts-header-flag { font-size: 24px; line-height: 1; }
.ts-header-name {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--vc-text);
}
.ts-header-iso {
  font-size: 11px;
  color: var(--vc-text-muted);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
}

/* ================================================================
   NARRATOR (Extension 4)
   ================================================================ */
.narrator-panel {
  padding: var(--sp-4);
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Empty state */
.narrator-icon {
  font-size: 32px;
  margin-bottom: var(--sp-3);
  text-align: center;
}
.narrator-empty-title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 16px;
  font-weight: 800;
  color: var(--vc-text);
  text-align: left;
  margin-bottom: var(--sp-2);
}
.narrator-empty-text {
  font-size: 12px;
  color: var(--vc-text-secondary);
  text-align: left;
  line-height: 1.6;
  margin-bottom: var(--sp-4);
}
.narrator-empty-quiz {
  font-size: 11px;
  color: var(--vc-text-muted);
  text-align: left;
  padding: var(--sp-3);
  background: var(--vc-section-bg);
  border-radius: var(--radius-md);
  margin-bottom: var(--sp-4);
}

/* Country header */
.narrator-country-header {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--vc-border);
  margin-bottom: var(--sp-3);
}
.narrator-flag { font-size: 28px; line-height: 1; }
.narrator-country-info { flex: 1; min-width: 0; }
.narrator-country-name {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--vc-text);
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.narrator-country-meta {
  font-size: 10px;
  color: var(--vc-text-muted);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
}
.narrator-grade {
  width: 36px;
  height: 36px;
  font-size: 16px;
  flex-shrink: 0;
}

/* Sections */
.narrator-section {
  margin-bottom: var(--sp-3);
}
.narrator-insight-text {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 14px;
  font-weight: 400;
  color: var(--vc-text);
  line-height: 1.4;
}
.narrator-so-what-text {
  font-size: 12px;
  color: var(--vc-text-secondary);
  line-height: 1.5;
  margin-top: var(--sp-1);
}

/* Metric */
.narrator-metric-section {
  text-align: center;
  padding: var(--sp-3) 0;
  margin-bottom: var(--sp-3);
  background: var(--vc-section-bg);
  border-radius: var(--radius-md);
}
.narrator-metric-value {
  font-family: 'Fraunces', Georgia, serif;
  font-optical-sizing: auto;
  font-size: 32px;
  font-weight: 900;
  line-height: 1;
  color: var(--vc-primary);
}
.narrator-metric-label {
  font-size: 10px;
  color: var(--vc-text-muted);
  margin-top: var(--sp-1);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Action */
.narrator-action-section {
  padding: var(--sp-3);
  background: var(--vc-primary-subtle);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--vc-primary);
  margin-bottom: var(--sp-3);
}
.narrator-action-text {
  font-size: 12px;
  color: var(--vc-primary);
  font-weight: 600;
  line-height: 1.5;
  cursor: default;
}

/* Footer */
.narrator-footer {
  margin-top: auto;
  padding-top: var(--sp-3);
  border-top: 1px solid var(--vc-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.narrator-module-text {
  font-size: 10px;
  color: var(--vc-text-muted);
  font-weight: 500;
}

/* Mode toggle */
.narrator-toggle-wrap {
  display: flex;
  gap: 2px;
  background: var(--vc-section-bg);
  border-radius: var(--radius-sm);
  padding: 2px;
}
.narrator-mode-btn {
  padding: 4px 12px;
  border: none;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background: transparent;
  color: var(--vc-text-secondary);
  transition: background var(--dur-fast) ease,
              color var(--dur-fast) ease;
}
.narrator-mode-btn.active {
  background: var(--vc-surface);
  color: var(--vc-primary);
  box-shadow: var(--shadow-xs);
}

/* Link style */
.narrator-link {
  color: var(--vc-primary);
  text-decoration: none;
  font-weight: 600;
}
.narrator-link:hover {
  color: var(--vc-primary-hover);
}

/* Free mode domain mini bars */
.narrator-free-summary {
  margin-top: var(--sp-2);
}
.narrator-free-domain-row {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  margin-bottom: 4px;
}
.narrator-free-domain-label {
  width: 80px;
  font-size: 10px;
  font-weight: 600;
  color: var(--vc-text-secondary);
  text-align: right;
  flex-shrink: 0;
}
.narrator-free-domain-track {
  flex: 1;
  height: 8px;
  background: var(--vc-section-bg);
  border-radius: 4px;
  overflow: hidden;
}
.narrator-free-domain-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s var(--ease-out-expo);
}
.narrator-free-domain-value {
  width: 32px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  text-align: right;
  flex-shrink: 0;
}

/* === GUIDED TOUR ADDITIONS === */

/* Quiz buttons */
.narrator-quiz-section {
  margin-bottom: var(--sp-3);
}
.narrator-quiz-buttons {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.narrator-quiz-btn {
  display: block;
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border: 1.5px solid var(--vc-border);
  border-radius: var(--radius-md);
  background: var(--vc-surface);
  color: var(--vc-text);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: border-color var(--dur-fast) ease,
              background var(--dur-fast) ease,
              transform var(--dur-fast) ease;
}
.narrator-quiz-btn:hover:not(:disabled) {
  border-color: var(--vc-primary);
  background: var(--vc-primary-subtle);
}
.narrator-quiz-btn:active:not(:disabled) {
  transform: scale(0.98);
}
.narrator-quiz-btn.correct {
  border-color: #0B6B3A;
  background: rgba(11, 107, 58, 0.1);
  color: #0B6B3A;
}
.narrator-quiz-btn.wrong {
  border-color: #8B1C1C;
  background: rgba(139, 28, 28, 0.1);
  color: #8B1C1C;
}
.narrator-quiz-btn:disabled {
  cursor: default;
  opacity: 0.85;
}

/* Step indicator (●●○○○○) */
.narrator-step-indicator {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: var(--sp-2) 0;
  margin-bottom: var(--sp-2);
}
.narrator-step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--vc-border);
  transition: background var(--dur-fast) ease,
              transform var(--dur-fast) ease;
}
.narrator-step-dot.active {
  background: var(--vc-primary);
  transform: scale(1.3);
}
.narrator-step-dot.completed {
  background: var(--vc-primary);
  opacity: 0.45;
}

/* Nudge pulse animation */
.narrator-nudge-pulse {
  animation: narratorNudge 2s ease-in-out infinite;
}
@keyframes narratorNudge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Sparkline placeholder */
.narrator-sparkline {
  margin-bottom: var(--sp-3);
  text-align: center;
}
.narrator-sparkline svg {
  width: 100%;
  max-width: 280px;
  height: 48px;
}

/* === INTERNAL QUIZ (Option C) — Editorial Factfulness =========
   A Hans-Rosling-inspired 5-question test rendered before the
   guided tour. Deliberately breaks from the rest of the extension's
   blue-tinted design system: warm paper background, Fraunces serif
   display, JetBrains Mono metadata, left-aligned editorial layout.
   Never centered. Never emoji. Never gradients.
   ================================================================ */
#narrator-internal-quiz {
  padding: 0;
  margin: 0;
  background: var(--vc-bg);
  color: var(--vc-text);
  border: none;
  box-shadow: none;
  overflow: hidden;
  position: relative;
}
#narrator-internal-quiz::before {
  display: none; /* dot pattern now on body globally */
}

.iq-frame {
  position: relative;
  padding: 24px 22px 22px;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ── Eyebrow header ── */
.iq-eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #0E0E0E;
}
.iq-eyebrow-title { white-space: nowrap; flex-shrink: 0; }
.iq-eyebrow-rule {
  flex: 1 1 auto;
  height: 1px;
  background: #0E0E0E;
  opacity: 0.28;
}
.iq-eyebrow-count {
  white-space: nowrap;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  color: #0E0E0E;
  opacity: 0.72;
}

/* ── Question ── */
.iq-question {
  font-family: 'Fraunces', Georgia, 'Times New Roman', serif;
  font-optical-sizing: auto;
  font-weight: 400;
  font-size: clamp(19px, 5.8vw, 23px);
  line-height: 1.18;
  letter-spacing: -0.018em;
  color: #0E0E0E;
  margin: 0 0 16px 0;
}

.iq-hook {
  font-family: 'Fraunces', Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: 12.5px;
  line-height: 1.4;
  color: #555;
  margin: 0 0 26px 0;
}
.iq-hook em {
  font-style: normal;
  font-weight: 700;
  color: #C2410C;
  font-feature-settings: 'tnum';
  letter-spacing: -0.005em;
}

/* ── Options: numbered editorial list ── */
.iq-options {
  list-style: none;
  padding: 0;
  margin: 0;
  border-top: 1px solid rgba(14,14,14,0.18);
}
.iq-option {
  display: flex;
  align-items: baseline;
  gap: 20px;
  padding: 14px 4px 14px 2px;
  border-bottom: 1px solid rgba(14,14,14,0.09);
  cursor: pointer;
  position: relative;
  color: #0E0E0E;
  transition:
    transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1),
    color 0.2s ease,
    opacity 0.35s ease;
}
.iq-option:hover:not(.disabled) {
  transform: translateX(7px);
  color: #C2410C;
}
.iq-option:hover:not(.disabled) .iq-option-num {
  color: #C2410C;
  opacity: 1;
}

.iq-option-num {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  font-weight: 500;
  color: #0E0E0E;
  opacity: 0.45;
  letter-spacing: 0.06em;
  font-feature-settings: 'tnum';
  flex-shrink: 0;
  width: 20px;
  transform: translateY(-1px);
  transition: color 0.2s ease, opacity 0.2s ease;
}

.iq-option-text {
  font-family: 'Fraunces', Georgia, serif;
  font-optical-sizing: auto;
  font-size: clamp(15px, 4.4vw, 17px);
  font-weight: 400;
  line-height: 1.28;
  color: inherit;
  letter-spacing: -0.005em;
}

.iq-option.disabled { cursor: default; }
.iq-option.disabled:hover { transform: none; color: inherit; }
.iq-option.disabled:hover .iq-option-num { color: #0E0E0E; opacity: 0.45; }

.iq-option.correct { color: #0E0E0E; }
.iq-option.correct .iq-option-num {
  color: #0B6B3A;
  opacity: 1;
  font-weight: 700;
}
.iq-option.correct .iq-option-text {
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: #0B6B3A;
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}

.iq-option.wrong .iq-option-text {
  text-decoration: line-through;
  text-decoration-color: rgba(139, 28, 28, 0.55);
  text-decoration-thickness: 1.5px;
  opacity: 0.6;
}

.iq-option.dim { opacity: 0.32; }

/* ── Fact reveal (after answer) ── */
.iq-fact-slot {
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  margin-top: 0;
  transition:
    opacity 0.45s ease 0.1s,
    max-height 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) 0.05s,
    margin-top 0.4s ease;
}
.iq-fact-slot.revealed {
  opacity: 1;
  max-height: 240px;
  margin-top: 18px;
}
.iq-fact-slot p {
  font-family: 'Fraunces', Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: 12.5px;
  line-height: 1.55;
  color: #555;
  margin: 0;
  padding: 14px 0 0 0;
  border-top: 1px solid rgba(14,14,14,0.14);
}
.iq-fact-slot strong {
  font-style: normal;
  font-weight: 700;
  color: #0E0E0E;
  font-feature-settings: 'tnum';
}

.iq-continue {
  margin-top: 18px;
  text-align: right;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #C2410C;
  opacity: 0;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.4s ease, color 0.2s ease;
}
.iq-continue.revealed { opacity: 0.85; }
.iq-continue:hover { color: #9A3410; opacity: 1; }

/* ── Result screen ── */
.iq-result .iq-score {
  font-family: 'Fraunces', Georgia, serif;
  font-optical-sizing: auto;
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 12px 0 22px -4px;
  line-height: 0.88;
}
.iq-score-num {
  font-size: clamp(72px, 22vw, 100px);
  font-weight: 900;
  font-feature-settings: 'tnum';
  letter-spacing: -0.045em;
  color: #0E0E0E;
}
.iq-score-denom {
  font-size: clamp(24px, 7vw, 32px);
  font-weight: 300;
  font-style: italic;
  color: #9A9A9A;
  letter-spacing: -0.02em;
}

.iq-verdict {
  font-family: 'Fraunces', Georgia, serif;
  font-optical-sizing: auto;
  font-size: clamp(16px, 4.8vw, 18px);
  line-height: 1.35;
  color: #0E0E0E;
  margin: 0 0 14px 0;
  font-weight: 400;
  letter-spacing: -0.01em;
}
.iq-verdict em {
  font-style: italic;
  color: #C2410C;
  font-weight: 600;
}

.iq-chimp {
  font-family: 'Fraunces', Georgia, serif;
  font-style: italic;
  font-size: 12.5px;
  line-height: 1.55;
  color: #6B6B6B;
  margin: 0 0 26px 0;
}
.iq-chimp strong {
  font-style: normal;
  font-weight: 700;
  color: #0E0E0E;
  font-feature-settings: 'tnum';
}

.iq-missed-block {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 14px 0;
  border-top: 1px solid rgba(14,14,14,0.25);
  border-bottom: 1px solid rgba(14,14,14,0.25);
  margin-bottom: 26px;
}
.iq-missed-label {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #555;
}
.iq-missed-values {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #C2410C;
  font-feature-settings: 'tnum';
}

.iq-cta {
  background: transparent;
  border: none;
  border-bottom: 2px solid #0E0E0E;
  padding: 0 0 4px 0;
  font-family: 'Fraunces', Georgia, serif;
  font-optical-sizing: auto;
  font-size: clamp(16px, 4.8vw, 19px);
  font-style: italic;
  font-weight: 500;
  color: #0E0E0E;
  cursor: pointer;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  letter-spacing: -0.012em;
  transition:
    color 0.22s ease,
    border-color 0.22s ease,
    gap 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.iq-cta:hover {
  color: #C2410C;
  border-color: #C2410C;
  gap: 14px;
}

/* ── Entrance animations ── */
@keyframes iqFadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes iqSlideIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}
.iq-frame > .iq-eyebrow {
  animation: iqFadeUp 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.iq-frame > .iq-question {
  animation: iqFadeUp 0.55s 0.08s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.iq-frame > .iq-hook {
  animation: iqFadeUp 0.5s 0.18s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.iq-options .iq-option {
  animation: iqSlideIn 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.iq-options .iq-option:nth-child(1) { animation-delay: 0.28s; }
.iq-options .iq-option:nth-child(2) { animation-delay: 0.36s; }
.iq-options .iq-option:nth-child(3) { animation-delay: 0.44s; }
.iq-options .iq-option:nth-child(4) { animation-delay: 0.52s; }

.iq-result .iq-score {
  animation: iqFadeUp 0.65s 0.1s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.iq-result .iq-verdict {
  animation: iqFadeUp 0.55s 0.28s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.iq-result .iq-chimp {
  animation: iqFadeUp 0.55s 0.42s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.iq-result .iq-missed-block {
  animation: iqFadeUp 0.55s 0.56s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.iq-result .iq-cta {
  animation: iqFadeUp 0.55s 0.72s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@media (prefers-reduced-motion: reduce) {
  #narrator-internal-quiz *,
  #narrator-internal-quiz *::before,
  #narrator-internal-quiz *::after {
    animation: none !important;
    transition: none !important;
  }
}
/* === END INTERNAL QUIZ === */

/* ================================================================
   LITERACY EXTENSION (Extension 5)
   ================================================================ */

/* ---- Panel (editorial warm paper, matches narrator internal quiz) ---- */
#literacy-panel {
  background: var(--vc-bg);
  color: var(--vc-text);
  position: relative;
  min-height: 100vh;
}
#literacy-panel::before {
  display: none; /* dot pattern now on body globally */
}

/* === END LITERACY === */
