/* =========================================
   1. VARIABLES & RESET
   ========================================= */
:root {
  /* Gradient Green Palette */
  --color-primary-dark: #1b4332;   /* Deep dark green */
  --color-primary-medium: #2d6a4f; /* Leaf green */
  --color-primary-light: #40916c;  /* Natural green */
  --color-accent: #74c69d;         /* Mint green for hover/accent */
  --color-bg-light: #f0f7f4;       /* Very light background, slightly green */
  
  /* Neutral Colors & Text */
  --text-main: #1f2937;
  --text-muted: #6b7280;
  --bg-white: #ffffff;
  --border-color: #d1d5db;
  
  /* Shadows & Borders */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --radius-md: 8px;
  --radius-lg: 12px;
  
  /* Dimensions */
  --header-height: 70px;
  --footer-height: 60px;
  --container-width: 1200px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--color-bg-light);
  color: var(--text-main);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* =========================================
   2. GLOBAL LAYOUT (Header / Footer)
   ========================================= */

/* Header with requested green gradient */
.main-header {
  height: var(--header-height);
  background: linear-gradient(135deg, var(--color-primary-dark) 0%, var(--color-primary-medium) 100%);
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  padding: 0 2rem;
}

  .dataset-switch {
    margin-left: auto;
    display: flex;
    gap: 8px;
    align-items: center;
  }

  .dataset-switch button {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.85);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    opacity: 0.95;
    transition: all 0.12s ease, transform 0.08s ease, opacity 0.12s ease;
  }

  .dataset-switch button:hover {
    background: rgba(255,255,255,0.04);
    transform: translateY(-1px);
    opacity: 1;
  }

  .dataset-switch button.selected {
    background: rgba(255,255,255,0.10);
    color: white;
    font-weight: 600;
  }
  
.main-navigation ul {
  display: flex;
  gap: 30px;
  list-style: none;
}

.main-navigation a {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  font-weight: 500;
  font-size: 1.1rem;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  transition: all 0.3s ease;
}

.main-navigation a:hover,
.main-navigation a.active {
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
  transform: translateY(-1px);
}

.main-footer {
  background-color: var(--color-primary-dark);
  color: white;
  text-align: center;
  padding: 15px;
  font-size: 0.9rem;
  margin-top: auto;
}

.main-headline {
  font-size: 2rem;
  color: var(--color-primary-dark);
  margin-bottom: 10px;
  font-weight: 700;
  text-align: center;
  letter-spacing: -0.5px;
}

/* =========================================
   3. WORLD MAP STYLES
   ========================================= */
.world-map-chart-wrapper {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  flex: 1 1 auto;
  min-height: 180px;
  width: 100%;
  border: 1px solid rgba(0,0,0,0.05);
}

.world-map-chart-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
}

#sst-toggle-container {
  position: fixed; 
  top: 9vh; 
  right: 10px; 
  background: rgba(255, 255, 255, 0.7); 
  padding: 4px 8px; 
  border-radius: 4px; 
  font-family: sans-serif; 
  font-size: 14px; 
  z-index: 1000;
}

/* =========================================
   4. TIMELINE STYLES
   ========================================= */
#timeline-chart {
  width: 100%;
  height: 100px;
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  margin-bottom: 10px;
  position: relative;
  overflow: hidden;
}

.timeline-selected {
  stroke: var(--text-main);
  stroke-width: 2px;
}

.magnifier text {
  font-family: sans-serif;
}



/* =========================================
   5. SCATTERPLOT CONTROLS (Professional Look)
   ========================================= */
/* The div generated by JS with id="scatter-controls" */
#scatter-controls {
  background: white !important; /* Force override of JS inline style */
  border-left: 5px solid var(--color-primary-medium);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-md) !important;
  padding: 20px !important;
  margin-bottom: 30px !important;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
}

#scatter-controls label {
  color: var(--color-primary-dark);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Style of inputs and selects */
#scatter-controls select {
  padding: 8px 12px !important;
  border: 1px solid var(--border-color) !important;
  border-radius: 6px !important;
  background-color: var(--bg-light);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-width: 150px;
}

#scatter-controls select:focus {
  outline: none;
  border-color: var(--color-primary-light) !important;
  box-shadow: 0 0 0 3px rgba(64, 145, 108, 0.2);
}

#scatter-controls select[multiple] {
  height: auto;
  min-height: 40px;
  max-height: 120px;
}

