/* ============================================================
   STYLE.CSS — Prosperity Diffusion: 2025–2100
   Premium dark-mode design system
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── CSS Variables ────────────────────────────────────────── */
:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-glass: rgba(17, 24, 39, 0.55);
  --border-glass: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);

  --text-primary: #f0f4f8;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-teal: #00E5FF;
  --accent-amber: #FFD740;
  --accent-coral: #FF6E40;
  --accent-green: #00E676;
  --accent-purple: #B388FF;
  --accent-rose: #FF5252;

  --gradient-main: linear-gradient(135deg, #0a0e17 0%, #111827 50%, #0f172a 100%);
  --gradient-teal: linear-gradient(135deg, #00E5FF, #00B8D4);
  --gradient-amber: linear-gradient(135deg, #FFD740, #FFAB00);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow-teal: 0 0 20px rgba(0, 229, 255, 0.15);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-heading: 'Outfit', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;
}

/* ── Reset & Base ─────────────────────────────────────────── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

body {
  background: var(--gradient-main);
}

/* ── Loading Overlay ──────────────────────────────────────── */
#loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 20px;
  background: var(--bg-primary);
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

#loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(0, 229, 255, 0.15);
  border-top-color: var(--accent-teal);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loader-text {
  font-family: var(--font-heading);
  font-size: 14px;
  color: var(--text-secondary);
  letter-spacing: 2px;
  text-transform: uppercase;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── App Layout ───────────────────────────────────────────── */
#app {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ── Header ───────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-glass);
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo {
  width: 32px;
  height: 32px;
  background: var(--gradient-teal);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: var(--bg-primary);
  box-shadow: var(--shadow-glow-teal);
}

.header-title {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-teal), var(--accent-amber));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-subtitle {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-year {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  color: var(--accent-teal);
  text-shadow: 0 0 20px rgba(0, 229, 255, 0.3);
  min-width: 60px;
  text-align: center;
}

.header-sources {
  font-size: 9px;
  color: var(--text-muted);
  text-align: right;
  line-height: 1.4;
  max-width: 200px;
}

/* ── Main Content Area ────────────────────────────────────── */
.main-content {
  display: grid;
  grid-template-columns: 1fr 300px;
  overflow: hidden;
  position: relative;
}

/* ── Map Container ────────────────────────────────────────── */
#map-container {
  position: relative;
  width: 100%;
  height: 100%;
  cursor: grab;
  background: radial-gradient(ellipse at 50% 50%, rgba(0, 229, 255, 0.03) 0%, transparent 70%);
}

#map-container:active {
  cursor: grabbing;
}

.map-legend {
  position: absolute;
  bottom: 12px;
  left: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px 10px;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  font-size: 9px;
  color: var(--text-secondary);
  z-index: 10;
}

.legend-title {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-size: 8px;
  color: var(--text-muted);
}

.legend-stops {
  display: flex;
  gap: 3px;
  align-items: center;
}

.legend-stop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.legend-swatch {
  width: 18px;
  height: 8px;
  border-radius: 2px;
}

.legend-stop span {
  font-size: 7px;
  color: var(--text-muted);
  white-space: nowrap;
}

.node-legend {
  position: absolute;
  bottom: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  font-size: 9px;
  color: var(--text-secondary);
  z-index: 10;
}

.node-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.node-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-left: 1px solid var(--border-glass);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 12px;
  transition: border-color 0.2s ease;
}

.panel:hover {
  border-color: var(--border-hover);
}

.panel-title {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.panel-title::before {
  content: '';
  width: 3px;
  height: 12px;
  background: var(--accent-teal);
  border-radius: 2px;
}

/* ── Driver Sliders ───────────────────────────────────────── */
.driver-slider {
  margin-bottom: 8px;
}

.driver-header {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 3px;
}

.driver-icon {
  font-size: 11px;
}

.driver-label {
  font-size: 10px;
  color: var(--text-secondary);
  flex: 1;
}

.driver-value {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent-teal);
  min-width: 20px;
  text-align: right;
}

/* ── Range Slider ─────────────────────────────────────────── */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--accent-teal);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--bg-primary);
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.3);
  transition: transform 0.15s ease;
}

.slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--accent-teal);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--bg-primary);
}

/* ── Policy Toggles ───────────────────────────────────────── */
.policy-toggle {
  margin-bottom: 6px;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 4px 0;
}

.toggle-label.negative .policy-name {
  color: var(--accent-rose);
}

.policy-icon {
  font-size: 12px;
}

.policy-name {
  font-size: 10px;
  color: var(--text-secondary);
  flex: 1;
}

.toggle-switch {
  position: relative;
  width: 32px;
  height: 16px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: all 0.3s ease;
}

.toggle-switch input:checked+.toggle-slider {
  background: rgba(0, 229, 255, 0.25);
}

.toggle-switch input:checked+.toggle-slider::before {
  transform: translateX(16px);
  background: var(--accent-teal);
  box-shadow: 0 0 6px rgba(0, 229, 255, 0.5);
}

.toggle-switch input:checked+.toggle-slider.negative {
  background: rgba(255, 82, 82, 0.25);
}

.toggle-switch input:checked+.toggle-slider.negative::before {
  background: var(--accent-rose);
  box-shadow: 0 0 6px rgba(255, 82, 82, 0.5);
}

