/*
 * Стили EvaMaps engine. Отдельный CSS-файл: подключается вручную через <link>,
 * никогда через JS (без eval, blob, инъекций <style>). Все классы с префиксом eva-.
 *
 * Шкала z-index (решение зафиксировано, менять только всю таблицу разом):
 *   0        тайлы (без z-index, неявно ниже всех слоёв)
 *   2        Circle/Polygon/ImageOverlay
 *   3        Polyline
 *   4+offset Marker/ClusterLayer (у каждой метки свой `.eva-layer`-контейнер —
 *            см. zIndexOffset/riseOnHover в Marker.ts, поднимает конкретную метку)
 *   5        Popup (самостоятельный openOn()). Балун метки живёт внутри её `.eva-layer`,
 *            поэтому пока он открыт, слой метки поднимается на +2000 (Marker.ts,
 *            POPUP_OPEN_Z_OFFSET) — иначе соседние метки перекрывают балун и крестик.
 *   Все слои выше — внутри `.eva-layers` (isolation: isolate): сколько ни поднимай
 *   метку, она остаётся под контролами.
 *   6        контролы (зум, атрибуция, линейка, переключатель слоёв)
 *   7        подсказка кооперативных жестов (поверх всего, модально-визуально)
 * Так же, как в Leaflet (markerPane 600 < popupPane 700 < controls 800): попап
 * формально ниже контролов, но не перекрывается ими на практике — Popup.autoPan
 * (autoPanPadding, по умолчанию [20,20]) подвигает карту так, чтобы открытый
 * балун не оказывался у края и не заходил на угловые контролы (зум, кнопки,
 * переключатель слоёв).
 */

.eva-map {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 100%;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  background: #ddd;
  font-family: system-ui, -apple-system, sans-serif;
  cursor: grab;
}

.eva-map:focus {
  outline: none;
}

.eva-map:focus-visible {
  outline: 2px solid #1a73e8;
  outline-offset: -2px;
}

