/* Standorte-Karte – Dark/Carwow-Stil, hell + html.mm-dark. */
.mm_sk {
  --sk-bg: #ffffff;
  --sk-card: #f4f6f9;
  --sk-border: #e2e6ee;
  --sk-text: #1a2535;
  --sk-muted: rgba(26, 37, 53, .6);
  --sk-accent: #e85d26;
  --sk-accent-h: #c04b1e;
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px 0 24px;
  color: var(--sk-text);
  /* Projektschrift (Barlow Semi Condensed) statt der hartkodierten Inter-Kette,
     die aus einer frueheren Design-Fassung stammte. */
  font-family: var(--font-sans, 'Barlow Semi Condensed', system-ui, sans-serif);
}

.mm_sk_head { margin-bottom: 16px; }
.mm_sk_title { font-size: 1.9rem; font-weight: 700; margin: 0 0 6px; }
.mm_sk_intro { margin: 0; color: var(--sk-muted); font-size: .95rem; line-height: 1.5; }
.mm_sk_intro strong { color: var(--sk-accent); }

.mm_sk_layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 16px;
  align-items: stretch;
}

.mm_sk_map {
  height: 560px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--sk-border);
  background: var(--sk-card);
  z-index: 0;
}

/* Legende */
.mm_sk_legend {
  background: var(--sk-card);
  border: 1px solid var(--sk-border);
  border-radius: 14px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.mm_sk_leg_list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  max-height: 512px;
  flex: 1;
}
.mm_sk_leg_item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 9px;
  cursor: pointer;
  transition: background .12s;
}
.mm_sk_leg_item:hover,
.mm_sk_leg_item:focus-visible { background: rgba(232, 93, 38, .10); outline: none; }
.mm_sk_leg_item.is-active { background: rgba(232, 93, 38, .16); }
.mm_sk_leg_count {
  flex: 0 0 auto;
  min-width: 30px;
  text-align: center;
  background: var(--sk-accent);
  color: #fff;
  font-weight: 700;
  font-size: .82rem;
  padding: 3px 7px;
  border-radius: 20px;
}
.mm_sk_leg_name { font-size: .92rem; line-height: 1.25; }
.mm_sk_leg_note {
  margin: 10px 4px 2px;
  font-size: .78rem;
  color: var(--sk-muted);
  line-height: 1.4;
  border-top: 1px solid var(--sk-border);
  padding-top: 8px;
}

/* Marker (divIcon) */
.mm_sk_pin_wrap { background: none; border: 0; }
.mm_sk_pin {
  display: inline-block;
  box-sizing: border-box;
  text-align: center;
  color: #fff;
  font-weight: 700;
  font-size: .82rem;
  background: var(--sk-accent);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
}

