/* ==========================================================================
   ИНТЕРАКТИВНАЯ КАРТА (js/features/map.js, route-planner.js): оболочка, панель слоёв, маркеры, попапы
   ========================================================================== */

.map-view-container {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: var(--bg-dark);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--transition-smooth), visibility var(--transition-smooth);
}

.map-view-container.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

#leaflet-map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-hero);
}

.leaflet-container { font-family: var(--font-body); background: var(--bg-hero); }

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent-gold-light);
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link-btn:hover { color: var(--text-strong); }

/* ---- верхняя панель ---- */
.map-top-bar {
  position: absolute;
  top: calc(var(--header-height) + 1rem);
  left: 1rem;
  right: 1rem;
  z-index: 1100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  pointer-events: none;
}

.map-info-badge {
  pointer-events: auto;
  background: rgba(var(--bg-rgb), 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  box-shadow: var(--shadow-sm);
  color: var(--text-strong);
  font-size: 0.85rem;
  margin-left: 290px;
  white-space: nowrap;
}

.map-controls-group {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.map-action-pill {
  background: rgba(var(--bg-rgb), 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  padding: 0.6rem 1.05rem;
  border-radius: var(--radius-full);
  color: var(--text-strong);
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  box-shadow: var(--shadow-sm);
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}
.map-action-pill:hover { background: rgba(200, 16, 46, 0.2); border-color: var(--accent-gold); color: var(--accent-gold-light); }
.map-action-pill.active, .map-action-pill[aria-expanded="true"] { background: var(--accent-primary); color: #fff; font-weight: 600; border-color: var(--accent-primary); }
.map-pill-icon { display: none; }

/* ---- панель слоёв ---- */
.map-panel {
  position: absolute;
  top: calc(var(--header-height) + 4.4rem);
  left: 1rem;
  width: 272px;
  max-height: calc(100% - var(--header-height) - 6.2rem);
  overflow-y: auto;
  z-index: 1050;
  padding: 0.9rem 0.9rem 1rem;
  background: rgba(var(--bg-rgb), 0.94);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  transform: translateX(-130%);
  transition: transform var(--transition-smooth);
  scrollbar-width: thin;
}
.map-panel.is-open { transform: none; }
.map-panel:empty { display: none; }

.map-panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.6rem; color: var(--text-strong); font-size: 0.9rem; }
.map-panel-quick { display: flex; gap: 0.75rem; }
.map-layer-list { display: flex; flex-direction: column; }

.map-layer-row {
  display: grid;
  grid-template-columns: auto 1.6rem 1fr auto;
  align-items: center;
  gap: 0.55rem;
  padding: 0.38rem 0.2rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.86rem;
  color: var(--text-secondary);
}
.map-layer-row:hover { background: rgba(var(--fg-rgb), 0.06); }
.map-layer-row input { width: 16px; height: 16px; accent-color: var(--accent-gold); margin: 0; }
.map-layer-dot {
  width: 1.5rem; height: 1.5rem; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.78rem; line-height: 1;
  background: var(--pin, #94a3b8); color: #121012;
}
.map-layer-count { font-size: 0.74rem; color: var(--text-muted); }
.map-layer-accessible { margin-top: 0.4rem; padding-top: 0.6rem; border-top: 1px solid rgba(var(--fg-rgb), 0.1); border-radius: 0; }

.map-nearby { margin-top: 0.8rem; padding-top: 0.7rem; border-top: 1px solid rgba(var(--fg-rgb), 0.1); }
.map-nearby-title { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 0.35rem; }
.map-nearby-item {
  display: flex; width: 100%; justify-content: space-between; gap: 0.6rem;
  padding: 0.4rem 0.3rem; background: none; border: none; color: var(--text-strong); font-size: 0.84rem; text-align: left; cursor: pointer; border-radius: var(--radius-sm);
}
.map-nearby-item:hover { background: rgba(var(--fg-rgb), 0.07); }
.map-nearby-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-nearby-dist { color: var(--accent-gold-light); white-space: nowrap; font-size: 0.78rem; }

.map-set-banner {
  position: absolute; left: 50%; bottom: 1.2rem; transform: translateX(-50%); z-index: 1050;
  display: flex; gap: 0.8rem; align-items: center;
  background: rgba(14, 18, 26, 0.94); border: 1px solid var(--border-glow); border-radius: var(--radius-full);
  padding: 0.55rem 1.1rem; font-size: 0.85rem; color: #fff; box-shadow: var(--shadow-sm);
}
.map-set-banner[hidden] { display: none; }

.map-fallback { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 1rem; align-items: center; justify-content: center; padding: 2rem; text-align: center; color: var(--text-secondary); }

/* ---- маркеры ---- */
.yo-pin-wrap { background: none !important; border: none !important; }
.yo-pin {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
  border-radius: 50%;
  background: var(--pin, #c8102e);
  border: 2px solid #0b0b0d;
  color: #121012;
  font-size: 15px; line-height: 1; font-weight: 700;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.6), 0 0 0 2px rgba(255, 255, 255, 0.22);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  cursor: pointer;
}
.yo-pin-wrap:hover .yo-pin, .yo-pin-wrap.is-active .yo-pin, .yo-pin-wrap:focus-visible .yo-pin { transform: scale(1.22); box-shadow: 0 0 0 3px #fff, 0 6px 20px rgba(0, 0, 0, 0.7); z-index: 5; }
.yo-pin-acc {
  position: absolute; right: -6px; top: -7px;
  width: 15px; height: 15px; border-radius: 50%;
  background: #2563eb; color: #fff; font-style: normal; font-size: 10px;
  display: flex; align-items: center; justify-content: center; border: 1px solid #fff;
}
.yo-me { display: block; width: 20px; height: 20px; border-radius: 50%; background: #3b82f6; border: 3px solid #fff; box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.6); animation: yo-pulse 2s infinite; }
@keyframes yo-pulse { 70% { box-shadow: 0 0 0 16px rgba(59, 130, 246, 0); } 100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); } }

/* кластеры */
.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large { background: rgba(200, 16, 46, 0.28) !important; }
.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-primary-hover)) !important;
  color: #fff; font-weight: 700; font-family: var(--font-body);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.55);
}

/* ---- попапы ---- */
.leaflet-popup-content-wrapper {
  background: var(--surface) !important;
  border: 1px solid var(--border-glass) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-lg), var(--glow-gold) !important;
  color: var(--text-main) !important;
  padding: 0 !important;
  overflow: hidden !important;
}
.leaflet-popup-content { margin: 0 !important; width: auto !important; }
.leaflet-popup-tip { background: var(--surface) !important; border: 1px solid var(--border-glass) !important; }
.leaflet-container a.leaflet-popup-close-button { color: var(--text-strong); background: rgba(0, 0, 0, 0.45); border-radius: 50%; width: 26px; height: 26px; top: 8px; right: 8px; font-size: 18px; line-height: 24px; text-align: center; padding: 0; z-index: 3; }
.leaflet-container a.leaflet-popup-close-button:hover { background: var(--accent-red); color: var(--text-strong); }

