/**
 * Location Viewer Styles
 * Standalone CSS for the location viewer library
 *
 * Copyright (c) 2026 Bx20.studio. All rights reserved.
 * Proprietary — see LICENSE.
 */

/* ==========================================================================
   CSS Custom Properties
   ========================================================================== */

/* .lv-modal lives on <body>, outside the container, so it needs the tokens too */
.location-viewer-container,
.lv-modal {
  --lv-primary-color: #4f627a;
  --lv-primary-hover: #3d4e63;
  --lv-dark-color: #4f627a;
  --lv-dark-hover: #3d4e63;
  --lv-text-color: #1e1e1e;
  --lv-text-muted: #757575;
  --lv-border-color: #ddd;
  --lv-background: #fff;
  --lv-background-alt: #f9f9f9;
  --lv-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --lv-radius: 4px;
  --lv-transition: 0.2s ease;

  /* Grid defaults */
  --lv-grid-min-width: 340px;
  --lv-grid-gap: 20px;
}

/* ==========================================================================
   Container & Layout
   ========================================================================== */

.location-viewer-container {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--lv-text-color);
  height: 100%;
}

.location-viewer-block {
  background: var(--lv-background);
  border: 1px solid var(--lv-border-color);
  border-radius: var(--lv-radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.lv-content {
  display: flex;
  flex: 1;
  min-height: 0; /* Important for flex children to shrink */
  overflow: hidden;
}

/* Split View */
.lv-view-split .lv-map-container {
  flex: 1;
  min-width: 50%;
  min-height: 0;
}

.lv-view-split .lv-grid-container {
  flex: 1;
  max-width: 50%;
  overflow-y: auto;
  min-height: 0;
}

/* Split Positions */
.lv-split-left .lv-content {
  flex-direction: row;
}

.lv-split-right .lv-content {
  flex-direction: row-reverse;
}

.lv-split-bottom.lv-view-split .lv-content {
  flex-direction: column;
}

.lv-split-bottom.lv-view-split .lv-map-container {
  min-width: auto;
  min-height: 50%;
  max-height: 60%;
}

.lv-split-bottom.lv-view-split .lv-grid-container {
  max-width: none;
  max-height: 50%;
  overflow-y: auto;
}

/* Map Only View */
.lv-view-map .lv-grid-container {
  display: none;
}

.lv-view-map .lv-map-container {
  width: 100%;
}

/* Grid Only View */
.lv-view-grid .lv-map-container {
  display: none;
}

.lv-view-grid .lv-grid-container {
  width: 100%;
  max-width: none;
  max-height: none;
  overflow-y: auto;
}

/* ==========================================================================
   Header
   ========================================================================== */

.lv-header {
  display: flex;
  align-items: center;
  padding: 10px 15px;
  background: var(--lv-background-alt);
  border-bottom: 1px solid var(--lv-border-color);
  gap: 10px;
}

.lv-header-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.lv-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Search Bar */
.location-viewer-container .lv-search-bar {
  display: inline-flex;
  align-items: stretch;
  flex-shrink: 0;
  height: 34px;
}

.location-viewer-container .lv-search-bar .lv-search-input {
  border: 1px solid var(--lv-border-color);
  border-right: none;
  border-radius: var(--lv-radius) 0 0 var(--lv-radius);
  padding: 0 12px;
  font-size: 13px;
  outline: none;
  font-family: inherit;
  width: 160px;
  min-width: 0;
  box-sizing: border-box;
  margin: 0;
  height: 34px;
  line-height: 34px;
  background: var(--lv-background);
  color: var(--lv-text-color);
  box-shadow: none;
}

.location-viewer-container .lv-search-bar .lv-search-input:focus {
  border-color: var(--lv-primary-color);
  box-shadow: none;
  outline: none;
}

.location-viewer-container .lv-search-bar .lv-search-btn {
  border: 1px solid var(--lv-border-color);
  border-radius: 0 var(--lv-radius) var(--lv-radius) 0;
  background: var(--lv-background);
  padding: 0 12px;
  cursor: pointer;
  color: var(--lv-text-muted);
  font-size: 13px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  height: 34px;
  box-shadow: none;
  box-sizing: border-box;
  transition: var(--lv-transition);
}

.location-viewer-container .lv-search-bar .lv-search-btn:hover {
  background: var(--lv-dark-color);
  color: #fff;
  border-color: var(--lv-dark-color);
}

/* Filter Chips — one row that scrolls sideways when it overflows. Wrapping
   made the header grow a line per overflow, squeezing the map below it; a
   twenty-layer viewer cost three rows of chrome. */
.lv-filter-chips {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  flex: 1 1 0;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  /* Scrollbar hidden — it sat on top of the chips, and the "More" pill already
     says the row continues. Scrolling itself still works. */
  scrollbar-width: none;
  --lv-chip-fade: 28px;
  /* Trailing room wider than the fade, so the last chip scrolls fully clear of
     the gradient with a margin to spare instead of stopping on its edge. */
  padding-right: calc(var(--lv-chip-fade) + 10px);
}

.lv-filter-chips::-webkit-scrollbar {
  display: none;
}

/* Soften the clipped edge on whichever side has chips beyond it — a chip
   sliced mid-word reads as broken, a fading one reads as "keep scrolling".
   JS toggles the classes; a side with nothing past it stays sharp. */
.lv-filter-chips.lv-fade-start {
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 var(--lv-chip-fade));
  mask-image: linear-gradient(to right, transparent 0, #000 var(--lv-chip-fade));
}

.lv-filter-chips.lv-fade-end {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - var(--lv-chip-fade)), transparent 100%);
  mask-image: linear-gradient(to right, #000 calc(100% - var(--lv-chip-fade)), transparent 100%);
}

.lv-filter-chips.lv-fade-start.lv-fade-end {
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 var(--lv-chip-fade), #000 calc(100% - var(--lv-chip-fade)), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 var(--lv-chip-fade), #000 calc(100% - var(--lv-chip-fade)), transparent 100%);
}

.lv-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--lv-primary-color);
  color: #fff;
  border-radius: 20px;
  font-size: 12px;
  /* Hold full width — without this they'd compress instead of scrolling. */
  flex: 0 0 auto;
  white-space: nowrap;
}

