/* Карта, метки, масштаб, режимы и выбор точки. */

/* Область карты и её размер на странице. */
.maparea {
  flex: 1;
  position: relative;
  min-width: 0;
  background: var(--soft);

  @media (max-width: 760px) {
    width: 100%;
    flex: none;
    height: 54%;
  }

  :where([data-layout="mobile"]) & {
    position: absolute !important;
    inset: 0 !important;
    height: 100% !important;
    width: 100%;
  }
}

#canvas {
  position: absolute;
  inset: 0;
}

/* Элементы управления в верхней части карты. */
.maptop {
  position: absolute;
  top: 20px;
  left: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  pointer-events: none;
  justify-content: flex-end;

  @media (max-width: 760px) {
    top: 12px;
    left: 13px;
    right: 13px;
  }

  @media (min-width: 761px) {
    justify-content: space-between;
    gap: 15px;
  }

  :where([data-layout="mobile"]) & {
    left: 14px !important;
    right: 14px !important;
    justify-content: space-between;
    gap: 8px;
    top: calc(58px + env(safe-area-inset-top)) !important;
  }
}

.maptop > * {
  pointer-events: auto;
}

.location {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 9px 14px;
  font-size: 11px;

  @media (max-width: 760px) {
    font-size: 10px;
    padding: 7px 10px;
  }
}

.mode {
  display: flex;
  align-items: center;
  background: var(--panel);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--line);
  gap: 2px;

  @media (max-width: 760px) {
    padding: 3px;
  }

  :where([data-layout="mobile"]) & {
    padding: 3px;
    gap: 0;
  }
}

/* Кнопки увеличения и уменьшения масштаба карты. */
#zoomIn, #zoomOut {
  display: grid;
  place-items: center;
  width: auto;
  height: 28px;
  min-width: 0;
  min-height: 0;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font-size: 16px;
  font-weight: 700;

  :where([data-layout="mobile"]) & {
    width: 44px;
    height: 44px;
    padding: 1px 6px;
    border-radius: 0;
    font-size: 20px;
    font-weight: 400;
  }

  &#zoomOut {
    :where([data-layout="mobile"]) & {
      border-top: 1px solid var(--line);
    }
  }
  :where([data-layout="desktop"] body.dark) &:not([aria-pressed="true"]) {
    color: #ededed;
  }
}

/* Переключатель режимов 2D и 3D. */
#mode2d, #mode3d {
  display: block;
  width: auto;
  height: auto;
  min-width: 0;
  min-height: 0;
  padding: 9px 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font-size: 13px;
  font-weight: 700;

  :where([data-layout="mobile"]) & {
    display: grid;
    place-items: center;
    width: 44px;
    height: 36px;
    padding: 1px 6px;
    border-radius: 0;
    font-size: 12px;
    background: var(--panel);
    color: var(--ink);
  }

  &[aria-pressed="true"] {
    background: var(--accent);
    color: var(--onaccent);

    :where([data-layout="mobile"]) & {
      font-weight: 800;
    }
  }

  &#mode3d {
    :where([data-layout="mobile"]) & {
      border-left: 1px solid var(--line);
    }
  }
  :where([data-layout="desktop"] body.dark) &:not([aria-pressed="true"]) {
    color: #ededed;
  }
}

.mode .divider {
  width: 1px;
  height: 18px;
  background: var(--line);
  margin: 0 6px;

  :where([data-layout="mobile"]) & {
    margin: 0 2px;
  }
}

/* Метки мест на карте. */
.pin {
  padding: 0;
  width: 32px;
  height: 39px;
  border-radius: 16px 16px 16px 4px;
  background: var(--accent);
  color: #102110;
  border: 3px solid #173624;
  box-shadow: 0 3px 12px #0003;
  font-size: 16px;
  display: grid;
  place-items: center;

  @media (max-width: 760px) {
    width: 36px;
    height: 42px;
    font-size: 18px;
  }
}

.locationfield {
  background: var(--soft);
  border-radius: 12px;
  padding: 12px;
  margin-top: 16px;
  font-size: 11px;
  display: flex;
  gap: 10px;
  align-items: center;
}

.locationfield button {
  margin-left: auto;
  text-decoration: underline;
  font-size: 10px;
  flex-shrink: 0;

  @media (max-width: 760px) {
    min-height: 40px;
    font-size: 11px;
  }
}

/* Сообщение об ошибке загрузки карты. */
.maperror {
  position: absolute;
  left: 20px;
  top: 80px;
  background: var(--panel);
  padding: 12px;
  border-radius: 10px;
  max-width: 290px;
  font-size: 12px;
  box-shadow: 0 3px 20px #0002;

  @media (max-width: 760px) {
    left: 13px;
    font-size: 11px;
    max-width: 245px;
    top: 74px;
  }

  @media (min-width: 761px) {
    top: 130px;
  }

  :where([data-layout="mobile"]) & {
    max-width: calc(100vw - 40px);
    top: calc(108px + env(safe-area-inset-top)) !important;
  }
}

