/* ---------- Карта проекта ---------- */

.mapview {
  padding: clamp(32px, 5vw, 64px) 0 var(--section-gap);
}

.map-head {
  max-width: 48rem;
}

.map-head h1 {
  margin: 0;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.12;
  font-size: clamp(1.9rem, 3.6vw, 3rem);
}

.map-note {
  margin-top: 14px;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.65;
}

/* ---------- Панель управления ---------- */

.map-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 18px;
  margin-top: clamp(24px, 3vw, 38px);
}

.map-crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-weight: 800;
}

.map-crumbs button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--blue);
  font: inherit;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.map-crumbs button:hover {
  border-bottom-color: var(--gold);
}

.map-crumbs span[aria-current] {
  color: var(--ink);
}

.map-crumbs i {
  color: var(--muted);
  font-style: normal;
}

.map-search {
  position: relative;
  margin-left: auto;
}

.map-search input {
  width: min(280px, 60vw);
  min-height: 44px;
  padding: 0 16px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: inherit;
  font: inherit;
}

.map-search input:focus-visible {
  outline: none;
  border-color: var(--blue);
}

.map-suggest {
  position: absolute;
  z-index: 6;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow-y: auto;
  padding: 6px;
  margin: 0;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow);
}

.map-suggest:empty,
.map-suggest[hidden] {
  display: none;
}

.map-suggest button {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.map-suggest button:hover,
.map-suggest button:focus-visible {
  outline: none;
  background: color-mix(in srgb, var(--blue) 10%, #fff);
}

.map-suggest small {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.map-zoom {
  display: flex;
  gap: 6px;
}

.map-zoom button {
  width: 44px;
  height: 44px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--blue-deep);
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
}

.map-zoom button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

/* ---------- Легенда ---------- */

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  padding: 0;
  margin: 18px 0 0;
  list-style: none;
}

.map-legend li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 13px 6px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--tone) 12%, #fff);
  color: var(--blue-deep);
  font-size: 0.82rem;
  font-weight: 800;
}

.map-legend i {
  width: 13px;
  height: 13px;
  border-radius: 4px;
  background: var(--tone);
}

/* ---------- Полотно ---------- */

.map-stage {
  position: relative;
  width: 100vw;
  margin: clamp(16px, 2vw, 28px) 0 0 calc(50% - 50vw);
  overflow: hidden;
  touch-action: pan-y;
  isolation: isolate;
}

.map-canvas {
  display: block;
  width: 100%;
  height: auto;
  cursor: grab;
  overflow: visible;
  -webkit-tap-highlight-color: transparent;
}

.map-canvas.is-panning {
  cursor: grabbing;
}

/* Никаких прямоугольников вокруг bbox: Chrome рисует outline у SVG-групп. */
.map-canvas,
.map-canvas:focus,
.map-canvas:focus-visible,
.map-canvas *:focus,
.map-canvas *:focus-visible,
.map-canvas *:hover,
.map-canvas *:active {
  outline: none !important;
  box-shadow: none !important;
}

.ms {
  cursor: pointer;
  outline: none !important;
  -webkit-tap-highlight-color: transparent;
}

.ms-glow {
  fill: none;
  stroke: var(--tone);
  stroke-width: 0;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
  transition: stroke-width 0.18s ease, opacity 0.18s ease;
}

