/* Incident Map Styles */

/* Map + side list layout (flush, no gap) */
.incident-map-wrap {
  display: flex;
  align-items: stretch;
  /* wrap so the full-width .map-controls bar (inserted before #incident-map)
     takes its own row; map + list still share the next row as before */
  flex-wrap: wrap;
  width: 100%;
}

/* Controls bar above the map (near-me, PLZ/Ort search, chips, share) */
.map-controls {
  flex: 0 0 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 12px;
}

.map-ctrl-btn {
  background: #f5f5f5;
  border: 1px solid #ddd;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1.3;
  cursor: pointer;
  color: #555;
  white-space: nowrap;
}

.map-ctrl-btn:hover {
  background: #e8e8e8;
}

.map-geo-group {
  display: inline-flex;
  gap: 6px;
  min-width: 0;
  position: relative;
}

/* PLZ/Ort typeahead dropdown */
.map-geo-suggest {
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  z-index: 1200;
  margin: 0;
  padding: 4px;
  list-style: none;
  width: max-content;
  min-width: 100%;
  max-width: 260px;
  max-height: 260px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #d7dde5;
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(16, 24, 40, .14);
}
.map-geo-suggest-item {
  list-style: none;
  padding: 7px 10px;
  font-size: 13px;
  color: #1a2233;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
}
.map-geo-suggest-item::marker { content: ""; }
.map-geo-suggest-item.active,
.map-geo-suggest-item:hover {
  background: #f2f6fc;
  color: #0d3f9e;
}

.map-geo-input {
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 12px;
  color: #333;
  width: 130px;
  min-width: 0;
  box-sizing: border-box;
}

.map-geo-input:focus {
  outline: none;
  border-color: #4a90e2;
}

.map-near-clear {
  font-size: 14px;
  font-weight: 700;
  padding: 6px 9px;
  color: #c62828;
}

/* Quick chips (topic toggles; Switzerland also had per-motorway A1–A5 chips
   and a Gotthard shortcut, neither of which applies here) */
.map-chips {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.map-chip {
  border: 1px solid #ddd;
  background: #fff;
  color: #555;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
}

.map-chip:hover {
  background: #f5f5f5;
}

.map-chip.active {
  background: #d3132b;
  border-color: #d3132b;
  color: #fff;
}

/* Share button feedback state ("✓ kopiert") */
.map-share-btn.copied {
  background: #2e9b3e;
  border-color: #2e9b3e;
  color: #fff;
}

/* Inline status/error message in the controls bar */
.map-controls-msg {
  font-size: 12px;
  color: #c62828;
}

/* Dashed near-me location circle (L.circle className) */
.near-me-circle {
  stroke-dasharray: 6 6;
}

/* Map container sizing */
#incident-map {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 480px;
  height: 70vh;
  border: 1px solid #ddd;
  border-right: none;
  border-radius: 8px 0 0 8px;
  overflow: hidden;
  position: relative;
}

/* Side article list */
.incident-list {
  flex: 0 0 300px;
  height: 70vh;
  min-height: 480px;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 0 8px 8px 0;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  transition: flex-basis 0.18s ease;
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 9px;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}

.list-header-title {
  font-size: 12px;
  font-weight: 600;
  color: #333;
  white-space: nowrap;
}

