/* public/css/map.css — 세계금융기관 지도 화면(fin:world): 제목 줄 오른쪽(기준 시각 + 지역 탭), 남색 지도 무대와 그 위의 범례·확대 버튼·요약 패널·툴팁,
   그리고 지도 SVG(js/app/map/world-map.js)의 층 — 나라 경로(진하기 b1~b4) · 연결선 · 점 · 노드 · 서울 허브 · 이름표.
   SVG 안 .wm-fixed 그룹은 world-map.js가 transform="scale(k)"(k = 지도 단위 / CSS px)로 늘려 화면 크기를 지키므로 그 안의 길이(r·stroke-width·글자)는
   CSS px·rem 그대로 화면 크기다. 연결선 굵기는 연결선 층의 --k로 같은 일을 한다.
   그림자는 떠 있는 요약 패널·툴팁에만. 구분선은 1px. */

/* ── 제목 줄 오른쪽: 기준 시각(위) · 지역 탭(아래, 각 탭에 기관 수) ───────────────────── */

.fin-world .page-heading-aside {
  flex-direction: column;
  align-items: flex-end;
  gap: 1.2rem;
}

.wm-regions {
  flex-wrap: nowrap;
}

/* ── 무대: 제목 줄 아래 남은 높이 전부 ─────────────────────────────────────── */

.wm-stage {
  /* 진하기(요건 3-3 · 스펙 6장): 일반 나라와 기관 수 구간 1–2 · 3–9 · 10–49 · 50+ */
  --wm-land: #16324f;
  --wm-land-line: var(--navy-line);
  --wm-b1: #1f5a96;
  --wm-b2: #2a73c2;
  --wm-b3: #3d8fea;
  --wm-b4: var(--sky);

  /* 무대 안쪽 여백과 아래 줄(범례·확대 버튼)의 높이 — 패널은 그 위까지만 내려온다 */
  --wm-inset: 1.6rem;
  --wm-control: 5.2rem;

  position: relative;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--navy);
  user-select: none;
  -webkit-user-select: none;
}

/* 데이터가 없으면 무대 자리를 빈 상태 안내가 채운다 */
.wm-stage.is-empty {
  display: flex;
  overflow: visible;
  background: none;
}

.wm-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none; /* 끌기·핀치는 지도가 받는다(페이지가 움직이지 않게) */
  cursor: grab;
}

.wm-svg.is-pointing {
  cursor: pointer;
}

.wm-svg.is-dragging {
  cursor: grabbing;
}

.wm-sea {
  fill: var(--navy);
}

/* ── 나라 ───────────────────────────────────────────────────────────────── */

