/*
 * «Список ремонта» (/plan/), номера маршрута и «Вы здесь» на карте (/map/, /here/<точка>/).
 * Токены и цвета групп — из app/globals.css (.map-page). Подключается со страниц плана и карты (precedence="default").
 */

/* ── «Список ремонта» ── */
.plan-app {
  display: grid;
  gap: 28px;
  padding-block: clamp(20px, 3vw, 32px) clamp(32px, 5vw, 72px);
}

@media (min-width: 1000px) {
  .plan-app {
    grid-template-columns: minmax(340px, 400px) minmax(0, 1fr);
    gap: 40px;
    align-items: start;
  }

  .plan-side {
    position: sticky;
    top: calc(var(--header-h) + 20px);
  }
}

.plan-side {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.plan-lead {
  max-width: 34em;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text-dim);
}

.plan-got {
  padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--c-tile) 50%, transparent);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--c-tile) 12%, var(--surface));
  font-size: 0.9375rem;
  line-height: 1.4;
}

.plan-items {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

/* Позиция: точка группы, слово, галочка при выборе. */
.plan-item {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: 10px 10px 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.2;
  text-align: start;
  color: var(--text);
  transition:
    border-color 0.18s var(--ease),
    background-color 0.18s var(--ease);
}

.plan-item i,
.plan-picks i,
.plan-sugg i,
.pf-cats i,
.pf-hall-list i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--c);
  flex: none;
}

.plan-item span {
  min-width: 0;
  hyphens: auto;
  overflow-wrap: anywhere;
}

.plan-item svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--accent-ink);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transform: scale(0.6);
  transition:
    opacity 0.16s var(--ease),
    transform 0.16s var(--ease);
}

.plan-item:hover {
  border-color: var(--c);
}

.plan-item[aria-pressed="true"] {
  border-color: var(--c);
  background: color-mix(in srgb, var(--c) 18%, var(--surface));
}

.plan-item[aria-pressed="true"] svg {
  opacity: 1;
  transform: none;
  border-radius: 50%;
  background: var(--c);
}

.plan-shop {
  display: grid;
  gap: 8px;
  margin-top: 6px;
}

.plan-shop-label {
  font-size: 1rem;
  font-weight: 500;
}

.plan-sugg {
  display: grid;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow: hidden;
}

.plan-sugg button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 8px 14px;
  text-align: start;
}

.plan-sugg li + li {
  border-top: 1px solid var(--line);
}

.plan-sugg button:hover,
.plan-sugg button:focus-visible {
  background: color-mix(in srgb, var(--c) 14%, var(--surface-2));
}

.plan-sugg span {
  flex: 1;
  font-weight: 500;
}

.plan-sugg em,
.plan-sugg-none {
  font-size: 0.875rem;
  font-style: normal;
  color: var(--text-dim);
}

.plan-sugg-none {
  padding: 12px 14px;
}

.plan-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.plan-picks:empty {
  display: none;
}

.plan-picks li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding-inline: 12px 4px;
  border: 1px solid var(--c);
  border-radius: 999px;
  background: color-mix(in srgb, var(--c) 14%, var(--surface));
  font-size: 0.9375rem;
  font-weight: 500;
}

.plan-picks bdi {
  font-size: 0.8125rem;
  color: var(--text-dim);
  font-feature-settings: "tnum";
}

.plan-picks button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
}

.plan-picks button:hover {
  background: rgb(255 255 255 / 0.08);
}

.plan-picks svg,
.pf-map svg,
.plan-jump svg,
.map-plan-link svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.plan-jump {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 6px;
  min-height: 44px;
  margin-top: 4px;
  font-weight: 500;
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 4px;
}

@media (min-width: 1000px) {
  .plan-jump {
    display: none;
  }
}

.plan-jump[hidden] {
  display: none;
}

/* ── маршрут ── */
.plan-route {
  display: grid;
  gap: 16px;
  min-width: 0;
  scroll-margin-top: calc(var(--header-h) + 12px);
}

.plan-route-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.plan-route-h {
  font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem);
  font-weight: 500;
  letter-spacing: -0.01em;
}

.plan-sum {
  font-size: 0.9375rem;
  color: var(--text-dim);
  font-feature-settings: "tnum";
}

.plan-empty {
  padding: 28px 20px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text-dim);
  text-align: center;
}

.plan-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.plan-actions[hidden] {
  display: none;
}

.plan-tg,
.plan-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding-inline: 18px;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 500;
  transition: background-color 0.18s var(--ease);
}

.plan-tg {
  flex: 1 1 100%;
  background: #fff;
  color: var(--accent-ink);
}