.ms-fill {
  fill: color-mix(in srgb, var(--tone) 16%, #fff);
  transition: fill 0.2s ease;
}

.ms-hatch {
  fill: var(--hatch);
  pointer-events: none;
}

.ms-line {
  fill: none;
  stroke: var(--tone);
  stroke-width: 1.15;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
  transition: stroke-width 0.18s ease, stroke 0.18s ease;
}

.ms:hover .ms-glow,
.ms.is-hot .ms-glow,
.ms.is-open .ms-glow,
.ms--mun.is-picked .ms-glow {
  opacity: 0.38;
  stroke-width: 7;
}

.ms:hover .ms-fill,
.ms.is-hot .ms-fill {
  fill: color-mix(in srgb, var(--tone) 38%, #fff);
}

.ms:hover .ms-line,
.ms.is-hot .ms-line,
.ms.is-open .ms-line,
.ms--mun.is-picked .ms-line {
  stroke-width: 2.6;
  stroke: color-mix(in srgb, var(--tone) 55%, #1c1c1c);
}

.ms-label {
  fill: color-mix(in srgb, var(--tone) 72%, #1c1c1c);
  font-family: "Caveat", "Nunito", cursive;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: middle;
  stroke: none;
  pointer-events: none;
  user-select: none;
  display: none;
}

.ms.is-label-on > .ms-label {
  display: block;
}

.ms-deeds {
  pointer-events: none;
  display: none;
}

.ms-deeds.is-on {
  display: block;
}

.ms-deeds-heart {
  fill: var(--gold);
  stroke: #fff;
  stroke-width: 1.6;
  paint-order: stroke fill;
}

.ms-deeds-count {
  fill: color-mix(in srgb, var(--tone) 62%, #1c1c1c);
  font-family: "Nunito", sans-serif;
  font-weight: 800;
  stroke: #fff;
  stroke-width: 0.7;
  paint-order: stroke fill;
  dominant-baseline: middle;
}

.ms.is-dimmed {
  pointer-events: none;
  opacity: 0.14;
  transition: opacity 0.35s ease;
}

.ms.is-open .ms-fill {
  fill: color-mix(in srgb, var(--tone) 8%, #fff);
}

.ms.is-open .ms-hatch,
.map-canvas.is-zoomed .ms--region .ms-hatch {
  display: none;
}

.ms--mun .ms-fill {
  fill: color-mix(in srgb, var(--tone) 18%, #fff);
}

.ms--mun:hover .ms-fill,
.ms--mun.is-hot .ms-fill,
.ms--mun.is-picked .ms-fill {
  fill: color-mix(in srgb, var(--tone) 40%, #fff);
}

.ms--mun .ms-line {
  stroke-width: 1.2;
}

.ms--mun:hover .ms-line,
.ms--mun.is-hot .ms-line,
.ms--mun.is-picked .ms-line {
  stroke-width: 2.4;
}

.ms--district .ms-fill {
  fill: color-mix(in srgb, var(--tone) 26%, #fff);
}

.ms--district:hover .ms-fill,
.ms--district.is-hot .ms-fill,
.ms--district.is-picked .ms-fill {
  fill: color-mix(in srgb, var(--tone) 48%, #fff);
}

.ms--district .ms-line {
  stroke-width: 2;
  stroke: color-mix(in srgb, var(--tone) 70%, #1c1c1c);
}

.ms--district:hover .ms-line,
.ms--district.is-hot .ms-line,
.ms--district.is-picked .ms-line {
  stroke-width: 3;
}

.ms--district .ms-label {
  fill: color-mix(in srgb, var(--tone) 78%, #1c1c1c);
}

.ms--district.is-picked .ms-glow {
  opacity: 0.42;
  stroke-width: 8;
}

/* ---------- Плавающая карточка справа ---------- */

.map-panel {
  position: absolute;
  top: clamp(20px, 3.5vw, 36px);
  right: clamp(18px, 3.2vw, 40px);
  z-index: 4;
  width: min(320px, calc(100% - 48px));
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 22px 22px 20px;
  border: 1px solid color-mix(in srgb, var(--tone, var(--line)) 22%, var(--line));
  border-radius: 22px;
  background: color-mix(in srgb, #fff 92%, var(--tone, #fff) 8%);
  box-shadow:
    0 18px 40px color-mix(in srgb, #1c1c1c 10%, transparent),
    0 2px 0 color-mix(in srgb, #fff 70%, transparent) inset;
  backdrop-filter: blur(10px);
  pointer-events: auto;
}

.map-panel[hidden] {
  display: none;
}

.map-panel h2 {
  margin: 0;
  font-size: clamp(1.15rem, 2vw, 1.45rem);
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.map-panel-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.map-panel-meta li {
  padding: 6px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--tone) 14%, #fff);
  color: var(--blue-deep);
  font-size: 0.8rem;
  font-weight: 800;
}

.map-panel-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.map-panel-stats {
  display: grid;
  gap: 10px;
  margin: 2px 0;
}

.map-panel-stat {
  margin: 0;
  font-size: 1.02rem;
  color: var(--blue-deep);
}

.map-panel-stat strong {
  font-size: 1.32rem;
  font-weight: 800;
  color: var(--tone, var(--blue));
  margin-right: 4px;
}

.map-panel-stat--muted {
  color: var(--muted);
  font-size: 0.92rem;
}

.map-panel-stat--muted strong {
  font-size: 1.05rem;
  color: var(--muted);
}

.map-panel-empty {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  margin: 0;
  padding: 14px 14px 13px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--tone, var(--gold)) 10%, #fff);
  color: var(--blue-deep);
  font-size: 0.9rem;
  line-height: 1.5;
}

.map-panel-empty-face {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--tone, var(--gold)) 22%, #fff);
  font-size: 1.25rem;
  line-height: 1;
}

.map-panel-empty p {
  margin: 0;
}

.map-panel-list {
  margin: 0;
  padding: 0 0 0 1.1rem;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
  max-height: 9.5rem;
  overflow: auto;
}

.map-panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}

.map-panel-actions .button,
.map-panel-actions .button--ghost {
  min-height: 42px;
  padding-inline: 14px;
  font-size: 0.9rem;
}

/* ---------- Мобильные ---------- */

@media (max-width: 720px) {
  .map-search {
    margin-left: 0;
    width: 100%;
  }

  .map-search input {
    width: 100%;
  }

  .ms--region > .ms-label {
    display: none;
  }

  .map-panel {
    top: auto;
    bottom: 14px;
    right: 12px;
    left: 12px;
    width: auto;
    max-height: min(42vh, 320px);
    overflow: auto;
    border-radius: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ms-fill,
  .ms-line,
  .ms-glow,
  .ms.is-dimmed {
    transition: none;
  }
}