.maplibregl-ctrl-attrib {
  display: none !important;
}

/* Сообщение об отсутствии результатов. */
.noresults {
  position: absolute;
  left: 20px;
  background: var(--panel);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 11px;
  top: 76px;

  @media (max-width: 760px) {
    left: 13px;
    top: 74px;
    max-width: 250px;
  }

  @media (min-width: 761px) {
    top: 130px;
  }

  :where([data-layout="mobile"]) & {
    max-width: calc(100vw - 40px);
    top: calc(108px + env(safe-area-inset-top)) !important;
  }
}

.maparea.selecting {

  @media (max-width: 760px) {
    z-index: 15;
    height: 100%;
  }
}

.pin.stale {
  background: var(--panel);
  color: var(--muted);
  border-color: var(--pin-cast, var(--muted));
}

/* Кнопка возврата к карте города. */
.backcity {
  position: absolute;
  top: 20px;
  left: 20px;
  border-radius: 12px;
  padding: 11px 15px;
  min-height: 44px;
  background: var(--accent);
  color: var(--onaccent);
  font-size: 11px;
  font-weight: 650;
  box-shadow: 0 4px 20px #0002;

  @media (max-width: 760px) {
    left: 12px;
    top: 13px;
    font-size: 10px;
    max-width: 200px;
    padding: 9px 12px;
  }

  @media (min-width: 761px) {
    top: 76px;
    font-size: 12px;
  }

  :where([data-layout="mobile"]) & {
    left: 50% !important;
    right: auto !important;
    top: calc(66px + env(safe-area-inset-top)) !important;
    bottom: auto !important;
    transform: translateX(-50%);
    max-width: calc(100% - 24px);
    white-space: nowrap;
  }
}

.backcity:hover {
  filter: brightness(1.08);
}

.pin.dragarmed {
  box-shadow: 0 0 0 2px var(--accent),
    0 5px 20px #0004;
  cursor: grabbing !important;
  outline: 4px solid var(--accent-soft);
}

.pin.dragging {
  cursor: grabbing !important;
  outline: 4px solid var(--accent-soft);
}

.pin[title] {
  -webkit-user-select: none;
}

.globalPin {
  pointer-events: none;
}

.viewSwitch {
  display: flex;
  gap: 4px;
  background: var(--soft);
  border-radius: 10px;
  padding: 4px;
  margin-top: 13px;

  @media (max-width: 760px) {
    margin-top: 9px;
  }

  @media (min-width: 761px) {
    margin-top: 0;
  }
}

.viewSwitch button {
  flex: 1;
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 650;

  @media (max-width: 760px) {
    min-height: 40px;
  }

  @media (min-width: 761px) {
    min-height: 41px;
    font-size: 14px;
  }

  :where([data-layout="mobile"]) & {
    min-height: 42px;
    font-size: 13px;
  }
}

.viewSwitch button.active {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 1px 6px #0001;
}

.pin:not(.stale) {
  background: var(--pin-cast, var(--accent));
}

/* Всплывающее окно при нажатии на карту. */
.maplibregl-popup-content {
  background: var(--panel);
  color: var(--ink);
  padding: 15px 40px 15px 15px;
  border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow: 0 6px 25px #0003;
}

.maplibregl-popup-close-button {
  width: 36px;
  height: 36px;
  color: var(--muted);
  font-size: 22px;
  border-radius: 10px;
  right: 2px;
  top: 2px;

  @media (max-width: 760px) {
    width: 38px;
    height: 38px;
  }
}

.maplibregl-popup-close-button:hover {
  background: var(--soft);
}

.maplibregl-popup-anchor-bottom .maplibregl-popup-tip {
  border-top-color: var(--panel);
}

.maplibregl-popup-anchor-top .maplibregl-popup-tip {
  border-bottom-color: var(--panel);
}

.maplibregl-popup-anchor-left .maplibregl-popup-tip {
  border-right-color: var(--panel);
}

.maplibregl-popup-anchor-right .maplibregl-popup-tip {
  border-left-color: var(--panel);
}

.mapClickAction .primary {
  min-height: 44px;
  font-size: 12px;
  padding: 10px 12px;
  white-space: nowrap;

  @media (max-width: 760px) {
    min-height: 46px;
  }
}

