/* 지도 화면. .screen.no-pad 안에서 전체 영역을 쓴다. 하단 탭 위. */

.map-wrap {
  position: relative; width: 100%; height: 100%; overflow: hidden;
  /* 시트가 현재 차지한 높이. JS(드래그)가 갱신해서 지도 도구가 따라 올라가게 함 */
  --sheet-h: 44%;
}

.map-canvas { position: absolute; inset: 0; z-index: 0; background: #e9ecf2; }
.map-canvas .leaflet-container { width: 100%; height: 100%; font: inherit; background: #e9ecf2; }

/* 상단 바 */
.map-topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 400;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 14px 8px;
  background: linear-gradient(#fff 62%, rgba(255,255,255,0));
  pointer-events: none;
}
.map-topbar > * { pointer-events: auto; }
.map-search { margin: 0 0 10px; background: white; box-shadow: 0 4px 16px rgba(20,24,40,.1); }
.map-modes, .map-cats { margin: 0 0 8px; }
.map-modes .filter-chip, .map-cats .filter-chip { box-shadow: 0 2px 8px rgba(20,24,40,.08); }

.map-suggest {
  position: absolute; top: calc(env(safe-area-inset-top, 0px) + 64px); left: 14px; right: 14px; z-index: 500;
  background: white; border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 10px 30px rgba(20,24,40,.16); overflow: hidden;
}
.suggest-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 12px 14px; border: 0; border-bottom: 1px solid var(--line); background: white; text-align: left; font-size: 13px; color: var(--ink); }
.suggest-item:last-child { border-bottom: 0; }
.suggest-item .icon { color: var(--muted); flex: none; }

/* 플로팅 버튼 — 시트 높이(--sheet-h)에 맞춰 따라 올라가 겹치지 않음 */
.map-search-here {
  position: absolute; left: 50%; z-index: 350;
  bottom: calc(var(--sheet-h) + 14px);
  transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 15px; border: 0; border-radius: 999px;
  background: var(--primary); color: white; font-size: 12px; font-weight: 740;
  box-shadow: 0 6px 18px rgba(85,72,232,.35);
  transition: bottom .05s linear;
}
.map-locate {
  position: absolute; right: 16px; z-index: 350;
  bottom: calc(var(--sheet-h) + 14px);
  background: white; box-shadow: 0 4px 14px rgba(20,24,40,.18);
  border: 1px solid var(--line);
  transition: bottom .05s linear;
}

/* 하단 시트 (자유 드래그 + 3단 스냅) */
.map-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 420;
  display: flex; flex-direction: column;
  background: white; border-radius: 22px 22px 0 0;
  box-shadow: 0 -8px 30px rgba(20,24,40,.14);
  height: 44%;
  touch-action: pan-y;
}
/* 드래그 중이 아닐 때만 부드럽게 스냅 */
.map-sheet:not(.is-dragging) { transition: height .26s cubic-bezier(.22,.61,.36,1); }
.map-sheet.is-dragging { transition: none; }

/* 손잡이 영역: 여기만 터치 제스처를 가로채 스크롤과 안 섞이게 */
.sheet-handle {
  flex: none; display: flex; flex-direction: column; align-items: center;
  padding: 8px 0 4px; cursor: grab; touch-action: none; user-select: none;
  -webkit-user-select: none;
}
.sheet-handle:active { cursor: grabbing; }
.sheet-grip {
  width: 44px; height: 5px; border: 0; border-radius: 3px;
  background: #d6d9e2; padding: 0; cursor: inherit;
}
.map-sheet:not([data-state="collapsed"]) .sheet-handle:focus-within .sheet-grip,
.sheet-grip:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }

.sheet-content {
  flex: 1; min-height: 0; overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 2px 20px calc(env(safe-area-inset-bottom, 0px) + 20px);
  scrollbar-width: none;             /* Firefox */
}
.sheet-content::-webkit-scrollbar { width: 0; height: 0; }  /* Chrome/Safari */
/* 접힘 단계에서는 내용 스크롤을 막아 손잡이만 보이게 */
.map-sheet[data-state="collapsed"] .sheet-content { overflow: hidden; }

.sheet-head { margin: 2px 0 12px; font-size: 16px; font-weight: 800; letter-spacing: -.3px; line-height: 1.35; overflow-wrap: anywhere; }
.sheet-sub { margin: -6px 0 12px; }
.sheet-empty { padding: 24px 6px; text-align: center; }
.sheet-empty p { margin: 0 0 12px; }