/* Overflow pill — sits outside the scroller so it never scrolls away.
   Outlined rather than filled so it reads as a control, not an active
   filter you can remove. */
.location-viewer-container .lv-chips-more {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
  padding: 4px 10px;
  height: auto;
  background: var(--lv-background);
  border: 1px dashed var(--lv-border-color);
  border-radius: 20px;
  color: var(--lv-text-muted);
  font-size: 12px;
  line-height: 1.5;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: none;
  transition: var(--lv-transition);
}

/* Hidden but still holding its place. Collapsing the pill handed its width
   back to the strip, which re-clamped the scroll and jerked every chip
   sideways the moment you reached the end. The chips scroll under the
   reserved gap instead. */
.location-viewer-container .lv-chips-more[hidden] {
  visibility: hidden;
}

.location-viewer-container .lv-chips-more i {
  font-size: 9px;
  opacity: 0.75;
}

.location-viewer-container .lv-chips-more:hover,
.location-viewer-container .lv-chips-more:focus {
  background: var(--lv-dark-color);
  border-color: var(--lv-dark-color);
  color: #fff;
}

.location-viewer-container .lv-filter-chip-remove {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  opacity: 0.8;
}

.location-viewer-container .lv-filter-chip-remove:hover,
.location-viewer-container .lv-filter-chip-remove:focus {
  background: none;
  border: none;
  color: inherit;
  opacity: 1;
}

/* Filters Button */
.location-viewer-container .lv-filters-button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  height: 34px;
  background: var(--lv-background);
  border: 1px solid var(--lv-border-color);
  border-radius: var(--lv-radius);
  cursor: pointer;
  font-size: 13px;
  color: var(--lv-dark-color);
  box-sizing: border-box;
  transition: var(--lv-transition);
}

.location-viewer-container .lv-filters-button:hover,
.location-viewer-container .lv-filters-button:focus {
  background: var(--lv-dark-color);
  color: #fff;
  border-color: var(--lv-dark-color);
}

.location-viewer-container .lv-filters-button:hover i,
.location-viewer-container .lv-filters-button:focus i {
  color: #fff;
}

.lv-filter-count {
  background: var(--lv-primary-color);
  color: #fff;
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 11px;
  min-width: 18px;
  text-align: center;
}

/* View Toggle */
.lv-view-toggle {
  display: flex;
  border: 1px solid var(--lv-border-color);
  border-radius: var(--lv-radius);
  overflow: hidden;
  height: 34px;
  box-sizing: border-box;
}

.location-viewer-container .lv-view-btn {
  padding: 0 12px;
  height: 100%;
  background: var(--lv-background);
  border: none;
  border-right: 1px solid var(--lv-border-color);
  cursor: pointer;
  font-size: 14px;
  color: var(--lv-dark-color);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  transition: var(--lv-transition);
}

/* First visible button - no extra radius needed, parent handles it */
.location-viewer-container .lv-view-btn.first-visible {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

/* Last visible button */
.location-viewer-container .lv-view-btn.last-visible {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: none;
}

/* Middle buttons - no radius */
.location-viewer-container .lv-view-btn:not(.first-visible):not(.last-visible) {
  border-radius: 0;
}

.location-viewer-container .lv-view-btn:hover,
.location-viewer-container .lv-view-btn:focus {
  background: var(--lv-dark-color);
  color: #fff;
}

.location-viewer-container .lv-view-btn.active {
  background: var(--lv-dark-color);
  color: #fff;
}

/* ==========================================================================
   Map
   ========================================================================== */

.lv-map-container {
  position: relative;
  display: flex;
  flex-direction: column;
}

.lv-map {
  width: 100%;
  flex: 1;
  min-height: 300px;
}

.lv-map-error {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--lv-text-muted);
  font-size: 14px;
  padding: 20px;
  text-align: center;
}

/* Marker Styles */
.lv-marker {
  background: transparent;
  border: none;
}

.leaflet-marker-icon.lv-marker,
.leaflet-marker-icon.lv-cluster-enter {
  cursor: pointer !important;
}

/* Highlighted state for all marker styles */
.lv-marker-highlighted {
  transform: scale(1.2);
  z-index: 1000 !important;
}

/* Pin marker style */
.lv-marker-style-pin {
  transition: transform 0.2s ease;
}

/* Shape marker style (circle/square) */
.lv-marker-style-shape {
  transition: transform 0.2s ease;
}

/* Icon-only marker style */
.lv-marker-style-icon-only {
  transition: transform 0.2s ease;
}

/* Default icon colors per marker style — overridden by inline `color:` from
   IconRenderer when config.color is set. White on shapes for contrast against
   the colored shape background. */
.lv-marker-style-shape > i,
.lv-marker-style-shape > .lv-icon-svg,
.lv-marker-style-shape > .lv-icon-emoji {
  color: #ffffff;
}

.lv-marker-style-pin i,
.lv-marker-style-pin .lv-icon-svg,
.lv-marker-style-pin .lv-icon-emoji,
.lv-marker-style-icon-only > i,
.lv-marker-style-icon-only > .lv-icon-svg,
.lv-marker-style-icon-only > .lv-icon-emoji {
  color: #007cba;
}

/* Disable marker CSS transitions during map animation — Leaflet updates
   marker translate3d every frame during flyTo/zoom, and the transition
   makes them lag behind instead of snapping */