.wm-country {
  fill: var(--wm-land);
  stroke: var(--wm-land-line);
  stroke-width: 1px;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.wm-country.b1 {
  fill: var(--wm-b1);
}

.wm-country.b2 {
  fill: var(--wm-b2);
}

.wm-country.b3 {
  fill: var(--wm-b3);
}

.wm-country.b4 {
  fill: var(--wm-b4);
}

.wm-country.is-selected {
  stroke: var(--on-fill);
  stroke-width: 1px;
}

/* 마우스 올림(고를 수 있는 나라만 — 선택한 나라의 흰 윤곽은 그대로, 흐린 다른 지역 나라는 반응하지 않는다) */
@media (hover: hover) {
  .wm-svg:not(.is-dragging) .wm-country.is-connected:not(.is-selected):not(.is-dim):hover {
    stroke: var(--navy-text);
  }
}

/* 다른 지역(요건: 선택하지 않은 지역은 흐리게). 바로 바뀐다 — 지역 이동(viewBox 420ms)이 움직임을 맡는다. 흐린 노드는 펄스도 쉰다 */
.wm-country.is-dim,
.wm-route.is-dim,
.wm-node.is-dim {
  opacity: 0.15;
}

.wm-node.is-dim .wm-pulse {
  visibility: hidden;
}

/* ── 연결선과 점 ─────────────────────────────────────────────────────────── */

.wm-routes {
  --k: 1;
}

.wm-route {
  fill: none;
  stroke: var(--hub);
  stroke-width: calc(var(--k) * 0.14rem); /* 화면 0.14rem(지도 단위 × --k) — 다른 크기처럼 화면 비율을 따른다 */
  stroke-linecap: round;
  opacity: 0.55;
  pointer-events: none;
}

.wm-route.is-selected {
  stroke-width: calc(var(--k) * 0.24rem);
  opacity: 1;
}

.wm-particles,
.wm-nodes,
.wm-hub,
.wm-labels {
  pointer-events: none;
}

/* 보기가 옮겨 가는 동안 이름표를 내려 둔다(world-map.js가 마지막 프레임에서 다시 놓는다) */
.wm-svg.is-flying .wm-labels {
  visibility: hidden;
}

/* 점: 허브와 같은 주황 구슬(나라 노드의 흰 점과 헷갈리지 않게 작고 색이 다르다) */
.wm-particle-dot {
  r: 0.28rem;
  fill: var(--hub);
}

.wm-particle.is-dim {
  visibility: hidden;
}

/* ── 노드(나라 점)와 펄스 ────────────────────────────────────────────────── */

.wm-node-dot {
  r: 0.42rem;
  fill: var(--on-fill);
  stroke: var(--navy);
  stroke-width: 0.15rem;
}

.wm-node-ring {
  r: 0.95rem;
  fill: none;
  stroke: var(--on-fill);
  stroke-width: 0.18rem;
  opacity: 0;
}

.wm-node.is-selected .wm-node-ring {
  opacity: 1;
}

/* 펄스 링: motion.js가 transform(배율)·opacity를 바꾼다 */
.wm-pulse {
  r: 0.42rem;
  fill: none;
  stroke: var(--sky);
  stroke-width: 0.15rem;
}

.wm-node.is-selected .wm-pulse {
  stroke: var(--on-fill);
}

/* ── 서울 허브 ──────────────────────────────────────────────────────────── */

.wm-hub-dot {
  r: 0.62rem;
  fill: var(--hub);
  stroke: var(--on-fill);
  stroke-width: 0.2rem;
}

.wm-hub-ring {
  r: 1.15rem;
  fill: none;
  stroke: var(--hub);
  stroke-width: 0.12rem;
  opacity: 0.55;
}

.wm-hub .wm-pulse {
  r: 0.62rem;
  stroke: var(--hub);
}

.wm-hub-bg {
  fill: var(--navy);
  stroke: var(--hub);
  stroke-width: 1px;
}

.wm-hub-text {
  font-size: var(--fs-eyebrow);
  font-weight: 900;
  letter-spacing: 0.08em;
  fill: var(--on-fill);
  text-anchor: middle;
  dominant-baseline: central;
}

/* ── 이름표: "일본 241" 알약 ─────────────────────────────────────────────── */

.wm-label-bg {
  fill: var(--navy-2);
  stroke: var(--navy-line);
  stroke-width: 1px;
}

.wm-label-text {
  font-size: var(--fs-table);
  font-weight: 700;
  fill: var(--on-fill);
  text-anchor: middle;
  dominant-baseline: central;
  white-space: pre;
}

.wm-label-count {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  fill: var(--sky);
}

.wm-label.is-selected .wm-label-bg {
  fill: var(--surface);
  stroke: var(--surface);
}

.wm-label.is-selected .wm-label-text {
  fill: var(--ink);
}

.wm-label.is-selected .wm-label-count {
  fill: var(--blue);
}

/* ── 범례(왼쪽 아래, 한 줄 — 확대 버튼 줄과 같은 높이) ───────────────────────────── */

.wm-legend {
  position: absolute;
  left: var(--wm-inset);
  bottom: var(--wm-inset);
  display: flex;
  align-items: center;
  gap: 2rem;
  min-height: var(--wm-control);
  padding: 0 1.8rem;
  border: 1px solid var(--navy-line);
  border-radius: var(--radius);
  background: var(--navy-2);
  pointer-events: none;
}

.wm-legend-title {
  font-size: var(--fs-small);
  font-weight: 700;
  line-height: 1.2;
  color: var(--navy-text);
}

.wm-legend-list {
  display: flex;
  gap: 1.8rem;
}

.wm-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  font-size: var(--fs-small);
  font-weight: 800;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--on-fill);
}

