/* ---------------------------------------------------------------------------
   Карта проектов: горизонтальное поле, звёзды, связи, HUD.
   Стиль: чёрный, моноширинный, технический — киберпанк без неона.
--------------------------------------------------------------------------- */

.map-page {
  height: 100dvh;
  overflow: hidden;
  background: #050505;
}

.map {
  position: relative;
  height: 100dvh;
  overflow: hidden;
}

/* ------------------------------- Поле ------------------------------------- */

.map-viewport {
  position: absolute;
  inset: 0;
  overflow-x: auto;
  overflow-y: hidden;
  cursor: grab;
  scrollbar-width: none;
  overscroll-behavior: contain;
}

.map-viewport::-webkit-scrollbar {
  display: none;
}

.map-viewport.is-dragging {
  cursor: grabbing;
}

.map-canvas {
  position: relative;
  width: 3200px;
  height: 100%;
}

.map-stars {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

.map-lines {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  overflow: visible;
}

.map-link {
  fill: none;
  stroke: rgba(255, 255, 255, 0.16);
  stroke-width: 1;
  stroke-dasharray: 2 7;
}

.map-link--cluster {
  stroke: rgba(255, 255, 255, 0.22);
  stroke-dasharray: 1 5;
}

.map-link--active {
  stroke: rgba(242, 242, 240, 0.5);
}

/* ------------------------------- Узлы ------------------------------------- */

.map-nodes {
  position: absolute;
  inset: 0;
}

.map-node {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
  transition: transform 0.4s var(--ease);
}

.map-node:hover,
.map-node:focus-visible {
  transform: translate(-50%, -50%) scale(1.06);
  outline: none;
}

.map-node-media {
  display: block;
  position: relative;
  flex: none;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: #0a0a0a;
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.02);
  transition: border-color 0.3s var(--ease), box-shadow 0.4s var(--ease);
}

.map-node img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0.86;
  filter: grayscale(0.5) contrast(1.05);
  transition: opacity 0.3s var(--ease), filter 0.4s var(--ease);
}

.map-node:hover img {
  opacity: 1;
  filter: none;
}

.map-node:hover .map-node-media {
  border-color: rgba(255, 255, 255, 0.5);
  box-shadow: 0 0 0 8px rgba(255, 255, 255, 0.04), 0 0 40px rgba(140, 175, 255, 0.12);
}

.map-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.56rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  transition: color 0.3s var(--ease);
}

.map-node:hover .map-label {
  color: var(--text);
}

/* Главные — крупные и яркие, архив — точка. */
.map-node--major .map-node-media { width: clamp(150px, 15vw, 250px); height: clamp(150px, 15vw, 250px); }
.map-node--major .map-label { font-size: 0.62rem; color: var(--muted-strong); }

.map-node--minor .map-node-media { width: clamp(84px, 8vw, 132px); height: clamp(84px, 8vw, 132px); }
.map-node--minor img { opacity: 0.62; }

.map-node--quiet .map-node-media { width: 58px; height: 58px; border-color: rgba(255, 255, 255, 0.1); }
.map-node--quiet img { opacity: 0.4; }
.map-node--quiet .map-label { opacity: 0.55; }

/* -------------------------------- HUD ------------------------------------- */

.map-hud {
  position: absolute;
  z-index: 5;
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  pointer-events: none;
}

.map-hud--tl { top: 84px; left: var(--gutter); }
.map-hud--tr { top: 84px; right: var(--gutter); }
.map-hud--bl { bottom: 26px; left: var(--gutter); gap: 18px; }
.map-hud--br { bottom: 26px; right: var(--gutter); }

.map-hud-value {
  color: var(--text);
}

.map-hud-label {
  opacity: 0.75;
}

/* ------------------------------ Адаптив ----------------------------------- */