.lv-map-animating .lv-marker-style-pin,
.lv-map-animating .lv-marker-style-shape,
.lv-map-animating .lv-marker-style-icon-only {
  transition: none !important;
}

/* Leaflet zoom control styling */
.leaflet-top.leaflet-right {
  top: 10px !important;
  right: 10px !important;
}

.leaflet-control-zoom {
  margin: 0 !important;
  border: none !important;
  border-radius: 4px !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
  width: 32px !important;
}

.leaflet-control-zoom-in,
.leaflet-control-zoom-out {
  width: 32px !important;
  height: 32px !important;
  text-decoration: none !important;
  border: none !important;
  box-shadow: none !important;
}

.leaflet-control-zoom-in:hover,
.leaflet-control-zoom-out:hover {
  text-decoration: none !important;
  background: var(--lv-background-alt) !important;
}

/* Show All Button */
.lv-show-all-wrapper {
  position: absolute;
  top: 84px;
  right: 10px;
  border-radius: 4px;
  width: 32px;
  height: 32px;
  z-index: 1001;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
}

.location-viewer-container .lv-show-all-control {
  background: white;
  border: none;
  border-radius: 2px;
  width: 100%;
  height: 100%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: inherit;
  transition: all 0.2s ease;
}

.location-viewer-container .lv-show-all-wrapper:hover .lv-show-all-control,
.location-viewer-container .lv-show-all-control:focus {
  background: var(--lv-background-alt);
  border: none;
  color: inherit;
}

.location-viewer-container .lv-show-all-control.disabled {
  background: var(--lv-background-alt);
  cursor: not-allowed;
  opacity: 0.5;
}

.location-viewer-container .lv-show-all-control.disabled:hover {
  background: var(--lv-background-alt);
}

.lv-show-all-control i {
  font-size: 14px;
  color: var(--lv-dark-color);
}

.lv-show-all-control.disabled i {
  color: var(--lv-text-muted);
}

/* Cluster Markers */
.lv-cluster {
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  border: 2px solid white;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.lv-cluster-small {
  width: 32px;
  height: 32px;
  font-size: 12px;
}

.lv-cluster-medium {
  width: 40px;
  height: 40px;
  font-size: 14px;
}

.lv-cluster-large {
  width: 48px;
  height: 48px;
  font-size: 16px;
}

.lv-cluster:hover {
  transform: scale(1.1);
}

/* Stack markers — several items at exactly the same spot */
.lv-stack-count {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  box-sizing: border-box;
  border-radius: 9px;
  background: var(--lv-dark-color);
  color: #fff;
  border: 2px solid #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 14px;
  text-align: center;
  pointer-events: none;
  z-index: 1;
}

.lv-stack-popup-header {
  padding: 0 16px 10px 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--lv-text-muted);
}

/* File-folder tabs, one per item; the tab carries the item's title.
   One row that scrolls sideways when a stack has many. The baseline is an
   inset shadow so the active tab's background can cover it. */
.lv-stack-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  /* Bleed to the popup's edges so the baseline and the fades run full width */
  margin: 0 -16px;
  padding: 0 16px;
  box-shadow: inset 0 -1px 0 var(--lv-border-color);
  user-select: none;
  /* No scrollbar — macOS overlay bars drew over the tabs. Edge fades show
     there's more; drag, trackpad and touch scroll it. */
  scrollbar-width: none;
}

.lv-stack-tabs::-webkit-scrollbar {
  display: none;
}

.lv-stack-tabs.can-scroll-right {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
}

.lv-stack-tabs.can-scroll-left {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 28px);
  mask-image: linear-gradient(to right, transparent, #000 28px);
}

.lv-stack-tabs.can-scroll-left.can-scroll-right {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent);
}

/* Mouse drag scrolls the row (see ClusterManager._enableTabScroll) */
.lv-stack-tabs.is-dragging,
.lv-stack-tabs.is-dragging .lv-stack-tab {
  cursor: grabbing;
}

/* Reset theme button styles — themes style <button> heavily, including
   button:focus (a clicked tab keeps focus), so the focus state is covered too */
.lv-stack-tab,
.lv-stack-tab:focus {
  flex: 0 0 auto;
  margin: 0;
  padding: 6px 10px;
  min-height: 0;
  border: 1px solid var(--lv-border-color);
  border-radius: 6px 6px 0 0;
  background: var(--lv-background-alt);
  color: var(--lv-text-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: normal;
  text-transform: none;
  box-shadow: none;
  cursor: pointer;
}

.lv-stack-tab:hover {
  background: var(--lv-background);
  color: var(--lv-text-color);
}

.lv-stack-tab:focus-visible {
  outline: 2px solid var(--lv-primary-color);
  outline-offset: -2px;
}

/* Active tab opens into the panel below: no bottom edge */
.lv-stack-tab.is-active,
.lv-stack-tab.is-active:focus,
.lv-stack-tab.is-active:hover {
  background: var(--lv-background);
  border-bottom-color: var(--lv-background);
  color: var(--lv-text-color);
}

/* Only the selected item shows */
.lv-stack-popup-list {
  max-height: 320px;
  overflow-y: auto;
}

.lv-stack-popup-item {
  display: none;
  padding-top: 12px;
}

.lv-stack-popup-item.is-active {
  display: block;
}

/* The tab already shows the title */
.lv-stack-popup-item .lv-popup-title {
  display: none;
}

/* Cluster Popup */
.lv-cluster-popup-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 200px;
  overflow-y: auto;
}

.lv-cluster-popup-item {
  padding: 6px 8px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--lv-border-color);
}

.lv-cluster-popup-item:last-child {
  border-bottom: none;
}

.lv-cluster-popup-item:hover {
  background: var(--lv-background-alt);
}

.lv-cluster-popup-more {
  padding: 6px 8px;
  color: var(--lv-text-muted);
  font-size: 12px;
  font-style: italic;
}

