html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: Arial, sans-serif;
  display: flex;
  flex-direction: column;
}

#map {
  height: calc(100% - 50px);
  width: 100%;
}

/* Neighborhood popup styling */
.neighborhood-popup .mapboxgl-popup-content {
  padding: 15px;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  min-width: 250px;
  max-width: 350px;
}

.neighborhood-info h3 {
  margin: 0 0 10px 0;
  color: #333;
  font-size: 18px;
  font-weight: bold;
}

.neighborhood-info .score {
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 10px;
  padding: 5px 10px;
  border-radius: 5px;
  display: inline-block;
  text-shadow: 1px 1px 0px #454545, 1px -1px 0px #454545, -1px 1px 0px #454545,
    -1px -1px 0px #454545, 0px 0px 1px #000000;
}

/* Score colors are now applied dynamically via JavaScript using polygon color system */

.neighborhood-info .reasoning {
  font-size: 14px;
  line-height: 1.4;
  color: #555;
  margin-top: 8px;
}

/* Remove the popup tip/arrow */
.neighborhood-popup .mapboxgl-popup-tip {
  display: none;
}

/* Neighborhood name and score box - positioned at top */
.neighborhood-name-score-box {
  position: absolute;
  top: 10px; /* Position at top */
  left: 10px;
  right: auto;
  z-index: 1000;
  background: white;
  padding: 12px;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  width: 500px;
  box-sizing: border-box;
  font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
  border: 2px solid #ddd;
}

.neighborhood-name-score-box .neighborhood-info .name-score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
}

.neighborhood-name-score-box .neighborhood-info h3 {
  margin: 0;
  color: #333;
  font-size: 18px;
  font-weight: bold;
  flex: 1;
}

.neighborhood-name-score-box .neighborhood-info .score {
  font-size: 16px;
  font-weight: bold;
  margin: 0;
  padding: 5px 10px;
  border-radius: 5px;
  display: inline-block;
  flex-shrink: 0;
}

/* Score colors in name/score box are now applied dynamically via JavaScript using polygon color system */

/* Tap to learn more indicator for mobile */
.neighborhood-name-score-box .tap-to-learn {
  font-size: 12px;
  color: #666;
  margin: 4px 0 0 0;
  display: block;
}

@media (max-width: 768px) {
  .neighborhood-name-score-box .tap-to-learn {
    display: block;
  }
}

/* Neighborhood description box - positioned under name/score box */
.neighborhood-description-box {
  position: absolute;
  top: 75px; /* Position below name/score box */
  left: 10px;
  right: auto;
  z-index: 1000;
  background: white;
  padding: 12px;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  width: 500px;
  box-sizing: border-box;
  max-height: calc(100vh - 90px);
  overflow-y: auto;
  font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
  border: 2px solid #ddd;
}

/* Close button for description box */
.description-close-button {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  background: #ef4444;
  border: 1px solid #dc2626;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: bold;
  color: white;
  user-select: none;
  z-index: 1001;
}

.description-close-button:hover {
  background: #dc2626;
  border-color: #b91c1c;
}

.description-close-button:active {
  background: #b91c1c;
}

.neighborhood-description-box .neighborhood-info .reasoning {
  font-size: 14px;
  line-height: 1.4;
  color: #555;
  margin: 0 0 15px 0;
}

/* Score breakdown section */
.scores-breakdown {
  margin-top: 15px;
  margin-bottom: 15px;
}

.scores-breakdown h4 {
  margin: 0 0 8px 0;
  font-size: 13px;
  font-weight: bold;
  color: #333;
}

.scores-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.score-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 6px;
  background-color: #f8f9fa;
  border-radius: 4px;
  border-left: 3px solid #e5e7eb;
}

.score-label {
  font-size: 11px;
  color: #000000;
  font-weight: bold;
}

.score-value {
  font-size: 12px;
  font-weight: bold;
  color: #1f2937;
}

/* Color-coding is now applied dynamically via JavaScript */

/* Pros/Cons/Must-Do sections */
.pros-cons-section {
  margin-top: 15px;
}

.pros-section,
.cons-section,
.must-do-section {
  margin-bottom: 12px;
}

.pros-section h4,
.cons-section h4,
.must-do-section h4 {
  margin: 0 0 6px 0;
  font-size: 13px;
  font-weight: bold;
  color: #333;
}

.pros-list,
.cons-list,
.must-do-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.pros-list li,
.cons-list li,
.must-do-list li {
  font-size: 12px;
  line-height: 1.3;
  margin-bottom: 3px;
  color: #555;
  padding-left: 12px;
}

.pros-list li {
  color: #22c55e;
}

.cons-list li {
  color: #ef4444;
}

.must-do-list li {
  color: #3b82f6;
}

/* POI clickable links */
.poi-link {
  cursor: pointer;
  text-decoration: underline;
  color: #2563eb;
  transition: color 0.2s;
}

.poi-link:hover {
  color: #1d4ed8;
  text-decoration: underline;
}

/* Feedback section */
.feedback-section {
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid #e5e7eb;
  text-align: center;
}