.list-toggle {
  border: none;
  background: #f0f0f0;
  color: #555;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.list-toggle:hover { background: #e2e6ea; }

.list-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.list-item {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid #f0f0f0;
}

.list-item:hover { background: #f5f8fb; }

.list-link {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 7px 9px;
  color: #2a2a2a;
  text-decoration: none;
}

.list-locate {
  flex-shrink: 0;
  width: 36px;
  border: none;
  border-left: 1px solid #f0f0f0;
  background: transparent;
  color: #4a90e2;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.list-locate:hover { background: #eaf3fd; }

.list-video {
  flex-shrink: 0;
  width: 34px;
  border-left: 1px solid #f0f0f0;
  background: transparent;
  color: #e23b2e;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.list-video:hover { background: #fdecea; }

.list-pin {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  margin-top: 1px;
}

.list-pin svg { width: 9px; height: 9px; fill: currentColor; }
.list-pin .text-glyph { font-size: 7px; font-weight: 700; line-height: 1; }

.list-canton {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  color: #555;
  background: #eee;
  padding: 0 4px;
  border-radius: 3px;
  margin-right: 2px;
  vertical-align: middle;
}

/* Small left thumbnail in list items (when incident.thumb present) */
.list-thumb {
  width: 48px;
  height: 36px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

/* Distance badge shown in near-mode ("x.x km") */
.list-distance {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  color: #777;
  background: #f0f0f0;
  padding: 0 4px;
  border-radius: 3px;
  margin-left: 3px;
  vertical-align: middle;
  white-space: nowrap;
}

.list-text {
  flex: 1;
  font-size: 12px;
  line-height: 1.3;
  color: #2a2a2a;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.list-chevron {
  flex-shrink: 0;
  color: #aaa;
  font-size: 18px;
  line-height: 1.2;
}

.list-item:hover .list-chevron { color: #4a90e2; }

.list-empty {
  padding: 14px 10px;
  color: #777;
  font-size: 12px;
}

/* Collapsed list -> thin strip with just the toggle */
.incident-list.collapsed { flex-basis: 34px; }
.incident-list.collapsed .list-header { justify-content: center; padding: 7px 0; }
.incident-list.collapsed .list-header-title { display: none; }
.incident-list.collapsed .list-body { display: none; }
.incident-list.collapsed .list-toggle { transform: rotate(180deg); }

/* Mobile: full-bleed, stack list under the map */
@media (max-width: 782px) {
  .incident-map-wrap {
    flex-direction: column;
    width: 100vw;
    max-width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
  }

  #incident-map {
    width: 100%;
    height: 60vh;
    height: 60dvh;
    min-height: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    border-radius: 0;
  }

  .incident-list {
    flex: 0 0 auto;
    width: 100%;
    height: 32vh;
    height: 32dvh;
    min-height: 0;
    border-left: none;
    border-right: none;
    border-radius: 0;
  }

  .incident-list.collapsed {
    height: 40px;
    flex-basis: auto;
  }

  /* Filter panel lifted above the map; legend dropped below the list */
  .incident-control-panel.mobile-extracted,
  .incident-legend.mobile-extracted {
    position: static !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    box-sizing: border-box;
  }

  .incident-control-panel.mobile-extracted {
    border-bottom: 1px solid #ddd;
    order: -1;
  }

  .incident-control-panel.mobile-extracted .control-panel-content {
    max-height: none;
  }

  .incident-legend.mobile-extracted {
    border-top: 1px solid #ddd;
  }

  /* Controls bar: wrap is full-bleed here, keep the bar padded and let it wrap */
  .map-controls {
    padding: 0 10px;
    box-sizing: border-box;
  }

  .map-geo-group {
    flex: 1 1 140px;
  }

  .map-geo-input {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
  }
}

/* Mobile portrait: list is always visible, no collapse toggle */
@media (max-width: 782px) and (orientation: portrait) {
  .list-toggle {
    display: none;
  }

  .incident-list.collapsed,
  .incident-list {
    height: 34vh;
    height: 34dvh;
    flex-basis: auto;
  }

  .incident-list.collapsed .list-body {
    display: block;
  }

  .incident-list.collapsed .list-header {
    justify-content: flex-start;
    padding: 7px 9px;
  }

  .incident-list.collapsed .list-header-title {
    display: inline;
  }
}

/* Two-finger gesture hint overlay */
.map-gesture-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  text-align: center;
  max-width: 80%;
  z-index: 1200;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.map-gesture-hint.show { opacity: 1; }

/* Incident pin markers */
.incident-pin {
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  width: 26px !important;
  height: 26px !important;
  margin-left: -13px !important;
  margin-top: -13px !important;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
}

.incident-pin svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.incident-pin .text-glyph {
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.incident-pin--sample {
  position: static;
  margin: 0 !important;
  width: 16px !important;
  height: 16px !important;
  flex-shrink: 0;
  background-color: #555;
}

.incident-pin--sample svg {
  width: 9px;
  height: 9px;
}

.incident-pin--sample .text-glyph {
  font-size: 7px;
}

/* Pin colors by precision level — traffic light: green=exact ... red=vague */
.incident-pin--street {
  background-color: #2e9b3e;
}

.incident-pin--city {
  background-color: #f2b705;
}

/* The class is built from the geocode level: `incident-pin--${level}`.
   incident-map.php writes 'region' for the Bundesland-centroid fallback; the
   Swiss 'canton' selector is kept as an alias so any row geocoded before that
   rename still gets its colour instead of rendering unstyled. */
.incident-pin--region,
.incident-pin--canton {
  background-color: #e23b2e;
}

/* Legend styling */
.incident-legend {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 6px;
  padding: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  line-height: 1.4;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
  min-width: 140px;
}

.legend-title {
  font-weight: 600;
  margin-bottom: 8px;
  color: #333;
}

.legend-item {
  display: flex;
  align-items: center;
  margin-bottom: 4px;
}

.legend-item .incident-pin {
  margin-right: 8px;
  flex-shrink: 0;
  position: relative;
  margin-left: 0 !important;
  margin-top: 0 !important;
}

.legend-item span {
  color: #555;
}

.legend-status {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid #eee;
  font-size: 11px;
  color: #666;
}

.legend-timestamp {
  font-style: italic;
  margin-bottom: 2px;
}

.legend-count {
  font-weight: 500;
  color: #333;
}

/* Mobile legend adjustments */
@media (max-width: 782px) {
  .incident-legend {
    font-size: 12px;
    padding: 8px;
    min-width: 130px;
  }

  .legend-timestamp {
    font-size: 10px;
  }
}

/* Popup styling */
.leaflet-popup-content a {
  color: #0066cc;
  text-decoration: none;
  font-weight: 500;
  display: block;
  margin-bottom: 4px;
}

.leaflet-popup-content a:hover {
  text-decoration: underline;
}

/* Thumbnail at the top of marker popups (when incident.thumb present) */
.popup-thumb {
  display: block;
  max-width: 100%;
  border-radius: 6px;
  margin-bottom: 6px;
}

/* Gotthard live-status popup styling removed with the layer (see map.js). */

.incident-meta {
  font-size: 12px;
  color: #666;
  border-top: 1px solid #eee;
  padding-top: 4px;
}

.canton-badge {
  background: #f0f0f0;
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 500;
  color: #333;
  margin-right: 4px;
}

.category-badge {
  background: #e3f2fd;
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 500;
  color: #1976d2;
  font-size: 11px;
  margin-right: 4px;
}

/* Overlay states (empty/error) */
.incident-overlay {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 8px;
  padding: 20px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: #555;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  max-width: 300px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
}

/* Mobile overlay adjustments */
@media (max-width: 782px) {
  .incident-overlay {
    font-size: 13px;
    padding: 16px;
    max-width: 280px;
    margin: 0 10px;
  }
}

/* Leaflet popup adjustments */
.leaflet-popup-content-wrapper {
  border-radius: 6px;
}

.leaflet-popup-content {
  margin: 12px 16px;
  line-height: 1.4;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
}

/* Marker cluster styling adjustments */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  border-radius: 50%;
}

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  border-radius: 50%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-weight: 600;
}

/* Control Panel (right side, collapsible) */
.incident-control-panel {
  background: rgba(255, 255, 255, 0.96);
  border-radius: 8px;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.25);
  width: 240px;
  overflow: hidden;
}

.control-panel-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 9px 12px;
  background: #4a90e2;
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

.control-panel-toggle .toggle-caret {
  transition: transform 0.15s;
}

.panel-collapsed .control-panel-toggle {
  border-radius: 8px;
}

.panel-collapsed .control-panel-toggle .toggle-caret {
  transform: rotate(-90deg);
}

.panel-collapsed .control-panel-content {
  display: none;
}

.control-panel-content {
  padding: 10px;
  max-height: 68vh;
  overflow-y: auto;
}

.section-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 5px;
}

.inline-controls {
  display: flex;
  gap: 10px;
}

.view-option {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  color: #555;
  font-size: 12px;
}

.view-option input {
  margin-right: 4px;
}

.filter-section {
  margin-bottom: 10px;
}

.filter-section:last-child {
  margin-bottom: 0;
}

.filter-section h4 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: #333;
}

.filter-controls {
  margin-bottom: 8px;
}

.toggle-all {
  background: #f5f5f5;
  border: 1px solid #ddd;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  color: #666;
}

.toggle-all:hover {
  background: #e8e8e8;
}

.filter-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cantons-scroll {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px 6px;
  max-height: 110px;
  overflow-y: auto;
  padding-right: 4px;
}

.filter-item {
  display: flex;
  align-items: center;
}

.filter-item label {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 12px;
  color: #555;
  line-height: 1.3;
}

.filter-item input[type="checkbox"] {
  margin-right: 6px;
  margin-top: 1px;
}

.category-swatch {
  display: flex;
  align-items: center;
  margin-right: 6px;
}

/* Time slider styling */
.time-filter {
  margin-top: 8px;
}

#time-slider {
  margin: 12px 0;
}