/* Popup Styles */
.lv-popup {
  animation: lv-popup-fade-in 0.2s ease-out;
}

@keyframes lv-popup-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.lv-popup .leaflet-popup-content-wrapper {
  border-radius: var(--lv-radius);
  box-shadow: var(--lv-shadow);
}

/* Even inner padding (Leaflet's default is 13px 24px 13px 20px) */
.lv-popup .leaflet-popup-content {
  margin: 16px;
}

/* Keep a popup's first line clear of the close button */
.leaflet-popup-content > .lv-popup-content > .lv-popup-title:first-child {
  padding-right: 16px;
}

/* No trailing gap after the last line */
.lv-popup-content > :last-child {
  margin-bottom: 0;
}

.lv-popup-title {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
}

.lv-popup-address {
  margin: 0 0 8px;
  color: var(--lv-text-muted);
  font-size: 13px;
}

.lv-popup-link {
  display: inline-block;
  color: var(--lv-primary-color);
  text-decoration: none;
  font-size: 13px;
}

.lv-popup-link:hover {
  text-decoration: underline;
}

/* "See details" — jumps to the item's grid card. Theme button styles reset. */
.lv-popup-details-btn,
.lv-popup-details-btn:focus {
  display: inline-block;
  margin: 12px 0 0;
  padding: 6px 12px;
  min-height: 0;
  border: 0;
  border-radius: var(--lv-radius);
  background: var(--lv-dark-color);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: normal;
  text-transform: none;
  box-shadow: none;
  cursor: pointer;
}

.lv-popup-details-btn:hover,
.lv-popup-details-btn:focus:hover {
  background: var(--lv-dark-hover);
  color: #fff;
}

/* Details modal — over the whole page, above Leaflet and the WP admin bar */
.lv-modal-open {
  overflow: hidden;
}

.lv-modal {
  position: fixed;
  inset: 0;
  z-index: 100001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  box-sizing: border-box;
}

.lv-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
  animation: lv-popup-fade-in 0.15s ease-out;
}

.lv-modal-dialog {
  position: relative;
  width: 100%;
  max-width: 640px;
  max-height: 100%;
  overflow-y: auto;
  background: var(--lv-background);
  color: var(--lv-text-color);
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  animation: lv-popup-fade-in 0.2s ease-out;
}

.lv-modal-dialog:focus {
  outline: none;
}

/* Reset theme button styles (incl. :focus) */
.lv-modal-close,
.lv-modal-close:focus {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 0;
  min-height: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--lv-text-muted);
  font: inherit;
  font-size: 26px;
  line-height: 36px;
  text-align: center;
  box-shadow: none;
  cursor: pointer;
}

.lv-modal-close:hover {
  background: var(--lv-background-alt);
  color: var(--lv-text-color);
}

.lv-modal-close:focus-visible {
  outline: 2px solid var(--lv-primary-color);
}

.lv-modal-body {
  padding: 24px;
}

/* Keep a heading clear of the close button */
.lv-modal-body h1:first-child,
.lv-modal-body h2:first-child,
.lv-modal-body h3:first-child,
.lv-modal-body .lv-item-title {
  padding-right: 32px;
}

/* Default content is a grid card: drop its card chrome inside the modal */
.lv-modal-card .lv-item-content {
  padding: 0;
}

/* ==========================================================================
   Legend
   ========================================================================== */

.lv-legend,
.lv-map-legend {
  position: absolute;
  /* Corner comes from .lv-legend-<position>; these are the fallback for a
     legend rendered without one. */
  bottom: 10px;
  left: 10px;
  background: var(--lv-background);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  min-width: 150px;
  max-width: 300px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: calc(100% - 20px);
}

/* Legend corners. Each sets both axes so switching corners can't leave the
   previous side's offset in play.

   --lv-map-gutter matches the margin Leaflet gives its own controls, so the
   legend lines up with the zoom buttons rather than floating on its own inset.
   The right edge carries a control column — zoom, then the show-all button —
   which the two right-hand corners dodge differently: top-right sits beside
   it (tops level with the zoom), bottom-right stays flush in its corner and
   simply stops growing before it reaches the stack. */
.lv-map-legend {
  --lv-map-gutter: 10px;
  --lv-map-control-column: 42px;
  --lv-map-control-stack: 116px;
}

.lv-map-legend.lv-legend-bottom-left {
  top: auto;
  right: auto;
  bottom: var(--lv-map-gutter);
  left: var(--lv-map-gutter);
}

.lv-map-legend.lv-legend-bottom-right {
  top: auto;
  right: var(--lv-map-gutter);
  bottom: var(--lv-map-gutter);
  left: auto;
  /* Grows upward only as far as the control column above it. */
  max-height: calc(100% - var(--lv-map-control-stack) - var(--lv-map-gutter) * 2);
}

.lv-map-legend.lv-legend-top-left {
  top: var(--lv-map-gutter);
  right: auto;
  bottom: auto;
  left: var(--lv-map-gutter);
}

.lv-map-legend.lv-legend-top-right {
  top: var(--lv-map-gutter);
  right: calc(var(--lv-map-control-column) + var(--lv-map-gutter));
  bottom: auto;
  left: auto;
}

/* Attribution sits in the bottom-right corner and has to stay legible, so
   lift the legend above it — unless the viewer hides attribution outright. */
.location-viewer-block:not(.lv-hide-attribution) .lv-map-legend.lv-legend-bottom-right {
  bottom: 28px;
}

/* Anchored at the top, the legend reads top-down: the toggle bar comes first
   and the list grows beneath it. DOM order already gives the bottom pair the
   mirror of that, so only the top pair flips — along with the divider and the
   chevron, which both have to follow the list to the other side. */
.lv-map-legend.lv-legend-top-left,
.lv-map-legend.lv-legend-top-right {
  flex-direction: column-reverse;
}

