/* 지도 메인 */
.home { overflow: hidden; height: 100dvh; }

.home-top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 900;
  padding: var(--s3) var(--s5) 0;
  background: var(--bg);
}

/* 검색창 (누르면 검색 화면이 열린다) */
.searchbar {
  width: 100%; display: flex; align-items: center; gap: var(--s2);
  height: 44px; padding: 0 var(--s4); border: 0; border-radius: var(--r2);
  background: var(--sunken); color: var(--text-disabled); text-align: left;
}
.searchbar:hover { background: var(--press); }
.searchbar .icon { color: var(--text-3); }
/* 아이콘을 담은 칸이 글자 줄(기준선)에 맞춰지면 위로 뜬다 → 칸 자체를 가운데 정렬 */
#search-icon { display: grid; place-items: center; flex: none; }
.searchbar span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.searchbar--filled { color: var(--text); font-weight: 600; }

/* 검색 화면 */
.search { position: fixed; inset: 0; z-index: 1500; display: flex; flex-direction: column; background: var(--bg); }
.search__bar { display: flex; align-items: center; gap: var(--s1); padding: var(--s3) var(--s4) var(--s2) var(--s2); }
.search__bar .input { height: 44px; }
.search__body { flex: 1; overflow-y: auto; padding: 0 var(--s5) var(--s8); }
.search__body .group-title--split { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2); }
.search__field { position: relative; flex: 1; }
.search__field .input { padding-right: 44px; }
.search__clear { position: absolute; right: 2px; top: 2px; color: var(--text-3); }
.place-row {
  display: grid; grid-template-columns: 20px 1fr; align-items: center; gap: var(--s3); width: calc(100% + var(--s6));
  margin: 0 calc(var(--s3) * -1); padding: var(--s3); border: 0; border-radius: var(--r2); background: none; text-align: left;
}
.place-row:hover { background: var(--sunken); }
.place-row .icon { color: var(--text-3); }
.place-row__name { display: block; font-weight: 600; }
.place-row__sub { display: block; margin-top: 2px; font-size: var(--fs-sm); color: var(--text-3); }

.map { position: fixed; inset: 0 0 var(--nav-h) 0; z-index: 0; background: var(--paper-200); }
/* 지도 위 줄: 화면 거리 표시 + 내 위치 */
.map-bar {
  position: fixed; top: calc(var(--top-h, 104px) + var(--s3)); left: var(--s4); right: var(--s4); z-index: 800;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2); pointer-events: none;
}
.map-bar > * { pointer-events: auto; }
/* 이 화면이 대략 얼마나 되는지 (600m 이내 · 도보 9분). 누를 수 없는 표시라 눌러도 지도가 받는다 */
.view-chip {
  pointer-events: none !important; display: inline-flex; align-items: center; height: 26px; padding: 0 10px;
  border-radius: 13px; background: var(--surface); box-shadow: var(--float);
  font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.map-btn {
  display: grid; place-items: center; width: 40px; height: 40px; flex: none;
  border: 0; border-radius: 50%; background: var(--surface); color: var(--text); box-shadow: var(--float);
}
.map-btn .icon { width: 20px; height: 20px; }


/* 아래 시트: peek(상위 3곳) ↔ full(전체 목록) */
.sheet {
  position: fixed; left: 0; right: 0; bottom: var(--nav-h); z-index: 950;
  display: flex; flex-direction: column;
  max-height: calc(100dvh - var(--nav-h) - 96px);
  background: var(--surface);
  border-radius: var(--r-sheet) var(--r-sheet) 0 0; box-shadow: var(--float);
  transition: height 0.22s ease;
}
.sheet[data-state='peek'] { height: var(--peek, 340px); }
.sheet[data-state='full'] { height: calc(100dvh - var(--nav-h) - 96px); }
.sheet__handle { flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 24px; padding: 8px 0 2px; border: 0; background: none; touch-action: none; cursor: grab; }
.sheet__handle span { width: 36px; height: 4px; border-radius: 2px; background: var(--paper-300); }
.sheet__handle small { font-size: var(--fs-xs); font-weight: 600; line-height: 1; color: var(--text-3); }
.sheet__handle small:empty { display: none; }
.sheet__body { flex: 1; overflow-y: auto; padding: 0 var(--s5) var(--s6); overscroll-behavior: contain; }
.sheet[data-state='peek'] .sheet__body { overflow: hidden; }
.sheet[data-state='peek'] #rest { display: none; }
.sheet__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); padding: 0 0 var(--s1); }
.sheet__title { font-size: var(--fs-lg); letter-spacing: -0.02em; }
.sheet__actions { display: flex; gap: var(--s2); padding-top: var(--s3); }
.sheet__actions:empty { display: none; }
.sheet__actions > * { flex: 1; }
.sheet[data-state='full'] [data-act='more'] { display: none; }

