/*
 * Интерактивная карта и страница локации (2.txt §71–§77).
 * Слева слои, в центре карта, справа выбранная точка. Сама карта яркая,
 * окружающий интерфейс — светлый и спокойный (§73). HEX здесь нет.
 */

.mapwrap {
    padding-bottom: var(--section-gap);
}

.mapwrap__head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--gap);
    margin-bottom: 20px;
}

.mapwrap__title {
    font-size: var(--fs-h1);
    line-height: var(--lh-tight);
}

.mapwrap__text {
    margin-top: 10px;
    max-width: 72ch;
    color: var(--text-secondary);
    font-size: var(--fs-body);
}

.mapwrap__meta {
    flex: none;
    color: var(--text-muted);
    font-size: var(--fs-xs);
    text-align: right;
}

.mapwrap__meta span {
    display: block;
    margin-top: 4px;
}

/* --- Рабочая область --- */

.mapw {
    border: 1px solid var(--border);
    border-radius: var(--radius-panel);
    background: var(--bg-card);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.mapw__topbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--gap-sm);
    padding: 14px var(--card-pad);
    border-bottom: 1px solid var(--border);
    background: var(--bg-soft);
}

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

.mapw__chip {
    background: var(--bg-card);
}

.mapw__search {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mapw__search-icon {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    pointer-events: none;
}

.mapw__input {
    flex: 1;
    min-width: 0;
    height: 40px;
    padding: 0 12px 0 38px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    font: inherit;
    font-size: var(--fs-sm);
}

.mapw__input:focus {
    outline: 2px solid var(--primary);
    outline-offset: -1px;
}

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

.mapw__body {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr) 300px;
    align-items: stretch;
}

.mapw__side,
.mapw__panel {
    padding: var(--card-pad);
    min-width: 0;
}

.mapw__side {
    border-right: 1px solid var(--border);
    max-height: 720px;
    overflow-y: auto;
}

.mapw__panel {
    border-left: 1px solid var(--border);
}

.mapw__subtitle {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
    color: var(--text-secondary);
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.mapw__subtitle + .maplist,
.mapw__subtitle + .maplayers {
    margin-top: 0;
}

.mapw__count {
    color: var(--text-muted);
    letter-spacing: 0;
}

.mapw__apply {
    width: 100%;
    margin: 12px 0 22px;
}

/* --- Слои --- */

.maplayers {
    list-style: none;
}

.maplayers__item + .maplayers__item {
    margin-top: 4px;
}

.maplayers__label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--fs-sm);
    font-weight: 600;
}

.maplayers__label:hover {
    background: var(--bg-soft);
}

.maplayers__label input {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.maplayers__dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--cyan);
    flex: none;
}

.maplayers__dot--named {
    width: 13px;
    height: 13px;
    background: var(--primary);
}

.maplayers__dot--text {
    width: auto;
    height: auto;
    border-radius: 0;
    background: none;
    color: var(--text-muted);
    font-size: var(--fs-xs);
    font-weight: 800;
}

.maplayers__name {
    flex: 1;
    min-width: 0;
}

.maplayers__count {
    color: var(--text-muted);
    font-size: var(--fs-xs);
}

/* --- Список локаций --- */

.maplist {
    list-style: none;
}

/* Название и сторона света в две строки: в одну колонку названия вроде
   «Причудливого парка» не помещаются и режутся многоточием. */
.maplist__item {
    display: grid;
    grid-template-columns: 10px minmax(0, 1fr);
    align-items: center;
    gap: 2px 10px;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: var(--fs-sm);
}

.maplist__item:hover {
    background: var(--bg-soft);
}

.maplist__item--active {
    background: var(--bg-active);
}

.maplist__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--cyan);
}

.maplist__dot--named {
    width: 10px;
    height: 10px;
    background: var(--primary);
}

.maplist__name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.maplist__note {
    grid-column: 2;
    color: var(--text-muted);
    font-size: var(--fs-xs);
    white-space: nowrap;
}

.maplist--plain {
    margin-top: 12px;
}

/* В коротких списках («что рядом», «ушли с карты») место есть — там строка одна. */
.maplist--plain .maplist__item {
    grid-template-columns: 10px minmax(0, 1fr) auto;
}

.maplist--plain .maplist__note {
    grid-column: auto;
}

