/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  line-height: 1.8;
  background-color: #f8f9fa; /* Lighter background */
  color: #495057; /* Darker grey for text */
  min-height: 100vh;
  display: flex;
  overflow: hidden;
}

.container {
  width: 100%;
  max-width: 1400px; /* Slightly wider */
  margin: 0 auto;
  padding: 30px 20px;
  flex-grow: 1;
}

h1, h3, h4 {
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  color: #343a40; /* Dark heading color */
}

/* Make h2 consistent with h1,h3,h4 */
h2 {
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  color: #343a40; 
  font-size: 1.75rem; /* Slightly smaller than h1 */
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid #dee2e6;
}

/* Site Header */
.site-header {
  text-align: center;
  margin-bottom: 40px;
  padding-bottom: 20px;
  border-bottom: 1px solid #dee2e6;
  max-width: 100%; /* Allow header to span full width */
  display: flex; /* Use flexbox for layout */
  align-items: center; /* Vertically align items */
  gap: 20px; /* Add space between logo and text */
}

.sidebar-logo {
  width: 80%; 
  margin: 30px auto; /* Adjusted margin for better spacing */
  display: block; 
}

.sidebar-logo img {
  max-width: 100%;
  max-height: 100%;
  display: block;
}

.header-text { /* New container for title and subtitle */
  text-align: left; /* Ensure text inside is left-aligned */
}

.site-header h1 {
  font-size: 2.5rem;
  margin-bottom: 5px; /* Reduce margin */
  color: #212529;
  text-align: left; /* Ensure h1 is left-aligned */
}

.statement-of-purpose {
  font-size: 1.1rem;
  color: #6c757d; /* Subtler description color */
  max-width: 100%; /* Allow full width within its container */
  /* margin: 0 auto; Removed */
  text-align: left; /* Ensure p is left-aligned */
}

/* Text Content Sections (Introduction, Explore, User Research) */
.text-content-section {
  background-color: #ffffff;
  padding: 25px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  margin-bottom: 30px;
}

.text-content-section p {
  margin-bottom: 15px;
}

.text-content-section ul {
  list-style: disc; /* Use standard bullets */
  margin-left: 25px; /* Indent lists */
  margin-bottom: 15px;
}

.text-content-section li {
  margin-bottom: 50px;
}

/* Style the Project Purpose H3 specifically -- Removing this rule to allow default h3 styling for better prominence on the intro page */
/*
.tab-content.active h3 {
  color: #6c757d; 
}
*/

/* Specific styles for User Research Summary */
.research-summary {
  /* margin-top: 15px; */
  /* Optional: Add a light background or border */
  /* background-color: #f8f9fa; */
  /* border: 1px solid #e9ecef; */
  /* padding: 15px; */
  /* border-radius: 6px; */
}

/* Controls Area */
.controls {
  display: flex;
  flex-direction: column; /* Stack title and wrapper vertically */
  align-items: center; /* Center items horizontally */
  /* justify-content: center; Moved to wrapper */
  /* align-items: center; Moved to wrapper */
  /* flex-wrap: wrap; Moved to wrapper */
  /* gap: 15px; Moved to wrapper */
  padding: 20px;
  background-color: #ffffff;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  margin-bottom: 30px;
  flex-shrink: 0; /* Prevent footer from shrinking */
}

/* Style the h2 within the controls box */
.controls h2 {
  width: 100%; /* Make h2 take full width */
  text-align: center; /* Center the text */
  margin-bottom: 20px; /* Add space below the title */
  padding-bottom: 15px; /* Add padding below text */
  border-bottom: 1px solid #dee2e6; /* Add separator line */
  /* Inherit other h2 styles from base */
}

/* Wrapper for the actual filter/button items */
.control-items-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
  width: 100%; /* Ensure it takes full width */
}

.filter-group label {
  margin-right: 8px;
  font-weight: 500; /* Medium weight */
  font-size: 0.9rem;
  color: #495057;
}

select, button {
  padding: 8px 12px;
  border: 1px solid #ced4da; /* Standard border color */
  border-radius: 6px;
  background-color: #ffffff;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

select:focus, button:focus {
  outline: none;
  border-color: #86b7fe;
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25); /* Bootstrap-like focus */
}

button {
  background-color: #0d6efd; /* Primary blue */
  color: white;
  cursor: pointer;
  font-weight: 500;
  transition: background-color 0.2s ease;
}

button:hover {
  background-color: #0b5ed7; /* Darker blue on hover */
}

button#reset-button {
  background-color: #6c757d; /* Secondary grey */
}

