/* 사용자 지도 (화면설계서 S 탐색 v0.2 S-06 · S-07 · 상태) — 그림 지도(S-06C) 화면
 * - 토큰은 public/user-tokens.css, 셸 · 준비 중 · 유형 색(home-tone--*)은 public/user-home.css 를 그대로 씀. 접두어 map-*.
 * - 값은 시안(고비_화면시안_261015v3) 지도 CSS 실측값(.mapw · .mtop · .mmine · .zbtn · .gps · .msheet · .asl · .asg · .ast · .note ·
 *   .row · .mdh · .mpi · .pin.cc · .ov .sheet · .toast). 시안에 없는 값은 "(제안)".
 * - 지도 화면에는 앱 상단 바가 없고(C-1) 지도가 화면 전체를 채움 → 이 화면에서만 머리를 숨기고 문서 스크롤을 막음(:has, 지원 안 하면 지도가 위를 덮음).
 * - 인라인 style 없음: 원 위치 · 그림 바탕 위치는 SVG transform 속성(서버 계산, 끌기 중에는 /static/shared/user-map.js 가 같은 속성을 바꿈). */

/* ---------- 지도 화면 셸 ---------- */
.app-shell:has(.map) {
  min-height: 0;
  padding-bottom: 0;
}

.app-shell:has(.map) > .app-header {
  display: none;
}

body:has(.map) {
  overflow: hidden;
}

/* 지도 전체 (시안 .mapw: 휴대폰 영역 전체, 배경 #F3F3F4) — 하단 탭(z-nav 20)이 시트 위에 떠 있음 */
.map {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1;
  width: 100%;
  max-width: var(--layout-max-width);
  margin: 0 auto;
  overflow: hidden;
  background: #f3f3f4;
}

.map__stage {
  position: absolute;
  inset: 0;
  touch-action: none;
  cursor: grab;
}

.map__stage.is-dragging {
  cursor: grabbing;
}

.map__svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- 4번 지역 묶음 원 (시안 .pin.cc: 빨강 88% · 흰 테두리 2px · 그림자, 숫자 15px 굵게 + 지역 이름 10px) ---------- */
.map-cc {
  cursor: pointer;
}

.map-cc.is-hidden {
  display: none;
}

.map-cc__dot {
  fill: var(--color-brand-primary);
  fill-opacity: 0.88;
  stroke: #fff;
  stroke-width: 2;
}

.map-cc.is-on .map-cc__dot {
  fill: var(--color-bg-inverse);
  fill-opacity: 1;
}

.map-cc__n {
  fill: #fff;
  font-size: 15px;
  font-weight: var(--font-weight-bold);
}

.map-cc__lab {
  fill: #fff;
  fill-opacity: 0.92;
  font-size: 10px;
  font-weight: var(--font-weight-medium);
}

.map-cc:focus {
  outline: none;
}

.map-cc:focus-visible .map-cc__dot {
  stroke: var(--focus-ring-color);
  stroke-width: 3;
}

/* ---------- 1 · 2 · 3번 떠 있는 줄 (시안 .mtop: 위 50px, 좌우 12px) ---------- */
.map-top {
  position: absolute;
  top: calc(50px + var(--app-safe-top));
  right: 12px;
  left: 12px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  pointer-events: none;
}

.map-top > * {
  pointer-events: auto;
}

/* 뒤로 (시안 .mback: 흰 네모 40px, 모서리 12px) */
.map-back {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: #fff;
  box-shadow: var(--elevation-2);
  color: var(--color-text-primary);
}

.map-back__icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 흰 상자 (시안 .mmine) */
.map-mine {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: 40px;
  padding: 0 6px 0 12px;
  border-radius: var(--radius-md);
  background: #fff;
  box-shadow: var(--elevation-2);
}

/* 2번 내 조건만 보기 토글 (시안 .mmine label · .sw 34 × 20) */
.map-switch {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 40px;
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  text-decoration: none;
}

.map-switch__sw {
  position: relative;
  flex: none;
  width: 34px;
  height: 20px;
  border-radius: 10px;
  background: #d5d7db;
  transition: background var(--motion-duration-base);
}

.map-switch__sw::after {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  content: "";
  transition: left var(--motion-duration-base);
}

.map-switch[aria-checked="true"] .map-switch__sw {
  background: var(--color-bg-inverse);
}

.map-switch[aria-checked="true"] .map-switch__sw::after {
  left: 16px;
}