.map-list { display: grid; gap: 2px; }
.map-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 4px; border: 0; border-bottom: 1px solid var(--line);
  background: transparent; text-align: left; text-decoration: none; color: inherit;
}
.map-row:last-child { border-bottom: 0; }
.map-row.is-selected { background: var(--primary-soft); border-radius: 12px; border-bottom-color: transparent; }
.row-num { display: grid; place-items: center; width: 26px; height: 26px; flex: none; border-radius: 9px; background: var(--primary-soft); color: var(--primary); font-size: 12px; font-weight: 800; }
.row-pin { display: grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: 9px; color: #fff; }
.row-pin .icon { width: 16px; height: 16px; }
.row-info { flex: 1; min-width: 0; }
.row-info strong { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-chevron { flex: none; color: var(--muted); }

.sheet-place .sheet-actions { gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.sheet-actions .primary-button, .sheet-actions .secondary-button { flex: 1 1 calc(50% - 4px); justify-content: center; white-space: nowrap; }

.trip-days, .travel-modes { margin: 0 0 14px; flex-wrap: wrap; }
.route-origin { margin-bottom: 14px; }
.route-origin .field-label { display: block; margin-bottom: 4px; }
.route-origin .btn-row { gap: 8px; margin: 8px 0 6px; flex-wrap: wrap; }
.route-result { margin-top: 8px; }
.route-card strong { display: block; font-size: 15px; margin-bottom: 4px; }
.route-card p { margin: 0 0 4px; }

.bus-notice { display: grid; gap: 12px; }
.bus-notice .primary-button { justify-content: center; }

/* 카테고리 색 (핀 + 목록 아이콘 공통) */
.cat-food { background: #e8590c; }
.cat-cafe { background: #9c6b3f; }
.cat-sight { background: #1c7ed6; }
.cat-culture { background: #ae3ec9; }
.cat-activity { background: #2f9e44; }
.cat-shop { background: #f08c00; }
.cat-default { background: var(--primary); }

/* 마커 */
.map-marker {
  display: grid; place-items: center; width: 30px; height: 30px;
  border: 2px solid white; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: var(--primary); box-shadow: 0 2px 6px rgba(20,24,40,.3); cursor: pointer; padding: 0;
}
.map-marker .marker-num, .map-marker .marker-ico, .map-marker .marker-dot { transform: rotate(45deg); color: white; }
.map-marker .marker-num { font-size: 12px; font-weight: 800; }
.map-marker .marker-ico { width: 15px; height: 15px; }
.map-marker .marker-dot { width: 7px; height: 7px; border-radius: 50%; background: white; }
.map-marker.selected { width: 36px; height: 36px; z-index: 10; box-shadow: 0 4px 12px rgba(20,24,40,.45); }
.map-marker.selected .marker-ico { width: 18px; height: 18px; }
.map-marker.k-trip { background: #1c2033; }
.map-marker-wrap { background: transparent; border: 0; }

/* 내 위치(파란 점) */
.map-mylocation { position: relative; width: 18px; height: 18px; }
.map-mylocation .ml-dot {
  position: absolute; inset: 0; margin: auto; width: 14px; height: 14px; border-radius: 50%;
  background: #1c7ed6; border: 2.5px solid #fff; box-shadow: 0 0 0 1px rgba(28,126,214,.5), 0 2px 5px rgba(20,24,40,.35);
}
.map-mylocation .ml-pulse {
  position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; border-radius: 50%;
  background: rgba(28,126,214,.25); animation: mlPulse 2s ease-out infinite;
}
@keyframes mlPulse { 0% { transform: scale(.6); opacity: .8; } 100% { transform: scale(2.2); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .map-mylocation .ml-pulse { animation: none; } }

/* 지도 실패 대체 */
.map-fallback { display: grid; place-items: center; gap: 8px; height: 100%; padding: 40px; text-align: center; color: var(--muted); }
.map-fallback .icon { width: 40px; height: 40px; }
.map-fallback p { margin: 0; }

@media (max-width: 380px) {
  .sheet-actions .primary-button, .sheet-actions .secondary-button { flex: 1 1 100%; }
}

/* 넓은 화면(PC)에서 앱 셸이 가운데 고정폭이면 시트/도구도 그 안에서 */
.route-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.route-head .sheet-head { flex: 1; }
.route-head .btn-sm { min-height: 40px; flex: none; }