@media (max-width: 900px) {
  .map-page { height: auto; overflow: auto; }

  .map {
    height: auto;
    padding-top: 90px;
    padding-bottom: 60px;
  }

  .map-viewport {
    position: static;
    overflow: visible;
  }

  .map-canvas {
    width: 100%;
    height: auto;
    display: flex;
    flex-direction: column;
    gap: 26px;
    padding: 0 var(--gutter);
  }

  .map-stars,
  .map-lines {
    display: none;
  }

  .map-nodes {
    position: static;
    display: flex;
    flex-direction: column;
    gap: 22px;
  }

  .map-node {
    position: static;
    transform: none;
    flex-direction: row;
    justify-content: flex-start;
    gap: 16px;
    text-align: left;
  }

  .map-node:hover {
    transform: none;
  }

  .map-node .map-node-media {
    width: 96px;
    height: 96px;
    flex: none;
  }

  .map-hud--tr,
  .map-hud--bl,
  .map-hud--br {
    display: none;
  }

  .map-hud--tl {
    top: 64px;
  }
}

/* ------------------------------ Статус-бар -------------------------------- */

.map-status {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  border: 1px solid var(--line-strong);
  background: rgba(5, 5, 5, 0.7);
  font-family: var(--font-mono);
  font-size: 0.54rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted-strong);
  pointer-events: none;
}

.map-status span {
  padding: 8px 16px;
  border-right: 1px solid var(--line);
}

.map-status span:last-child {
  border-right: 0;
}

@media (max-width: 900px) {
  .map-status {
    display: none;
  }
}
/* --------------------- Узлы карты: рамки, не круги -------------------------
   Как на референсе: тонкая прямоугольная рамка, изображение внутри, подпись
   снизу. Уголки и засечки дают технический вид.
--------------------------------------------------------------------------- */

.map-node-media {
  border-radius: 0;
  width: clamp(150px, 13vw, 230px);
  height: auto;
  aspect-ratio: 4 / 3;
  border: 1px solid rgba(255, 255, 255, 0.26);
  background: #070707;
  box-shadow: none;
  overflow: visible;
  position: relative;
}

.map-node-medium {
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.map-node-media > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.86;
  filter: grayscale(0.45) contrast(1.05);
  transition: opacity 0.3s var(--ease), filter 0.4s var(--ease);
}

/* уголки рамки */
.map-node-media::before,
.map-node-media::after {
  content: "";
  position: absolute;
  width: 9px;
  height: 9px;
  border-color: rgba(255, 255, 255, 0.55);
  border-style: solid;
  pointer-events: none;
}

.map-node-media::before {
  top: -1px;
  left: -1px;
  border-width: 1px 0 0 1px;
}

.map-node-media::after {
  right: -1px;
  bottom: -1px;
  border-width: 0 1px 1px 0;
}

.map-node--major .map-node-media {
  width: clamp(180px, 16vw, 270px);
  aspect-ratio: 4 / 3;
}

.map-node--minor .map-node-media {
  width: clamp(96px, 8.5vw, 150px);
  aspect-ratio: 3 / 2;
}

.map-node--quiet .map-node-media {
  width: 62px;
  aspect-ratio: 1;
  border-color: rgba(255, 255, 255, 0.16);
}

.map-node:hover .map-node-media {
  border-color: rgba(255, 255, 255, 0.6);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.map-node:hover img {
  opacity: 1;
  filter: none;
}

.map-node--minor img { opacity: 0.7; }
.map-node--quiet img { opacity: 0.45; }

.map-label {
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  width: 100%;
  text-align: left;
}
/* Телефон: рамки одинаковые и небольшие */

@media (max-width: 900px) {
  .map-node .map-node-media,
  .map-node--major .map-node-media,
  .map-node--minor .map-node-media,
  .map-node--quiet .map-node-media {
    width: 92px;
    aspect-ratio: 1;
  }

  .map-label {
    border-top: 0;
    padding-top: 0;
  }
}
/* --------------------------- Масштаб и мини-карта -------------------------- */

.map-canvas {
  width: calc(3200px * var(--zoom, 1));
}

.map-node--major .map-node-media {
  width: calc(clamp(180px, 16vw, 270px) * var(--zoom, 1));
}

.map-node--minor .map-node-media {
  width: calc(clamp(96px, 8.5vw, 150px) * var(--zoom, 1));
}

.map-node--quiet .map-node-media {
  width: calc(62px * var(--zoom, 1));
}

.map-zoom {
  position: absolute;
  right: var(--gutter);
  bottom: 76px;
  z-index: 7;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-strong);
  background: rgba(5, 5, 5, 0.72);
}