/* 3번 조건 변경 (시안 .mmine button: 높이 30, 어두운 바탕, 빨간 배지) */
.map-cond {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  height: 30px;
  padding: 0 10px;
  border-radius: 9px;
  background: var(--color-bg-inverse);
  color: var(--color-text-inverse);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  text-decoration: none;
}

.map-cond__icon {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.map-cond__badge {
  padding: 0 5px;
  border-radius: 9px;
  background: var(--color-brand-primary);
  font-size: 10px;
  font-style: normal;
}

/* ---------- 6번 확대 · 축소 (시안 .zbtn: 시트 위 오른쪽, 아래 366px) · 7번 현재 위치 (시안 .gps: 아래 318px) ---------- */
.map-zoom {
  position: absolute;
  right: 14px;
  bottom: 366px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--elevation-2);
}

.map-zoom__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  color: var(--color-text-primary);
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-medium);
  text-decoration: none;
}

.map-zoom__btn + .map-zoom__btn {
  border-top: 1px solid var(--color-border-default);
}

.map-zoom__btn[aria-disabled="true"] {
  color: var(--color-text-disabled);
}

.map-gps {
  position: absolute;
  right: 14px;
  bottom: 318px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--elevation-2);
  color: var(--color-text-primary);
}

.map-gps__icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

/* ---------- 9 ~ 13번 하단 시트 (시안 .msheet: 높이 306px 고정, 위 모서리 16px, 안에서 세로 스크롤) ---------- */
.map-sheet {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  height: 306px;
  padding: var(--space-2) var(--space-4) 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: #fff;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
  touch-action: pan-y;
}

.map-sheet__grab {
  flex: none;
  width: 40px;
  height: 4px;
  margin: 0 auto 10px;
  border-radius: 2px;
  background: #d5d8dd;
}

.map-sheet__body {
  flex: 1 1 auto;
  min-height: 0;
  padding-bottom: 150px; /* 시안 .msl: 떠 있는 하단 탭에 가리지 않게 */
  overflow-y: auto;
  scrollbar-width: none;
}

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

/* 9번 지역 이름 (시안 .asl) */
.map-asl {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-bold);
}

.map-asl__icon {
  flex: none;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

/* 10번 요약 3칸 · 23번 금액 3칸 (시안 .asg) */
.map-sum {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--space-1_5);
  margin-top: var(--space-2_5);
}

.map-sum__cell {
  min-width: 0;
  padding: var(--space-2);
  border-radius: 10px;
  background: var(--color-bg-subtle);
}

.map-sum__k {
  display: block;
  color: var(--color-text-secondary);
  font-size: var(--font-size-2xs);
}

.map-sum__v {
  display: block;
  font-size: 0.9375rem; /* 시안 .asg b 15px */
  font-weight: var(--font-weight-bold);
}

.map-sum__v--gain {
  color: var(--color-money-gain);
}

/* 11번 유형별 시세 (시안 .ast) — 1차는 '시세 준비 중' 한 칸 */
.map-ast {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1_5) var(--space-3);
  margin-top: var(--space-2);
  color: var(--color-text-secondary);
  font-size: var(--font-size-xs);
}

/* 12번 안내 (시안 .note margin 6px 0 8px) */
.map-note {
  margin: var(--space-1_5) 0 var(--space-2);
  color: var(--color-text-tertiary);
  font-size: var(--font-size-2xs);
  line-height: var(--font-leading-xs);
}

.map-more {
  padding: var(--space-2) 0;
  color: var(--color-text-tertiary);
  font-size: var(--font-size-xs);
  text-align: center;
}

/* 0건 (제안: S-06B 13번) */
.map-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1_5);
  padding: var(--space-5) 0;
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
}

.map-lnk {
  color: var(--color-text-link);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  text-decoration: none;
}

/* 15번 동 목록 머리 (시안 .mdh) */
.map-dh {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-1) 0 var(--space-2);
}

/* ---------- 13번 목록 행 카드: 공용 /static/shared/user-item-row.css (partials/user-item-row, C-6) ---------- */

/* S-07D 22번 물건 요약 사진 칸 (시안 .mpx .im 64px): 유형 색 + 글자 1자 위에 사진 */
.map-pi__im {
  position: relative;
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  overflow: hidden;
  border-radius: 10px;
}

.map-pi__glyph {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-heavy);
  line-height: 1;
}

.map-pi__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--color-bg-image-placeholder);
}

.map-pi__img[hidden] {
  display: none;
}

