/* Reset and Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #f4f4f4;
  font-family: 'Merriweather', serif;
  color: #000000;
  /* Black font color */
  display: flex;
  flex-direction: column;
}

/* Map Container - Flex area below the header */
#map-container {
  flex: 1;
  position: relative;
  width: 100%;
  z-index: 1;
}

#map-container svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* D3 SVG Elements Styling */
.county {
  fill: #dfdfdf;
  /* Milder county gray color */
  stroke: #f4f4f4;
  /* County outline color from photo */
  stroke-width: 1px;
  stroke-linejoin: round;
  stroke-linecap: round;
}

/* Motorway cartographic styles */
.motorway-under {
  fill: none;
  stroke: #ffffff;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.motorway-over {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  cursor: pointer;
  transition: filter 0.15s ease;
}

.motorway-over:hover {
  filter: brightness(1.2);
}

.header-overlay {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 15px 20px 10px 20px;
  text-align: center;
  z-index: 10;
}

.nav-tabs {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 12px;
  pointer-events: auto;
}

.nav-tab {
  font-family: 'Merriweather', serif;
  font-size: clamp(11px, 1.1vw, 13px);
  font-weight: 700;
  color: #777777;
  text-decoration: none;
  padding: 4px 12px;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.nav-tab:hover {
  color: #000000;
}

.nav-tab.active {
  color: #000000;
  border-bottom-color: #000000;
}

.title {
  font-size: clamp(20px, 2.2vw, 30px);
  /* Responsive title font size */
  font-weight: 700;
  color: #000000;
  /* Black font color */
  margin-bottom: 12px;
  letter-spacing: -0.4px;
  line-height: 1.3;
  pointer-events: auto;
}

/* Year Selector */
.year-selector {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 18px;
  pointer-events: auto;
}

.year-label {
  font-family: 'Merriweather', serif;
  font-size: clamp(11px, 1.1vw, 13px);
  font-weight: 700;
  color: #000000;
  margin-right: 6px;
}

.year-btn {
  font-family: 'Merriweather', serif;
  font-size: clamp(12px, 1.2vw, 14px);
  font-weight: 700;
  color: #333333;
  background-color: #f4f4f4;
  border: 1px solid #cccccc;
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  box-shadow: none;
  transition: background-color 0.15s ease, border-color 0.15s ease;
  user-select: none;
  white-space: nowrap;
}

.year-btn:hover {
  background-color: #e8e8e8;
  border-color: #bbbbbb;
}

.year-btn:active {
  background-color: #e0e0e0;
}

.year-btn.active {
  background-color: #777777;
  color: #ffffff;
  border-color: #777777;
  font-weight: 700;
  box-shadow: none;
}

.legend-title {
  font-family: 'Merriweather', serif;
  font-size: clamp(10px, 1.0vw, 13px);
  font-weight: 700;
  color: #000000;
  margin: 0;
  pointer-events: auto;
  letter-spacing: -0.2px;
}

/* Legend Styles matching the dots style in the photo */
.legend {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(8px, 1.2vw, 18px);
  flex-wrap: wrap;
  pointer-events: auto;
}

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

.legend-color {
  display: inline-block;
  width: clamp(10px, 1.1vw, 14px);
  /* Responsive dots */
  height: clamp(10px, 1.1vw, 14px);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.legend-color.cap-low {
  background-color: #2f9ae3;
}

.legend-color.cap-med {
  background-color: #00be8d;
}

.legend-color.cap-high {
  background-color: #e4af1e;
}

.legend-color.cap-critical {
  background-color: #f37900;
}

.legend-color.cap-overload {
  background-color: #ff0000;
}

.legend-label {
  font-size: clamp(10px, 1.0vw, 13px);
  /* Responsive legend text */
  font-weight: 400;
  color: #000000;
  /* Black font color */
}



.footer-overlay {
  position: absolute;
  bottom: 15px;
  left: 15px;
  right: 15px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
  /* Let clicks pass through to map */
  z-index: 10;
}

.source-info {
  font-family: 'Merriweather', serif;
  font-size: clamp(11px, 1.1vw, 14px);
  /* Responsive source font size */
  font-weight: 300;
  color: #7A7A7A;
  /* Muted source text color */
  pointer-events: auto;
  /* Allow text selection */
}

.logo-container {
  pointer-events: auto;
}

#logo-img {
  height: 32px;
  /* Good visible size on mobile */
  width: auto;
  display: block;
}

@media (min-width: 768px) {
  #logo-img {
    height: clamp(28px, 2.0vw, 38px);
    /* Scales smoothly on desktop screens, slightly smaller */
  }
}

/* Tooltip Styling */
.tooltip {
  position: absolute;
  visibility: hidden;
  background-color: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 6px;
  padding: 8px 12px;
  font-family: 'Merriweather', serif;
  font-size: 13px;
  color: #000000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  pointer-events: none;
  z-index: 100;
}

.tooltip-title {
  font-weight: 700;
  margin-bottom: 2px;
}

.tooltip-detail {
  font-size: 11px;
  color: #555555;
}

/* Mobile responsive styles */
@media (max-width: 768px) {
  .year-selector {
    gap: 8px 6px;
    margin-bottom: 12px;
  }

  .year-label {
    display: none;
  }

  .year-btn {
    font-size: 13px;
  }

  .legend {
    gap: 8px 12px;
  }

  .legend-title {
    font-size: 12px;
  }

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

/* Bridge Point Map Labels */
.bridge-label-bg {
  fill: none;
  stroke: #f4f4f4;
  stroke-width: 3px;
  stroke-linejoin: round;
  font-family: 'Merriweather', serif;
  font-size: clamp(11px, 1.2vw, 14px);
  font-weight: 700;
  pointer-events: none;
}

.bridge-label-fg {
  fill: #000000;
  font-family: 'Merriweather', serif;
  font-size: clamp(11px, 1.2vw, 14px);
  font-weight: 700;
  pointer-events: none;
}

@media (max-width: 768px) {

  .bridge-label-bg,
  .bridge-label-fg {
    font-size: 10.5px;
  }
}

/* Inset Map Styles */
.inset-map-container {
  position: absolute;
  bottom: 50px;
  left: 20px;
  width: clamp(100px, 15vw, 160px);
  height: clamp(70px, 10vw, 110px);
  background-color: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  z-index: 5;
  pointer-events: none;
}

@media (max-width: 768px) {
  .inset-map-container {
    bottom: 40px;
    left: 15px;
    width: 90px;
    height: 60px;
  }
}