/* ============================================================================
   Секция "Карта фулфилментов" (map)
   ============================================================================ */

.map {
  /* Секция закрепляется при скролле, и под ней проезжает предыдущий
     контент — фон обязан быть непрозрачным, иначе он просвечивает. */
  background: var(--bg-main);

  display: flex;
  flex-direction: column;
  gap: var(--space-max);
  align-items: center;
  width: min(1652px, 100% - 2 * var(--page-gutter));
  max-width: 1652px;
  margin-inline: auto;
}

/* --- Заголовок секции ---------------------------------------------------- */

.map__header {
  display: flex;
  flex-direction: column;
  gap: var(--space-m);
  align-items: center;
  text-align: center;
  width: 1136px;
  margin-inline: auto;
}

.map__header .t-h2 {
  width: 100%;
}

.map__header .t-lead {
  width: 100%;
}

/* --- Контейнер карты ---------------------------------------------------- */

.map__container {
  position: relative;
  width: 100%;
  height: 724px;
}

/* --- Карточка с картой --------------------------------------------------- */

.map__card {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--bg-dark-primary);
  border-radius: var(--radius-xl);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Градиент-гlow слева на картой */
.map__card-glow {
  position: absolute;
  top: 0;
  left: 0;
  width: 865px;
  height: 724px;
  background: linear-gradient(
    to right,
    rgba(0, 85, 255, 0.08),
    rgba(0, 0, 0, 0)
  );
  pointer-events: none;
  z-index: 1;
}

/* SVG карта России */
.map__russia {
  position: absolute;
  top: -11px;
  left: 145px;
  width: 1364px;
  height: 705.188px;
  z-index: 2;
}

.map__russia image {
  display: block;
  width: 100%;
  height: 100%;
}

/* --- Подпись внизу ------------------------------------------------------- */

.map__hint {
  /* Центр раскладкой, не transform: полупиксельный сдвиг мылит текст. */
  position: absolute;
  bottom: 15px;
  inset-inline: 0;
  margin-inline: auto;
  width: fit-content;
  font-size: 20px;
  line-height: 1.5;
  color: var(--text-constant-light-secondary);
  text-align: center;
  max-width: 895px;
  z-index: 10;
  white-space: normal;
  word-break: break-word;
}

/* --- Города на карте ---------------------------------------------------- */

.map__cities {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
}

/* Отдельный город — цельная плашка с точкой слева и текстом справа */
.map__city {
  position: absolute;
  top: var(--city-top);
  left: var(--city-left);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 25px;
  padding: 4px;
  border-radius: 4.667px;
  font-size: 14px;
  line-height: 1.2;
  letter-spacing: 0.01em;
  white-space: nowrap;
  font-weight: var(--weight-400);
  z-index: 6;
  cursor: pointer;
  backdrop-filter: blur(10px);
}

/* Type A: Solid white (только Москва) */
.map__city--type-a {
  background: var(--text-constant-light);
  color: var(--text-accent);
  border: 1.167px solid rgba(255, 255, 255, 0.3);
}

/* Type B: Light semi-transparent with border */
.map__city--type-b {
  background: rgba(255, 255, 255, 0.17);
  color: var(--text-constant-light);
  border: 1.167px solid rgba(255, 255, 255, 0.3);
}

/* Выбранный город: в макете так нарисована Москва (белая плашка, синий текст).
   Отдельный класс, чтобы выбор переключался JS без подмены type-* классов. */
.map__city.is-selected {
  background: var(--text-constant-light);
  color: var(--text-accent);
  border: 1.167px solid rgba(255, 255, 255, 0.3);
}

/* Доступные города кликабельны, «скоро» — нет */
.map__city[role="button"] {
  cursor: pointer;
  pointer-events: auto;
}

.map__city[role="button"]:hover:not(.is-selected) {
  background: rgba(255, 255, 255, 0.28);
}

.map__city[role="button"]:focus-visible {
  outline: 2px solid var(--text-constant-light);
  outline-offset: 2px;
}

/* Type C: Dark without border */
.map__city--type-c {
  background: rgba(41, 40, 36, 0.1);
  color: var(--text-constant-light-secondary);
  border: none;
}

/* Точка города — элемент потока внутри плашки.
   В макете это ELLIPSE 10x10 сплошного цвета с тенью
   0 0 4.67 rgba(32,124,255,0.5): у доступных городов синяя #0055ff,
   у «Скоро в MPGO» — тёмная #292824/0.52. Раньше рисовалась
   svg-картинкой, у которой заливка была белой — отсюда белые кружки. */