.time-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #666;
}

.time-labels span {
  flex: 1;
}

/* noUiSlider customization */
.noUi-horizontal {
  height: 6px;
  border: none;
  box-shadow: none;
  background: #dfe3e8;
}

.noUi-horizontal .noUi-handle {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #4a90e2;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  top: -7px;
  right: -9px;
  cursor: grab;
}

.noUi-handle:active {
  cursor: grabbing;
}

.noUi-handle:before, .noUi-handle:after {
  display: none;
}

.noUi-connect {
  background: #4a90e2;
}

.noUi-target {
  margin: 0 9px;
}

/* Mobile responsive control panel */
@media (max-width: 782px) {
  .incident-control-panel {
    width: min(220px, calc(100vw - 20px));
  }

  .control-panel-content {
    max-height: 50vh;
  }

  .cantons-scroll {
    max-height: 80px;
  }

  .filter-section {
    margin-bottom: 12px;
  }

  .time-labels {
    flex-direction: column;
    gap: 2px;
  }
}

/* Ensure map controls are accessible on mobile */
@media (max-width: 782px) {
  .leaflet-control-zoom {
    font-size: 16px;
  }

  .leaflet-control-zoom a {
    width: 30px;
    height: 30px;
    line-height: 30px;
  }
}

/* Layer control styling */
.leaflet-control-layers {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 6px;
}