.map-popup-inner { width: 260px; }
.map-popup-thumb { width: 100%; height: 118px; object-fit: cover; display: block; background: var(--surface-2); }
.map-popup-body { padding: 0.8rem 0.85rem 0.9rem; }
.map-popup-category { font-size: 0.7rem; text-transform: uppercase; font-weight: 700; letter-spacing: 0.05em; margin-bottom: 0.2rem; }
.map-popup-title { font-family: var(--font-heading); font-size: 1.08rem; color: var(--text-strong); margin: 0 0 0.35rem; line-height: 1.25; }
.map-popup-hours:empty { display: none; }
.map-popup-hours { margin-bottom: 0.35rem; }
.map-popup-addr { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 0.35rem; }
.map-popup-tagline { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.4; margin-bottom: 0.75rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.map-popup-actions { display: flex; gap: 0.35rem; }
.map-popup-btn { flex: 1 1 auto; min-width: 0; padding: 0.45rem 0.5rem; font-size: 0.74rem; text-align: center; white-space: nowrap; gap: 0.25rem; }
.map-popup-fav { flex: 0 0 38px; padding: 0.45rem 0; font-size: 0.95rem; }
.map-mini-link { color: var(--accent-gold-light); font-weight: 600; text-decoration: none; }
.leaflet-container .map-mini-link { color: var(--accent-gold-light); }

/* ---- контролы Leaflet (тёмная тема) ---- */
.leaflet-bar { border: 1px solid var(--border-glass) !important; border-radius: var(--radius-md) !important; overflow: hidden; box-shadow: var(--shadow-sm) !important; }
.leaflet-bar a { background-color: rgba(var(--bg-rgb), 0.92) !important; color: var(--text-strong) !important; border-bottom: 1px solid rgba(var(--fg-rgb), 0.08) !important; }
.leaflet-bar a:hover { background-color: var(--accent-primary) !important; color: var(--text-strong) !important; }
.leaflet-control-layers { background: rgba(var(--bg-rgb), 0.94) !important; color: var(--text-strong) !important; border: 1px solid var(--border-glass) !important; border-radius: var(--radius-md) !important; }
.leaflet-control-layers-toggle { background-color: rgba(var(--bg-rgb), 0.94) !important; border-radius: var(--radius-md); }
.leaflet-control-layers label { color: var(--text-strong); font-size: 0.82rem; }
.leaflet-control-attribution { background: rgba(var(--bg-rgb), 0.75) !important; color: var(--text-muted) !important; font-size: 10px; }
.leaflet-control-attribution a { color: var(--text-secondary) !important; }
body.mode-map .leaflet-bottom.leaflet-right { margin-bottom: 0.3rem; }

/* ---- мини-карта карточки ---- */
.entry-map.is-ready { height: 280px; min-height: 280px; position: relative; z-index: 0; }
.entry-map .leaflet-container { height: 100%; }
.yo-mini-open {
  display: block; background: rgba(var(--bg-rgb), 0.92); color: var(--text-strong) !important; text-decoration: none;
  font-size: 0.78rem; padding: 0.4rem 0.7rem; border-radius: var(--radius-full); border: 1px solid var(--border-glass); margin: 8px 8px 0 0;
}
.yo-mini-open:hover { background: var(--accent-primary); color: var(--text-strong) !important; }

/* ---- карта отелей на главной ---- */
.slot-box.is-map { display: block; padding: 0; border-style: solid; overflow: hidden; min-height: 0; }
.hotels-map { height: 400px; position: relative; z-index: 0; }
.hotels-map-link { margin: 1rem auto; display: flex; width: fit-content; }
.card-dist { color: var(--accent-gold-light); }

/* ---- нижняя панель пошагового маршрута (route-planner.js) ---- */
.map-guide {
  position: absolute; left: 50%; bottom: 1.4rem; transform: translateX(-50%);
  width: min(560px, calc(100% - 2rem)); z-index: 1060;
  background: rgba(var(--bg-rgb), 0.96); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border-glow); border-radius: var(--radius-md); box-shadow: var(--shadow-lg), var(--glow-gold);
  padding: 0.9rem 1rem 1rem;
}
.map-guide[hidden] { display: none; }
.guide-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem; }
.guide-route { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent-gold); }
.guide-title { font-family: var(--font-heading); font-size: 1.1rem; color: var(--text-strong); line-height: 1.25; margin-top: 0.15rem; }
.guide-meta { font-size: 0.78rem; color: var(--accent-emerald); margin-top: 0.2rem; }
.guide-close { flex: none; background: rgba(var(--fg-rgb), 0.1); border: 1px solid var(--border-glass); color: var(--text-strong); width: 32px; height: 32px; border-radius: 50%; cursor: pointer; }
.guide-close:hover { background: var(--accent-red); }
.guide-steps { display: flex; gap: 0.3rem; margin: 0.75rem 0; }
.guide-step { flex: 1; height: 5px; border-radius: 3px; background: rgba(var(--fg-rgb), 0.15); border: none; padding: 0; cursor: pointer; transition: background var(--transition-fast); }
.guide-step.is-done { background: rgba(200, 16, 46, 0.55); }
.guide-step.is-current { background: var(--accent-primary); }
.guide-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.guide-actions .btn { padding: 0.55rem 1rem; font-size: 0.82rem; }
.guide-actions .guide-next { margin-left: auto; }
.guide-leg { font-size: 0.8rem; color: var(--accent-emerald); margin: 0 0 0.6rem; }
.guide-badge {
  display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-primary); color: #fff; font-weight: 700; font-size: 0.82rem; border: 2px solid #0b0b0d; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}