/* ── Scenario Buttons ─────────────────────────────────────── */
#scenario-buttons {
  display: flex;
  gap: 4px;
}

.scenario-btn {
  flex: 1;
  padding: 6px 4px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 9px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.scenario-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-hover);
}

.scenario-btn.active {
  background: rgba(0, 229, 255, 0.1);
  border-color: var(--accent-teal);
  color: var(--accent-teal);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.1);
}

.scenario-name {
  display: block;
  line-height: 1.3;
}

/* ── Region Toggles ───────────────────────────────────────── */
#region-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.region-btn {
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 9px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.region-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.region-btn.active {
  background: rgba(0, 229, 255, 0.08);
  border-color: rgba(0, 229, 255, 0.3);
  color: var(--text-primary);
}

/* ── Dashboard Strip ──────────────────────────────────────── */
.dashboard-strip {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-glass);
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  transition: border-color 0.2s ease;
}

.metric-card:hover {
  border-color: var(--border-hover);
}

.metric-label {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.metric-trend {
  font-size: 10px;
  margin-left: 4px;
}

.trend-good {
  color: var(--accent-green);
}

.trend-bad {
  color: var(--accent-rose);
}

.metric-spark {
  height: 24px;
  margin-top: 4px;
  opacity: 0.8;
}

/* ── Structure Bar ────────────────────────────────────────── */
#structure-bar {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 6px;
}

.struct-seg {
  transition: width 0.3s ease;
}

.struct-agri {
  background: #66BB6A;
}

.struct-industry {
  background: #42A5F5;
}

.struct-services {
  background: #AB47BC;
}

#structure-labels {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.struct-label {
  font-size: 8px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 3px;
}

.struct-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.struct-agri-dot {
  background: #66BB6A;
}

.struct-ind-dot {
  background: #42A5F5;
}

.struct-svc-dot {
  background: #AB47BC;
}

/* ── Regional Metrics ─────────────────────────────────────── */
#regional-metrics {
  font-size: 9px;
}

.regional-header {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 0.6fr;
  gap: 4px;
  padding-bottom: 4px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border-glass);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 8px;
}

.regional-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 0.6fr;
  gap: 4px;
  padding: 3px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

.regional-name {
  color: var(--text-secondary);
  font-weight: 500;
}

.regional-stat {
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 9px;
}

/* ── Time Controls ────────────────────────────────────────── */
.time-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-glass);
}

.play-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

#play-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  background: rgba(0, 229, 255, 0.1);
  border: 1px solid rgba(0, 229, 255, 0.3);
  border-radius: var(--radius-sm);
  color: var(--accent-teal);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

#play-btn:hover {
  background: rgba(0, 229, 255, 0.2);
  box-shadow: var(--shadow-glow-teal);
}

#play-btn.playing {
  background: rgba(255, 215, 64, 0.1);
  border-color: rgba(255, 215, 64, 0.3);
  color: var(--accent-amber);
}

.play-icon {
  font-size: 12px;
}

#speed-select {
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 10px;
  cursor: pointer;
  outline: none;
}

#speed-select option {
  background: var(--bg-secondary);
}

.time-slider-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
}

.time-slider-track {
  position: relative;
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  overflow: hidden;
}

#time-progress {
  height: 100%;
  background: var(--gradient-teal);
  border-radius: 3px;
  transition: width 0.3s ease;
  width: 0%;
}

#time-slider {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 6px;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.time-labels {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ── Tooltip ──────────────────────────────────────────────── */
.map-tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 1000;
  background: rgba(10, 14, 23, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(0, 229, 255, 0.2);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  max-width: 240px;
  box-shadow: var(--shadow-lg);
  transition: opacity 0.15s ease;
}

.tooltip-title {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.tooltip-year {
  font-size: 9px;
  color: var(--accent-teal);
  font-family: var(--font-mono);
  margin-bottom: 6px;
}

.tooltip-grid {
  display: grid;
  grid-template-columns: auto auto;
  gap: 2px 10px;
  font-size: 10px;
  color: var(--text-secondary);
}

.tooltip-val {
  font-family: var(--font-mono);
  color: var(--text-primary);
  text-align: right;
}

/* ── Node Labels ──────────────────────────────────────────── */
.node-label {
  pointer-events: none;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

/* ── SVG Country Styles ───────────────────────────────────── */
.country {
  transition: fill 0.3s ease;
  cursor: pointer;
}

.country:hover {
  stroke: rgba(255, 255, 255, 0.4) !important;
  stroke-width: 1.5 !important;
}

/* ── Animations ───────────────────────────────────────────── */
@keyframes pulse {

  0%,
  100% {
    opacity: 0.8;
    transform: scale(1);
  }

  50% {
    opacity: 1;
    transform: scale(1.1);
  }
}

.growth-node .node-glow {
  animation: pulse 3s ease-in-out infinite;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.panel {
  animation: fadeIn 0.4s ease-out;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1024px) {
  .main-content {
    grid-template-columns: 1fr 260px;
  }

  .dashboard-strip {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .main-content {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }

  .sidebar {
    max-height: 200px;
  }

  .dashboard-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .header-sources {
    display: none;
  }
}