.map-widget-section { background-color: var(--surface); }

/* ── Map wrapper ── */
.map-widget-wrapper {
  position: relative;
  height: 500px;
  width: 75%;
  margin: 0 auto;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.13);
}

#homepage-map { width: 100%; height: 100%; }

/* ── Dataset panel — overlaid top-left inside map ── */
.map-dataset-panel {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.map-dataset-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
}

/* Circle icon badge */
.mdb-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(55, 55, 55, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1rem;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.mdb-icon svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

/* Text label */
.mdb-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: rgba(30, 30, 30, 0.88);
  background: rgba(255, 255, 255, 0.0);
  padding: 3px 12px 5px;
  border-radius: 20px;
  line-height: 1.2;
  display: flex;
  align-items: center;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
  /* subtle text shadow so label is readable over any map */
  text-shadow: 0 1px 3px rgba(255,255,255,0.8);
}

/* Hover — inactive */
.map-dataset-btn:not(.is-active):hover .mdb-icon {
  background: rgba(55, 55, 55, 0.88);
  transform: scale(1.06);
}
.map-dataset-btn:not(.is-active):hover .mdb-label {
  background: rgba(55, 55, 55, 0.65);
  color: #fff;
  text-shadow: none;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* Active */
.map-dataset-btn.is-active .mdb-icon {
  background: var(--accent);
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
.map-dataset-btn.is-active .mdb-label {
  background: rgba(30, 30, 30, 0.78);
  color: #fff;
  text-shadow: none;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* ── Loading spinner ── */
.map-widget-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.7);
  z-index: 10;
}

.map-widget-spinner {
  width: 36px;
  height: 36px;
  border: 4px solid var(--brand);
  border-top-color: transparent;
  border-radius: 50%;
  animation: mapwidget-spin 0.8s linear infinite;
}

@keyframes mapwidget-spin { to { transform: rotate(360deg); } }

/* ── Legend panel — bottom right ── */
#map-widget-legend {
  position: absolute;
  bottom: 24px;
  right: 10px;
  background: rgba(255, 255, 255, 0.95);
  padding: 12px 14px;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.14);
  min-width: 160px;
  max-width: 210px;
  display: none;
  z-index: 5;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

#legend-title {
  font-weight: 550;
  margin-bottom: 7px;
  font-size: 0.78rem;
  color: rgba(0, 0, 0, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 0.78rem;
  color: rgba(0, 0, 0, 0.75);
}

.legend-swatch { width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; }
.legend-gradient-bar { height: 12px; border-radius: 3px; flex: 1; }
.legend-gradient-row { display: flex; align-items: center; gap: 6px; font-size: 0.75rem; margin-top: 2px; }
.legend-layer-title { font-size: 0.75rem; font-weight: 500; margin: 6px 0 3px; opacity: 0.65; }

/* ── CTA row below map ── */
.map-widget-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  margin-top: 1.1rem;
}

.map-cta-text {
  font-size: 0.95rem;
  color: var(--text);
}

.map-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.6rem 1.4rem;
  border-radius: 64px;
  background: var(--secondary);
  color: var(--on-secondary);
  font-weight: 500;
  font-size: 0.9rem;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: background 0.18s;
}