.map-zoom button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  color: var(--muted-strong);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
}

.map-zoom button:last-child {
  border-bottom: 0;
}

.map-zoom button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.map-minimap {
  position: absolute;
  left: var(--gutter);
  right: var(--gutter);
  bottom: 62px;
  z-index: 6;
  padding: 0 0 4px;
}

.map-minimap-track {
  position: relative;
  height: 2px;
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
}

.map-minimap-thumb {
  position: absolute;
  top: -3px;
  height: 8px;
  min-width: 28px;
  background: rgba(242, 242, 240, 0.75);
  transition: left 0.08s linear, width 0.2s var(--ease);
}

.map-minimap::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

@media (max-width: 900px) {
  .map-zoom,
  .map-minimap {
    display: none;
  }
}
/* Связи: клиент — сплошная тонкая, серия — редкий пунктир */

.map-link--client {
  stroke: rgba(255, 255, 255, 0.16);
  stroke-dasharray: 1 5;
}

.map-link--series {
  stroke: rgba(255, 255, 255, 0.12);
  stroke-dasharray: 5 6;
}

.map-link--active {
  stroke: rgba(242, 242, 240, 0.55);
  stroke-width: 1.2;
}

.map-link--dim {
  opacity: 0.25;
}
/* Кадр держит пропорцию при любом масштабе: изображение не диктует высоту */

.map-node-media {
  position: relative;
  overflow: hidden;
}

.map-node-media > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* --------------------------- Мобильный список карты ------------------------ */

.map-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 0 40px;
}

.map-list-item {
  display: grid;
  grid-template-columns: 38px 64px 1fr;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 0;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  cursor: pointer;
}

.map-list-index {
  font-family: var(--font-mono);
  font-size: 0.54rem;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.map-list-media {
  display: block;
  width: 64px;
  height: 48px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: #070707;
}

.map-list-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.85;
  filter: grayscale(0.3);
}