/* Обозначения цветов на карте. */
.maplegend {
  position: absolute;
  bottom: 35px;
  left: 15px;
  display: flex;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 7px 11px;
  border-radius: 10px;
  box-shadow: 0 2px 12px #0001;
  font-size: 10px;
  color: var(--muted);
  pointer-events: none;

  @media (max-width: 760px) {
    left: 12px;
    bottom: 34px;
    padding: 6px 8px;
    font-size: 9px;
    gap: 9px;
  }

  @media (min-width: 761px) {
    font-size: 11px;
  }

  :where([data-layout="mobile"]) & {
    display: none !important;
  }
}

.maplegend span {
  display: flex;
  gap: 5px;
  align-items: center;
}

.maplegend i {
  width: 9px;
  height: 9px;
  display: inline-block;
  border-radius: 3px;
}

.legendpark {
  background: #b1cea3;
}

.legendwater {
  background: #a2d3ed;
}

.mapNaturalDark .legendpark {
  background: #477351;
}

.mapNaturalDark .legendwater {
  background: #397498;
}

.selecting .maplegend {
  display: none;
}

/* Кнопки управления картой на компьютере. */
.desktopMapActions {

  @media (min-width: 761px) {
    display: flex;
    align-items: center;
    gap: 14px;
    pointer-events: auto;
  }
}

#locateDesktop {
  @media (min-width: 761px) {
    padding: 10px 14px;
    min-height: 43px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    font-size: 13px;
  }

  :where([data-layout="mobile"]) & {
    min-height: 0;
    width: 44px;
    height: 44px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    font-size: 0;
    box-shadow: 0 4px 18px #0002;
    position: absolute;
    right: 12px;
    bottom: 0;
    pointer-events: auto;
    display: grid !important;
    place-items: center !important;
    padding: 0 !important;
    color: transparent !important;
  }

  /* Значок геопозиции внутри мобильной кнопки. */
  :where([data-layout="mobile"]) &::before {
    font-size: 21px;
    line-height: 1;
    content: "" !important;
    position: absolute;
    left: 50%;
    top: 50%;
    width: 27px;
    height: 27px;
    transform: translate(-50%, -50%) translateY(1px);
    background: var(--ink);
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='7'/%3E%3Cpath d='M12 2v4m0 12v4M2 12h4m12 0h4'/%3E%3C/g%3E%3Ccircle cx='12' cy='12' r='2.5'/%3E%3C/svg%3E")
      center/contain no-repeat;
  }

  :where(body.dark) & {
    :where([data-layout="mobile"]) & {
      background: #1a1a1a;
    }
  }
}

.desktopMapActions span {

  @media (min-width: 761px) {
    font-size: 12px;
    padding: 6px 10px;
    color: var(--muted);
    background: var(--panel);
    border-radius: 8px;
  }

  @media (min-width: 761px) and (max-width: 1320px) {
    display: none;
  }
}

.pin.dragarmed:after {
  content: "Перетащите";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 9px);
  transform: translateX(-50%);
  padding: 6px 10px;
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 3px 15px #0003;
  display: none !important;
}

.pin.dragging:after {
  content: "Отпустите, чтобы сохранить";
  display: none !important;
}

body.dark .viewSwitch {
  background: #262626;
}

body.dark .maplegend {
  background: #1a1a1a;
}

body.dark .legendpark {
  background: #353535;
}

body.dark .legendwater {
  background: #727272;
}

body.dark .pin {
  border-color: #151515;
}

body.dark .desktopMapActions span {
  color: #d0d0d0;
}

.maparea .maplibregl-canvas {

  @media (min-width: 761px) {
    opacity: 1;
  }
}

/* Настройки отображения карты и окраски по высоте. */
.mapAppearance {
  position: absolute;
  bottom: 72px;
  left: 16px;
  z-index: 4;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 9px 12px;
  box-shadow: 0 4px 22px #0002;
  width: auto;
  min-width: 190px;
  box-sizing: border-box;

  @media (max-width: 760px) {
    left: 12px;
    bottom: 62px;
    min-width: 160px;
    padding: 7px 10px;
  }

  :where([data-layout="mobile"]) & {
    display: none !important;
  }
}

.mapAppearance .heightColorToggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  margin: 0;
  padding: 0;
  border-top: none;
  font-size: 12px;
  font-weight: 550;
  white-space: nowrap;

  @media (max-width: 760px) {
    font-size: 11px;
    gap: 8px;
  }
}