/* Selected country chips (visual cue for multi-select) */
.selected-country-chips {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: 12px;
  flex-wrap: wrap;
  max-height: 120px;
  width: 150px;
  overflow-y: auto;
}
.country-chip {
  background: var(--color-accent);
  color: var(--color-primary-dark);
  border: none;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
  box-shadow: var(--shadow-sm);
}
.country-chip.all {
  background: var(--color-primary-medium);
  color: #fff;
}
.country-chip:hover {
  filter: brightness(0.95);
}

#reset-button {
  background-color: var(--color-primary-medium) !important;
  color: white !important;
  font-weight: 600;
  padding: 10px 20px !important;
  border-radius: 6px !important;
  transition: background-color 0.2s, transform 0.1s;
  box-shadow: var(--shadow-sm);
}

#reset-button:hover {
  background-color: var(--color-primary-dark) !important;
  transform: translateY(-1px);
}

#reset-button:active {
  transform: translateY(1px);
}


.content {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  max-width: 1800px; 
  margin: 0 auto;
  padding-top: 0px; 
}

/* =========================================
   6. SCATTERPLOT LAYOUT (DASHBOARD MODE)
   ========================================= */

/* Main container becomes a grid */
#scatterplot-chart {
  display: grid;
  /* Column definition: 
     - 65% for the large chart
     - The rest (1fr) for the small charts */
  grid-template-columns: 65% 1fr; 
  align-items: start; /* Align elements at the top */
}

/* Controls take the full width at the top (Row 1) */
#scatter-controls {
  grid-column: 1 / -1; /* Extends from column 1 to the end */
  background: white !important;
  border-left: 5px solid var(--color-primary-medium);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-md) !important;
  padding: 15px 20px !important;
  margin-bottom: 10px !important;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}

/* Large chart (Left column) */
#scatter-svg-container {
  grid-column: 1 / 2; /* Stays in the first column */
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 600px;
  /* Trick to make SVG responsive if needed */
  overflow: hidden; 
}
/* Ensure the SVG doesn't overflow */
#scatter-svg-container svg {
  max-width: 100%;
  height: auto;
}


/* =========================================
   7. COUNTRY COMPARISON (RIGHT COLUMN)
   ========================================= */

#country-comparison-container {
  grid-column: 2 / 3; /* Places in the right column */
  
  /* Internal grid for small charts */
  display: grid !important;
  /* Force 1 or 2 columns depending on available space on the right */
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); 
  gap: 15px !important;
  
  /* SCROLL MANAGEMENT: 
     Set a max height so this column scrolls 
     independently from the page */
  max-height: 700px; 
  overflow-y: auto;
  padding: 5px; /* Small padding to not cut off shadows */
  
  /* Styled scrollbar (optional, for Webkit/Chrome) */
  scrollbar-width: thin;
  scrollbar-color: var(--color-primary-light) #f1f1f1;
}

/* Style of individual cards */
#country-comparison-container > div {
  background: white !important;
  border: 1px solid rgba(0,0,0,0.05) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-sm) !important;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: 10px !important;
}

#country-comparison-container > div:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md) !important;
  border-color: var(--color-primary-light) !important;
}

/* Country title */
#country-comparison-container > div > div:first-child {
  width: 100%;
  background: linear-gradient(to right, var(--bg-light), white);
  color: var(--color-primary-dark);
  padding: 8px 0;
  border-bottom: 1px solid #e5e7eb;
  font-weight: 700 !important;
  font-size: 12px !important;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* =========================================
   RESPONSIVE (Mobile)
   ========================================= */
@media (max-width: 1100px) {
  /* If screen is too small, switch back to single column */
  #scatterplot-chart {
    grid-template-columns: 1fr;
  }
  
  #scatter-svg-container {
    grid-column: 1 / -1;
  }
  
  #country-comparison-container {
    grid-column: 1 / -1;
    max-height: none; /* Remove internal scroll on mobile */
    overflow-y: visible;
  }
}

/* =========================================
   8. TOOLTIP
   ========================================= */
#scatter-tooltip {
  background-color: rgba(27, 67, 50, 0.95) !important; /* Very dark green almost black */
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  color: #fff !important;
  padding: 12px 16px !important;
  border-radius: 8px !important;
  line-height: 1.5;
  font-size: 0.85rem !important;
  z-index: 10000 !important;
}