.guide-pin-wrap { background: none !important; border: none !important; }
.guide-pin-wrap .guide-badge { width: 100%; height: 100%; }
.guide-pin-wrap.is-current .guide-badge { background: var(--accent-red); color: #fff; transform: scale(1.25); box-shadow: 0 0 0 3px #fff, 0 4px 14px rgba(0, 0, 0, 0.7); }

/* ---- адаптив ---- */
@media (max-width: 899px) {
  .map-info-badge { display: none; }
  .map-top-bar { justify-content: flex-end; top: calc(var(--header-height) + 0.5rem); }
  .map-controls-group { justify-content: flex-end; }
  .map-panel {
    top: auto; left: 0.6rem; right: 0.6rem; bottom: 0.6rem; width: auto;
    max-height: 52%; transform: translateY(130%);
  }
  .map-panel.is-open { transform: none; }
  .map-set-banner { bottom: auto; top: calc(var(--header-height) + 3.6rem); }
  .map-guide { bottom: 0.6rem; }
  body.mode-map .leaflet-bottom.leaflet-right { margin-bottom: 3.6rem; }
}

@media (max-width: 560px) {
  .map-pill-text { display: none; }
  .map-pill-icon { display: inline; }
  .map-action-pill { padding: 0.6rem 0.8rem; }
  .map-layers-btn .map-pill-text { display: inline; }
  .map-popup-inner { width: 236px; }
  .hotels-map { height: 320px; }
}

/* когда открыта нижняя панель маршрута — поднимаем зум и переключатель подложек */
body.mode-map:has(.map-guide:not([hidden])) .leaflet-bottom { margin-bottom: 10.5rem; }
@media (min-width: 900px) { body.mode-map:has(.map-guide:not([hidden])) .leaflet-bottom { margin-bottom: 9rem; } }

/* Нижняя панель вкладок мобильной версии: карта заканчивается над ней (правило в layout.css: body.mode-map.has-tabbar .map-view-container),
   поэтому панель слоёв, плашка маршрута (.map-guide) и кнопки Leaflet лежат выше вкладок и не прячутся под ними. */