.maplist--plain .maplist__item {
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    padding-left: 0;
    padding-right: 0;
}

.maplist--plain li:last-child .maplist__item {
    border-bottom: 0;
}

/* --- Карта --- */

.mapw__stage {
    position: relative;
    background: var(--brand-900);
    min-height: 420px;
}

/* Высоту окна карты задаёт сама картинка: при масштабе 1 карта видна целиком,
   а зум — это transform, который на поток не влияет и высоту не двигает. */
.mapw__viewport {
    position: relative;
    overflow: hidden;
    touch-action: pan-y;
}

.mapw__canvas {
    position: relative;
    width: 100%;
    transform-origin: 0 0;
    --map-zoom: 1;
}

.mapw__image {
    display: block;
    width: 100%;
    height: auto;
}

.mapw__zoom {
    position: absolute;
    right: 12px;
    bottom: 12px;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    border-radius: var(--radius-pill);
    background: var(--bg-card);
    box-shadow: var(--shadow-card);
}

.mapw__zoom-btn {
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 50%;
    background: var(--bg-soft);
    color: var(--text-primary);
    font-size: var(--fs-body);
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
}

.mapw__zoom-btn:hover {
    background: var(--bg-active);
    color: var(--primary);
}

.mapw__zoom-value {
    min-width: 46px;
    color: var(--text-secondary);
    font-size: var(--fs-xs);
    font-weight: 700;
    text-align: center;
}

/* --- Метки --- */

.mapmark {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: inherit;
    transform: translate(-50%, -50%) scale(calc(1 / var(--map-zoom, 1)));
    transform-origin: 50% 50%;
    cursor: pointer;
}

.mapmark__dot {
    width: 9px;
    height: 9px;
    border: 2px solid var(--bg-card);
    border-radius: 50%;
    background: var(--cyan);
    box-shadow: 0 1px 4px rgba(16, 24, 40, .45);
    transition: transform var(--transition);
}

.mapmark--named .mapmark__dot {
    width: 13px;
    height: 13px;
    background: var(--primary);
}

.mapmark__label {
    margin-top: 4px;
    padding: 2px 8px;
    max-width: 22ch;
    border-radius: var(--radius-pill);
    background: rgba(16, 24, 40, .74);
    color: var(--text-on-brand);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Ориентиров два десятка, и половина из них называется одинаково: на общем
   плане их подписи сливаются в кашу. Появляются при приближении карты. */
.mapmark--landmark .mapmark__label {
    display: none;
    font-size: 10px;
    font-weight: 600;
    background: rgba(16, 24, 40, .55);
}

.mapw--zoomed .mapmark--landmark .mapmark__label {
    display: block;
}

.mapmark:hover .mapmark__dot {
    transform: scale(1.35);
}

.mapmark:hover .mapmark__label {
    background: var(--primary);
}

.mapmark--active .mapmark__dot {
    background: var(--warning);
    transform: scale(1.4);
}

.mapmark--active .mapmark__label {
    background: var(--warning);
    color: var(--text-primary);
}

.mapmark--dim {
    opacity: .28;
}

/* Специфичность здесь не для красоты: правило должно перебивать подписи,
   которые включает приближение карты. */
.mapmark.mapmark--dim .mapmark__label {
    display: none;
}

.mapw--hide-named .mapmark--named,
.mapw--hide-landmark .mapmark--landmark {
    display: none;
}

.mapw--no-labels .mapmark .mapmark__label {
    display: none;
}

/* --- Панель выбранной точки --- */

.mappanel__empty .empty__title {
    font-size: var(--fs-body);
}

.mappanel__empty .empty__text {
    margin-top: 8px;
    color: var(--text-secondary);
    font-size: var(--fs-sm);
}

.mappanel__kind {
    background: var(--bg-soft);
    color: var(--text-secondary);
}

.mappanel__title {
    margin-top: 10px;
    font-size: var(--fs-h3);
    line-height: var(--lh-tight);
}

.mappanel__facts {
    margin-top: 16px;
}

.mappanel__facts div {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.mappanel__facts div:last-child {
    border-bottom: 0;
}

.mappanel__facts dt {
    color: var(--text-muted);
    font-size: var(--fs-xs);
}

.mappanel__facts dd {
    margin-top: 2px;
    font-size: var(--fs-sm);
    font-weight: 700;
}

.mappanel__action {
    width: 100%;
    margin-top: 16px;
    justify-content: center;
}

.mappanel__note {
    margin-top: 14px;
    color: var(--text-muted);
    font-size: var(--fs-xs);
    line-height: var(--lh-body);
}

.fpanel__lead {
    margin-top: 10px;
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    line-height: var(--lh-body);
}

/* --- Полноэкранный режим (§77) --- */

.mapw:fullscreen {
    border-radius: 0;
    background: var(--bg-card);
    display: flex;
    flex-direction: column;
}

.mapw:fullscreen .mapw__body {
    flex: 1;
    min-height: 0;
}

.mapw:fullscreen .mapw__side,
.mapw:fullscreen .mapw__viewport {
    max-height: none;
}

.mapw:fullscreen .mapw__viewport {
    height: 100%;
}

/* --- Страница локации --- */

.poihero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: var(--gap);
    align-items: center;
    padding: 28px var(--card-pad);
    border: 1px solid var(--border);
    border-radius: var(--radius-hero);
    background: var(--bg-card);
    box-shadow: var(--shadow-card);
}

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

.poihero__title {
    margin-top: 14px;
    font-size: var(--fs-h1);
    line-height: var(--lh-tight);
}

.poihero__text {
    margin-top: 12px;
    max-width: 60ch;
    color: var(--text-secondary);
    font-size: var(--fs-body);
    line-height: var(--lh-body);
}

.poihero__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}