.mapAppearance .heightRamp {
  height: 8px;
  flex: 1;
  min-width: 40px;
  border-radius: 5px;
  background: linear-gradient(90deg, #647c8e, var(--accent));
  transition: opacity 0.2s;
}

.mapAppearance .heightOff .heightRamp {
  opacity: 0.25;
  filter: grayscale(1);
}

.mapAppearance .heightColorToggle input {
  appearance: none !important;
  position: relative;
  width: 32px !important;
  height: 19px !important;
  min-height: 19px !important;
  flex-shrink: 0;
  margin: 0 !important;
  padding: 0 !important;
  border: 1px solid var(--line);
  background: var(--soft);
  border-radius: 20px;
  cursor: pointer;

  @media (max-width: 760px) {
    width: 28px !important;
    height: 17px !important;
    min-height: 17px !important;
  }
}

.mapAppearance .heightColorToggle input:after {
  content: "";
  position: absolute;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  background: var(--muted);
  transition: left 0.15s;

  @media (max-width: 760px) {
    width: 11px;
    height: 11px;
  }
}

.mapAppearance .heightColorToggle input:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.mapAppearance .heightColorToggle input:checked:after {
  left: 15px;
  background: #202020;

  @media (max-width: 760px) {
    left: 13px;
  }
}

body.dark .mapAppearance {
  background: #1a1a1a;
}

/* Расположение дополнительных кнопок на карте. */
.maptools {
  position: absolute;
  bottom: 45px;
  right: 16px;
  left: auto;
  display: flex;
  flex-direction: row;
  gap: 7px;
  z-index: 4;

  @media (max-width: 760px) {
    right: 12px;
    bottom: 40px;
    gap: 5px;
  }

  :where([data-layout="mobile"]) & {
    bottom: calc(92px + env(safe-area-inset-bottom)) !important;
    right: 14px !important;
  }
}

.maptools button {
  height: 38px;
  width: 38px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 11px;
  font-size: 20px;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 22px #0002;

  @media (max-width: 760px) {
    height: 36px;
    width: 36px;
    border-radius: 9px;
    font-size: 18px;
  }

  :where([data-layout="mobile"]) & {
    height: 44px !important;
    width: 44px !important;
  }
}

body.dark .maptools button {
  background: #1a1a1a;
}

.selecting .maptools {
  display: none !important;
}

.selecting .mapAppearance {
  display: none !important;
}

/* Кнопки масштаба и режимов карты на телефоне. */
.mobileZoom {
  display: none;

  :where([data-layout="mobile"]) & {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    position: fixed;
    z-index: 20;
    left: 0 !important;
    right: 0 !important;
    height: 142px;
    display: block !important;
    pointer-events: none;
    bottom: var(--mobile-controls-bottom, calc(160px + env(safe-area-inset-bottom))) !important;
  }
}

/* Отметка текущего местоположения пользователя. */
.userLocation {
  width: 20px;
  height: 20px;
  border: 3px solid white;
  border-radius: 50%;
  background: #2979ef;
  box-shadow: 0 0 0 9px #2979ef33, 0 1px 8px #0004;
}

.userLocation span {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 700;
  box-shadow: 0 2px 8px #0003;
}

/* Общая метка с количеством мест, расположенных рядом. */
.placeCluster {
  display: grid;
  place-items: center;
  min-width: 44px;
  height: 44px;
  padding: 0 10px;
  border: 3px solid var(--panel);
  border-radius: 50%;
  background: var(--accent);
  color: var(--onaccent);
  box-shadow: 0 0 0 7px color-mix(in srgb, var(--accent) 20%, transparent), 0 3px 12px #0004;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}

.placeCluster:hover {
  box-shadow: 0 0 0 9px color-mix(in srgb, var(--accent) 28%, transparent), 0 3px 12px #0004;
}

body.routing .placeCluster {
  visibility: hidden;
}

.mode #providerBtn {
  font-size: 10px;
  padding: 7px 9px;
}

.maplibregl-ctrl-bottom-right {

  :where([data-layout="mobile"]) & {
    bottom: calc(78px + env(safe-area-inset-bottom)) !important;
  }
}

.maptop .mode {

  :where([data-layout="mobile"]) & {
    display: none !important;
  }
}

.maptop .desktopMapActions {

  :where([data-layout="mobile"]) & {
    display: none !important;
  }
}

.mobileZoom .mzGroup {

  :where([data-layout="mobile"]) & {
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 18px #0002;
  }
}

.mobileZoom .mzModes {

  :where([data-layout="mobile"]) & {
    flex-direction: row;
    position: absolute;
    left: 12px;
    bottom: 0;
    pointer-events: auto;
  }
}

body.dark .mobileZoom .mzGroup {

  :where([data-layout="mobile"]) & {
    background: #1a1a1a;
  }
}

body.mobile-list .mobileZoom {

  :where([data-layout="mobile"]) & {
    display: none !important;
  }
}

body:has(.selecting) .mobileZoom {

  :where([data-layout="mobile"]) & {
    display: none !important;
  }
}

.mobileZoom .mzZoom {

  :where([data-layout="mobile"]) & {
    position: absolute;
    right: 12px;
    bottom: 52px;
    pointer-events: auto;
  }
}

body.mobile-controls-hidden .mobileZoom {

  :where([data-layout="mobile"]) & {
    display: none !important;
  }
}