.plan-tg:hover {
  background: var(--accent);
}

.plan-btn {
  flex: 1 1 0;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  white-space: nowrap;
}

.plan-btn:hover {
  background: var(--surface-2);
}

.plan-btn.ok {
  border-color: var(--ok);
}

@media (min-width: 700px) {
  .plan-tg {
    flex: 0 0 auto;
  }

  .plan-btn {
    flex: 0 0 auto;
  }
}

.plan-start {
  font-size: 0.9375rem;
  color: var(--text-dim);
}

.plan-floors {
  display: grid;
  gap: 14px;
  counter-reset: none;
}

/* Этаж маршрута: номер этажа крупно, «поднимитесь/спуститесь», группы; ниже — мини-план и список по порядку. */
.pf {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.pf-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.pf-badge {
  display: grid;
  place-items: center;
  min-width: 52px;
  height: 52px;
  padding-inline: 8px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 1.625rem;
  font-weight: 600;
  line-height: 1;
  font-feature-settings: "tnum";
}

.pf-head h3 {
  font-size: 1.1875rem;
  font-weight: 500;
  line-height: 1.25;
}

.pf-move {
  margin-top: 2px;
  font-size: 0.9375rem;
  color: var(--text);
}

.pf-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 6px;
  font-size: 0.875rem;
  color: var(--text-dim);
}

.pf-cats span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pf-body {
  display: grid;
}

@media (min-width: 700px) {
  .pf-body {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .pf-plan-wrap {
    border-inline-end: 1px solid var(--line);
  }
}

.pf-plan-wrap {
  padding: 10px;
  background:
    radial-gradient(circle at 1px 1px, rgb(255 255 255 / 0.05) 1px, transparent 1.4px) 0 0 / 18px 18px,
    var(--bg);
}

@media (max-width: 699px) {
  .pf-plan-wrap {
    border-bottom: 1px solid var(--line);
  }
}

.pf-plan {
  display: block;
  width: 100%;
  height: auto;
  max-height: 460px;
}

.pf-plan rect {
  fill: rgb(255 255 255 / 0.035);
  stroke: rgb(255 255 255 / 0.1);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.pf-plan rect.also {
  fill: color-mix(in srgb, var(--c) 30%, transparent);
  stroke: color-mix(in srgb, var(--c) 60%, transparent);
}

.pf-plan rect.on {
  fill: color-mix(in srgb, var(--c) 62%, transparent);
  stroke: var(--c);
}

.pf-path {
  fill: none;
  stroke: rgb(255 255 255 / 0.55);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pf-n circle {
  fill: var(--c);
  stroke: var(--bg);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.pf-n text,
.pf-start text {
  fill: var(--accent-ink);
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
  font-feature-settings: "tnum";
}

.pf-dot {
  fill: #fff;
}

.pf-start circle {
  fill: #fff;
  stroke: var(--bg);
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
}

.pf-start text {
  fill: var(--text);
  paint-order: stroke;
  stroke: var(--bg);
  stroke-width: 4px;
  stroke-linejoin: round;
}

.pf-list {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 10px 12px 14px;
  min-width: 0;
}

.pf-stops {
  display: grid;
}

.pf-stops.short li.more {
  display: none;
}

.pf-stops a {
  display: grid;
  grid-template-columns: 28px 58px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 6px 4px;
  border-bottom: 1px solid var(--line);
}

.pf-stops li:last-child a {
  border-bottom: 0;
}

.pf-stops a:hover .pf-name {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.pf-num {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--c);
  color: var(--accent-ink);
  font-size: 0.8125rem;
  font-weight: 700;
  font-feature-settings: "tnum";
}

.pf-room {
  font-size: 0.9375rem;
  font-weight: 600;
  font-feature-settings: "tnum";
  color: var(--text);
}

.pf-name {
  display: grid;
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.25;
  min-width: 0;
}

.pf-name em {
  overflow: hidden;
  font-size: 0.8125rem;
  font-style: normal;
  font-weight: 400;
  color: var(--text-dim);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pf-all {
  justify-self: start;
  min-height: 44px;
  font-size: 0.9375rem;
  color: var(--text-dim);
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 4px;
}

.pf-hall {
  font-size: 0.9375rem;
  line-height: 1.4;
  color: var(--text-dim);
}

.pf-hall-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pf-hall-list li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding-inline: 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.875rem;
}

.pf-map {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 6px;
  min-height: 44px;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
}

.pf-map:hover {
  color: var(--accent);
}

[dir="rtl"] .pf-map svg,
[dir="rtl"] .map-plan-link svg {
  transform: scaleX(-1);
}

.plan-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 16px;
  font-size: 0.875rem;
  color: var(--text-dim);
}

.plan-foot[hidden] {
  display: none;
}

.plan-foot button {
  min-height: 44px;
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 4px;
}

/* ── карта: ссылка на список, номера маршрута, «вы здесь» ── */
.map-plan-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
}

.map-plan-link:hover {
  border-color: rgb(255 255 255 / 0.3);
}

.map-route-edit {
  margin-inline-start: auto;
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--text-dim);
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 4px;
}

.map-route-floor {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 0.875rem;
  color: var(--text-dim);
}

.map-route-floor b {
  display: grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  padding-inline: 4px;
  border-radius: 4px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.8125rem;
}

.map-route-n {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--c);
  color: var(--accent-ink);
  font-size: 0.75rem;
  font-weight: 700;
  font-feature-settings: "tnum";
}