/* Popup */
.mm_sk_pop { text-align: center; min-width: 140px; }
.mm_sk_pop strong { display: block; font-size: 1rem; margin-bottom: 2px; }
.mm_sk_pop_c { display: block; color: #666; font-size: .85rem; margin-bottom: 8px; }
.mm_sk_pop_btn {
  border: 0;
  background: var(--sk-accent);
  color: #fff;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.mm_sk_pop_btn:hover { background: var(--sk-accent-h); }

/* Ergebnisliste unter der Karte */
.mm_sk_results { margin-top: 22px; }
.mm_sk_results_head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.mm_sk_results_h2 { font-size: 1.3rem; font-weight: 700; margin: 0; }
.mm_sk_results_close {
  border: 1px solid var(--sk-border);
  background: var(--sk-bg);
  color: var(--sk-text);
  width: 34px; height: 34px;
  border-radius: 8px;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
}
.mm_sk_results_close:hover { border-color: var(--sk-accent); color: var(--sk-accent); }
.mm_sk_loading { color: var(--sk-muted); }
.mm_sk_err { color: #c0392b; }

/* Kartenliste im Ergebnis-Panel.
   Der AJAX-Endpunkt liefert das alte float-Markup (#maschinen_markt_liste mit
   `float: left` je Karte). Ohne eigene Regeln stehen die Karten deshalb in
   unterschiedlich hohen, ausgefransten Reihen – dieselbe Umstellung auf ein
   Flex-Grid gibt es schon in Filter, Merkliste, Händlerprofil und Karussell;
   für dieses Modul fehlte sie. align-items: stretch macht die Karten einer
   Reihe gleich hoch (Fußzeile mit Preis/Button bündig). */
.mm_sk #maschinen_markt_liste {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: stretch;
}
.mm_sk .maschinen_markt_liste_element {
  float: none !important;
  width: calc(33.333% - 11px) !important;
  margin: 0 !important;
  box-sizing: border-box;
}
@media (max-width: 1100px) {
  .mm_sk .maschinen_markt_liste_element { width: calc(50% - 8px) !important; }
}
@media (max-width: 700px) {
  .mm_sk .maschinen_markt_liste_element { width: 100% !important; }
}

/* Responsive: Legende unter die Karte */
@media (max-width: 820px) {
  .mm_sk_layout { grid-template-columns: 1fr; }
  .mm_sk_map { height: 420px; }
  .mm_sk_leg_list { max-height: 240px; }
}

/* ---- Dunkles Theme --------------------------------------------------- */
html.mm-dark .mm_sk {
  --sk-bg: #0f1923;
  --sk-card: #1a2535;
  --sk-border: #2a3a4f;
  --sk-text: #ffffff;
  --sk-muted: rgba(255, 255, 255, .55);
}
/* Leaflet-Attribution im Dunkelmodus lesbar halten */
html.mm-dark .mm_sk .leaflet-control-attribution {
  background: rgba(26, 37, 53, .8);
  color: rgba(255, 255, 255, .6);
}
html.mm-dark .mm_sk .leaflet-control-attribution a { color: rgba(255, 255, 255, .8); }

/* Zoom-Buttons im Dunkelmodus: Leaflet setzt weissen Grund, die globale Dark-Regel
   faerbt Links weiss -> "+"/"-" waren unsichtbar. Deshalb Grund UND Farbe hier setzen. */
html.mm-dark .mm_sk .leaflet-bar { border-color: rgba(0, 0, 0, .5); }
html.mm-dark .mm_sk .leaflet-bar a,
html.mm-dark .mm_sk .leaflet-bar a:link,
html.mm-dark .mm_sk .leaflet-bar a:visited {
  background: var(--sk-card);
  color: var(--sk-text);
  border-bottom-color: var(--sk-border);
}
html.mm-dark .mm_sk .leaflet-bar a:hover,
html.mm-dark .mm_sk .leaflet-bar a:focus {
  background: #22334a;
  color: var(--sk-accent);
}
html.mm-dark .mm_sk .leaflet-bar a.leaflet-disabled {
  background: #141f2b;
  color: rgba(255, 255, 255, .3);
}

/* Dunkelmodus-Kacheln: Meere schwarz, Laender hell.
   CARTO liefert dafuer keinen fertigen Stil, deshalb rechnen wir die hellen
   Positron-Kacheln (light_all, s. maschinen_markt_standorte_karte.js) um:
   Wasser hat dort ~85 %, Land ~98 % Helligkeit -> brightness(.546) schiebt die
   Schwelle dazwischen auf 50 %, contrast(30) binarisiert daran (Wasser -> schwarz,
   Land -> weiss). grayscale davor verhindert Farbsaeume an Grenzen/Fluessen,
   brightness/sepia/hue-rotate danach dimmen das Land und tonen es leicht blaugrau.
   Beschriftungen sind in Positron dunkel und bleiben auf dem hellen Land lesbar. */
html.mm-dark .mm_sk .leaflet-tile {
  filter: grayscale(1) brightness(.546) contrast(30) brightness(.8) sepia(.45) hue-rotate(168deg) saturate(.75);
}