button#reset-button:hover {
  background-color: #5c636a;
}

/* View Toggle */
.view-toggle {
  display: flex;
  margin-bottom: 0;
}

.toggle-button {
  padding: 8px 20px;
  background-color: #e9ecef; /* Light grey */
  color: #495057;
  border: 1px solid #dee2e6;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s ease;
  border-radius: 0; /* For segmented control look */
}

.toggle-button:first-child {
  border-top-left-radius: 6px;
  border-bottom-left-radius: 6px;
}

.toggle-button:last-child {
  border-top-right-radius: 6px;
  border-bottom-right-radius: 6px;
  border-left: none; /* Avoid double border */
}

.toggle-button:hover {
  background-color: #dee2e6;
}

/* Define active state colors specifically */
.toggle-button.active-connectivity {
  background-color: #0d6efd; /* Primary blue */
  color: white;
  border-color: #0d6efd; /* Primary blue */
  z-index: 1; /* Ensure active border overlaps */
}

.toggle-button.active-outcome {
  background-color: #fd7e14; /* Accent orange */
  color: white;
  border-color: #fd7e14; /* Accent orange */
  z-index: 1; /* Ensure active border overlaps */
}

/* Main Content Area */
.content {
  display: grid; /* Use Grid for layout */
  grid-template-columns: 2fr 1fr; /* 2/3 for map, 1/3 for data */
  gap: 30px;
  align-items: start; /* Align items to the top */
  margin-bottom: 30px; /* Added margin to separate from following content */
}

/* New styles for geographic content layout */
.geographic-content-wrapper {
  display: flex;
  gap: 30px; /* Space between map and data panel */
  align-items: flex-start; /* Align items to the top */
  margin-top: 20px; /* Space below filters */
}

.geographic-content-wrapper .map-section {
  flex: 2; /* Map takes 2 parts of the space */
  /* Ensure map-section specific styles from before still apply if needed */
  /* background-color, padding, border-radius, box-shadow are already defined for .map-section */
}

.geographic-content-wrapper .data-section {
  flex: 1; /* Data panel takes 1 part of the space */
  /* Ensure data-section specific styles from before still apply if needed */
}
/* End of new styles */

.map-section {
  background-color: #ffffff;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  position: relative; /* For positioning error message */
}

#map-container {
  width: 100%;
  /* height: 600px; Let aspect ratio control height */
  background-color: #ffffff;
  aspect-ratio: 960 / 600; /* Enforce the SVG's aspect ratio */
  overflow: hidden; /* Prevent content from spilling out */
}

/* Map SVG Styles */
.state {
  stroke: #fff;
  stroke-width: 0.5px;
  transition: fill 0.3s ease, stroke-width 0.3s ease;
  cursor: pointer;
}

.state:hover {
  stroke-width: 1px;
}

.county {
  stroke: #fff;
  stroke-width: 0.2px;
  transition: fill 0.3s ease, stroke-width 0.3s ease;
  cursor: pointer;
}

.county:hover {
  stroke-width: 0.8px;
}

.county-borders {
  fill: none;
  stroke: #fff;
  stroke-width: 0.3px;
  pointer-events: none;
}

/* Legend */
#legend-container {
  margin-top: 20px;
  padding: 15px;
  background-color: #f8f9fa; /* Slightly different background */
  border-radius: 6px;
  border: 1px solid #dee2e6;
}

.legend-label {
  font-size: 0.8rem;
  fill: #495057;
}

/* Data Section */
.data-section {
 /* No specific container styles needed if panel has them */
}

#data-panel {
  background-color: #ffffff;
  padding: 25px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  height: 100%; /* Try to match map section height (adjust if needed) */
  display: flex; /* Use flexbox for internal layout */
  flex-direction: column;
}

.panel-header {
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid #dee2e6;
  flex-shrink: 0; /* Prevent header from shrinking */
}

.panel-header h3 {
  font-size: 1.5rem;
  color: #212529;
  margin: 0;
}

.panel-content {
  flex-grow: 1; /* Allow content to fill remaining space */
  overflow-y: auto; /* Add scroll if content overflows */
}

.tab-content {
  display: none; /* Hide inactive tabs */
}

.tab-content.active {
  display: block; /* Show active tab */
}

.prominent-summary {
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  margin-bottom: 25px;
  padding-bottom: 20px;
  border-bottom: 1px solid #e9ecef;
  gap: 15px;
}

.summary-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 15px;
  background-color: #f8f9fa;
  border-radius: 6px;
  border: 1px solid #dee2e6;
  text-align: center;
}