.poicrop {
    margin: 0;
}

.poicrop__frame {
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    background: var(--brand-900);
}

.poicrop__image {
    position: absolute;
    max-width: none;
}

.poicrop__pin {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 14px;
    height: 14px;
    border: 3px solid var(--bg-card);
    border-radius: 50%;
    background: var(--cyan);
    box-shadow: 0 2px 8px rgba(16, 24, 40, .5);
    transform: translate(-50%, -50%);
}

.poicrop__pin--named {
    background: var(--primary);
}

.poicrop__caption {
    margin-top: 10px;
    color: var(--text-muted);
    font-size: var(--fs-xs);
    line-height: var(--lh-body);
}

.poifacts {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: var(--gap);
}

.kpi__value--text {
    font-size: var(--fs-h3);
    line-height: var(--lh-tight);
}

.poitime {
    margin-top: 14px;
    list-style: none;
}

.poitime__item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 4px 12px;
    padding: 10px 0 10px 16px;
    border-left: 2px solid var(--border);
    position: relative;
}

.poitime__item::before {
    position: absolute;
    left: -5px;
    top: 16px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    content: '';
}

.poitime__item--removed::before {
    background: var(--danger);
}

.poitime__item--added::before,
.poitime__item--returned::before {
    background: var(--success);
}

.poitime__date {
    color: var(--text-muted);
    font-size: var(--fs-xs);
    white-space: nowrap;
}

.poitime__label {
    font-weight: 700;
    font-size: var(--fs-sm);
}

.poitime__detail {
    grid-column: 1 / 3;
    color: var(--text-secondary);
    font-size: var(--fs-xs);
}

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

@media (max-width: 1280px) {
    .mapw__body {
        grid-template-columns: 230px minmax(0, 1fr) 270px;
    }
}

@media (max-width: 1024px) {
    .mapw__topbar {
        grid-template-columns: minmax(0, 1fr);
    }

    /* Мобильный — не сжатый десктоп: сначала карта, под ней выбранная точка,
       а слои и список локаций уходят вниз. */
    .mapw__body {
        grid-template-columns: minmax(0, 1fr);
    }

    .mapw__stage {
        order: 1;
    }

    .mapw__panel {
        order: 2;
        border-left: 0;
        border-top: 1px solid var(--border);
    }

    .mapw__side {
        order: 3;
        border-right: 0;
        border-top: 1px solid var(--border);
        max-height: 420px;
    }

    .poihero {
        grid-template-columns: minmax(0, 1fr);
    }

    .poicrop {
        max-width: 420px;
    }

    .poifacts {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .mapwrap__head {
        flex-direction: column;
        align-items: flex-start;
    }

    .mapwrap__meta {
        text-align: left;
    }

    .mapw__tools {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .mapw__viewport {
        min-height: 320px;
    }

    .mapmark--landmark .mapmark__label {
        display: none;
    }

    .poicrop {
        max-width: none;
    }
}