.map-cta-btn .cta-arrow {
  display: inline-block;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.map-cta-btn:hover { background: var(--secondary-hover); color: #fff; }
.map-cta-btn:hover .cta-arrow { transform: translateX(4px); }

/* ── CTA dropdown ── */
.map-cta-dropdown-wrapper {
  position: relative;
  display: inline-block;
}

/* Bridge gap so hover doesn't break when moving cursor into the menu */
.map-cta-dropdown-wrapper::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  height: 8px;
  background: transparent;
}

.cta-dropdown-arrow {
  transition: transform 0.3s ease;
  margin-left: 0.15rem;
}

.map-cta-dropdown-wrapper.is-open .cta-dropdown-arrow {
  transform: rotate(180deg);
}

.map-cta-dropdown-menu {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 200px;
  background: color-mix(in srgb, var(--secondary) 70%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid color-mix(in srgb, white 20%, transparent);
  border-radius: 8px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2), 0 2px 4px rgba(0, 0, 0, 0.1);
  padding: 0.6rem 0;
  z-index: 10;
  transition: opacity 0.2s ease-out, visibility 0.2s ease-out;
}

.map-cta-dropdown-wrapper.is-open .map-cta-dropdown-menu {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.map-cta-dropdown-item {
  display: block;
  padding: 0.75rem 1.25rem;
  color: #fff;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  white-space: nowrap;
  border-left: 3px solid transparent;
  transition: all 0.2s ease;
}

.map-cta-dropdown-item:hover {
  background: color-mix(in srgb, white 12%, transparent);
  border-left-color: var(--accent);
  padding-left: 1.6rem;
  color: #fff;
}

/* ── Map logo — bottom left ── */
.map-widget-logo {
  position: absolute;
  bottom: 10px;
  left: 10px;
  z-index: 5;
}
.map-widget-logo img {
  display: block;
  max-height: 60px;
  max-width: 120px;
  width: auto;
  height: auto;
}

/* ── Timing pill — bottom centre ── */
.map-timing-pill {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  background: rgba(15, 15, 15, 0.70);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: rgba(255, 255, 255, 0.92);
  padding: 5px 13px 5px 9px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 500;
  display: none;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  transition: opacity 0.25s ease;
}

.map-timing-pill.is-fading { opacity: 0; }

.map-timing-pill svg {
  width: 13px;
  height: 13px;
  fill: var(--accent);
  flex-shrink: 0;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .map-widget-wrapper { width: 90%; }
}

@media (max-width: 768px) {
  .map-widget-wrapper { height: 360px; width: 100%; }
  .map-dataset-panel { top: 10px; left: 10px; gap: 8px; }
  .mdb-icon { width: 34px; height: 34px; font-size: 0.9rem; }
  .mdb-label { font-size: 0.76rem; padding: 4px 10px; }
  .map-widget-cta { flex-wrap: wrap; justify-content: center; gap: 0.5rem; }
  .map-cta-text { font-size: 0.85rem; text-align: center; width: 100%; }
  .map-cta-btn { font-size: 0.85rem; padding: 0.5rem 1.1rem; }
  #map-widget-legend { max-width: 155px; min-width: 115px; }
}

@media (max-width: 480px) {
  .map-widget-wrapper { height: 300px; }

  /* Map nav controls (+, -, home) */
  .maplibregl-ctrl-group button {
    width: 22px !important;
    height: 22px !important;
  }
  .maplibregl-ctrl-icon {
    background-size: 12px 12px !important;
  }

  /* Dataset toggles */
  .map-dataset-panel { gap: 5px; }
  .map-dataset-btn { gap: 5px; }
  .mdb-icon { width: 26px; height: 26px; font-size: 0.75rem; }
  .mdb-icon svg { width: 12px; height: 12px; }
  .mdb-label { font-size: 0.62rem; padding: 2px 6px; }

  /* Legend */
  #map-widget-legend {
    bottom: 5px;
    right: 4px;
    padding: 5px 7px;
    min-width: 90px;
    max-width: 120px;
    border-radius: 4px;
  }
  #legend-title { font-size: 0.48rem; margin-bottom: 2px; letter-spacing: 0.02em; }
  .legend-layer-title { font-size: 0.42rem; margin: 3px 0 2px; }
  .legend-item { font-size: 0.45rem; gap: 3px; margin-bottom: 2px; overflow: hidden; }
  .legend-item span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 82px; }
  .legend-swatch { width: 7px; height: 7px; flex-shrink: 0; }
  .legend-gradient-bar { height: 6px; }
  .legend-gradient-row { font-size: 0.42rem; }

  /* Timing pill — smaller on phones */
  .map-timing-pill {
    font-size: 0.62rem;
    padding: 3px 8px 3px 6px;
    bottom: 8px;
    gap: 4px;
    max-width: 72%;
  }
  .map-timing-pill svg { width: 10px; height: 10px; }
  #map-timing-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* CTA buttons — compact, centred */
  .map-widget-cta {
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.6rem;
  }
  .map-cta-text { font-size: 0.78rem; text-align: center; }
  .map-cta-btn {
    font-size: 0.76rem;
    padding: 0.4rem 1rem;
    border-radius: 50px;
  }
}