.feedback-button {
  background: #6366f1;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 0 16px;
  height: 40px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
  width: 100%;
  max-width: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.feedback-button:hover {
  background: #4f46e5;
}

.feedback-button:active {
  background: #4338ca;
  transform: scale(0.98);
}

/* Legend bar at bottom of screen */
#legend-bar {
  z-index: 1000;
  height: 50px;
  box-shadow: 0 -3px 10px rgba(0, 0, 0, 0.15);
}

.legend-gradient {
  display: flex;
  width: 100%;
  height: 100%;
  border-top: 1px solid rgba(0, 0, 0, 0.2);
}

.legend-item {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border-right: 1px solid rgb(255, 255, 255);
}

.legend-extreme {
  flex: 2;
}

.legend-middle {
  flex: 0.5;
}

.legend-item:last-child {
  border-right: none;
}

.legend-color {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
}

.legend-label {
  font-size: clamp(10px, 2.5vw, 18px);
  text-align: center;
  line-height: 1.2;
  color: white;
  font-weight: 600;
  z-index: 1;
  position: relative;
  padding: 4px;
  text-shadow: 1px 1px 0px #454545, 1px -1px 0px #454545, -1px 1px 0px #454545,
    -1px -1px 0px #454545, 0px 0px 1px #000000;
}

/* Responsive adjustments for different screen sizes */
@media (max-width: 768px) {
  .legend-label {
    font-size: clamp(8px, 3vw, 14px);
    padding: 2px;
  }
}

@media (max-width: 480px) {
  .legend-label {
    font-size: clamp(6px, 3.5vw, 12px);
    padding: 1px;
  }
}

@media (min-width: 1200px) {
  .legend-label {
    font-size: clamp(14px, 2vw, 20px);
  }
}

/* Legend color backgrounds */
.legend-item:nth-child(1) .legend-color {
  background-color: #ff0000;
}

.legend-item:nth-child(2) .legend-color {
  background-color: #ff5500;
}

.legend-item:nth-child(3) .legend-color {
  background-color: #ffaa00;
}

.legend-item:nth-child(4) .legend-color {
  background-color: #ffff00;
}

.legend-item:nth-child(5) .legend-color {
  background-color: #bfff00;
}

.legend-item:nth-child(6) .legend-color {
  background-color: #80ff00;
}

.legend-item:nth-child(7) .legend-color {
  background-color: #40ff00;
}

.legend-item:nth-child(8) .legend-color {
  background-color: #00ff00;
}

/* Mobile-specific improvements */
@media (max-width: 768px) {
  .neighborhood-name-score-box {
    top: 5px;
    left: 5px;
    right: 5px;
    padding: 10px;
    max-width: calc(100vw - 10px);
    width: auto;
  }

  .neighborhood-description-box {
    top: 60px;
    left: 5px;
    right: 5px;
    padding: 10px;
    max-width: calc(100vw - 10px);
    width: auto;
    max-height: calc(100vh - 100px);
    font-size: 13px;
  }

  .neighborhood-name-score-box .neighborhood-info h3 {
    font-size: 16px;
  }

  .neighborhood-name-score-box .neighborhood-info .score {
    font-size: 14px;
    padding: 4px 8px;
    text-shadow: 1px 1px 0px #454545, 1px -1px 0px #454545, -1px 1px 0px #454545,
      -1px -1px 0px #454545, 0px 0px 1px #000000, 0px 0px 3px #000000,
      0px 0px 3px #000000;
  }

  .scores-grid {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .score-item {
    padding: 6px 8px;
  }

  .score-label {
    font-size: 12px;
  }

  .score-value {
    font-size: 13px;
  }

  .pros-section h4,
  .cons-section h4,
  .must-do-section h4 {
    font-size: 12px;
  }

  .pros-list li,
  .cons-list li,
  .must-do-list li {
    font-size: 11px;
    line-height: 1.4;
    padding-left: 10px;
  }

  #legend-bar {
    height: 40px;
  }

  #map {
    height: calc(100% - 40px);
  }

  .legend-label {
    font-size: clamp(6px, 2.5vw, 12px) !important;
    padding: 1px !important;
    text-shadow: 1px 1px 0px #454545, 1px -1px 0px #454545, -1px 1px 0px #454545,
      -1px -1px 0px #454545, 0px 0px 1px #000000, 0px 0px 3px #000000,
      0px 0px 3px #000000 !important;
  }
}

/* Very small mobile screens */
@media (max-width: 480px) {
  .neighborhood-name-score-box {
    top: 5px;
  }

  .neighborhood-description-box {
    top: 60px;
    max-height: calc(100vh - 80px);
  }

  .scores-breakdown h4 {
    font-size: 11px;
  }

  .neighborhood-description-box .neighborhood-info .reasoning {
    font-size: 12px;
    line-height: 1.3;
  }
}

/* Touch-friendly interactions */
@media (hover: none) and (pointer: coarse) {
  .neighborhood-name-score-box,
  .neighborhood-description-box {
    -webkit-overflow-scrolling: touch;
  }
}

/* Improve text contrast on mobile */
@media (max-width: 768px) {
  .neighborhood-info .reasoning {
    color: #333;
    font-weight: 500;
  }
}
