*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden; /* prevent any page scroll */
}

#map {
  position: absolute;
  inset: 0; /* fills full viewport */
}

.weather-widget {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.95);
  padding: 10px 12px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  font-family: Arial, sans-serif;
  font-size: 13px;
  line-height: 1.4;
  min-width: 210px;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
}

.weather-widget__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.weather-widget h3 {
  margin: 0;
  font-size: 14px;
}

.weather-toggle-btn {
  background: none;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 12px;
  cursor: pointer;
  color: #555;
  line-height: 1;
  transition: background 0.15s;
  flex-shrink: 0;
}

.weather-toggle-btn:hover {
  background: #e8e8e8;
}

.weather-toggle-btn:focus-visible {
  outline: 2px solid #1a6fc4;
  outline-offset: 2px;
}

.weather-widget__body {
  margin-top: 6px;
}

/* Collapsed state */
.weather-widget.is-collapsed .weather-widget__body {
  display: none;
}

.weather-widget.is-collapsed {
  padding-bottom: 8px;
}

.weather-widget .updated {
  color: #555;
  font-size: 11px;
  margin-bottom: 6px;
}

.weather-widget ul {
  margin: 0;
  padding-left: 16px;
}

.extent-panel {
  position: fixed;
  top: 12px;
  bottom: 12px;
  left: 12px;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.95);
  padding: 10px 12px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  font-family: Arial, sans-serif;
  font-size: 13px;
  line-height: 1.4;
  min-width: 252px;
  max-width: 336px;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
}

.extent-panel h3 {
  margin: 0 0 12px;
  font-size: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.extent-panel .back-button {
  background: #4CAF50;
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.extent-panel .back-button:hover {
  background: #45a049;
}

.extent-panel .meta {
  color: #555;
  font-size: 11px;
  margin-bottom: 6px;
}

.extent-panel ul {
  margin: 0;
  padding-left: 16px;
  max-width: 320px;
  overflow-y: auto;
}
.basemap-switcher {
  position: fixed;
  bottom: 52px;
  right: 10px;
  z-index: 1000;
  display: flex;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  font-family: Arial, sans-serif;
}

.basemap-btn {
  padding: 7px 13px;
  font-size: 12px;
  border: none;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.95);
  color: #333;
  transition: background 0.15s, color 0.15s;
}

.basemap-btn:not(:last-child) {
  border-right: 1px solid #ddd;
}

.basemap-btn.active {
  background: #4CAF50;
  color: #fff;
}

.basemap-btn:hover:not(.active) {
  background: #e8e8e8;
}

/* Nordic ski marker */
.ski-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.35));
  cursor: pointer;
}

/* Compact dot shown at low zoom */
.ski-marker--compact .ski-marker__dot {
  width: 16px;
  height: 16px;
  background: linear-gradient(145deg, #1a6fc4, #0d4f9e);
  border: 2.5px solid white;
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0,0,0,0.4);
}

.ski-marker__pin {
  background: linear-gradient(145deg, #1a6fc4, #0d4f9e);
  border: 2.5px solid white;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ski-marker__pin svg {
  transform: rotate(45deg);
}

.ski-marker__label {
  background: #0d4f9e;
  color: white;
  font-family: Arial, sans-serif;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  margin-top: 3px;
  white-space: nowrap;
  letter-spacing: 0.3px;
}

/* Push Leaflet zoom control above the basemap switcher */
.leaflet-bottom.leaflet-right {
  bottom: 88px;
}

.map-attribution {
  position: fixed;
  bottom: 0;
  right: 10px;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.8);
  padding: 2px 8px;
  font-family: Arial, sans-serif;
  font-size: 11px;
  color: #333;
  border-radius: 4px 4px 0 0;
}

.map-attribution a {
  color: #0078a8;
  text-decoration: none;
}

.map-attribution a:hover {
  text-decoration: underline;
}

/* ─── Tablet: ≤ 900px ─────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .extent-panel {
    min-width: 200px;
    max-width: 260px;
  }

  .weather-widget {
    min-width: 180px;
  }

  .basemap-btn {
    padding: 9px 12px; /* larger tap target */
  }

  .weather-toggle-btn {
    min-height: 44px;
    min-width: 44px;
  }
}

/* ─── Phone: ≤ 600px ──────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  /* Extent panel: bottom sheet */
  .extent-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 12px 12px 0 0;
    max-width: none;
    min-width: 0;
    width: 100%;
    max-height: 50vh;
    margin: 0;
    padding: 10px 16px 12px;
  }

  /* Weather widget: top-right, narrower */
  .weather-widget {
    min-width: 0;
    max-width: calc(100vw - 80px); /* leave room for left side */
    font-size: 12px;
    padding: 8px 10px;
  }

  /* Basemap switcher: move up slightly to avoid bottom-sheet */
  .basemap-switcher {
    bottom: calc(50vh + 10px);
  }

  /* Leaflet zoom control: above basemap switcher */
  .leaflet-bottom.leaflet-right {
    bottom: calc(50vh + 52px);
  }

  /* Larger tap targets for buttons */
  .extent-panel .back-button,
  .basemap-btn {
    min-height: 44px;
    padding: 10px 14px;
    font-size: 13px;
  }

  .weather-toggle-btn {
    min-height: 44px;
    min-width: 44px;
    font-size: 14px;
  }
}
