/* ── Map container ──────────────────────────────────────── */
#map-container {
  position: relative;
  width: 100%;
  height: calc(100dvh - var(--nav-h));
  overflow: hidden;
}
#map { width: 100%; height: 100%; }

/* Strip page-content padding when map is active */
#page-content.map-fullscreen {
  padding: 0;
  max-width: none;
  margin: 0;
}

/* Slim header replaces the hidden #app-nav — same height so map calc stays correct */
.map-page-header {
  height: var(--nav-h);
  padding: 0 12px;
  margin-bottom: 0 !important;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

/* ── Control groups ─────────────────────────────────────── */
.map-controls-topleft {
  position: absolute;
  top: 10px; left: 10px;
  display: flex; gap: 6px; flex-wrap: wrap;
  z-index: 10;
}
.map-controls-topright {
  position: absolute;
  top: 10px; right: 10px;
  display: flex; gap: 6px; align-items: flex-start;
  z-index: 10;
}
.map-controls-side {
  position: absolute;
  right: 10px; bottom: 32px;
  display: flex; flex-direction: column; gap: 6px;
  z-index: 10;
}

/* ── Map buttons ────────────────────────────────────────── */
.map-btn {
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 1.05rem;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  line-height: 1;
  color: var(--color-text);
  transition: background 0.15s, border-color 0.15s;
  min-width: 38px;
  text-align: center;
}
.map-btn:hover { background: var(--color-surface2); border-color: var(--color-primary-light); }
.map-btn.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.map-btn:disabled { opacity: 0.5; cursor: default; }

/* ── Basemap switcher ───────────────────────────────────── */
.map-basemap-switcher {
  display: flex;
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.map-basemap-btn {
  background: transparent; border: none;
  padding: 7px 10px;
  font-size: 0.78rem; font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer; line-height: 1;
  border-right: 1px solid var(--color-border);
  transition: background 0.12s, color 0.12s;
}
.map-basemap-btn:last-child { border-right: none; }
.map-basemap-btn.active { background: var(--color-primary); color: #fff; }
.map-basemap-btn:hover:not(.active) { background: var(--color-surface2); color: var(--color-text); }

/* ── Layers panel ───────────────────────────────────────── */
.map-layers-panel {
  position: absolute;
  top: 50px; right: 10px;
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0;
  min-width: 172px;
  box-shadow: var(--shadow-sm);
  z-index: 20;
  overflow: hidden;
}
.layers-panel-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  padding: 5px 10px 4px;
  border-bottom: 1px solid var(--color-border);
  background: rgba(255,255,255,0.03);
}
.layers-item {
  padding: 5px 10px;
  font-size: 0.82rem;
  border-bottom: 1px solid var(--color-border);
}
.layers-item:last-child { border-bottom: none; }
.layers-item label {
  display: flex; align-items: center; gap: 7px;
  cursor: pointer; user-select: none;
  line-height: 1.3;
}
.layers-item input[type="checkbox"] {
  accent-color: var(--color-primary);
  flex-shrink: 0;
  width: 13px; height: 13px;
  margin: 0;
}
/* Kleine Quellen-Attribution (z. B. "swisstopo") neben Label */
.layers-source {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--color-border);
  border-radius: 3px;
  padding: 0 4px;
  line-height: 1.5;
  cursor: default;
  white-space: nowrap;
}

/* ── HTML Markers ───────────────────────────────────────── */
.map-marker { position: absolute; cursor: pointer; z-index: 5; }
.map-marker-inner {
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-family: system-ui, -apple-system, sans-serif;
  box-shadow: 0 1px 5px rgba(0,0,0,0.45);
  user-select: none;
  line-height: 1;
}
.map-marker-inner.rect {
  border-radius: 3px;
  padding: 0 4px;
  white-space: nowrap;
}
.map-marker-inner.circle { border-radius: 50%; }
.map-marker-label {
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  font-family: system-ui, sans-serif;
  color: #111;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 2px #fff;
  white-space: nowrap;
  margin-top: 2px;
  pointer-events: none;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.map-marker-work {
  position: absolute;
  top: -6px; right: -6px;
  font-size: 12px;
  line-height: 1;
  pointer-events: none;
}

/* ── Marker popup ───────────────────────────────────────── */
.map-popup { font-family: var(--font); }
.map-popup-title { font-weight: 700; font-size: 1rem; margin-bottom: 4px; }
.map-popup-meta  { font-size: 0.8rem; color: var(--color-text-muted); margin-bottom: 6px; }
.map-popup-desc  { font-size: 0.85rem; margin-bottom: 6px; }
.map-popup-work  { font-size: 0.82rem; color: var(--color-danger); margin-bottom: 6px; }
.map-popup-actions { display: flex; gap: 6px; margin-top: 8px; }
.map-popup-actions button { font-size: 0.82rem; padding: 6px 12px; }
/* Popup photo thumbnails */
.map-popup-photos { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0 4px; }
.map-popup-photo  {
  width: 70px; height: 70px;
  object-fit: cover; border-radius: 4px;
  border: 1px solid var(--color-border);
  transition: opacity 0.15s;
}

/* ── Edit sheet (bottom panel) ──────────────────────────── */
.marker-sheet {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: var(--color-surface);
  border-top: 2px solid var(--color-border);
  border-radius: var(--radius) var(--radius) 0 0;
  z-index: 30;
  max-height: 70vh;
  overflow-y: auto;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
  transition: transform 0.25s ease;
}
.marker-sheet.hidden { transform: translateY(110%); display: block !important; }
.marker-sheet-handle {
  width: 40px; height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  margin: 10px auto 4px;
}
.marker-sheet-content { padding: 8px 16px 24px; }

/* MapLibre attribution compact */
.maplibregl-ctrl-attrib { font-size: 0.62rem !important; }
.maplibregl-ctrl-bottom-right { bottom: 4px !important; }

/* Popup above markers */
.maplibregl-popup { z-index: 20; }

/* ── Phase 7: GPS dot ───────────────────────────────────── */
.map-gps-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #4285F4;
  border: 2.5px solid #fff;
  box-shadow: 0 0 0 3px rgba(66,133,244,0.3);
  animation: gps-pulse 2s ease-in-out infinite;
}
@keyframes gps-pulse {
  0%,100% { box-shadow: 0 0 0 3px rgba(66,133,244,0.3); }
  50%      { box-shadow: 0 0 0 8px rgba(66,133,244,0.06); }
}

/* ── Phase 7: Distance ring labels ─────────────────────── */
.map-ring-label {
  font-size: 10px;
  font-weight: 700;
  background: rgba(0,0,0,0.55);
  color: #fff;
  padding: 1px 4px;
  border-radius: 2px;
  pointer-events: none;
  white-space: nowrap;
  line-height: 1.2;
}
.rings-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px 8px;
  font-size: 0.67rem;
  margin-top: 4px;
  padding-left: 20px; /* bündig mit Label-Text nach Checkbox */
  line-height: 1.5;
}

