html, body {
  height: 100%;
  margin: 0;
  font-family: "Lato", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

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

/* Overlay box */
.map-overlay {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(255, 255, 255, 0.92);
  padding: 10px 12px;
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  max-width: 280px;
}

.map-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 2px;
}

.map-subtitle {
  font-size: 12px;
  opacity: 0.85;
  line-height: 1.35;
}

.filter-block {
  margin-top: 10px;
}

.filter-label {
  display: block;
  font-size: 12px;
  margin-bottom: 6px;
  opacity: 0.85;
}

.filter-select {
  width: 100%;
  font-size: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.15);
  background: rgba(255,255,255,0.95);
}

/* Popup base */
.mapboxgl-popup {
  max-width: 320px;
}

.mapboxgl-popup-content {
  border-radius: 12px;
  padding: 12px 12px 10px 12px;
}

/* Date line (bold, first line) */
.popup-date {
  font-size: 12px;
  margin: 0 0 6px 0;
  opacity: 0.95;
  line-height: 1.25;
}

/* Title line (regular, second line) */
.popup-title {
  font-weight: 400;
  margin: 0 0 10px 0;
  font-size: 14px;
  line-height: 1.3;
}

/* Link button */
.popup-link {
  display: inline-block;
  font-size: 12px;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  color: inherit;
}

.popup-link:hover {
  border-color: rgba(0, 0, 0, 0.25);
}

.popup-meta {
  font-size: 12px;
  line-height: 1.35;
  margin: 0 0 6px 0;
  opacity: 0.9;
}

.popup-label {
  opacity: 0.7;
  margin-right: 6px;
}

.popup-thumb {
  display: block;
  margin: 8px 0 10px 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.10);
}

.popup-thumb img {
  display: block;
  width: 100%;
  height: auto;
}

/* Mobile: make overlay smaller + hide subtitle */
@media (max-width: 768px) {
  .map-overlay {
    max-width: 220px;
    padding: 8px 10px;
    top: 10px;
    left: 10px;
  }

  .map-title {
    font-size: 13px;
    margin-bottom: 6px;
  }

  .map-subtitle {
    display: none;
  }

  .filter-label {
    font-size: 11px;
    margin-bottom: 5px;
  }

  .filter-select {
    font-size: 12px;
    padding: 7px 9px;
  }
}

/* =========================
   Year picker v2 (custom)
   ========================= */

.yearpicker {
  position: relative;
}

.yearpicker-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;

  font-size: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.15);
  background: rgba(255,255,255,0.95);
  cursor: pointer;
}

.yearpicker-btn:active {
  transform: translateY(0.5px);
}

.yearpicker-caret {
  opacity: 0.7;
  margin-left: 10px;
}

.yearpicker-panel {
  position: absolute;
  z-index: 9999;
  top: calc(100% + 8px);
  left: 0;
  right: 0;

  background: rgba(255,255,255,0.98);
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 12px;
  box-shadow: 0 10px 26px rgba(0,0,0,0.16);
  padding: 8px;
}

.yearpicker-list {
  max-height: 220px;
  overflow: auto;
  border-radius: 10px;
}

.yearpicker-item {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 12px;
}

.yearpicker-item:hover {
  background: rgba(0,0,0,0.06);
}

.yearpicker-item[aria-selected="true"] {
  background: rgba(0,0,0,0.10);
  font-weight: 600;
}

@media (max-width: 768px) {
  .yearpicker-list {
    max-height: 180px;
  }
}

/* Ensure popups render above the overlay */
.map-overlay {
  z-index: 10;
}

.mapboxgl-popup {
  z-index: 9999;
}

.mapboxgl-popup-tip {
  z-index: 9999;
}

/* =========================
   Popup thumbnail placeholder
   ========================= */

.popup-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;

  background: linear-gradient(135deg, #f1f1f1, #e6e6e6);
  border-radius: 10px;
}

.popup-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;

  opacity: 0;
  transition: opacity 0.25s ease-in;
}

.popup-thumb img[src] {
  opacity: 1;
}

/* =========================
   WebGL fallback message
   ========================= */

/* ✅ Respect the HTML `hidden` attribute */
#webgl-fallback[hidden] {
  display: none !important;
}

#webgl-fallback:not([hidden]) {
  display: flex;
}

#webgl-fallback {
  position: absolute;
  inset: 0;
  z-index: 10000;

  align-items: center;
  justify-content: center;

  background: #f6f6f6;
}

.webgl-fallback-box {
  max-width: 360px;
  padding: 18px 20px;
  border-radius: 12px;

  background: #ffffff;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);

  font-size: 14px;
  line-height: 1.45;
}

.webgl-fallback-box strong {
  display: block;
  margin-bottom: 6px;
}