.lv-map-legend.lv-legend-top-left .lv-legend-toggle,
.lv-map-legend.lv-legend-top-right .lv-legend-toggle {
  border-top: none;
  border-bottom: 1px solid rgba(0,0,0,0.1);
}

.lv-map-legend.lv-legend-top-left .lv-legend-arrow,
.lv-map-legend.lv-legend-top-right .lv-legend-arrow {
  transform: rotate(180deg);
}

.lv-map-legend.lv-legend-top-left.collapsed .lv-legend-arrow,
.lv-map-legend.lv-legend-top-right.collapsed .lv-legend-arrow {
  transform: rotate(0deg);
}

/* Legend toggle button */
.lv-legend-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 1em 8px 14px;
  cursor: pointer;
  user-select: none;
  border-top: 1px solid rgba(0,0,0,0.1);
  flex-shrink: 0;
}

.lv-legend-toggle:hover {
  background: rgba(0,0,0,0.03);
}

.lv-legend-label {
  font-weight: 600;
  font-size: 13px;
  color: var(--lv-dark-color);
  display: flex;
  align-items: center;
  gap: 5px;
}

.lv-legend-arrow {
  font-size: 12px;
  color: var(--lv-text-muted);
  width: 12px;
  text-align: center;
  flex-shrink: 0;
  transition: transform 0.2s ease;
  margin-left: auto;
}

.lv-map-legend.collapsed .lv-legend-arrow {
  transform: rotate(180deg);
}

/* Legend items container — scrollbar-gutter reserves consistent space for scrollbar */
.lv-legend-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: .75em 1em .75em 14px;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.2) rgba(0,0,0,0.05);
  transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.2s ease;
  flex: 1;
  min-height: 0;
}

.lv-map-legend.collapsed .lv-legend-items {
  max-height: 0 !important;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
}

/* Custom scrollbar */
.lv-legend-items::-webkit-scrollbar {
  width: 6px;
}

.lv-legend-items::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.05);
  border-radius: 3px;
}

.lv-legend-items::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.2);
  border-radius: 3px;
}

.lv-legend-items::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,0.3);
}

/* Legend item */
/* legendLayerScope 'view': layers with nothing in the current map view */
.lv-legend-item.lv-legend-item-out-of-view {
  display: none;
}

.lv-legend-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  position: relative;
}

.lv-legend-item input[type="checkbox"] {
  display: none;
}

.lv-legend-item label {
  cursor: pointer;
  margin: 0;
  font-size: 13px;
  color: var(--lv-dark-color);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex: 1;
  min-width: 0;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.lv-legend-item .label-text {
  padding-top: 8px;
}

/* Legend icon container with stacked icons */
.lv-legend-item .icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  position: relative;
  padding-top: 5px;
}

.lv-legend-item .icon i {
  font-size: 14px;
  text-shadow: none !important;
  filter: none !important;
}

/* Legend swatch in the layer's marker style (IconRenderer.createLegendSwatch) */
.lv-legend-item .icon .lv-legend-swatch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.lv-legend-item .icon .lv-legend-swatch-pin {
  width: 20px;
  height: 26px;
  align-items: flex-start;
}

.lv-legend-item .icon .lv-legend-swatch-pin .fa-location-pin {
  font-size: 24px;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.3)) !important;
}

.lv-legend-item .icon .lv-legend-swatch-inner {
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  line-height: 1;
}

.lv-legend-item .icon .lv-legend-swatch-shape {
  width: 22px;
  height: 22px;
  box-sizing: border-box;
  border: 2px solid #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.lv-legend-item .icon .lv-legend-swatch-circle { border-radius: 50%; }
.lv-legend-item .icon .lv-legend-swatch-square { border-radius: 4px; }

/* Inner icon is white unless the layer sets a colour (inline style wins) */
.lv-legend-item .icon .lv-legend-swatch-inner i,
.lv-legend-item .icon .lv-legend-swatch-shape i {
  color: #fff;
}

/* Font Awesome stack for overlaying ban symbol */
.lv-legend-item .fa-stack {
  display: inline-block;
  width: 2em;
  height: 2em;
  line-height: 2em;
  position: relative;
  vertical-align: middle;
}

.lv-legend-item .fa-stack > :first-child {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

/* Explicit box + line-height: a theme line-height on <i> otherwise shrinks
   the box (e.g. 13px for a 26px glyph) and the circle draws off-centre */
.lv-legend-item .fa-stack .fa-stack-2x {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 2em;
  margin: 0;
  width: 1em;
  height: 1em;
  line-height: 1;
  text-align: center;
  color: #ff4444 !important;
  text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
  display: none;
}

/* Show ban symbol on hover and when item is hidden */
.lv-legend-item:hover .fa-stack .fa-stack-2x {
  display: block;
}

.lv-legend-item.item-hidden .fa-stack .fa-stack-2x {
  display: block;
}

.lv-legend-item.no-hover:hover .fa-stack .fa-stack-2x {
  display: none;
}

/* Dim the item when hidden */
.lv-legend-item.item-hidden {
  opacity: 0.6;
}

/* ==========================================================================
   Grid
   ========================================================================== */

.lv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--lv-grid-min-width), 1fr));
  gap: var(--lv-grid-gap);
  padding: 15px;
  align-content: start;
  width: 100%;
}

/* Filtered-out grid items and empty section headers */
.lv-grid-item.lv-grid-item-filtered,
.lv-grid-section-header.lv-grid-item-filtered {
  display: none;
}

/* Scroll sentinel — spans the full row so it sits below the last item rather
   than consuming a grid cell. Zero height; only its intersection matters. */
.lv-grid-sentinel {
  grid-column: 1 / -1;
  height: 1px;
  margin: 0;
  padding: 0;
  pointer-events: none;
}