/* ── Revier-Gebietsbezeichnungen ────────────────────────── */
.map-revier-label {
  font-size: 11.5px;
  font-weight: 700;
  color: #ffd34d;
  background: rgba(0,0,0,0.58);
  padding: 2px 8px;
  border-radius: 3px;
  white-space: nowrap;
  pointer-events: none;
  letter-spacing: 0.05em;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
  border: 1px solid rgba(255,211,77,0.28);
}

/* ── Phase 7: Ring center crosshair ────────────────────── */
.map-ring-center {
  width: 16px; height: 16px;
  pointer-events: none;
  position: relative;
}
.map-ring-center::before,
.map-ring-center::after {
  content: '';
  position: absolute;
  background: rgba(255,255,255,0.95);
  border-radius: 1px;
  box-shadow: 0 0 2px rgba(0,0,0,0.8);
}
.map-ring-center::before { width: 2px; height: 100%; top: 0; left: 50%; transform: translateX(-50%); }
.map-ring-center::after  { height: 2px; width: 100%; top: 50%; left: 0; transform: translateY(-50%); }

/* ── Phase 7: Flurnamen labels ──────────────────────────── */
.map-flurname {
  font-size: 10.5px;
  font-weight: 600;
  color: #eef5ee;
  background: rgba(0,0,0,0.52);
  padding: 1px 4px;
  border-radius: 2px;
  white-space: nowrap;
  pointer-events: none;
  letter-spacing: 0.15px;
}
.map-flurname[data-kind="Gewässer"] { color: #7ecfff; }
.map-flurname[data-kind="Ort"]      { color: #ddeedd; font-size: 11px; }

/* ── Phase 7: Wind widget ───────────────────────────────── */
.map-wind-widget {
  position: absolute;
  bottom: 36px; left: 10px;
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  padding: 8px 10px;
  box-shadow: var(--shadow-sm);
  z-index: 10;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 64px; text-align: center;
}
.map-wind-arrow {
  font-size: 22px; line-height: 1;
  display: inline-block;
  transition: transform 0.6s ease;
}
.map-wind-speed { font-size: 0.88rem; font-weight: 700; }
.map-wind-label { font-size: 0.72rem; color: var(--color-text-muted); }

/* ── Location picker dot ────────────────────────────────── */
.loc-pick-dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #e53935;
  border: 2.5px solid #fff;
  box-shadow: 0 1px 6px rgba(0,0,0,0.5);
  pointer-events: none;
}
.loc-gps-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #2979ff;
  border: 2px solid #fff;
  box-shadow: 0 0 0 3px rgba(41,121,255,0.25), 0 1px 6px rgba(0,0,0,0.4);
  pointer-events: none;
}