/* номера обхода и «вы здесь» на 3D-этаже карты (map.js, слой #mp-marks; размеры — в пикселях экрана) */
#mp-iso-svg .mp-marks {
  pointer-events: none;
}

#mp-iso-svg .mp-stop circle {
  fill: #fff;
  stroke: #0b0d10;
  stroke-width: 2.5px;
}

#mp-iso-svg .mp-stop text {
  fill: var(--accent-ink);
  font-size: 13px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
  font-feature-settings: "tnum";
}

#mp-iso-svg .you-dot {
  fill: #fff;
  stroke: #2f80ed;
  stroke-width: 4px;
}

#mp-iso-svg .you-ring {
  fill: rgb(47 128 237 / 0.32);
  transform-box: fill-box;
  transform-origin: center;
  animation: you-pulse 2.2s var(--ease) infinite;
}

#mp-iso-svg .you-tag {
  fill: #2f80ed;
}

#mp-iso-svg .you-txt {
  fill: #fff;
  font-size: 13px;
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: central;
}

@keyframes you-pulse {
  0% {
    transform: scale(0.55);
    opacity: 1;
  }

  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  #mp-iso-svg .you-ring {
    animation: none;
  }
}

.mc-dir,
.map-res-dir {
  font-size: 0.875rem;
  font-weight: 500;
  color: #8fb8f5;
}

/* карточка магазина светлая — синий потемнее (контраст ≥ 4.5:1 на #f8f9fa) */
.mc-dir {
  margin-top: 2px;
  color: #1d5bb8;
}

.map-res-dir {
  display: block;
  width: 100%;
  margin-top: 2px;
}

/* ── «Вы здесь» (/here/<точка>/) ── */
.here-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-top: clamp(18px, 3vw, 28px);
}

.here-badge b {
  display: grid;
  place-items: center;
  min-width: 60px;
  height: 60px;
  padding-inline: 10px;
  border-radius: var(--radius);
  background: #2f80ed;
  color: #fff;
  font-size: 1.875rem;
  font-weight: 600;
  line-height: 1;
}

.here-h1 {
  font-size: clamp(1.75rem, 1.3rem + 2vw, 2.75rem);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.here-where {
  margin-top: 4px;
  font-size: 0.9375rem;
  color: var(--text-dim);
}

.map-find-h {
  margin-top: 0;
}

/* на телефоне у точки QR этаж — сразу под «Вы здесь» (высота этажа — за вычетом этой строки), поиск — шторкой */
@media (max-width: 999px) {
  .here-page {
    --above: 92px;
  }
}

/* список маршрута на карте: номер обхода вместо цветной точки, «Изменить список» — отдельной строкой */
.map-app[data-route] .map-res-list button {
  grid-template-columns: 24px minmax(0, 1fr);
  min-height: 56px;
}

.map-app[data-route] .map-res-list button i {
  justify-self: center;
}

.map-app[data-route] .map-res-meta {
  grid-row: 2;
}

.map-app[data-route] .map-route-n {
  grid-row: span 2;
}

.map-app[data-route] .map-res-head .map-route-edit {
  display: inline-block;
  margin-top: 4px;
}

.map-app[data-route] .map-res-head b:first-child {
  margin-inline-end: 4px;
}

/* узкий телефон: все четыре этажа + «Весь этаж» не помещаются в строку (страница уезжала вбок на 30 px) —
   у кнопки остаётся значок, подпись — для чтения с экрана (текст кнопки не удалён, только font-size: 0) */
@media (max-width: 459px) {
  .map-fit {
    gap: 0;
    width: 44px;
    padding: 0;
    justify-content: center;
    font-size: 0;
  }
}

@media (max-width: 999px) {
  .map-results.short p.more {
    display: none;
  }
}

.pf-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 20px;
}

.pf-3d {
  color: var(--text-dim);
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 4px;
}
