/* AP-R · apr-map.css — стили модала search-карты + балунов.
   Подключается в шаблоне main_v2 (один раз) и используется только когда модал открыт.
   Палитра AP-R: navy #13374f, mint #17b7bf, grass #6bb547, ink #1a2b3a, muted #6b7d8c. */

/* ---------- Modal shell ---------- */
.apr-mm {
  position: fixed; inset: 0;
  z-index: 9000;
  display: none;
}
.apr-mm.is-open { display: block; }

.apr-mm__backdrop {
  position: absolute; inset: 0;
  background: rgba(20, 28, 36, 0.62);
}
.apr-mm__panel {
  position: absolute;
  inset: 24px;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- Header ---------- */
.apr-mm__head {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 18px 22px;
  border-bottom: 1px solid #e8edf1;
  background: #fff;
  flex-wrap: nowrap;
}
.apr-mm__title { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex-shrink: 0; }
.apr-mm__t1 { font-size: 18px; font-weight: 700; color: #13374f; letter-spacing: -0.01em; }
.apr-mm__t2 { font-size: 12px; color: #8a96a0; }
.apr-mm__chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}
.apr-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 11px;
  background: #f0f5f9;
  color: #13374f;
  font-size: 12px;
  font-weight: 500;
  border-radius: 3px;
  white-space: nowrap;
}
.apr-mm__close {
  width: 36px; height: 36px;
  background: transparent;
  border: 1px solid #d6dde3;
  color: #6b7d8c;
  border-radius: 4px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.15s;
  flex-shrink: 0;
}
.apr-mm__close:hover { border-color: #13374f; color: #13374f; }
.apr-mm__close svg { width: 18px; height: 18px; }

/* ---------- Toolbar ---------- */
.apr-mm__toolbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 22px;
  background: #fafbfc;
  border-bottom: 1px solid #e8edf1;
}
.apr-mm__toggle {
  display: flex;
  background: #fff;
  border: 1px solid #d6dde3;
  border-radius: 4px;
  overflow: hidden;
}
.apr-mm__toggle button {
  background: #fff;
  border: 0;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: #6b7d8c;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.apr-mm__toggle button + button { border-left: 1px solid #d6dde3; }
.apr-mm__toggle button.is-active {
  background: #13374f;
  color: #fff;
}
.apr-mm__toggle button span {
  background: rgba(255,255,255,0.15);
  padding: 1px 6px;
  border-radius: 2px;
  font-size: 11px;
}
.apr-mm__toggle button:not(.is-active) span {
  background: #eef2f5;
  color: #8a96a0;
}

/* Переключатели слоёв «Округа» / «Районы» */
.apr-mm__layers {
  display: flex;
  gap: 14px;
  padding-left: 14px;
  border-left: 1px solid #e8edf1;
}
.apr-layer {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  color: #1a2b3a;
  font-weight: 500;
}
.apr-layer input { position: absolute; opacity: 0; pointer-events: none; }
.apr-layer__box {
  width: 18px; height: 18px;
  border: 1.5px solid #c4cdd5;
  border-radius: 3px;
  display: inline-grid;
  place-items: center;
  background: #fff;
  transition: all 0.15s;
  position: relative;
}
.apr-layer__box::after {
  content: '';
  width: 10px; height: 6px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translate(1px, -1px);
  opacity: 0;
  transition: opacity 0.15s;
}
.apr-layer input:checked + .apr-layer__box {
  background: #13374f;
  border-color: #13374f;
}
.apr-layer input:checked + .apr-layer__box::after { opacity: 1; }
.apr-layer input:checked + .apr-layer__box i { display: none; }
.apr-layer__box .layer-okrug {
  width: 10px; height: 10px;
  background: #17b7bf30;
  border: 1.5px solid #17b7bf;
  border-radius: 1px;
}
.apr-layer__box .layer-rayon {
  width: 12px; height: 0;
  border-top: 1.5px solid #13374f;
}
.apr-layer:hover .apr-layer__box { border-color: #13374f; }
.apr-layer input:not(:checked) + .apr-layer__box + .apr-layer__txt { color: #8a96a0; }

.apr-mm__legend {
  display: flex;
  gap: 18px;
  font-size: 12px;
  color: #6b7d8c;
  margin-left: auto;
  flex-wrap: wrap;
}
.apr-mm__legend span { display: inline-flex; align-items: center; gap: 6px; }
.apr-mm__legend .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.apr-mm__legend .dot-blue { background: #13374f; }
.apr-mm__legend .dot-gray { background: #c4cdd5; }
.apr-mm__legend .dot-line { width: 14px; height: 0; border-top: 1.5px solid #13374f; border-radius: 0; }

/* ---------- Body ---------- */
.apr-mm__body {
  position: relative;
  flex: 1;
  overflow: hidden;
}
.apr-mm__map {
  position: absolute;
  inset: 0;
  background: #eef2f5;
}
.apr-mm__error {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #8a96a0;
  font-size: 14px;
  padding: 24px;
  text-align: center;
}

/* ---------- Sticky-bar внизу ---------- */
.apr-mm__sticky {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 8px 28px rgba(20, 28, 36, 0.18), 0 0 0 1px rgba(20, 28, 36, 0.06);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 500;
  transition: padding 0.2s ease;
}
.apr-mm__sticky[data-empty="1"] { background: rgba(255,255,255,0.92); }
.apr-mm__sticky[data-empty="1"] .sel-filled { display: none; }
.apr-mm__sticky[data-empty="0"] .sel-empty  { display: none; }
.apr-mm__sticky[data-empty="0"] {
  border-top: 3px solid #13374f;
  padding-top: 9px;
}

.apr-mm__sel { flex: 1; font-size: 14px; color: #1a2b3a; }
.apr-mm__sel .sel-empty { color: #6b7d8c; font-size: 13px; }
.apr-mm__sel .sel-filled strong {
  color: #13374f;
  font-size: 16px;
  font-weight: 700;
  margin: 0 2px;
}
.apr-mm__sel .dot-sep { color: #c4cdd5; margin: 0 6px; }

.apr-mm__sel-actions { display: flex; gap: 8px; }
.apr-mm__sel-actions .btn-ghost {
  background: transparent;
  border: 1px solid #d6dde3;
  color: #6b7d8c;
  padding: 9px 16px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}
.apr-mm__sel-actions .btn-ghost:hover { color: #13374f; border-color: #13374f; }
.apr-mm__sel-actions .btn-ghost:disabled { opacity: 0.4; cursor: not-allowed; }
.apr-mm__sel-actions .btn-apply {
  background: #6bb547;
  border: 0;
  color: #fff;
  padding: 10px 22px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}
.apr-mm__sel-actions .btn-apply:hover { background: #5da43c; }
.apr-mm__sel-actions .btn-apply:disabled { background: #c4cdd5; cursor: not-allowed; }

/* ---------- Попап ЖК (балун Я.Карт) ---------- */
.apr-zk-pop {
  width: 280px;
  font-family: inherit;
}
.apr-zk-pop__top {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}
.apr-zk-pop__img {
  width: 80px;
  height: 60px;
  border-radius: 4px;
  background: #eef2f5 center/cover no-repeat;
  flex-shrink: 0;
}
.apr-zk-pop__head { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.apr-zk-pop__name {
  font-size: 15px;
  font-weight: 700;
  color: #13374f;
  text-decoration: none;
  line-height: 1.2;
}
.apr-zk-pop__name:hover { text-decoration: underline; }
.apr-zk-pop__meta { font-size: 12px; color: #8a96a0; }
.apr-zk-pop__row {
  font-size: 13px;
  color: #1a2b3a;
  padding: 5px 0;
  border-top: 1px solid #f0f3f5;
}
.apr-zk-pop__cls { color: #6b7d8c; }
.apr-zk-pop__price { font-size: 14px; }
.apr-zk-pop__price b { font-size: 17px; color: #13374f; }
/* Разбивка цен по типам квартир (Студии / 1-2-3-комн «от X млн ₽») */
.apr-zk-pop__rooms {
  border-top: 1px solid #f0f3f5;
  padding: 6px 0 2px;
}
.apr-zk-pop__rmrow {
  display: flex;
  align-items: baseline;
  font-size: 13px;
  line-height: 1.9;
}
.apr-zk-pop__rmlabel { color: #6b7d8c; white-space: nowrap; }
.apr-zk-pop__rmdots {
  flex: 1 1 auto;
  margin: 0 6px;
  border-bottom: 1px dotted #cdd6dd;
  transform: translateY(-3px);
}
.apr-zk-pop__rmprice { color: #1a2b3a; white-space: nowrap; }
.apr-zk-pop__rmprice b { color: #13374f; font-weight: 700; }
.apr-zk-pop__rooms-empty {
  border-top: 1px solid #f0f3f5;
  padding: 6px 0 2px;
  font-size: 12px;
  color: #8a96a0;
}
.apr-zk-pop__match {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #6bb547;
  font-weight: 600;
}
.apr-zk-pop__match b { color: #5da43c; font-size: 14px; }
.apr-zk-pop__cta {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.apr-zk-pop__cta .cta-primary {
  background: #13374f;
  color: #fff;
  border: 0;
  padding: 10px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  border-radius: 4px;
  text-decoration: none;
  cursor: pointer;
}
.apr-zk-pop__cta .cta-primary:hover { background: #1a4761; }
.apr-zk-pop__cta .cta-toggle {
  background: transparent;
  border: 1px solid #d6dde3;
  color: #13374f;
  padding: 9px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
}
.apr-zk-pop__cta .cta-toggle:hover { border-color: #13374f; }
.apr-zk-pop__cta .cta-toggle .remove { display: none; }
.apr-zk-pop__cta .cta-toggle.is-selected { background: #f0f5f9; border-color: #13374f; }
.apr-zk-pop__cta .cta-toggle.is-selected .add { display: none; }
.apr-zk-pop__cta .cta-toggle.is-selected .remove { display: inline; }

/* ---------- Tablet (641–1023px) ---------- */
@media (max-width: 1023px) and (min-width: 641px) {
  .apr-mm__panel { inset: 12px; }
  .apr-mm__legend span:last-child { display: none; }
}

@media (max-width: 1100px) {
  .apr-mm__layers { padding-left: 10px; gap: 10px; }
  .apr-mm__legend { display: none; }
}

/* ---------- Mobile (≤640px) ---------- */
@media (max-width: 640px) {
  .apr-mm__panel { inset: 0; border-radius: 0; }
  .apr-mm__head { flex-wrap: wrap; gap: 8px; padding: 12px 14px; }
  .apr-mm__chips { width: 100%; order: 3; }
  .apr-mm__close { order: 2; }
  .apr-mm__t2 { display: none; }
  .apr-mm__toolbar { padding: 10px 14px; gap: 10px; flex-wrap: wrap; }
  .apr-mm__layers { padding-left: 0; border-left: 0; margin-left: 0; }
  .apr-mm__legend { display: none; }
  .apr-mm__sticky {
    left: 8px; right: 8px; bottom: 8px;
    padding: 10px 12px;
    flex-wrap: wrap;
    gap: 10px;
  }
  .apr-mm__sel { flex-basis: 100%; }
  .apr-mm__sel-actions { width: 100%; }
  .apr-mm__sel-actions .btn-ghost,
  .apr-mm__sel-actions .btn-apply { flex: 1; }
  .apr-zk-pop { width: 240px; }
}

/* ===== Кастомный пин ЖК из правого списка (inCatalog) с pulse-эффектом ===== */
.apr-cat-pin {
  position: relative;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px; /* центр иконки = координата ЖК */
  pointer-events: auto;
}
.apr-cat-pin__dot {
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: #6bb547;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(19,55,79,.32), 0 0 0 1px rgba(19,55,79,.12);
  z-index: 2;
}
.apr-cat-pin__pulse {
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: #6bb547;
  opacity: 0;
  transform: scale(1);
  z-index: 1;
  pointer-events: none;
}
/* ymaps оборачивает шаблон в <ymaps class="is-pulsing">…</ymaps> — селекторы строим оттуда. */
/* Активный/наведённый пин: волны + красный цвет (приоритет фокуса над зелёным базовым). */
.is-pulsing .apr-cat-pin__pulse {
  background: #e23939;
  animation: apr-cat-pulse 1.6s ease-out infinite;
}
.is-pulsing .apr-cat-pin__pulse--2 {
  animation-delay: .55s;
}
.is-pulsing .apr-cat-pin__dot {
  background: #e23939;
  box-shadow: 0 2px 12px rgba(226,57,57,.55), 0 0 0 2px #fff, 0 0 0 4px rgba(226,57,57,.35);
  transform: scale(1.1);
  transition: transform .2s, box-shadow .2s, background .2s;
  z-index: 3;
}
@keyframes apr-cat-pulse {
  0%   { transform: scale(.8); opacity: .55; }
  80%  { opacity: 0; }
  100% { transform: scale(3.6); opacity: 0; }
}

/* ===== Маркер ЖК: светлое ядро + «бегущий» по контуру градиент =====
   Заменяет полое тёмное кольцо ymaps circleIcon (выглядело «закрыто/траурно»). */
.apr-zk-pin { position: absolute; }
.apr-zk-pin__core {
  position: absolute;
  left: calc(var(--apr-sz, 24px) / -2);
  top:  calc(var(--apr-sz, 24px) / -2);
  width:  var(--apr-sz, 24px);
  height: var(--apr-sz, 24px);
  border-radius: 50%;
  background: var(--apr-c, #17b7bf);
  border: 2.5px solid #fff;
  box-shadow: 0 2px 6px rgba(19,55,79,.35), 0 0 0 1px rgba(19,55,79,.10);
  box-sizing: border-box;
  z-index: 2;
  transition: transform .15s ease;
}
/* Кольцо чуть больше ядра — из-под ядра виден вращающийся цветной ободок («бегущий» контур). */
.apr-zk-pin__ring {
  position: absolute;
  left: calc(var(--apr-sz, 24px) / -2 - 3px);
  top:  calc(var(--apr-sz, 24px) / -2 - 3px);
  width:  calc(var(--apr-sz, 24px) + 6px);
  height: calc(var(--apr-sz, 24px) + 6px);
  border-radius: 50%;
  background: conic-gradient(from 0deg, #17b7bf, #6bb547, #b6f09c, #17b7bf, #6bb547, #17b7bf);
  box-shadow: 0 2px 6px rgba(19,55,79,.30);
  z-index: 1;
  animation: apr-pin-spin 3s linear infinite;
}
.apr-zk-pin:hover .apr-zk-pin__core { transform: scale(1.12); }
.apr-zk-pin:hover .apr-zk-pin__ring { animation-duration: 1.1s; }
/* Подсветка пина при наведении на карточку ЖК в списке справа (pulsePlacemark). */
.apr-zk-pin.is-pulsing .apr-zk-pin__core {
  transform: scale(1.28);
  box-shadow: 0 0 0 3px rgba(23,183,191,.40), 0 3px 12px rgba(19,55,79,.50);
}
.apr-zk-pin.is-pulsing .apr-zk-pin__ring { animation-duration: .9s; }
@keyframes apr-pin-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .apr-zk-pin__ring { animation: none; }
}