/* Grid item styling */
.lv-grid-item {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
  scroll-margin: 20px 0;

  /* Skip layout and paint for items scrolled out of view. The intrinsic size
     keeps the scrollbar stable for items the browser hasn't measured yet. */
  content-visibility: auto;
  contain-intrinsic-size: auto 320px;
}

.lv-grid-item:hover,
.lv-grid-item.lv-grid-item-hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.lv-grid-item-highlighted,
.lv-grid-item.lv-grid-highlighted,
.lv-grid-item-highlighted:hover,
.lv-grid-item-highlighted.lv-grid-item-hover {
  box-shadow: 0 4px 16px rgba(17, 38, 66, 0.7);
}

/* Item image */
.lv-item-image {
  width: 100%;
  height: 160px;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 8px 8px 0 0;
  background: var(--lv-background-alt);
}

.lv-item-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Item content */
.lv-item-content {
  padding: 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.lv-item-title {
  margin: 0 0 8px 0;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
}

.lv-item-title a {
  text-decoration: none;
  color: var(--lv-dark-color);
}

.lv-item-title a:hover {
  color: var(--lv-primary-color);
  text-decoration: underline;
}

.lv-item-excerpt {
  color: var(--lv-text-muted);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 12px;
}

/* Item actions */
.lv-item-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: auto;
}

.location-viewer-container .lv-item-actions .button,
.location-viewer-container .lv-item-link {
  font-size: 13px;
  padding: 0 14px;
  height: 34px;
  line-height: 34px;
  border-radius: var(--lv-radius);
  text-decoration: none;
  cursor: pointer;
  border: 1px solid var(--lv-border-color);
  background: var(--lv-background);
  color: var(--lv-dark-color);
  transition: var(--lv-transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.location-viewer-container .lv-item-actions .button:hover,
.location-viewer-container .lv-item-actions .button:focus,
.location-viewer-container .lv-item-link:hover,
.location-viewer-container .lv-item-link:focus {
  background: var(--lv-dark-color);
  color: #fff;
  border-color: var(--lv-dark-color);
}

.location-viewer-container .lv-item-actions .lv-item-link {
  background: var(--lv-dark-color);
  color: #fff;
  border-color: var(--lv-dark-color);
}

.location-viewer-container .lv-item-actions .lv-item-link:hover,
.location-viewer-container .lv-item-actions .lv-item-link:focus {
  background: var(--lv-dark-hover);
  color: #fff;
  border-color: var(--lv-dark-hover);
}

/* Grid Section Headers */
.lv-grid-section-header {
  grid-column: 1 / -1;
  width: 100%;
  margin: 15px 0 0 0;
}

.lv-grid-section-header:first-child {
  margin-top: 0;
}

.lv-grid-section-title {
  padding: 12px 16px;
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--lv-text-color);
  border-bottom: 1px solid var(--lv-dark-color);
  display: flex;
  align-items: center;
}

.lv-grid-section-title .lv-header-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
  width: 20px;
  min-width: 20px;
}

.lv-grid-section-title .lv-header-icon i,
.lv-grid-section-title .lv-header-icon img {
  font-size: 16px;
}

/* Grid Empty/Loading/Error States */
.lv-grid-empty,
.lv-grid-loading,
.lv-grid-error {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 20px;
  color: var(--lv-text-muted);
}

/* The filtered empty state is a sentence, not a label — hold the line short
   enough to read in a narrow split panel. */
.lv-grid-empty p {
  max-width: 32em;
  margin: 0 auto;
}

/* Deferred Loading Indicator */
.lv-grid-deferred-loading {
  grid-column: 1 / -1;
  text-align: center;
  padding: 20px;
  color: var(--lv-text-muted);
}

.lv-grid-deferred-loading .lv-spinner {
  width: 24px;
  height: 24px;
  border-width: 2px;
}

.lv-grid-deferred-loading p {
  font-size: 13px;
  margin: 0;
}

.lv-grid-error {
  color: #c0392b;
}

.lv-grid-error i {
  font-size: 28px;
  margin-bottom: 10px;
  display: block;
}

.lv-spinner {
  width: 30px;
  height: 30px;
  border: 3px solid var(--lv-border-color);
  border-top-color: var(--lv-primary-color);
  border-radius: 50%;
  animation: lv-spin 0.8s linear infinite;
  margin: 0 auto 15px;
}

@keyframes lv-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ==========================================================================
   Filter Modal
   ========================================================================== */

.lv-filter-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
}

.lv-filter-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lv-filter-modal-content {
  background: var(--lv-background);
  border-radius: var(--lv-radius);
  width: 100%;
  max-width: 500px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.lv-filter-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid var(--lv-border-color);
}

.lv-filter-modal-header h3 {
  margin: 0;
  font-size: 18px;
}

.location-viewer-container .lv-filter-modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--lv-text-muted);
  padding: 5px;
}

.location-viewer-container .lv-filter-modal-close:hover,
.location-viewer-container .lv-filter-modal-close:focus {
  background: none;
  color: var(--lv-text-color);
  border: none;
}

.lv-filter-modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

/* In-modal search field — desktop uses the inline search bar, so this is
   hidden until the mobile breakpoint reveals it. */
.lv-filter-search-section {
  display: none;
}

.location-viewer-container .lv-modal-search-input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  font-size: 14px;
  border: 1px solid var(--lv-border-color);
  border-radius: var(--lv-radius);
  box-sizing: border-box;
}

.location-viewer-container .lv-modal-search-input:focus {
  border-color: var(--lv-primary-color);
  outline: none;
}

.lv-filter-section {
  margin-bottom: 20px;
}

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

.lv-filter-section > label {
  display: block;
  font-weight: 600;
  margin-bottom: 10px;
}

/* Extra spacing before "Show on Map" section */
#lv-show-on-map-section {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--lv-border-color);
}