.leaflet-control-layers-expanded {
  padding: 8px 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
}

.leaflet-control-layers label {
  font-weight: 500;
  color: #333;
}
/* ---- Server-rendered SEO block (crawlable content below the map) ---- */
.incident-map-seo {
  max-width: 1040px;
  margin: 28px auto 0;
  padding: 0 4px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #16202b;
}
.incident-map-seo h2 {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -.01em;
  margin: 0 0 8px;
  padding-left: 11px;
  border-left: 4px solid #e3000f;
}
.incident-map-seo > p {
  font-size: 14.5px;
  line-height: 1.55;
  color: #63707e;
  margin: 0 0 16px;
  max-width: 70ch;
}
.incident-map-latest {
  list-style: none !important;
  margin: 0 0 22px;
  padding: 0 !important;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 7px;
}
.incident-map-latest li {
  list-style: none !important;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  background: #fff;
  border: 1px solid #e2e7ee;
  border-radius: 10px;
  padding: 10px 13px;
  transition: border-color .12s ease, box-shadow .12s ease, transform .12s ease;
}
.incident-map-latest li::marker { content: ""; }
.incident-map-latest li:hover {
  border-color: #c9d3de;
  box-shadow: 0 6px 16px rgba(16, 24, 40, .08);
  transform: translateY(-1px);
}
.incident-map-latest li a {
  align-self: stretch;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.32;
  color: #1b57c4;
  text-decoration: none;
  overflow-wrap: anywhere;
}
.incident-map-latest li a:hover { color: #0d3f9e; text-decoration: underline; }
.incident-map-latest .date {
  font-size: 11.5px;
  color: #8a93a3;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.incident-map-faq {
  background: #fff;
  border: 1px solid #e2e7ee;
  border-radius: 10px;
  margin: 0 0 8px;
  overflow: hidden;
}
.incident-map-faq summary {
  list-style: none;
  cursor: pointer;
  padding: 13px 44px 13px 15px;
  font-weight: 700;
  font-size: 14px;
  position: relative;
  color: #16202b;
}
.incident-map-faq summary::-webkit-details-marker { display: none; }
.incident-map-faq summary::after {
  content: "";
  position: absolute;
  right: 17px;
  top: 50%;
  width: 9px;
  height: 9px;
  margin-top: -6px;
  border-right: 2px solid #e3000f;
  border-bottom: 2px solid #e3000f;
  transform: rotate(45deg);
  transition: transform .2s ease;
}
.incident-map-faq[open] summary::after { transform: rotate(-135deg); }
.incident-map-faq summary:hover { color: #e3000f; }
.incident-map-faq > p {
  margin: 0;
  padding: 0 15px 15px;
  font-size: 13.5px;
  line-height: 1.55;
  color: #63707e;
}
@media (max-width: 600px) {
  .incident-map-latest { grid-template-columns: 1fr; }
}
