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

html, body, #map {
  height: 100%;
  width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Legend */
#legend {
  position: fixed;
  bottom: 28px;
  left: 28px;
  z-index: 1000;
  background: white;
  border-radius: 8px;
  padding: 14px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  font-size: 13px;
  line-height: 1.8;
  min-width: 160px;
}

.legend-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

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

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.gradient-label-title {
  font-size: 11px;
  color: #666;
  margin-bottom: 2px;
}

.score-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #ddd;
  color: #555;
  font-size: 9px;
  font-weight: 700;
  cursor: default;
  vertical-align: middle;
}

.legend-gradient {
  margin: 4px 0 6px;
}

.gradient-bar {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, hsl(55,95%,72%), hsl(30,95%,55%), hsl(5,85%,42%));
}

.gradient-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #666;
  margin-top: 2px;
}

.legend-toggles {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

.toggle-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f5f5f5;
  border: 1px solid #e0e0e0;
  border-radius: 5px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  transition: opacity 0.15s, background 0.15s;
}

.toggle-btn:hover { background: #eee; }

.toggle-btn.inactive {
  opacity: 0.4;
}

.line-solid, .line-dashed {
  display: inline-block;
  width: 24px;
  height: 3px;
  background: #555;
  flex-shrink: 0;
}

.line-dashed {
  background: repeating-linear-gradient(
    to right, #555 0, #555 5px, transparent 5px, transparent 9px
  );
}

/* Popup */
.leaflet-popup-pane { z-index: 1100; }

/* When a popup is open, hide legend and zoom controls so the popup is
   unobstructed. Leaflet's popup pane lives inside a transformed
   .leaflet-map-pane which forms its own stacking context, so a high
   z-index alone can't lift the popup above siblings of #map. */
body.popup-open #legend,
body.popup-open .leaflet-control-container { display: none; }

.leaflet-popup-content-wrapper {
  border-radius: 10px;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
}

.leaflet-popup-content {
  margin: 0 !important;
  width: 360px !important;
}

.popup-header {
  padding: 12px 16px 10px;
  border-bottom: 1px solid #f0f0f0;
}

.popup-header h3 {
  font-size: 14px;
  font-weight: 700;
  color: #111;
}

.popup-header .alley-type {
  font-size: 11px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Slideshow */
.slideshow {
  position: relative;
  background: #111;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.slideshow img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.slide-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.45);
  color: white;
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background 0.15s;
}

.slide-btn:hover { background: rgba(0,0,0,0.7); }
.slide-btn.prev { left: 8px; }
.slide-btn.next { right: 8px; }

.slide-count {
  position: absolute;
  bottom: 6px;
  right: 10px;
  font-size: 11px;
  color: rgba(255,255,255,0.8);
  background: rgba(0,0,0,0.3);
  padding: 1px 6px;
  border-radius: 10px;
}

/* Scores */
.popup-scores {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  padding: 10px 14px;
  border-bottom: 1px solid #f0f0f0;
  gap: 4px;
}

.score-item {
  text-align: center;
}

.score-label {
  font-size: 10px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: block;
}

.score-value {
  font-size: 20px;
  font-weight: 700;
  color: #111;
  line-height: 1.2;
}

.score-mean {
  grid-column: 1 / -1;
  text-align: center;
  padding-top: 4px;
  border-top: 1px solid #f0f0f0;
  margin-top: 4px;
  font-size: 12px;
  color: #555;
}

.score-mean b { color: #111; }

/* Notes */
.popup-notes {
  padding: 10px 16px 14px;
  font-size: 13px;
  color: #333;
  line-height: 1.55;
  max-height: min(45vh, 300px);
  overflow-y: auto;
}

/* Lightbox */
#lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
#lightbox.active { display: flex; }
#lightbox-img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

/* Unreviewed popup */
.popup-unreviewed {
  padding: 14px 16px;
  font-size: 13px;
  color: #888;
  font-style: italic;
}
