/* 맛집 지도 -- 레이아웃과 색. 색은 토큰으로 두고 다크는 토큰만 바꾼다. */
:root {
  color-scheme: light dark;
  --bg: #f6f3ee;
  --panel: #ffffff;
  --panel-2: #f1ede6;
  --text: #1d1a17;
  --muted: #6d675f;
  --line: #e2dcd2;
  --accent: #c8412b;
  --accent-ink: #ffffff;
  --shadow: 0 6px 24px rgba(30, 20, 10, .14);
  --radius: 12px;
  --topbar-h: 56px;
  --sidebar-w: 340px;
  /* 점수 색 (낮음 -> 높음). 지도 원 색과 목록 배지 색이 같은 값을 쓴다. */
  --s-neg: #9a9a9a;
  --s-1: #f2c08a;
  --s-2: #ee9a5b;
  --s-3: #e2673a;
  --s-4: #c8412b;
  --s-5: #8f1d1d;
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
}
:root[data-theme="dark"] {
  --bg: #15161a;
  --panel: #1e2026;
  --panel-2: #262932;
  --text: #ecebe7;
  --muted: #9a9890;
  --line: #34373f;
  --accent: #ff7a5c;
  --accent-ink: #1a0f0c;
  --shadow: 0 6px 24px rgba(0, 0, 0, .5);
  --s-neg: #6b6b6b;
  --s-1: #b98a5a;
  --s-2: #d98a4e;
  --s-3: #e86a3a;
  --s-4: #ff7a5c;
  --s-5: #ffb199;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.45;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ---- 상단 바 ---- */
.topbar {
  height: var(--topbar-h);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto; /* 검색창이 좁은 화면에서 버튼을 밀어내지 않게 */
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: inherit; white-space: nowrap; }
.brand-mark { font-size: 22px; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.brand-count { color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.search { position: relative; display: flex; max-width: 560px; width: 100%; min-width: 0; justify-self: center; }
.search input {
  flex: 1; height: 38px; padding: 0 14px; border-radius: 999px 0 0 999px;
  border: 1px solid var(--line); background: var(--panel-2); outline: none; min-width: 0;
}
.search input:focus { border-color: var(--accent); }
.search .icon-btn { border-radius: 0 999px 999px 0; border-left: 0; height: 38px; width: 44px; }
.search-results {
  position: absolute; top: 44px; left: 0; right: 0; margin: 0; padding: 6px; list-style: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); max-height: 60vh; overflow: auto; z-index: 30;
}
.search-results li { padding: 8px 10px; border-radius: 8px; cursor: pointer; display: flex; gap: 10px; align-items: baseline; }
.search-results li:hover, .search-results li[aria-selected="true"] { background: var(--panel-2); }
.search-results .kind { font-size: 11px; color: var(--muted); flex: none; width: 40px; }
.search-results .sub { color: var(--muted); font-size: 12px; margin-left: auto; text-align: right; }
.search-results .group { font-size: 11px; color: var(--muted); padding: 8px 10px 2px; cursor: default; }
.search-results .group:hover { background: none; }

.icon-btn, .pill {
  height: 36px; border: 1px solid var(--line); background: var(--panel); border-radius: 999px;
  cursor: pointer; padding: 0 12px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; flex: none;
}
.icon-btn { width: 36px; padding: 0; justify-content: center; }
.icon-btn:hover, .pill:hover { background: var(--panel-2); }
.pill[aria-expanded="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pill.ghost { color: var(--muted); }
.badge { background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: 11px; padding: 0 6px; min-width: 18px; text-align: center; }
.pill[aria-expanded="true"] .badge { background: var(--accent-ink); color: var(--accent); }

/* ---- 필터 ---- */
.filters {
  background: var(--panel); border-bottom: 1px solid var(--line); padding: 10px 14px; z-index: 19;
  display: flex; flex-direction: column; gap: 8px;
}
.filters-row { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: end; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.field select, .field input[type="range"] { height: 32px; }
.field select { border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); padding: 0 8px; max-width: 220px; }
.field output { color: var(--text); font-weight: 600; }
.check { display: inline-flex; gap: 6px; align-items: center; height: 32px; cursor: pointer; }
.tags { gap: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 999px; padding: 3px 10px;
  font-size: 12px; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* ---- 본문 ---- */
.layout { flex: 1; min-height: 0; position: relative; display: flex; }
.map { flex: 1; min-width: 0; }
.sidebar {
  width: var(--sidebar-w); flex: none; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.sidebar-head { padding: 10px 14px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: baseline; }
.place-list { list-style: none; margin: 0; padding: 6px; overflow: auto; flex: 1; }
.place-list li {
  display: grid; grid-template-columns: 44px 1fr; gap: 10px; padding: 8px; border-radius: 10px; cursor: pointer;
}
.place-list li:hover, .place-list li.active { background: var(--panel-2); }
.score {
  width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center;
  font-weight: 700; font-size: 15px; color: #fff; background: var(--s-3);
}
.score.neg { background: var(--s-neg); }
.score.s1 { background: var(--s-1); color: #4a2a10; }
.score.s2 { background: var(--s-2); color: #3a1c08; }
.score.s3 { background: var(--s-3); }
.score.s4 { background: var(--s-4); }
.score.s5 { background: var(--s-5); }
.place-name { font-weight: 600; display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.place-sub { color: var(--muted); font-size: 12px; }
.tag-line { font-size: 12px; color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mark { font-size: 11px; border-radius: 4px; padding: 0 5px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.mark.tv { color: var(--accent); border-color: var(--accent); }
.mark.closed { text-decoration: line-through; }
.empty { padding: 24px 16px; color: var(--muted); text-align: center; }

/* ---- 상세 패널 ---- */
.detail {
  position: absolute; top: 12px; right: 12px; width: min(400px, calc(100% - 24px)); max-height: calc(100% - 24px);
  overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 16px 18px; z-index: 10;
}
.detail-close { position: absolute; top: 8px; right: 8px; }
.detail h2 { margin: 0 34px 4px 0; font-size: 20px; letter-spacing: -.01em; }
.detail .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 6px 0; }
.detail .score { width: 56px; height: 56px; font-size: 20px; }
.detail dl { margin: 10px 0; display: grid; grid-template-columns: 84px 1fr; gap: 4px 8px; font-size: 13px; }
.detail dt { color: var(--muted); }
.detail dd { margin: 0; }
.detail .desc { white-space: pre-wrap; font-size: 13px; background: var(--panel-2); border-radius: 8px; padding: 10px; margin: 8px 0; }
.detail .src { border-top: 1px solid var(--line); padding: 10px 0 0; margin-top: 10px; font-size: 13px; }
.detail .src h3 { margin: 0 0 4px; font-size: 13px; }
.detail .links a { margin-right: 10px; }
.detail .skeleton { color: var(--muted); }

/* ---- 지도 위 ---- */
.maplibregl-popup-content { font: inherit; color: var(--text); background: var(--panel); border-radius: 10px; box-shadow: var(--shadow); padding: 10px 12px; }
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip { border-top-color: var(--panel); }
.maplibregl-popup-anchor-top .maplibregl-popup-tip { border-bottom-color: var(--panel); }
.maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: var(--panel); }
.maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: var(--panel); }
.maplibregl-ctrl-group { background: var(--panel); box-shadow: var(--shadow); }
.maplibregl-ctrl-group button + button { border-top-color: var(--line); }
:root[data-theme="dark"] .maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1) hue-rotate(180deg); }
.maplibregl-ctrl-attrib { font-size: 11px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 8px 14px; border-radius: 999px; font-size: 13px; box-shadow: var(--shadow); z-index: 50;
}

/* ---- 모바일: 사이드바를 하단 시트로 ---- */
@media (max-width: 760px) {
  :root { --sidebar-w: 100%; }
  .topbar { grid-template-columns: auto 1fr auto; gap: 8px; padding: 0 10px; }
  .brand-name, .brand-count { display: none; }
  .layout { flex-direction: column; }
  .map { flex: 1; }
  .sidebar {
    order: 2; height: 38vh; border-right: 0; border-top: 1px solid var(--line);
  }
  /* 필터 패널이 지도를 다 가리지 않게. 넘치면 패널 안에서 스크롤. */
  .filters { max-height: 42vh; overflow: auto; }
  .filters-row { gap: 8px 14px; }
  .field select { max-width: 100%; }
  .detail { top: auto; bottom: 0; right: 0; left: 0; width: 100%; max-height: 70%; border-radius: 16px 16px 0 0; }
}