.eva-layers,
.eva-layer,
.eva-tile-level {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

/* Свой стекинг-контекст: z-index меток (zIndexOffset, riseOnHover, открытый балун) не выходит выше контролов. */
.eva-layers {
  isolation: isolate;
}

.eva-tile-level {
  transform-origin: 0 0;
  will-change: transform;
}

/* Защита от чужого CSS: img { max-width: 100% } из Bootstrap/Tailwind preflight
   и подобного ломает раскладку тайлов, поэтому явно перебиваем важностью. */
.eva-tile {
  position: absolute;
  max-width: none !important;
  max-height: none !important;
  opacity: 0;
  transition: opacity 150ms ease-out;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
}

.eva-tile-loaded {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .eva-tile {
    transition: none;
  }
}

.eva-attribution {
  position: absolute;
  right: 4px;
  bottom: 2px;
  z-index: 6;
  padding: 0 4px;
  font-size: 11px;
  line-height: 1.5;
  background: rgba(255, 255, 255, 0.7);
  color: #333;
  white-space: nowrap;
  pointer-events: auto;
}

.eva-attribution a {
  color: inherit;
}

/* Плашка о превышении лимита (PLAN.md §5, D22): рядом с атрибуцией, не закрывается, не перекрывает
   карту и кнопки (зум — слева сверху, масштаб — слева снизу, эта плашка — справа снизу). */
.eva-limit-badge {
  position: absolute;
  right: 4px;
  bottom: 22px;
  z-index: 6;
  padding: 2px 6px;
  font-size: 11px;
  line-height: 1.4;
  background: rgba(255, 244, 214, 0.95);
  color: #7a4a00;
  border: 1px solid rgba(122, 74, 0, 0.3);
  border-radius: 3px;
  white-space: nowrap;
  pointer-events: auto;
}

.eva-limit-badge a {
  color: inherit;
  font-weight: 600;
}

.eva-zoom-control {
  position: absolute;
  left: 8px;
  top: 8px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.eva-zoom-control.eva-zoom-right {
  left: auto;
  right: 8px;
}

.eva-zoom-control button {
  width: 30px;
  height: 30px;
  border: none;
  background: #fff;
  color: #333;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.eva-zoom-in {
  border-bottom: 1px solid #ddd;
}

.eva-zoom-control button:hover {
  background: #f0f0f0;
}

.eva-zoom-control button:active {
  background: #e0e0e0;
}

.eva-tools button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: #fff;
  color: #333;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.eva-tools button:hover {
  background: #f0f0f0;
}

.eva-tools button:active {
  background: #e0e0e0;
}

.eva-fullscreen-btn[aria-pressed='true'] {
  color: #ff6a2b;
}

.eva-geolocate-btn[aria-invalid='true'] {
  color: #b42318;
}

.eva-map-fullscreen-fallback {
  position: fixed !important;
  inset: 0 !important;
  z-index: 10000 !important;
  margin: 0 !important;
}

.eva-marker-layer {
  pointer-events: none;
  z-index: 4;
}

.eva-marker {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.eva-marker-pin {
  position: absolute;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
  line-height: 0;
}

.eva-marker-label {
  box-sizing: border-box;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.85);
  color: #222;
  font-size: 12px;
  line-height: 1.4;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.eva-marker-label[hidden] {
  display: none !important;
}

.eva-marker-hint {
  position: absolute;
  left: 0;
  z-index: 1;
  box-sizing: border-box;
  max-width: 240px;
  padding: 2px 6px;
  border-radius: 3px;
  background: rgba(33, 33, 33, 0.92);
  color: #fff;
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  transform: translateX(-50%);
}

.eva-marker-hint[hidden] {
  display: none !important;
}

.eva-popup {
  position: absolute;
  left: 0;
  bottom: 14px;
  box-sizing: border-box;
  width: max-content;
  max-width: 220px;
  padding: 6px 8px;
  border-radius: 4px;
  background: #fff;
  color: #222;
  font-size: 13px;
  line-height: 1.35;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  pointer-events: auto;
  user-select: text;
  overflow-wrap: anywhere;
  transform: translateX(-50%);
}

.eva-popup[hidden] {
  display: none !important;
}

.eva-popup-link {
  display: block;
  margin-top: 4px;
  color: #1a73e8;
  font-size: 12px;
}

.eva-popup-close {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: #666;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.eva-popup-close:hover {
  background: rgba(0, 0, 0, 0.08);
}

.eva-popup-text {
  padding-right: 16px;
}

.eva-scale-control {
  position: absolute;
  left: 8px;
  bottom: 4px;
  z-index: 6;
  pointer-events: none;
}

.eva-scale-bar {
  box-sizing: border-box;
  padding: 0 4px 2px;
  border: 2px solid #333;
  border-top: none;
  font-size: 11px;
  line-height: 1.4;
  color: #222;
  background: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
  overflow: hidden;
}

/* Кооперативные жесты во встраивании: touch-action:none заменяем на pan-y —
   один палец скроллит страницу, двумя двигают и масштабируют карту.
   Жест pinch самой страницы на iOS дополнительно гасится в TouchGestures
   (gesturestart), потому что Safari не всегда слушает touch-action. */
.eva-map-cooperative {
  touch-action: pan-y;
}

.eva-cooperative-hint {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 7;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  text-align: center;
  font-size: 15px;
  color: #fff;
  background: rgba(0, 0, 0, 0.45);
  pointer-events: none;
  opacity: 0;
  transition: opacity 200ms ease-out;
}

.eva-cooperative-hint-visible {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .eva-cooperative-hint {
    transition: none;
  }
}

.eva-layers-control {
  position: absolute;
  right: 8px;
  top: 8px;
  z-index: 6;
}

.eva-layers-control-toggle {
  width: 30px;
  height: 30px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: #fff;
  color: #333;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.eva-layers-control-toggle:hover {
  background: #f0f0f0;
}

.eva-layers-control-panel {
  position: absolute;
  right: 0;
  top: 34px;
  min-width: 140px;
  padding: 8px 10px;
  border-radius: 4px;
  background: #fff;
  color: #222;
  font-size: 13px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.eva-layers-control-panel[hidden] {
  display: none !important;
}

.eva-layers-control-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.eva-layers-control-group + .eva-layers-control-group {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #eee;
}

.eva-layers-control-item {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
}

.eva-image-overlay {
  position: absolute;
  max-width: none !important;
  max-height: none !important;
  -webkit-user-drag: none;
  user-select: none;
}

.eva-cluster-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.eva-cluster,
.eva-cluster-point {
  position: absolute;
  top: 0;
  left: 0;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  color: #fff;
  font: 600 12px/1 system-ui, sans-serif;
  cursor: pointer;
  pointer-events: auto;
}

.eva-cluster-icon {
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  line-height: 0;
}

.eva-cluster-icon img {
  display: block;
  max-width: none;
  max-height: none;
  width: 100%;
  height: 100%;
}

.eva-cluster-open {
  opacity: 0.45;
}

.eva-cluster-spider {
  z-index: 1;
}

.eva-cluster:focus-visible,
.eva-cluster-point:focus-visible {
  outline: 2px solid #1a73e8;
  outline-offset: 2px;
}

.eva-points-layer {
  position: absolute;
  top: 0;
  left: 0;
  max-width: none;
  max-height: none;
  pointer-events: none;
}