.summary-column .value {
  font-size: 2rem; /* Larger values */
  font-weight: 600; /* Bold but not overly so */
  font-family: 'Poppins', sans-serif; /* Heading font for numbers */
  margin-bottom: 5px;
  line-height: 1.2;
}

.summary-column .label {
  font-size: 0.8rem; /* Smaller labels */
  color: #6c757d;
  line-height: 1.3;
}

.summary-column .connectivity-value {
  color: #0d6efd; /* Primary blue */
}

.summary-column .score-value {
  color: #fd7e14; /* Accent orange */
}

.summary-instruction {
  font-size: 0.9rem;
  color: #6c757d;
  text-align: center;
  margin-top: 15px;
}

/* Table Styles */
#data-panel h4 { /* County table heading */
  font-size: 1.1rem;
  margin-top: 25px;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e9ecef;
}

.table-container {
  max-height: 350px; /* Allow slightly more height */
  overflow-y: auto;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  margin-top: 15px; /* Add space above table */
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 12px 15px; /* More padding */
  text-align: left;
  border-bottom: 1px solid #dee2e6;
  font-size: 0.9rem;
  vertical-align: middle;
}

th {
  background-color: #f8f9fa;
  font-weight: 600; /* Bold headers */
  color: #343a40;
  position: sticky; /* Keep headers visible */
  top: 0;
  z-index: 1;
}

tbody tr {
  transition: background-color 0.2s ease;
}

tbody tr:nth-child(even) {
 background-color: #fdfdfe; /* Very subtle striping */
}

tbody tr:hover {
  background-color: #e9ecef; /* Clearer hover */
}

tbody tr[data-fips] {
  cursor: pointer; /* Indicate clickable rows */
}

td[style*="background-color"] { /* Style colored cells */
  color: white; /* Default white text on colored background */
  font-weight: 500;
}

/* Add styles for narrative buttons */
.narrative-button {
  display: block; /* Place on its own line */
  margin: 15px auto 5px auto; /* Center with margins */
  padding: 8px 15px;
  background-color: #198754; /* Bootstrap success green */
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background-color 0.2s ease;
}

.narrative-button:hover {
  background-color: #157347; /* Darker green */
}

.narrative-button.active {
  background-color: #dc3545; /* Bootstrap danger red for 'remove' state */
}

.narrative-button.active:hover {
  background-color: #bb2d3b;
}

/* Style for the highlight circle/line */
.highlight-marker {
  fill: none;
  stroke: #ffc107; /* Bootstrap warning yellow */
  stroke-width: 3px;
  pointer-events: none; /* Don't interfere with clicks */
}

/* Error Message */
.error-message {
  padding: 15px;
  background-color: #f8d7da;
  color: #842029;
  border: 1px solid #f5c2c7;
  border-radius: 6px;
  margin-top: 20px;
}

/* Loading Indicator */
.loading-indicator {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 5px solid #dee2e6; /* Light border */
  border-top: 5px solid #0d6efd; /* Blue spinner top */
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

.loading-text {
  font-size: 1.1rem;
  font-weight: 500;
  color: #495057;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Footer */
footer.site-footer {
  margin-top: 40px;
  padding: 20px;
  text-align: center;
  font-size: 0.9rem;
  color: #6c757d;
  background-color: #ffffff;
  border-top: 1px solid #dee2e6;
  flex-shrink: 0; /* Prevent footer from shrinking */
}

footer.site-footer p {
  margin-bottom: 5px;
}

footer.site-footer a {
  color: #0d6efd;
  text-decoration: none;
}

footer.site-footer a:hover {
  text-decoration: underline;
}

/* Style the Resources Section*/
.resources-section {
  margin-top: 15px;
  margin-bottom: 15px;
  /* padding-top: 15px; Removed */
  /* border-top: 1px solid #e9ecef; Removed Separator line */

  /* Apply styles similar to .text-content-section */
  background-color: #ffffff;
  padding: 20px; /* Slightly less padding than main sections */
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  text-align: left; /* Ensure content inside is left-aligned */
}

/* Style for the columns within the resources section */
.resource-column {
  flex: 1; /* Allow columns to share space equally */
}

.resources-section h4 {
  font-size: 1rem;
  margin-bottom: 10px;
  color: #495057;
}

.resources-section ul {
  list-style: none; /* Remove bullets for resource links */
  padding-left: 0;
}

.resources-section li {
  margin-bottom: 5px;
}

.resources-section a {
  color: #0d6efd;
  text-decoration: none;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .content {
    grid-template-columns: 1fr; /* Stack map and data */
  }
  .map-section {
    min-height: 450px; /* Ensure map has decent height */
  }
  #data-panel {
    height: auto; /* Let panel height adjust */
    min-height: 400px; /* Give it some minimum height */
  }
}

@media (max-width: 768px) {
  body {
    font-size: 14px;
  }
  .container {
    padding: 20px 15px;
  }
  .site-header h1 {
    font-size: 2rem;
  }
  .statement-of-purpose {
    font-size: 1rem;
  }
  .controls {
    flex-direction: column;
    align-items: stretch;
    padding: 15px;
  }
  .filter-group {
     display: flex;
     flex-direction: column;
     align-items: stretch;
     width: 100%;
  }
   .filter-group label {
     margin-bottom: 5px;
   }
  select, button {
    width: 100%;
  }
  .map-section {
    padding: 15px;
    min-height: 400px;
  }
  #data-panel {
    padding: 20px;
  }
  .prominent-summary {
    flex-direction: column;
  }
  .summary-column .value {
     font-size: 1.8rem;
  }
  th, td {
    padding: 10px 12px;
  }
}