/* Data Loader Status (from data-processing.js) */
.status {
  padding: 10px;
  margin: 5px 0;
  border-radius: 4px;
  font-size: 0.9em;
}
.status.loading { background: #e0f2fe; color: #0369a1; }
.status.success { background: #dcfce7; color: #166534; }
.status.error { background: #fee2e2; color: #991b1b; }

/* Responsive Adjustments */
@media (max-width: 768px) {
  .main-navigation ul {
    gap: 15px;
  }
  
  #scatter-controls {
    flex-direction: column;
    align-items: stretch;
  }
  
  #reset-button {
    margin-left: 0 !important;
    width: 100%;
  }
}

/* =========================================
   9. DRAG AND DROP STYLES
   ========================================= */
.draggable-card {
  cursor: grab; /* "Open hand" cursor */
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
}

.draggable-card:active {
  cursor: grabbing; /* "Closed hand" cursor when clicked */
}

/* Class automatically applied during drag */
.draggable-card.dragging {
  opacity: 0.4;
  border: 2px dashed var(--color-primary-medium) !important;
  transform: scale(0.95);
}

/* =========================================
   10. OVERLAY / MODAL STYLES
   ========================================= */
/* Dark blurred background */
.overlay-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent background */
  backdrop-filter: blur(5px); /* Blur effect on the background */
  z-index: 9000; /* Very high to pass in front of everything */
  display: none; /* Hidden by default */
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* Active class to display overlay with transition */
.overlay-backdrop.active {
  display: flex;
  opacity: 1;
}

/* White container of the chart in the center */
.overlay-content {
  background: white;
  padding: 30px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 1000px; /* Max width */
  height: 80vh; /* 80% of screen height */
  position: relative;
  display: flex;
  flex-direction: column;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.overlay-backdrop.active .overlay-content {
  transform: scale(1);
}

/* Close button (X) */
#overlay-close-btn {
  position: absolute;
  top: 15px;
  right: 20px;
  font-size: 28px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
}

#overlay-close-btn:hover {
  color: var(--color-primary-dark);
}

/* Title in overlay */
#overlay-title {
  margin-bottom: 20px;
  color: var(--color-primary-dark);
  text-align: center;
}

/* SVG container flex to take remaining space */
#overlay-chart-container {
  flex: 1;
  min-height: 0; /* Important for flex */
  display: flex;
  justify-content: center;
  align-items: center;
}

/* --- Expand button styles on small cards --- */

/* Necessary to position button absolute relative to card */
.draggable-card {
  position: relative; 
}

.expand-card-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  cursor: pointer;
  padding: 4px;
  opacity: 0; /* Hidden by default */
  transition: opacity 0.2s ease, background-color 0.2s;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

.expand-card-btn svg {
  width: 16px;
  height: 16px;
  fill: var(--text-muted);
}

/* Show button on card hover */
.draggable-card:hover .expand-card-btn {
  opacity: 1;
}

.expand-card-btn:hover {
  background: var(--color-primary-light);
}
.expand-card-btn:hover svg {
  fill: white;
}


.footer-link {
  color: white;   
  position: relative;
  z-index: 10000;
}

body, html {
    height: 100%;
    margin: 0;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

.hero-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('https://images.unsplash.com/photo-1505228395891-9a51e7e86bf6?q=80&w=2833&auto=format&fit=crop'); 
    background-size: cover;
    background-position: center;
    z-index: -1;
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to bottom, 
        rgba(27, 67, 50, 0.6),
        rgba(0, 0, 0, 0.8)
    );
    z-index: 0;
}

.hero-content {
    position: relative;
    z-index: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 0 20px;
    color: white;
}

.glass-card {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 3rem 4rem;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    max-width: 800px;
    animation: fadeInUp 1s ease-out;
}

h1 {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
    letter-spacing: -1px;
    background: linear-gradient(to right, #ffffff, #a7f3d0);
    -webkit-background-clip: text;
    line-height: 1.1;
}

p.subtitle {
    font-size: 1.25rem;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 2.5rem;
    font-weight: 300;
    line-height: 1.6;
}

.cta-group {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.cta-btn {
    padding: 14px 28px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 1rem;
    text-decoration: none;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.cta-primary {
    background-color: #2d6a4f;
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
    box-shadow: 0 4px 15px rgba(45, 106, 79, 0.4);
}

.cta-primary:hover {
    background-color: #40916c;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(45, 106, 79, 0.6);
}

.cta-secondary {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(4px);
}

.cta-secondary:hover {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: white;
    transform: translateY(-2px);
}

.footer-credits {
    position: absolute;
    bottom: 20px;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.4);
}

.footer-credits a {
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 768px) {
    .glass-card { padding: 2rem; width: 90%; }
    h1 { font-size: 2.5rem; }
    .cta-group { flex-direction: column; }
    .cta-btn { width: 100%; justify-content: center; }
}