.map__city-dot {
  position: relative;
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--text-accent);
  /* Обводка из макета: 1.17px белая, внутрь (strokeAlign INSIDE) */
  border: 1.17px solid #ffffff;
  box-sizing: border-box;
  box-shadow: 0 0 4.67px rgba(32, 124, 255, 0.5); /* тень из макета */
}

.map__city--type-c .map__city-dot {
  background: rgba(41, 40, 36, 0.52);
}

/* --- Плашка «Скоро в MPGO» -----------------------------------------------
   В макете нарисована зафиксированной у Новосибирска — это состояние
   наведения. Живьём показываем её по ховеру над любым городом type-c
   (размеры макетные: плашка 130x29, хвостик 16). Центрируем отрицательным
   отступом, а не transform, чтобы текст не мылился.                       */

.map__city--type-c {
  cursor: default;
  pointer-events: auto;
}

.map__city--type-c::after,
.map__city--type-c::before {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.map__city--type-c::after {
  content: 'Скоро в MPGO';
  position: absolute;
  left: 50%;
  margin-left: -65px;
  bottom: calc(100% + 12px);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 130px;
  height: 29px;
  padding: 4px 8px;
  box-sizing: border-box;
  border-radius: 8px;
  background: #ffffff;
  font-size: 16px;
  font-weight: var(--weight-500);
  line-height: 1.3;
  letter-spacing: 0;
  color: #207cff;
  white-space: nowrap;
}

.map__city--type-c::before {
  content: '';
  position: absolute;
  left: 50%;
  margin-left: -8px;
  bottom: calc(100% - 3px);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 16px solid #ffffff;
}

.map__city--type-c:hover {
  z-index: 9; /* тултип должен перекрывать соседние плашки */
}

.map__city--type-c:hover::after,
.map__city--type-c:hover::before {
  opacity: 1;
}

/* Статичная плашка из первой вёрстки (разметки больше нет, правила
   оставлены на случай возврата зафиксированного состояния). */
.map__coming-soon {
  position: absolute;
  width: 130px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  z-index: 7;
}

.map__coming-soon-text {
  width: 130px;
  height: 29px;
  background: #ffffff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1.3;
  font-weight: 500;
  color: #207cff;
  padding: 4px 8px;
  box-sizing: border-box;
}

.map__coming-soon-arrow {
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 16px solid #ffffff;
}

/* --- Тултип справа внизу ----------------------------------------------- */

.map__tooltip {
  position: absolute;
  right: 32px;
  bottom: 32px;
  width: 264px;
  padding: 16px 12px;
  background: rgba(255, 255, 255, 0.17);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  backdrop-filter: blur(10px);
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.map__tooltip-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.map__tooltip-title {
  /* В макете 20px/1.5 (237px в боксе 240px). При 24px строка не влезала. */
  font-size: 20px;
  font-weight: var(--weight-500);
  line-height: 1.5;
  color: var(--text-constant-light);
  margin: 0;
  white-space: nowrap;
}

.map__tooltip-text {
  font-size: var(--scale-00);
  line-height: 1.3;
  color: var(--text-constant-light-secondary);
  margin: 0;
}

.map__tooltip-btn {
  width: 100%;
  font-weight: var(--weight-400);
  letter-spacing: 0.01em;
}

/* --- Боковая карточка Москвы -------------------------------------------- */

.map__sidebar {
  position: absolute;
  top: 32px;
  left: 32px;
  width: 303px;
  padding: 16px;
  background: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  backdrop-filter: blur(10px);
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.map__sidebar-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.map__sidebar-header h3.map__sidebar-title {
  font-size: 20px !important;
  font-weight: var(--weight-500) !important;
  line-height: 1.5 !important;
  color: var(--text-constant-dark);
  margin: 0;
  white-space: nowrap;
  letter-spacing: 0 !important;
}

.map__sidebar-description {
  font-size: var(--scale-00);
  line-height: 1.3;
  color: var(--text-secondary);
  margin: 0;
}

.map__sidebar-chips {
  display: flex;
  flex-direction: row;
  gap: 4px;
  flex-wrap: nowrap;
}

.map__sidebar-btn {
  width: 100%;
  padding: 8px 24px;
  height: 44px;
  border-radius: 12px;
  gap: 4px;
  font-weight: var(--weight-400);
  letter-spacing: 0.01em;
}

/* Планшетный заголовок вне планшета скрыт */
.map__title-tablet { display: none; }

/* ============================================================================
   Промежуточные ширины (1025–1439px) — текучая раскладка
   ============================================================================ */

@media (min-width: 1200px) and (max-width: 1439px) {
  .map__header {
    width: min(1136px, calc(100% - 64px));
    padding-inline: 32px;
  }
}

/* ============================================================================
   Планшет (≤1024) — узел 518:3223. Карта = десктопная, равномерно сжатая:
   слои внутри карточки получают transform translate(-105.3px,-25.5px)
   scale(0.678) (мастшаб полотна 925/1364). Координатная система пилюль
   (.map__cities) фиксируется десктопной 1652x724, иначе проценты поедут.
   Тултип становится белой строкой под картой, сайдбар — справа сверху.
   ============================================================================ */

@media (max-width: 1199px) {
  .map {
    max-width: calc(100% - 64px);
    gap: 24px;
  }

  .map__title-desktop { display: none; }
  .map__title-tablet { display: inline; }

  .map__header {
    width: 100%;
    align-items: flex-start;
    text-align: left;
    gap: 16px;
  }

  .map__header .t-h2 {
    font-size: 40px;
    line-height: 1.1;
    max-width: 520px; /* бокс заголовка в макете 514: перенос на 2 строки */
  }

  .map__header .t-lead {
    font-size: 20px;
    line-height: 1.4;
  }

  .map__container {
    height: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .map__card {
    width: 100%;
    height: 470px;
    flex: 0 0 auto;
    border-radius: 24px;
  }

  /* Слои карты: десктопная геометрия, аффинно сжатая к планшетной.
     transform НЕ масштабирует собственные left/top элемента, поэтому у
     полотна (left:145, top:-11) свой translate: 145+tx=-7, -11+ty=-33. */
  .map__card-glow,
  .map__cities {
    transform-origin: 0 0;
    transform: translate(-105.3px, -25.5px) scale(0.678);
  }

  .map__russia {
    transform-origin: 0 0;
    transform: translate(-152px, -22px) scale(0.678);
  }

  .map__cities {
    width: 1652px;   /* система координат пилюль — десктопная */
    height: 724px;
  }

  .map__russia {
    max-width: none; /* глобальный сброс max-width:100% сжимал полотно до 704 */
  }

  /* Плашки «Скоро в MPGO» на планшете в макете нет */
  .map__coming-soon { display: none; }

  .map__hint {
    font-size: 12px;
    bottom: 17px;
    z-index: 6;
  }

  /* Сайдбар Москвы: 316x164 справа сверху (узел map-sidebar) */
  .map__sidebar {
    top: 17px;
    left: auto;
    right: 11px;
    width: 316px;
    padding: 12px;
    gap: 8px;
    border-radius: 16px;
  }

  .map__sidebar-header h3.map__sidebar-title {
    font-size: 18px !important;
  }

  .map__sidebar-description {
    font-size: 10px;
  }

  .map__sidebar-btn {
    font-size: 14px;
  }

  /* Тултип: белая строка 704x110 под картой (узел map-tooltip) */
  .map__tooltip {
    position: static;
    width: 100%;
    min-height: 110px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px;
    background: #ffffff;
    border: 1px solid var(--border-main-quarteary);
    border-radius: 16px;
    backdrop-filter: none;
  }

  .map__tooltip-title {
    color: var(--text-constant-dark);
    font-size: 20px;
  }

  .map__tooltip-text {
    color: var(--text-secondary);
    font-size: 14px;
  }

  .map__tooltip-btn {
    width: 216px;
    flex-shrink: 0;
    height: 44px;
    border-radius: var(--radius-s);
    font-size: 14px;
    background: var(--text-accent);
    color: var(--text-constant-light);
    border: none;
  }

  .map__tooltip-btn-tail { display: none; }
}

/* ============================================================================
   Временное состояние (просьба заказчика): все города показаны как
   «Скоро в MPGO», карточка выбранного города скрыта. Возврат: снять
   display:none ниже и вернуть в разметке классы type-a/type-b вместе с
   role="button" tabindex="0" у доступных городов.
   ============================================================================ */

.map__sidebar {
  display: none;
}

/* Подпись обещала клик по городу — пока города некликабельны, прячем и её */
.map__hint {
  display: none;
}
