/*
 * 게임 지도 — templates/_game-map.php 가 그리는 지도 한 장과, 지도 곁에 두는 점 표시·지역 알약.
 * 지도를 그리는 화면(지도 · 아이템의 얻는 곳 · 숙련도 올리기)이 싣는다. → docs/game-map.md 「지도 그리기」
 *
 * 점은 SVG 의 길이 0 인 선에 둥근 끝을 단 것이다. vector-effect: non-scaling-stroke 라 지도를 줄여도 점 크기(px)가 그대로다.
 * 색은 tokens.css 의 --map-* 이다.
 */

.game-map {
    margin: 0;
}

.game-map__view {
    position: relative;
    max-width: 62.625rem;
    overflow: hidden;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius);
    background: var(--map-halo);
}

.game-map__image {
    display: block;
    width: 100%;
    height: auto;
}

.game-map__layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.game-map__layer path,
.world-map__layer .game-map__group path {
    fill: none;
    vector-effect: non-scaling-stroke;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.game-map__halo {
    stroke: var(--map-halo);
    stroke-width: 10px;
}

.game-map__dot {
    stroke: var(--map-npc);
    stroke-width: 6px;
}

.game-map__group--object .game-map__dot { stroke: var(--map-object); }
.game-map__group--vendor .game-map__dot { stroke: var(--map-vendor); }
.game-map__group--instance .game-map__dot { stroke: var(--map-instance); }
.game-map__group--fishing .game-map__dot { stroke: var(--map-fishing); }
.game-map__group--route .game-map__dot { stroke: var(--map-route); }

/* 던전 입구는 한두 개라 크게 */
.game-map__group--instance .game-map__halo { stroke-width: 16px; }
.game-map__group--instance .game-map__dot { stroke-width: 11px; }

/* 하나를 강조하면 나머지는 흐리게, 강조한 것은 크게 */
.game-map.has-active .game-map__group:not(.is-active),
.game-map.has-active .game-map__pin:not(.is-active) {
    opacity: 0.3;
}

.game-map__group.is-active .game-map__halo { stroke-width: 14px; }
.game-map__group.is-active .game-map__dot { stroke-width: 9px; }

/* 이동 경로 같은 선 */
.game-map__line {
    stroke: var(--map-route);
    stroke-width: 3px;
}

.game-map__line--route {
    stroke-dasharray: 8 6;
}

/* 번호를 담은 동그라미(text 가 있는 묶음) */
.game-map__pin {
    position: absolute;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.375rem;
    height: 1.375rem;
    padding: 0 0.25rem;
    transform: translate(-50%, -50%);
    border: 2px solid var(--map-halo);
    border-radius: var(--radius-round);
    background: var(--map-npc);
    color: var(--map-pin-text);
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
}

.game-map__pin--object { background: var(--map-object); }
.game-map__pin--vendor { background: var(--map-vendor); }
.game-map__pin--instance { background: var(--map-instance); }
.game-map__pin--fishing { background: var(--map-fishing); }
.game-map__pin--route { background: var(--map-route); }

.game-map__pin.is-active {
    z-index: 1;
    transform: translate(-50%, -50%) scale(1.25);
}

/* 끝낸 곳(퀘스트 동선에서 할 일을 다 체크한 곳 — quest-route.js) — 연하게. 강조하지 않는다 */
.game-map__pin.is-done,
.game-map__group.is-done {
    opacity: 0.3;
}

/* 대륙 지도 위 지역 이름 */
.game-map__label {
    position: absolute;
    transform: translate(-50%, -50%);
    padding: 0.0625rem 0.125rem;
    color: var(--map-label);
    font-size: 0.6875rem;
    font-weight: 700;
    white-space: nowrap;
    text-shadow: 0 0 3px var(--map-halo), 0 0 3px var(--map-halo), 0 1px 2px var(--map-halo);
}

/* 이름 아래 작은 줄(퀘스트 찾기의 레벨 폭) */
.game-map__label-sub {
    display: block;
    font-size: 0.625rem;
    font-weight: 400;
    text-align: center;
}

.game-map__label:hover,
.game-map__label:focus-visible {
    color: var(--map-pin-text);
    text-decoration: underline;
}

.game-map__caption {
    margin-top: var(--space-xs);
    min-height: 1.4em;
    color: var(--color-muted);
    font-size: 0.8125rem;
}

/* 좁은 화면에서는 지역 이름이 겹쳐 읽을 수 없다. 지도 아래 목록으로 고른다 */
@media (max-width: 47.9375em) {
    .game-map__label {
        display: none;
    }

    .game-map__halo { stroke-width: 8px; }
    .game-map__dot { stroke-width: 5px; }
}

/* 점이 수천 개인 지도(아이템 출처의 대륙 지도 — 지역 지도의 4분의 1 크기) — 점을 작게. 던전 입구는 그래도 크게 */
.game-map--dense .game-map__halo { stroke-width: 6px; }
.game-map--dense .game-map__dot { stroke-width: 3.5px; }
.game-map--dense .game-map__group--instance .game-map__halo { stroke-width: 12px; }
.game-map--dense .game-map__group--instance .game-map__dot { stroke-width: 8px; }
.game-map--dense .game-map__group.is-active .game-map__halo { stroke-width: 9px; }
.game-map--dense .game-map__group.is-active .game-map__dot { stroke-width: 6px; }

/* 세계 지도(templates/_world-map.php)의 점 — 대륙 지도보다 더 작게 그린다. 지역이 들릴 때 그 지역의 점은 조금 키운다 */
.world-map .game-map__halo { stroke-width: 4.5px; }
.world-map .game-map__dot { stroke-width: 2.5px; }
.world-map .game-map__group--instance .game-map__halo { stroke-width: 10px; }
.world-map .game-map__group--instance .game-map__dot { stroke-width: 7px; }
.world-map .game-map__group.is-active .game-map__halo { stroke-width: 7px; }
.world-map .game-map__group.is-active .game-map__dot { stroke-width: 4.5px; }

/* 폰에서는 세계 지도가 330px 안팎이라 점을 더 줄인다. 지역 모양을 눌러 그 지역 지도로 간다 */
@media (max-width: 47.9375em) {
    .world-map .game-map__halo { stroke-width: 3.5px; }
    .world-map .game-map__dot { stroke-width: 2px; }
}

/* ── 지도 곁의 것 ─────────────────────────────── */

/* 목록·범례의 점 — 지도 위 점과 같은 색 */
.map-dot {
    display: inline-block;
    flex: none;
    width: 0.625rem;
    height: 0.625rem;
    border: 2px solid var(--map-halo);
    border-radius: 50%;
    background: var(--map-npc);
    vertical-align: -0.07em;
}

.map-dot--object { background: var(--map-object); }
.map-dot--vendor { background: var(--map-vendor); }
.map-dot--instance { background: var(--map-instance); }
.map-dot--fishing { background: var(--map-fishing); }
.map-dot--route { background: var(--map-route); }

/* 지역 고르기 · 지도에서 보기 — 글자 링크를 줄을 바꿔 가며 놓는다 */
.map-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.125rem 1.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* 테두리 없는 글자 링크. 마우스를 올리거나 고른 곳은 옅게 칠한다(칠한 바탕이 글 밖으로 조금 나오게 좌우를 당긴다) */
.map-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 0.375rem;
    margin: 0 -0.375rem;
    padding: 0.25rem 0.375rem;
    border-radius: var(--radius);
    color: var(--color-accent);
}

