/* Base styles from "Tiller" theme */
body {
  margin: 0;
  padding: 0;
  font-family: Arial, sans-serif;
  /* Updated with beige/brown palette */
  background-color: #e6ded5; /* The main "brown"/beige background */
  color: #5a534c; /* The dark, warm-gray text color */
}

#map {
  position: absolute;
  top: 98px; /* Adjusted for smaller header/legend */
  bottom: 26px; /* Adjusted for smaller footer */
  width: 100%;
}

.header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: #fbfaf8; /* TILLER off-white bg */
  color: #5a534c; /* TILLER dark-warm-gray text */
  padding: 10px 15px; /* Reduced padding */
  border-bottom: 2px solid #dcd5cb; /* TILLER beige-based border */
  z-index: 1;
}

.header h1 {
  margin: 0 0 5px 0;
  font-size: 20px; /* Reduced font size */
}

.header p {
  margin: 0;
  font-size: 11px; /* Reduced font size */
  color: #8a817a; /* TILLER secondary warm-gray text */
}

.legend {
  position: absolute;
  top: 58px; /* Adjusted for smaller header */
  left: 0;
  right: 0;
  background: #fbfaf8; /* TILLER off-white bg */
  color: #5a534c; /* TILLER dark-warm-gray text */
  padding: 8px 15px; /* Reduced padding */
  border-bottom: 1px solid #dcd5cb; /* TILLER beige-based border */
  z-index: 1;
  display: flex;
  gap: 15px; /* Reduced gap */
  flex-wrap: wrap;
  font-size: 12px; /* Reduced font size */
  align-items: center;
}

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

.legend-dot {
  width: 10px; /* Reduced size */
  height: 10px; /* Reduced size */
  border-radius: 50%;
}

.toggle-btn {
  background: #fbfaf8; /* TILLER off-white bg */
  color: #5a534c; /* TILLER dark-warm-gray text */
  border: 1px solid #dcd5cb; /* TILLER beige-based border */
  padding: 5px 10px; /* Reduced padding */
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px; /* Reduced font size */
  margin-left: auto;
}

.toggle-btn:hover {
  background: #e6ded5; /* TILLER beige hover */
}

.toggle-btn.active {
  background: #5a534c; /* TILLER dark-warm-gray "active" state */
  border-color: #5a534c;
  color: #fbfaf8; /* TILLER off-white text for contrast */
}