.sidebar {
  width: 220px; /* Slightly wider sidebar */
  background-color: #f1f3f5; /* Lighter background for a professional look */
  padding-top: 20px;
  flex-shrink: 0;
  height: 100vh;
  border-right: 1px solid #dee2e6; /* Subtle border to separate from main content */
}

.sidebar nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar nav ul li a {
  display: block;
  padding: 12px 20px;
  text-decoration: none;
  color: #495057; /* Darker text for readability on light background */
  border-left: 3px solid transparent;
  transition: background 0.2s, border-left-color 0.2s, color 0.2s;
  font-weight: 500; /* Slightly bolder font */
}

.sidebar nav ul li a:hover {
  color: #0d6efd; /* Primary blue on hover */
  background-color: #e9ecef; /* Subtle hover background */
}

.sidebar nav ul li a.active {
  color: #0d6efd; /* Primary blue for active link text */
  background-color: #e9ecef; /* Light background for active link */
  border-left-color: #0d6efd; /* Primary blue for active border */
  font-weight: 600; /* Bolder for active link */
}

.main-content {
  flex-grow: 1;
  overflow-y: auto;
  height: 100vh;
  padding: 30px;
  background-color: #f8f9fa;
}

.main-content ul {
  list-style-position: inside;  
  padding-left: 1rem;
  margin: 1rem 0;
}

.main-content li {
  padding-left: 0;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Graph card style for time graphs */
.graph-card {
  background-color: #fff;
  padding: 25px 25px 20px 25px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  margin-top: 15px;
  margin-bottom: 15px;
}

.section-source {
  font-size: 0.75rem;
  color: #6c757d;
  margin-left: 6px;
  text-decoration: none;
  vertical-align: super; /* Aligns the citation to the top like a superscript */
  cursor: pointer;
  border-bottom: 1px dotted transparent;
}

.section-source:hover {
  color: #0d6efd;
  border-bottom-color: #0d6efd;
}

/* Highlight animation */
@keyframes glowHighlight {
  0%   { background-color: #c1d5fd; }  
  100% { background-color: transparent; }
}

.glow {
  animation: glowHighlight 1s ease-out;
}

/* Correlation Visualization Styles */
.correlation-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.correlation-controls .filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.correlation-controls label {
    font-size: 0.9rem;
    color: #495057;
    font-weight: 500;
}

.correlation-controls select {
    padding: 0.5rem;
    border: 1px solid #ced4da;
    border-radius: 4px;
    background-color: white;
    font-size: 0.9rem;
    min-width: 150px;
}

.correlation-stats {
    margin-bottom: 1.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-label {
    font-size: 0.9rem;
    color: #6c757d;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: #212529;
}

.scatter-plot-container {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.scatter-tooltip {
    position: absolute;
    visibility: hidden;
    background-color: white;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 0.75rem;
    font-size: 0.9rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 1000;
    pointer-events: none;
}

.dot {
    transition: all 0.2s ease;
}

.dot:hover {
    cursor: pointer;
}

.regression-line {
    stroke: #ff7f0e;
    stroke-width: 2;
    fill: none;
}

.confidence-interval {
    fill: #ff7f0e;
    fill-opacity: 0.1;
    stroke: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .correlation-controls {
        flex-direction: column;
        gap: 0.75rem;
    }

    .correlation-controls select {
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}