/* Hide separator when no filters are present */
.lv-filter-sections:empty + #lv-show-on-map-section {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

/* Filter Toggles */
.lv-filter-toggles {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lv-filter-toggle {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  position: relative;
}

.lv-filter-toggle input[type="checkbox"] {
  display: none;
}

.lv-filter-toggle label {
  cursor: pointer;
  margin: 0;
  font-size: 13px;
  color: var(--lv-dark-color);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex: 1;
  min-width: 0;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.lv-filter-toggle .label-text {
  padding-top: 8px;
}

.lv-filter-toggle .icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  position: relative;
  padding-top: 5px;
}

.lv-filter-toggle .icon i {
  font-size: 14px;
  text-shadow: none !important;
  filter: none !important;
  font-style: normal !important;
}

.lv-filter-toggle .fa-stack {
  display: inline-block;
  width: 2em;
  height: 2em;
  line-height: 2em;
  position: relative;
  vertical-align: middle;
}

.lv-filter-toggle .fa-stack > :first-child {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.lv-filter-toggle .fa-stack .fa-stack-2x {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 2em;
  margin: 0;
  width: 1em;
  height: 1em;
  line-height: 1;
  text-align: center;
  color: #ff4444 !important;
  text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
  display: none;
}

.lv-filter-toggle:hover .fa-stack .fa-stack-2x {
  display: block;
}

.lv-filter-toggle.item-hidden .fa-stack .fa-stack-2x {
  display: block;
}

.lv-filter-toggle.no-hover:hover .fa-stack .fa-stack-2x {
  display: none;
}

.lv-filter-toggle.item-hidden {
  opacity: 0.6;
}

/* Filter Checkboxes */
.lv-filter-checkboxes {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.lv-filter-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lv-filter-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

/* Filter Select */
.lv-filter-select {
  width: 100%;
  padding: 0 12px;
  height: 34px;
  border: 1px solid var(--lv-border-color);
  border-radius: var(--lv-radius);
  font-size: 13px;
  color: var(--lv-dark-color);
  box-sizing: border-box;
}

/* Range Slider */
.lv-filter-range {
  padding: 10px 0;
}

.lv-range-slider-container {
  padding: 0 10px;
}

.lv-range-value-labels {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--lv-text-muted);
}

.lv-range-slider-track {
  position: relative;
  height: 6px;
  background: var(--lv-border-color);
  border-radius: 3px;
  margin: 15px 0;
}

.lv-range-slider-active {
  position: absolute;
  height: 100%;
  background: var(--lv-primary-color);
  border-radius: 3px;
}

.lv-range-slider-handle {
  position: absolute;
  width: 18px;
  height: 18px;
  background: var(--lv-primary-color);
  border: 2px solid #fff;
  border-radius: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  cursor: grab;
  box-shadow: var(--lv-shadow);
  z-index: 1;
}

.lv-range-slider-handle:active,
.lv-range-slider-handle.active {
  cursor: grabbing;
  transform: translate(-50%, -50%) scale(1.1);
}

.lv-range-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--lv-text-color);
  color: #fff;
  padding: 4px 8px;
  border-radius: var(--lv-radius);
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s;
  margin-bottom: 8px;
}

.lv-range-slider-handle.show-tooltip .lv-range-tooltip {
  opacity: 1;
}

/* Modal Footer */
.lv-filter-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 15px 20px;
  border-top: 1px solid var(--lv-border-color);
}

.location-viewer-container .lv-filter-clear-btn,
.location-viewer-container .lv-filter-apply-btn {
  padding: 0 20px;
  height: 38px;
  border-radius: var(--lv-radius);
  font-size: 13px;
  cursor: pointer;
  transition: var(--lv-transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.location-viewer-container .lv-filter-clear-btn {
  background: var(--lv-background);
  border: 1px solid var(--lv-border-color);
  color: var(--lv-dark-color);
}

.location-viewer-container .lv-filter-clear-btn:hover,
.location-viewer-container .lv-filter-clear-btn:focus {
  background: var(--lv-dark-color);
  color: #fff;
  border-color: var(--lv-dark-color);
}

.location-viewer-container .lv-filter-apply-btn {
  background: var(--lv-primary-color);
  border: 1px solid var(--lv-primary-color);
  color: #fff;
}

.location-viewer-container .lv-filter-apply-btn:hover,
.location-viewer-container .lv-filter-apply-btn:focus {
  background: var(--lv-primary-hover);
  color: #fff;
  border-color: var(--lv-primary-hover);
}

/* ==========================================================================
   Custom Icons
   ========================================================================== */

.lv-custom-icon {
  display: inline-block;
  vertical-align: middle;
}

/* ==========================================================================
   Attribution Hide
   ========================================================================== */

.lv-hide-attribution .leaflet-control-attribution {
  display: none !important;
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

/* Screen reader only — hides visually, remains available to assistive tech */
.lv-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Focus indicators */
.lv-view-btn:focus-visible,
.lv-filters-button:focus-visible,
.lv-filter-modal-close:focus-visible,
.lv-filter-apply-btn:focus-visible,
.lv-filter-clear-btn:focus-visible,
.lv-filter-chip-remove:focus-visible,
.lv-chips-more:focus-visible,
.lv-show-all-control:focus-visible {
  outline: 2px solid var(--lv-primary-color);
  outline-offset: 2px;
}

.lv-grid-item:focus-visible {
  outline: 3px solid var(--lv-primary-color);
  outline-offset: 2px;
}

.lv-range-slider-handle:focus-visible {
  outline: 2px solid var(--lv-primary-color);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(0, 124, 186, 0.25);
}

.lv-legend-toggle:focus-visible {
  outline: 2px solid var(--lv-primary-color);
  outline-offset: -2px;
}

.lv-filter-select:focus-visible {
  outline: 2px solid var(--lv-primary-color);
  border-color: var(--lv-primary-color);
}

.lv-filter-checkbox input[type="checkbox"]:focus-visible,
.lv-filter-toggle input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--lv-primary-color);
  outline-offset: 2px;
}

.lv-popup-link:focus-visible,
.lv-item-link:focus-visible,
.lv-item-title a:focus-visible {
  outline: 2px solid var(--lv-primary-color);
  outline-offset: 2px;
}

/* ==========================================================================
   Progressive Loading Animations
   ========================================================================== */

/* Marker entrance — pop with slight overshoot */
@keyframes lv-marker-pop {
  0%   { opacity: 0; transform: scale(0.3); }
  60%  { opacity: 1; transform: scale(1.08); }
  100% { transform: scale(1); }
}

.lv-marker-enter .lv-marker-style-pin,
.lv-marker-enter .lv-marker-style-shape,
.lv-marker-enter .lv-marker-style-icon-only {
  animation: lv-marker-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* Cluster entrance — fade in + pop */
@keyframes lv-cluster-enter {
  0%   { opacity: 0; transform: scale(0.5); }
  100% { opacity: 1; transform: scale(1); }
}

.lv-cluster-enter .lv-cluster {
  animation: lv-cluster-enter 0.3s ease-out both;
}

/* Cluster exit — fade out + shrink */
@keyframes lv-cluster-exit {
  0%   { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.6); }
}

.lv-cluster-exit .lv-cluster {
  animation: lv-cluster-exit 0.2s ease-in forwards;
}

/* Grid item entrance — slide up + fade with stagger */
@keyframes lv-grid-slide-in {
  0%   { opacity: 0; transform: translateY(12px); }
  100% { opacity: 1; transform: translateY(0); }
}

.lv-grid-item-enter {
  animation: lv-grid-slide-in 0.3s ease-out both;
  animation-delay: calc(var(--lv-stagger-index, 0) * 30ms);
}

/* Grid item exit — fade + slide up with stagger (used by fade-teleport-reveal) */
@keyframes lv-grid-slide-out {
  0%   { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-8px); }
}

