/* Wildeshausen-App · Karte (map.css)
   Gehört zu assets/map.js. Setzt auf den Variablen aus style.css auf:
   Rot #ba092f, Weiß, Grau – keine runden Ecken, Bedienelemente 44 px. */

/* ---------- Rahmen ------------------------------------------------------ */
/* .map bringt in style.css bereits Rahmen, Hintergrund und overflow mit.
   Hier nur, was der Tile-Viewer zusätzlich braucht. */
.map.has-map {
  height: 240px;          /* Fallback, falls aspect-ratio fehlt */
  min-height: 200px;      /* Touch-Fläche */
  max-height: 300px;
  background: #eaeaec;    /* gleiche Fläche wie die Platzhaltergrafik */
  touch-action: none;     /* Pan-Gesten gehören der Karte, nicht der Seite */
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Breite Spalte (gestapeltes Layout) soll nicht zu einem flachen Streifen werden */
@supports (aspect-ratio: 3 / 2) {
  .map.has-map {
    height: auto;
    aspect-ratio: 3 / 2;
  }
}

.map.has-map.ist-gerufen {
  outline: 3px solid var(--accent, #ba092f);
  outline-offset: 2px;
}

.map.has-map:focus-visible {
  outline: 2px solid var(--accent, #ba092f);
  outline-offset: 2px;
}

/* ---------- Platzhalter / Offline-Zustand ------------------------------- */
.map-fallback {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #eaeaec;
}
/* style.css setzt .map svg auf height:auto – hier soll die Grafik die Fläche füllen */
.map.has-map .map-fallback svg {
  display: block;
  width: 100%;
  height: 100%;
}
.map.is-live .map-fallback { display: none; }

.map-hint {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 6;
  display: none;
  align-items: center;
  gap: 8px;
  margin: 0;
  max-width: calc(100% - 120px);
  padding: 4px 4px 4px 10px;
  background: #fff;
  border: 1px solid var(--line-strong, #d4d4d9);
  border-radius: 0;
  font-size: 12px;
  line-height: 1.3;
  color: var(--ink-2, #4d4e53);
}
.map.is-offline .map-hint { display: flex; }

.map-retry {
  min-height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line-ui, #686971);
  border-radius: 0;
  background: #fff;
  color: var(--accent, #ba092f);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.map-retry:hover { background: var(--accent, #ba092f); color: #fff; }
.map-retry:focus-visible { outline: 2px solid var(--accent, #ba092f); outline-offset: -3px; }

/* ---------- Kachelfläche ------------------------------------------------ */
.map-stage {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;       /* Kacheln und Labels bleiben im Ausschnitt */
  touch-action: none;
  cursor: grab;
}
.map-stage.is-drag { cursor: grabbing; }

/* Offline ohne je geladene Kachel: Platzhalter zeigen, Kachelebene weg */
.map.is-offline:not(.is-live) .map-stage { display: none; }

.map-stage.is-zoom {
  animation: map-zoom 180ms ease-out;
  transform-origin: 50% 50%;
}
@keyframes map-zoom {
  from { transform: scale(1.05); opacity: .72; }
  to   { transform: scale(1); opacity: 1; }
}

.map-world {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  will-change: transform;
}

.map-tile {
  position: absolute;
  width: 256px;
  height: 256px;
  max-width: none;        /* kein .map svg/global img-Resize dazwischenfunken */
  opacity: 0;
  transition: opacity .18s linear;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  image-rendering: auto;
}
.map-tile.is-ready { opacity: 1; }

/* ---------- Zoom-Bedienung --------------------------------------------- */
.map-ui {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  /* Umgrenzung eines Bedienelements: WCAG 1.4.11 verlangt 3:1, #686971
     liegt auf Weiß bei 5,46:1 (var(--line-strong) waren nur 1,48:1). */
  border: 1px solid var(--line-ui, #686971);
  border-radius: 0;
  background: #fff;
}

.map-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--line-ui, #686971);
  border-radius: 0;
  background: #fff;
  color: var(--ink, #161618);
  cursor: pointer;
}
.map-btn:last-child { border-bottom: 0; }
.map-btn svg {
  width: 20px;
  height: 20px;
  max-width: 20px;
  max-height: 20px;
  display: block;
}
.map-btn:hover { background: #f4f4f6; color: var(--accent, #ba092f); }
.map-btn:active { background: #eaeaec; }
.map-btn:focus-visible { outline: 2px solid var(--accent, #ba092f); outline-offset: -3px; }
.map-btn[disabled] {
  color: #c9c9cf;
  background: #fff;
  cursor: default;
}

/* ---------- Marker ------------------------------------------------------ */
.map-pin {
  position: absolute;
  left: 0;
  top: 0;
  width: 44px;            /* Trefferfläche, Punkt selbst bleibt klein */
  height: 44px;
  margin: -22px 0 0 -22px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 3;
  -webkit-tap-highlight-color: transparent;
}
.map-pin-dot {
  display: block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--accent, #ba092f);
  box-shadow: 0 0 0 2px #fff, 0 1px 2px rgba(0, 0, 0, .35);
  transition: transform .12s ease-out;
}
.map-pin.is-open .map-pin-dot { transform: scale(1.45); }
.map-pin:focus-visible { outline: none; }
.map-pin:focus-visible .map-pin-dot {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent, #ba092f);
}

.map-pin-label {
  position: absolute;
  top: 34px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  width: max-content;
  max-width: 168px;
  padding: 2px 6px;
  background: #fff;
  border: 1px solid var(--line-strong, #d4d4d9);
  border-radius: 0;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--ink, #161618);
  white-space: normal;
  text-align: left;
  pointer-events: none;
  z-index: 5;
}
.map-pin.is-open .map-pin-label { display: block; }
.map-pin.is-low .map-pin-label { top: auto; bottom: 34px; }

/* ---------- Attribution (Lizenzbedingung, immer sichtbar) --------------- */
.map-attrib {
  position: absolute;
  right: 0;
  bottom: 0;
  z-index: 6;
  margin: 0;
  padding: 3px 7px 4px;
  background: rgba(255, 255, 255, .94);
  border-top: 1px solid var(--line, #e6e6e9);
  border-left: 1px solid var(--line, #e6e6e9);
  border-radius: 0;
  font-size: 10.5px;
  line-height: 1.5;
  letter-spacing: .01em;
  color: var(--ink-2, #4d4e53);
}
.map-attrib a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid rgba(22, 22, 24, .25);
}
.map-attrib a:hover { color: var(--accent, #ba092f); border-bottom-color: currentColor; }
.map-attrib a:focus-visible { outline: 2px solid var(--accent, #ba092f); outline-offset: 2px; }

/* ---------- Ruhige Bewegung -------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .map-tile { transition: none; }
  .map-stage.is-zoom { animation: none; }
  .map-pin-dot { transition: none; }
}

/* ---------- Partner: Punkt wie alle anderen ----------------------------- */
/* Der Partner ist ein normaler Marker; erst der Kontakt öffnet die Karte.
   z-index 4, weil die 52-px-Tippflächen der Nachbar-Pins in der Altstadt
   direkt daneben liegen (Zorbas 3 px entfernt) und Klick wie Hover abfingen. */
.map-pin--partner { z-index: 4; }

/* ---------- Partner-Leiste in der Karte --------------------------------- */
/* Flach am unteren Kartenrand: Logo, Name/Adresse (als Knopf zum Ortsblatt),
   Website-Knopf, Schließen. Höhe rund 66 px, damit die Karte sichtbar bleibt. */
.map-karte {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 6px;
  z-index: 8;                 /* über Markern (4) und Bedienleiste (6) */
  display: none;
  align-items: center;
  gap: 8px;
  padding: 6px 34px 6px 7px;
  background: #fff;
  border: 1px solid var(--line-strong, #d4d4d9);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .18);
  text-align: left;
}
.map-karte.ist-da { display: flex; }

.map-karte-logo { flex: none; width: 34px; height: 44px; object-fit: contain; }

.map-karte-text {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 0;
  padding: 4px 2px;
  font: inherit;
  text-align: left;
  background: none;
  border: 0;
  cursor: pointer;
}
.map-karte-name {
  font-size: 12.5px;
  line-height: 1.25;
  color: var(--ink, #161618);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.map-karte-adr {
  font-size: 10.5px;
  line-height: 1.3;
  color: var(--muted, #686971);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.map-karte-text:hover .map-karte-name { color: var(--accent, #ba092f); }

.map-karte-aktionen { flex: none; display: flex; gap: 6px; }
.map-karte-website {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap, 44px);
  padding: 0 10px;
  font-family: var(--ui, sans-serif);
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: var(--accent, #ba092f);
  border: 1px solid var(--accent, #ba092f);
  border-radius: 0;
  text-decoration: none;
}
.map-karte-website:hover { background: var(--accent-ink, #94071f); border-color: var(--accent-ink, #94071f); }
.map-karte-text:focus-visible,
.map-karte-website:focus-visible,
.map-karte-close:focus-visible { outline: 2px solid var(--accent, #ba092f); outline-offset: 2px; }

.map-karte-close {
  position: absolute;
  top: 0;
  right: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--ink-2, #4d4e53);
  background: none;
  border: 0;
  cursor: pointer;
}
.map-karte-close svg { width: 16px; height: 16px; display: block; margin: auto; }
.map-karte-close:hover { color: var(--accent, #ba092f); }
.map-karte-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Windows-Kontrastmodus (forced colors) ----------------------- */
/* Im Kontrastmodus ersetzt das System alle Farben. Marker und Bedienelemente
   brauchen deshalb echte Ränder und Systemfarben, sonst verschwinden sie
   (gemessen: Punkt schwarz auf schwarz, also 1:1). */
@media (forced-colors: active) {
  .map-pin-dot {
    background: CanvasText;
    border: 2px solid Canvas;
    box-shadow: none;
  }
  .map-pin--partner .map-pin-dot { background: Highlight; }
  .map-pin:focus-visible .map-pin-dot {
    outline: 2px solid Highlight;
    outline-offset: 2px;
    box-shadow: none;
  }
  .map-btn,
  .map-retry,
  .map-attrib,
  .map-karte,
  .map-karte-website,
  .map-karte-close,
  .map-karte-text { border: 1px solid CanvasText; }
  .map-karte-website { background: ButtonFace; color: ButtonText; }
  .map-karte:focus-visible,
  .map-karte-text:focus-visible,
  .map-karte-website:focus-visible,
  .map-karte-close:focus-visible { outline: 2px solid Highlight; outline-offset: 2px; }
  .map.has-map.ist-gerufen { outline: 3px solid CanvasText; }
}
