html, body { height: 100%; margin: 0; }
/* Ensure default text is dark regardless of OS color scheme */
body { color: #222; background: #fff; }
#app { height: 100%; }
#map { width: 100%; height: 100%; }

/* Swiss UI theme tokens */
:root {
  --sw-red: #e30613;
  --sw-black: #111;
  --sw-border: 2px;
  --sw-btn-size: 36px;
  --sw-font: 13px/1.2 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

.overlays-control {
  font: 14px/1.3 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: #222;
}
.overlays-control .panel {
  display: block;
  margin-top: 0;
  background: rgba(255,255,255,0.96);
  border: 1px solid #aaa;
  border-radius: 0;
  /* No scrollbar; let it grow as needed */
  max-height: none;
  overflow: visible;
  padding: 8px;
  color: #222;
}
.overlays-control .panel .close-btn { display: none; }
.overlays-control .panel h4 { margin: 0 0 8px 0; font-size: 13px; font-weight: 600; color: #333; }
.overlay-list { display: flex; flex-direction: column; gap: 6px; }
.overlay-list label { display: flex; align-items: center; gap: 8px; color: #222; }

/* Embedded hiking toggle used on mobile */
.hiking-embed { display: none; margin: 4px 0 8px; }
.hiking-embed label { display: flex; align-items: center; gap: 8px; }

/* Legend control */
.legend-control { background: rgba(255,255,255,0.96); border: 1px solid #aaa; border-radius: 0; padding: 6px 8px; font: 13px/1.3 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; color: #222; }
.legend-control .legend-title { font-weight: 600; margin-bottom: 4px; }
.legend-control .legend-list { display: flex; flex-direction: column; gap: 4px; }
.legend-control .legend-item { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend-control .legend-swatch { width: 12px; height: 12px; border: 1px solid #777; display: inline-block; }

/* Language control: 4 horizontal buttons */
.leaflet-control.lang-control {
  display: flex;
  gap: 6px;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  margin-bottom: 6px;
}
.leaflet-control.lang-control .btn {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  border: var(--sw-border) solid var(--sw-black);
  background: white;
  color: var(--sw-black);
  border-radius: 0;
  width: var(--sw-btn-size);
  height: var(--sw-btn-size);
  padding: 0;
  font: var(--sw-font);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  outline: none;
  box-shadow: none;
}
.leaflet-control.lang-control .btn:focus,
.leaflet-control.lang-control .btn:focus-visible {
  outline: none;
  box-shadow: none;
}
.leaflet-control.lang-control .btn.active {
  color: var(--sw-red);
  border-color: var(--sw-red); /* Swiss gov red */
}
/* Consistent hover/active behavior across buttons */
.leaflet-control.lang-control .btn:hover,
.leaflet-control.lang-control .btn:active,
.overlays-toggle-control .btn:hover,
.overlays-toggle-control .btn:active,
.info-note-control .close-btn:hover,
.info-note-control .close-btn:active,
.overlays-control.open .panel .close-btn:hover,
.overlays-control.open .panel .close-btn:active,
.leaflet-control-zoom.leaflet-bar a:hover,
.leaflet-control-zoom.leaflet-bar a:active,
.leaflet-control-layers-toggle:hover,
.leaflet-control-layers-toggle:active,
.leaflet-control .btn-like:hover,
.leaflet-control .btn-like:active {
  border-color: var(--sw-red);
  color: var(--sw-red);
}

/* Mobile Overlays toggle button (hidden on desktop) */
.overlays-toggle-control { display: none; background: transparent; border: none; box-shadow: none; }
.overlays-toggle-control .btn {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  border: var(--sw-border) solid var(--sw-black);
  background: white;
  color: var(--sw-black);
  border-radius: 0;
  height: var(--sw-btn-size);
  padding: 0 10px;
  font: var(--sw-font);
  font-weight: 700;
}
.overlays-toggle-control .btn:focus,
.overlays-toggle-control .btn:focus-visible { outline: none; box-shadow: none; }

/* Informational note control */
.info-note-control {
  background: rgba(255,255,255,0.96);
  max-height: 50vh; /* at most half the page */
  border: 1px solid #aaa;
  border-radius: 0;
  padding: 8px;
  padding-right: 30px; /* room for close button */
  font: 12px/1.4 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: #222;
  max-width: 340px;
  position: relative;
}
.info-note-control .close-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  border: var(--sw-border) solid var(--sw-black);
  background: white;
  color: var(--sw-black);
  border-radius: 0;
  width: 22px;
  height: 22px;
  line-height: 1;
  padding: 0;
  font: 16px/1 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
.info-note-control .close-btn:hover { border-color: var(--sw-red); color: var(--sw-red); }

/* Ensure popup/content text stays dark */
.leaflet-popup-content { color: #222; }
.leaflet-control { color: #222; }

/* Stack controls with small gaps (esp. top-right) */
.leaflet-control-container .leaflet-top .leaflet-control { margin-top: 6px; }
.leaflet-control-container .leaflet-left .leaflet-control { margin-left: 6px; }
.leaflet-control-container .leaflet-right .leaflet-control { margin-right: 6px; }

/* Reset default Leaflet bar look */
.leaflet-bar { box-shadow: none; border: 0; background: transparent; }
.leaflet-touch .leaflet-bar,
.leaflet-touch .leaflet-control-layers {
  border: 0 !important;
  box-shadow: none;
  background: transparent;
}
.leaflet-bar a,
.leaflet-bar a:link,
.leaflet-bar a:visited {
  text-decoration: none;
}

/* Zoom buttons: match Swiss .btn */
.leaflet-control-zoom.leaflet-bar a,
.leaflet-control-layers-toggle,
.leaflet-control .btn-like {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: var(--sw-black);
  border: var(--sw-border) solid var(--sw-black);
  border-radius: 0;
  box-shadow: none;
  outline: none;
  font: var(--sw-font);
  /* Ensure touch-friendly size on all viewports */
  width: var(--sw-btn-size);
  height: var(--sw-btn-size);
}
.leaflet-control-zoom.leaflet-bar a + a { margin-top: 6px; }
.leaflet-control-zoom a:focus,
.leaflet-control-zoom a:focus-visible,
.leaflet-control-layers-toggle:focus,
.leaflet-control-layers-toggle:focus-visible { outline: none; box-shadow: none; }
.leaflet-control-zoom a:hover,
.leaflet-control-zoom a:active,
.leaflet-control-layers-toggle:hover,
.leaflet-control-layers-toggle:active {
  border-color: var(--sw-red);
  color: var(--sw-red);
}
.leaflet-control-zoom a.leaflet-disabled {
  opacity: 0.45;
  border-color: #888;
  color: #888;
  cursor: default;
}

/* Make +/- symbols visually balanced */
.leaflet-control-zoom-in, .leaflet-control-zoom-out { line-height: 1; font-weight: 700 }

/* Checkboxes: Swiss square look */
.overlays-control input[type="checkbox"],
.hiking-panel input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  box-sizing: border-box;
  border: var(--sw-border) solid var(--sw-black);
  background: #fff;
  border-radius: 0;
  display: inline-block;
  position: relative;
}
.overlays-control input[type="checkbox"]:focus,
.hiking-panel input[type="checkbox"]:focus { outline: none; box-shadow: none; }
.overlays-control input[type="checkbox"]:checked,
.hiking-panel input[type="checkbox"]:checked {
  background: var(--sw-red);
  border-color: var(--sw-red);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='10' viewBox='0 0 12 10'%3E%3Cpath d='M1 5l3 3 7-7' stroke='%23fff' stroke-width='2' fill='none' stroke-linecap='square'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 12px 10px;
}

/* Align label text nicely next to custom checkbox */
.overlay-list label { gap: 8px; cursor: pointer; }
.overlay-list label input { flex: none; }

/* Optional: subtle frame for attribution to match boxes */
.leaflet-control-attribution {
  background: rgba(255,255,255,0.96);
  border: 1px solid #aaa;
  border-radius: 0;
  padding: 2px 6px;
  margin: 0 6px 6px 6px;
  font: 11px/1.3 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

/* Leaflet popups: square corners */
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  border-radius: 0 !important;
}

/* Embedded legend used inside overlays on mobile */
.legend-embed { display: none; margin-top: 8px; }
.legend-embed .legend-title { font-weight: 600; margin-bottom: 4px; }
.legend-embed .legend-list { display: flex; flex-direction: column; gap: 4px; }
.legend-embed .legend-item { display: flex; align-items: center; gap: 6px; }
.legend-embed .legend-swatch { width: 12px; height: 12px; border: 1px solid #777; display: inline-block; }

/* Mobile adjustments (<= 800px) */
@media (max-width: 800px) {
  :root {
    /* Smaller, denser UI on mobile */
    --sw-btn-size: 30px;
    --sw-border: 2px;
    --sw-font: 12px/1.25 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  }

  /* Overlays becomes a popup (hidden by default) */
  .overlays-control .panel {
    position: fixed;
    top: 12%;
    left: 6vw;
    right: 6vw;
    max-width: 88vw;
    max-height: 70vh;
    overflow: auto;
    padding: 10px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.25);
    display: none;
    z-index: 10000;
  }
  .overlays-control.open .panel { display: block; }
  .overlays-control.open .panel .close-btn {
    display: inline-flex;
    position: absolute;
    top: 6px;
    right: 6px;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    border: var(--sw-border) solid var(--sw-black);
    background: white;
    color: var(--sw-black);
    border-radius: 0;
    width: 24px;
    height: 24px;
    line-height: 1;
    padding: 0;
    font: 18px/1 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  }
  .overlays-control.open .panel .close-btn:hover { border-color: var(--sw-red); color: var(--sw-red); }

  /* Language buttons: keep compact spacing */
  .leaflet-control.lang-control { gap: 4px; }
  .leaflet-control.lang-control .btn {
    width: var(--sw-btn-size);
    height: var(--sw-btn-size);
    font-size: 12px;
  }

  /* Zoom and other Leaflet buttons inherit size via var above */
  .leaflet-control-zoom.leaflet-bar a,
  .leaflet-control-layers-toggle,
  .leaflet-control .btn-like {
    width: var(--sw-btn-size);
    height: var(--sw-btn-size);
  }

  /* Slightly larger checkboxes for touch */
  .overlays-control input[type="checkbox"],
  .hiking-panel input[type="checkbox"] {
    width: 14px;
    height: 14px;
  }

  /* Tighter label spacing to save space */
  .overlay-list label { gap: 6px; }

  /* Make overlay list text a bit smaller */
  .overlays-control { font: 12px/1.25 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
  .overlays-control .panel h4 { font-size: 12px; }

  /* Show the mobile toggle button */
  .overlays-toggle-control { display: block; }

  /* On mobile, hide the separate legend control and show embedded legend */
  .legend-control { display: none; }
  .legend-embed { display: block; }

  /* On mobile, hide separate hiking panel and show embedded toggle */
  .hiking-panel { display: none; }
  .hiking-embed { display: block; }
}