.lv-grid-fade-out {
  animation: lv-grid-slide-out 0.15s ease-in both;
  animation-delay: calc(var(--lv-stagger-index, 0) * 20ms);
}

/* Legend count — right-aligned with minimum 3-digit width */
.lv-legend-count {
  font-size: 11px;
  color: var(--lv-text-muted);
  margin-left: auto;
  font-weight: 400;
  white-space: nowrap;
  align-self: center;
  margin-top: 4px;
  min-width: 2.2em;
  text-align: right;
}

/* Legend total count in toggle bar */
.lv-legend-total {
  font-size: 11px;
  color: var(--lv-text-muted);
  font-weight: 400;
  white-space: nowrap;
  min-width: 2.2em;
  text-align: right;
}

/* Hide legend counts when disabled */
.lv-legend-hide-count .lv-legend-count,
.lv-legend-hide-count .lv-legend-total {
  display: none;
}

/* Legend spinner — tiny inline rotating indicator */
.lv-legend-spinner {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 1.5px solid var(--lv-border-color);
  border-top-color: var(--lv-primary-color);
  border-radius: 50%;
  animation: lv-spin 0.8s linear infinite;
  margin-left: 4px;
  vertical-align: middle;
}

/* Legend count glint — JS-driven flash on actively loading layer counts */
.lv-legend-count {
  transition: color 0.4s ease-out;
}

.lv-legend-glint {
  color: var(--lv-primary-color) !important;
  transition: color 0.15s ease-in !important;
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .lv-marker-enter .lv-marker-style-pin,
  .lv-marker-enter .lv-marker-style-shape,
  .lv-marker-enter .lv-marker-style-icon-only,
  .lv-cluster-enter .lv-cluster,
  .lv-grid-item-enter {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }

  .lv-cluster-exit .lv-cluster {
    animation: none !important;
    opacity: 0 !important;
  }

  .lv-grid-fade-out {
    animation: none !important;
    opacity: 0 !important;
    transform: none !important;
  }

  .lv-legend-glint {
    color: inherit !important;
    transition: none !important;
  }
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
  .lv-view-split .lv-content {
    flex-direction: column !important;
  }

  .lv-view-split .lv-map-container,
  .lv-view-split .lv-grid-container {
    max-width: none;
    min-width: auto;
  }

  .lv-view-split .lv-map-container {
    min-height: 300px;
    max-height: none;
  }

  .lv-view-split .lv-grid-container {
    max-height: 400px;
  }

  .lv-controls {
    flex-shrink: 0;
  }

  .lv-legend {
    bottom: 10px;
    left: 10px;
    right: 10px;
    max-width: none;
  }

  .lv-grid-section-title {
    font-size: 14px;
    padding: 10px 12px;
  }

  /* Hide split view button on mobile */
  .lv-view-btn[data-view="split"] {
    display: none;
  }

  /* Collapse the inline search bar to a magnifier-only button —
     the input moves into the filter modal. */
  .location-viewer-container .lv-search-bar .lv-search-input {
    display: none;
  }

  .location-viewer-container .lv-search-bar .lv-search-btn {
    border-radius: var(--lv-radius);
  }

  /* Filter button shows just the dials icon + count (no "Filters" label) */
  .location-viewer-container .lv-filters-button .lv-filters-label {
    display: none;
  }

  /* Hide filter chips on mobile — the count badge conveys active state */
  .lv-filter-chips {
    display: none;
  }

  /* No chip row means nothing to count. */
  .location-viewer-container .lv-chips-more {
    display: none;
  }

  /* Reveal the in-modal search field */
  .lv-filter-search-section {
    display: block;
  }

  /* Filter modal goes full-screen */
  .lv-filter-modal-overlay {
    padding: 0;
  }

  .lv-filter-modal-content {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border-radius: 0;
  }
}