/* 핀을 눌렀을 때 시트 대신 올라오는 카드 */
.preview {
  position: fixed; left: var(--s3); right: var(--s3); bottom: calc(var(--nav-h) + var(--s3)); z-index: 960;
  padding: var(--s4) var(--s5) var(--s5); border-radius: var(--r-sheet); background: var(--surface); box-shadow: var(--float);
}
.preview__back { display: block; margin-bottom: var(--s2); }
/* 한 자리에 여러 곳: 고르는 목록 (길면 카드 안에서 스크롤) */
.group-list { max-height: min(46vh, 320px); overflow-y: auto; margin: var(--s2) calc(var(--s2) * -1) 0; }
.group-list button { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); width: 100%; padding: var(--s3) var(--s2); border: 0; border-radius: var(--r2); background: none; text-align: left; }
.group-list button:hover { background: var(--sunken); }
.group-list__name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.group-list .score { font-size: var(--fs-lg); }
.preview__close { position: absolute; top: var(--s2); right: var(--s2); color: var(--text-3); }
.preview__rank { padding-right: 40px; font-size: var(--fs-sm); color: var(--text-3); }
.preview__rank b { color: var(--terracotta); }
.preview__main { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: var(--s3); margin-top: 2px; }
.preview__name { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.02em; line-height: 1.3; }
.preview__meta { display: flex; flex-wrap: wrap; gap: 0 var(--s2); margin-top: var(--s1); font-size: var(--fs-sm); color: var(--text-3); }
.preview__meta > * + *::before { content: '·'; margin-right: var(--s2); }
.preview .score { font-size: var(--fs-2xl); font-weight: 800; letter-spacing: -0.03em; }
.preview .score--empty { font-size: var(--fs-sm); }
.preview__actions { display: flex; gap: var(--s2); margin-top: var(--s4); }
.preview__actions > * { flex: 1; }
.has-preview .sheet { visibility: hidden; }
/* 지도 화면: 비교 바는 카드·시트 위에, 시트 목록 끝이 가려지지 않게 */
.home .tray { z-index: 1100; }
.has-preview .tray { bottom: calc(var(--nav-h) + var(--s3) + var(--preview-h, 200px) + var(--s2)); }
.has-tray .sheet__body { padding-bottom: 88px; }

.group-title { padding: var(--s6) 0 var(--s2); font-size: var(--fs-sm); font-weight: 700; color: var(--text-2); }
.group-title .muted { font-weight: 400; }

/* 넓은 화면: 시트를 왼쪽 패널로 */
/* PC: 맨 위 메뉴 아래에 [목록 패널 400px | 지도] */
@media (min-width: 900px) {
  .home { --panel: 400px; }
  .home-top { top: var(--topnav); left: 0; right: auto; width: var(--panel); padding-bottom: 0; background: var(--surface); }
  .sheet, .sheet[data-state] {
    top: calc(var(--topnav) + var(--top-h, 104px)); bottom: 0; left: 0; right: auto; width: var(--panel); height: auto; max-height: none;
    border-radius: 0; box-shadow: none;
  }
  .sheet__handle { display: none; }
  .sheet[data-state] .sheet__body { overflow-y: auto; padding-top: var(--s3); }
  .sheet[data-state] #rest { display: block; }
  .sheet [data-act='more'] { display: none; }
  .has-preview .sheet { visibility: visible; }
  .map { top: var(--topnav); left: var(--panel); bottom: 0; }
  .map-bar { top: calc(var(--topnav) + var(--s4)); left: calc(var(--panel) + var(--s4)); }
  .preview { left: calc(var(--panel) + var(--s4)); right: auto; bottom: var(--s4); width: 380px; }
  .search { top: var(--topnav); left: 0; right: auto; width: var(--panel); box-shadow: var(--float); }
  /* PC 지도: 비교 바는 목록 패널 아래쪽 */
  .home .tray { left: var(--s3); width: calc(var(--panel) - var(--s6)); transform: none; bottom: var(--s4); }
  .has-preview .tray { bottom: var(--s4); }
}

/* 지도 화면의 알림은 위쪽(지도 위)에: 아래는 시트·목록이 바뀌는 자리라 가리지 않게 */
.home .toast { bottom: calc(var(--nav-h) + var(--peek, 340px) + var(--s3)); white-space: nowrap; } /* 접힌 시트 바로 위 */
.home.has-preview .toast { bottom: calc(var(--nav-h) + var(--preview-h, 200px) + var(--s5)); } /* 카드 위 */
.home:has(.sheet[data-state='full']) .toast { bottom: calc(var(--nav-h) + var(--s4)); }
@media (min-width: 900px) {
  /* 넓은 화면: 지도 칸 아래쪽 가운데 */
  .home .toast, .home.has-preview .toast { bottom: var(--s6); left: calc(var(--panel) + (100% - var(--panel)) / 2); }
}