/* ---------- S-07D 물건 정보 (시안 .mpi · .mpx · .mpc · .mpn · .mpt · .mpa · .mpb) ---------- */
.map-pi__back {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  margin-bottom: var(--space-2);
  color: var(--color-text-secondary);
  font-size: var(--font-size-xs);
  text-decoration: none;
}

.map-pi__back-icon {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.map-pi__card {
  display: flex;
  gap: var(--space-2_5);
  color: var(--color-text-primary);
  text-decoration: none;
}

.map-pi__tx {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.map-pi__no,
.map-pi__addr {
  color: var(--color-text-secondary);
  font-size: var(--font-size-xs);
}

.map-pi__dd {
  color: var(--color-brand-primary);
}

.map-pi__name {
  margin: 2px 0;
  font-size: 0.9375rem;
}

.map-pi__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  margin-top: var(--space-2_5);
}

.map-pi__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid var(--color-border-default);
  border-radius: 10px;
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  text-decoration: none;
}

.map-pi__btn--on {
  border-color: var(--color-bg-inverse);
  background: var(--color-bg-inverse);
  color: var(--color-text-inverse);
}

.map-pi__favorite { margin: 0; }
.map-pi__favorite .map-pi__btn { width: 100%; background: var(--color-bg-fav); font-family: inherit; cursor: pointer; }
.map-pi__favorite [aria-pressed="true"] { border-color: var(--color-text-primary); font-weight: var(--font-weight-bold); }
/* 공통 하트 부분 뷰(partials/user-fav-heart)를 시안 글자 버튼(mpb)으로 쓸 때: 하트 아이콘은 그리지 않고 글자만(시안 정합 G4 M-04) */
.map-pi__fav .app-fav__icon { display: none; }

/* ---------- S-07B 위치 권한 시트 (C-4, 시안 locAsk: .ov .sheet 가운데 정렬) ---------- */
.map-ov {
  position: fixed;
  inset: 0;
  z-index: var(--z-sheet);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.map-ov__scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.map-ov__sheet {
  position: relative;
  width: 100%;
  max-width: var(--layout-max-width);
  padding: 10px var(--space-4) calc(28px + var(--app-safe-bottom));
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: #fff;
  text-align: center;
}

.map-ov__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  margin: 6px auto 10px;
  border-radius: 50%;
  background: var(--color-bg-subtle);
}

.map-ov__icon-svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: var(--color-text-primary);
  stroke-width: 1.8;
}

.map-ov__title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
}

.map-ov__desc {
  margin: 6px 0 18px;
  color: var(--color-text-tertiary);
  font-size: var(--font-size-sm);
  line-height: var(--font-leading-sm);
}

.map-ov__allow {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border-radius: var(--radius-md);
  background: var(--color-brand-primary);
  color: #fff;
  font-size: 0.9375rem;
  font-weight: var(--font-weight-bold);
  text-decoration: none;
}

.map-ov__later {
  display: inline-block;
  margin-top: var(--space-3);
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  text-decoration: none;
}

/* ---------- 20번 토스트 (C-5, 시안 .toast: 아래 100px 가운데) ---------- */
.map-toast {
  position: fixed;
  bottom: calc(100px + var(--app-safe-bottom));
  left: 50%;
  z-index: var(--z-toast);
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(27, 27, 30, 0.94);
  color: #fff;
  font-size: var(--font-size-sm);
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
}

.map-toast .home-pending {
  color: #8fb0f0; /* 어두운 바탕 위 파란 "준비 중" (제안, 대비 7.3 : 1) */
}

.map-toast.is-hidden {
  display: none;
}

/* ---------- 누를 수 없는 링크 (대상 화면 없음 — 모양은 그대로, 눌림만 막음) ---------- */
.map [aria-disabled="true"] {
  cursor: default;
}

@media (prefers-reduced-motion: reduce) {
  .map-switch__sw,
  .map-switch__sw::after {
    transition: none;
  }
}

/* ---------- 시안 v15 (body.app--v15, 계획 4-3 지도 — 스타일만) ----------
 * 지도 바탕은 v15 회색(--color-bg-page), 시트는 흰색 그대로. 핀 판정 색 · 묶음 원 빨강 · 잉크 버튼(조건 변경)은 그대로.
 * 시트 안 행 카드(C-6)의 바탕은 행 카드 CSS 한 곳(/static/shared/user-item-row.css)에서 정함. */
.app--v15 .map {
  background: var(--color-bg-page);
}