.map-list-caption {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.map-list-title {
  font-size: 0.88rem;
  line-height: 1.2;
  color: var(--text);
  overflow-wrap: anywhere;
}

.map-list-meta {
  font-family: var(--font-mono);
  font-size: 0.52rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.map-list-item:hover .map-list-media img {
  opacity: 1;
  filter: none;
}
/* --------------- Телефон: та же карта, только под палец -------------------
   Отменяет прежний «список»: поле остаётся горизонтальным, двигается свайпом,
   масштабируется пинчем и кнопками.
--------------------------------------------------------------------------- */

@media (max-width: 900px) {
  .map-page {
    height: 100dvh;
    overflow: hidden;
  }

  .map {
    height: 100dvh;
    padding: 0;
  }

  .map-viewport {
    position: absolute;
    inset: 0;
    overflow-x: auto;
    overflow-y: hidden;
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
  }

  .map-canvas {
    width: calc(3200px * var(--zoom, 1));
    height: 100%;
    display: block;
    padding: 0;
  }

  .map-nodes {
    position: absolute;
    inset: 0;
    display: block;
  }

  .map-node {
    position: absolute;
    transform: translate(-50%, -50%);
    flex-direction: column;
    text-align: center;
  }

  .map-node:hover,
  .map-node:focus-visible {
    transform: translate(-50%, -50%) scale(1.04);
  }

  .map-stars,
  .map-lines {
    display: block;
  }

  .map-zoom {
    display: flex;
    bottom: 82px;
    right: 12px;
  }

  .map-minimap {
    display: block;
    left: 12px;
    right: 12px;
    bottom: 52px;
  }

  .map-status {
    display: flex;
    bottom: 12px;
    font-size: 0.46rem;
  }

  .map-status span {
    padding: 6px 10px;
  }

  .map-hud--tl,
  .map-hud--tr,
  .map-hud--bl,
  .map-hud--br {
    display: none;
  }

  .map-label {
    border-top: 1px solid rgba(255, 255, 255, 0.14);
    padding-top: 6px;
    font-size: 0.5rem;
  }

  .tech-dots {
    display: none;
  }
}
@media (max-width: 900px) {
  .map-label {
    font-size: 0.46rem;
    letter-spacing: 0.1em;
    max-width: 150px;
    white-space: normal;
    line-height: 1.25;
    text-align: center;
  }

  .map-node--major .map-label {
    font-size: 0.48rem;
  }
}
/* --------------------------- Живое звёздное поле --------------------------- */

.map-twinkle {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.map-twinkle span {
  position: absolute;
  width: var(--size, 2px);
  height: var(--size, 2px);
  border-radius: 50%;
  background: #fff;
  opacity: 0;
  animation: twinkle var(--d, 6s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}

@keyframes twinkle {
  0%, 100% { opacity: 0; transform: scale(0.6); }
  45% { opacity: 0.85; transform: scale(1); }
}

.map-shoot {
  position: absolute;
  width: 140px;
  height: 1px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.9) 100%);
  opacity: 0;
  transform: rotate(16deg);
  pointer-events: none;
  animation: shoot 1.1s linear forwards;
}

@keyframes shoot {
  0% { opacity: 0; transform: translate(0, 0) rotate(16deg); }
  12% { opacity: 0.9; }
  100% { opacity: 0; transform: translate(260px, 74px) rotate(16deg); }
}

@media (prefers-reduced-motion: reduce) {
  .map-twinkle,
  .map-shoot {
    display: none;
  }
}
/* ------------------------- Созвездие VV ------------------------------------ */

.map-vv {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 2;
}

.map-vv-line {
  fill: none;
  stroke: rgba(255, 255, 255, 0.16);
  stroke-width: 1;
  stroke-dasharray: 3 8;
  transition: stroke 0.4s var(--ease);
}

.map-vv-star {
  fill: #fff;
  opacity: 0.55;
  transition: opacity 0.4s var(--ease), r 0.4s var(--ease);
}

.map-vv.is-hot .map-vv-line {
  stroke: rgba(255, 255, 255, 0.5);
}

.map-vv.is-hot .map-vv-star {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .map-vv-line,
  .map-vv-star {
    transition: none;
  }
}
/* Созвездие читаемее: линии чуть ярче, точки крупнее */
.map-vv-line {
  stroke: rgba(255, 255, 255, 0.3);
  stroke-dasharray: 2 6;
}

.map-vv-star {
  opacity: 0.75;
}
/* Лира: линии почти невидимы, пока не подойдёшь курсором */
.map-vv-line {
  stroke: rgba(255, 255, 255, 0.07);
  stroke-width: 1;
  stroke-dasharray: 2 9;
  transition: stroke 0.5s var(--ease);
}

.map-vv-star {
  fill: #fff;
  opacity: 0.5;
  transition: opacity 0.5s var(--ease);
}

.map-vv.is-hot .map-vv-line {
  stroke: rgba(255, 255, 255, 0.26);
}

.map-vv.is-hot .map-vv-star {
  opacity: 0.95;
}
.map-vv-line {
  stroke: rgba(255, 255, 255, 0.1);
}
/* Страховка для мобильных: если dvh не поддерживается, карта не схлопывается */

.map-page {
  height: 100vh;
  min-height: 100vh;
}

.map {
  height: 100vh;
  min-height: 100vh;
}

@supports (height: 100dvh) {
  .map-page,
  .map {
    height: 100dvh;
    min-height: 100dvh;
  }
}

@media (max-width: 900px) {
  .map-viewport {
    height: 100%;
  }
}