/* Timeline Controls - Updated to Tiller Theme */
.timeline-controls {
  position: absolute;
  bottom: 30px;
  left: 0;
  right: 0;
  background: #fbfaf8; /* TILLER off-white bg */
  padding: 15px 30px;
  border-top: 2px solid #dcd5cb; /* TILLER beige-based border */
  z-index: 1;
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.timeline-label {
  font-size: 18px;
  font-weight: bold;
  color: #5a534c; /* TILLER dark-warm-gray text */
}

.timeline-info {
  font-size: 12px;
  color: #8a817a; /* TILLER secondary warm-gray text */
}

.slider-container {
  position: relative;
  padding: 10px 0;
}

.slider {
  width: 100%;
  height: 8px;
  -webkit-appearance: none;
  appearance: none;
  /* Updated gradient to match theme */
  background: linear-gradient(to right, #dcd5cb, #8a817a);
  border-radius: 5px;
  outline: none;
  cursor: pointer;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  background: #5a534c; /* TILLER accent color */
  cursor: pointer;
  border-radius: 50%;
  border: 3px solid #fbfaf8; /* TILLER bg color */
  box-shadow: 0 0 10px rgba(90, 83, 76, 0.6); /* Shadow from accent */
}

.slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: #5a534c; /* TILLER accent color */
  cursor: pointer;
  border-radius: 50%;
  border: 3px solid #fbfaf8; /* TILLER bg color */
  box-shadow: 0 0 10px rgba(90, 83, 76, 0.6); /* Shadow from accent */
}

.quarter-markers {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  font-size: 10px;
  color: #8a817a; /* TILLER secondary warm-gray text */
}

.quarter-marker {
  flex: 1;
  text-align: center;
}

.quarter-marker.major {
  color: #5a534c; /* TILLER dark-warm-gray text */
  font-weight: bold;
}

/* Event Popup - Updated to Tiller Theme */
.event-popup {
  position: absolute;
  top: 140px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(251, 250, 248, 0.98); /* Semi-transparent off-white */
  color: #5a534c; /* TILLER dark-warm-gray text */
  padding: 20px;
  border-radius: 8px;
  max-width: 500px;
  font-size: 13px;
  z-index: 100;
  border: 2px solid #dcd5cb; /* TILLER beige-based border */
  box-shadow: 0 4px 20px rgba(90, 83, 76, 0.3); /* Softer shadow */
  animation: fadeIn 0.3s ease;
  pointer-events: none;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.event-popup.hidden {
  display: none;
}

.event-popup h3 {
  margin: 0 0 10px 0;
  color: #5a534c; /* TILLER dark-warm-gray text */
  font-size: 16px;
}

/* Semantic event type colors preserved from File 1 */
.event-popup .event-type {
  display: inline-block;
  background: #a85a5a;
  color: white;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  margin-bottom: 10px;
}

.event-popup .event-type.neutral {
  background: #6b7280;
}

.event-popup .event-type.positive {
  background: #10b981;
}

.event-popup ul {
  margin: 10px 0 0 0;
  padding-left: 20px;
}

.event-popup li {
  margin: 5px 0;
}

/* Info Panel styles from Tiller theme */
.info-panel {
  position: absolute;
  bottom: 36px; /* Positioned above footer */
  left: 10px;
  right: 10px;
  /* Swapped to light, semi-transparent bg */
  background: rgba(251, 250, 248, 0.95); /* Semi-transparent off-white */
  color: #5a534c; /* TILLER dark-warm-gray text */
  padding: 10px; /* Reduced padding */
  border-radius: 8px;
  max-width: none; /* Allow full width */
  font-size: 11px; /* Reduced font size */
  z-index: 1;
  border: 1px solid #dcd5cb; /* TILLER beige-based border */
}

.info-panel h3 {
  margin: 0;
  color: #5a534c; /* Use main text color */
  font-size: 13px; /* Reduced font size */
}

.info-panel ul {
  margin: 0;
  padding-left: 15px;
}

.info-panel li {
  margin: 5px 0; /* Reduced margin */
  color: #5a534c; /* TILLER dark-warm-gray text */
}

.info-panel summary {
  cursor: pointer;
  list-style: revert; /* Show default triangle */
}

.info-panel summary h3 {
  display: inline;
}

.info-panel details[open] summary h3 {
  margin-bottom: 10px;
}

/* Mapbox Popup styles from Tiller theme */
.mapboxgl-popup-content {
  background: #fbfaf8; /* TILLER off-white bg */
  color: #5a534c; /* TILLER dark-warm-gray text */
  border-radius: 8px;
  padding: 12px;
  font-size: 13px;
  max-width: 280px;
  border: 1px solid #dcd5cb; /* Added border to match */
}

.mapboxgl-popup-content h3 {
  margin: 0 0 8px 0;
  font-size: 15px;
}

.mapboxgl-popup-content h4 {
  margin: 8px 0 4px 0;
  font-size: 13px;
  color: #5a534c; /* Use main text color */
}

.mapboxgl-popup-content p {
  margin: 4px 0;
}

.popup-label {
  color: #8a817a; /* TILLER secondary warm-gray text */
  font-size: 11px;
}

.popup-value {
  color: #5a534c; /* TILLER dark-warm-gray text */
  font-weight: bold;
}

/* --- Semantic/Data-Viz Colors (Preserved from File 1) --- */
.stockpile-indicator {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: bold;
  margin-left: 5px;
}

.stockpile-critical {
  background: #dc2626;
  color: white;
}

.stockpile-warning {
  background: #f59e0b;
  color: white;
}

.stockpile-healthy {
  background: #10b981;
  color: white;
}

.incident-marker {
  cursor: pointer;
  border: 2px solid white;
}

.incident-marker.energy {
  background: #c94b4b;
}

.incident-marker.transport {
  background: #eb9494;
}

.incident-marker.military {
  background: #5b7ba8;
}

.incident-marker.water {
  background: #2c4a6b;
}

.incident-marker.other {
  background: #7a7a7a;
}

.incident-marker.assassination {
  background: #2a2a2a;
  transform: rotate(45deg);
  border-radius: 0;
}

.price-indicator {
  font-size: 11px;
  color: #fbbf24;
  margin-top: 4px;
}

/* --- New Elements from File 2 --- */
.footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fbfaf8; /* TILLER off-white bg */
  color: #8a817a; /* TILLER secondary warm-gray text */
  padding: 5px; /* Reduced padding */
  text-align: center;
  font-size: 10px; /* Reduced font size */
  border-top: 1px solid #dcd5cb; /* TILLER beige-based border */
  z-index: 1;
}

/* --- Responsive Media Query from File 2 --- */
@media (min-width: 768px) {
  /* Restore desktop styles */
  #map {
    top: 120px;
    bottom: 30px;
  }

  .header {
    padding: 15px;
  }

  .header h1 {
    font-size: 24px;
  }

  .header p {
    font-size: 12px;
  }

  .legend {
    top: 80px;
    padding: 10px 15px;
    gap: 20px;
    font-size: 13px;
  }

  .legend-dot {
    width: 12px;
    height: 12px;
  }

  .toggle-btn {
    padding: 6px 12px;
    font-size: 12px;
  }

  .footer {
    padding: 8px;
    font-size: 11px;
  }

  .info-panel {
    top: 140px;
    right: 20px;
    bottom: auto; /* Override mobile style */
    left: auto; /* Override mobile style */
    padding: 15px;
    max-width: 320px;
    font-size: 12px;
  }

  .info-panel h3 {
    font-size: 14px;
  }

  .info-panel li {
    margin: 6px 0;
  }

  /* Original desktop-only rules */
  .info-panel details > ul {
    display: block;
  }

  .info-panel summary {
    list-style: none;
    cursor: default;
  }
  .info-panel summary::-webkit-details-marker {
    display: none;
  }

  .info-panel summary h3 {
    display: block;
    margin-bottom: 10px;
  }
}

.header-home-btn {
  float: right; /* Pushes the button to the far right */
  padding: 6px 14px;
  background: #e6ded5; /* TILLER beige hover color */
  color: #5a534c; /* TILLER dark-warm-gray text */
  text-decoration: none;
  border-radius: 4px;
  font-weight: bold;
  font-size: 14px;
  border: 1px solid #dcd5cb; /* TILLER beige-based border */
  margin: 10px 0 0 20px; /* Adds space */
}

.header-home-btn:hover {
  background: #dcd5cb; /* Darker beige on hover */
}