.map-chip:hover {
    background: var(--color-surface-2);
    text-decoration: none;
}

.map-chip.is-active {
    background: var(--color-accent-soft);
    color: var(--color-text);
    font-weight: 700;
}

.map-chip__count {
    color: var(--color-muted);
    font-size: 0.75rem;
}

/* 범례 — 점의 종류 */
.map-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm) var(--space-md);
    color: var(--color-muted);
    font-size: 0.8125rem;
}

.map-legend > span {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

/* 지도에서 보기 — 대륙 줄과 지역 줄(templates/_map-choices.php) */
.map-choices > * + * {
    margin-top: var(--space-sm);
}

.map-choices__row {
    display: flex;
    align-items: baseline;
    gap: var(--space-sm);
}

.map-choices__label {
    flex: none;
    width: 2.5em;
    color: var(--color-muted);
    font-size: 0.8125rem;
}

.map-choices__row .map-chips {
    flex: 1;
    min-width: 0;
}

/* 크게 보기(game-map.js) — [data-map-zoom] 묶음의 지도를 누르면 팝업에 크게 그린다(퀘스트 화면).
 * 지도는 화면 높이에 맞춘다(--map-ratio 는 지도 그림의 가로 ÷ 세로 — 스크립트가 넣는다). 넓은 화면은 범례를 오른쪽에, 767px 이하는 아래에 */
.js [data-map-zoom] .game-map__view {
    cursor: zoom-in;
}

.dialog.map-zoom {
    width: fit-content;
    max-width: calc(100vw - 2 * var(--gutter));
}

.map-zoom__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
}

.map-zoom__body {
    display: grid;
    grid-template-columns: auto 16rem;
    gap: var(--space-md) var(--space-lg);
    align-items: start;
}

.map-zoom__body > * {
    margin: 0;
}

/* 폭은 팝업 안쪽 폭에서 범례 칸(16rem)을 뺀 만큼, 높이는 팝업 높이(화면 - 3rem)에서 위아래 여백 · 제목 줄 · 지도 아래 글을 뺀 만큼까지 */
.map-zoom .game-map__view {
    width: min(
        62.625rem,
        calc(100vw - 4 * var(--gutter) - 16rem - var(--space-lg)),
        calc((100vh - 11.5rem) * var(--map-ratio, 1.5))
    );
    max-width: none;
}

@media (max-width: 47.9375em) {
    .map-zoom__body {
        grid-template-columns: minmax(0, 1fr);
    }

    .map-zoom .game-map__view {
        width: auto;
    }
}