.wm-legend-swatch {
  width: 1.8rem;
  height: 1.2rem;
  border-radius: 0.3rem;
  background: var(--wm-b1);
}

.wm-legend-swatch.b2 {
  background: var(--wm-b2);
}

.wm-legend-swatch.b3 {
  background: var(--wm-b3);
}

.wm-legend-swatch.b4 {
  background: var(--wm-b4);
}

/* ── 확대 버튼(오른쪽 아래, 한 줄: 확대 · 축소 · 전체 보기) ──────────────────────────── */

.wm-zoom {
  position: absolute;
  right: var(--wm-inset);
  bottom: var(--wm-inset);
  display: flex;
  gap: 0.6rem;
}

.wm-zoom-btn {
  display: grid;
  place-items: center;
  width: var(--wm-control);
  height: var(--wm-control);
  border: 1px solid var(--navy-line);
  border-radius: var(--radius);
  background: var(--navy-2);
  color: var(--on-fill);
}

.wm-zoom-btn svg {
  width: 2.4rem;
  height: 2.4rem;
}

.wm-zoom-btn:active {
  background: var(--navy-line);
}

@media (hover: hover) {
  .wm-zoom-btn:hover {
    border-color: var(--navy-text);
  }
}

/* ── 요약 패널(오른쪽 위에 떠 있음 — 고른 노드를 가리면 왼쪽 위). 아래 줄(범례·확대 버튼) 위까지만 내려오고, 모자라면 기관명 목록만 줄어 스크롤한다 ── */

.wm-panel {
  position: absolute;
  top: var(--wm-inset);
  right: var(--wm-inset);
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  width: 46rem;
  max-height: calc(100% - 2 * var(--wm-inset) - var(--wm-control) - 1.2rem);
  overflow: hidden;
  padding: 2rem 2.2rem 2.2rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 0.8rem 2.4rem rgba(2, 10, 22, 0.35);
  color: var(--text);
  animation: wm-panel-in 0.2s ease-out;
}

.wm-panel.is-left {
  right: auto;
  left: var(--wm-inset);
}

.wm-panel > * {
  flex: 0 0 auto;
}

@keyframes wm-panel-in {
  from {
    opacity: 0;
  }
}

.wm-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.6rem;
}

.wm-panel-title {
  min-width: 0;
}

.wm-panel-region {
  margin-bottom: 0.5rem;
  font-size: var(--fs-eyebrow);
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--blue);
}

.wm-panel-name {
  font-size: var(--fs-section);
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
  color: var(--ink);
}

.wm-panel-close {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 4.4rem;
  height: 4.4rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-2);
}

.wm-panel-close svg {
  width: 2rem;
  height: 2rem;
}

.wm-panel-close:active {
  background: var(--blue-soft);
}

.wm-panel-count {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
}

.wm-panel-count .num {
  font-size: var(--fs-title);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--blue);
}

.wm-panel-unit {
  font-size: var(--fs-body);
  font-weight: 700;
  color: var(--text-2);
}

.wm-panel-types {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.wm-panel-type {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 3rem;
  padding: 0 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: var(--fs-small);
  font-weight: 700;
  color: var(--text-2);
}

.wm-panel-type .num {
  font-weight: 800;
  color: var(--ink);
}

.wm-panel > .wm-panel-list {
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-top: 1px solid var(--line);
}

.wm-panel-list li {
  overflow: hidden;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-table);
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--ink);
}

.wm-panel-more {
  margin-top: -0.5rem;
  font-size: var(--fs-small);
  font-weight: 700;
  color: var(--muted);
}

.wm-panel-open {
  flex: 0 0 auto;
  width: 100%;
}

@media (hover: hover) {
  .wm-panel-close:hover {
    border-color: var(--blue);
    color: var(--blue);
  }
}

/* ── 툴팁(마우스 올림에만 — 터치는 탭 → 패널) ─────────────────────────────── */

.wm-tooltip {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 1rem 1.4rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: 0 0.6rem 1.6rem rgba(2, 10, 22, 0.3);
  white-space: nowrap;
  pointer-events: none;
}

.wm-tooltip b {
  font-size: var(--fs-body);
  font-weight: 800;
  color: var(--ink);
}

.wm-tooltip span {
  font-size: var(--fs-small);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
}
