/* ===================================================================
   주말N 디자인 시스템 — 맵 퍼스트 커머셜 UI
   지도가 화면을 채우고, 컨트롤은 지도 위에 떠 있는 카드·칩·버튼으로.
   카테고리별 액센트 컬러가 body[data-tab]을 타고 UI 전체에 스며든다.
   =================================================================== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --navy: #10233f;
  --ink: #0f172a;
  --ink-soft: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #e2e8f0;
  --surface: #ffffff;
  --surface-dim: #f1f5f9;
  --shadow-sm: 0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.05);
  --shadow-md: 0 4px 16px rgba(15,23,42,.13), 0 2px 4px rgba(15,23,42,.06);
  --shadow-lg: 0 12px 32px rgba(15,23,42,.18), 0 4px 10px rgba(15,23,42,.08);
  --radius: 14px;
  /* 카테고리 액센트 — 기본: 주차장 */
  --accent: #4a5d84;
  --accent-strong: #33436a;
  --accent-soft: #edf1f8;
}
body[data-tab="camping"]  { --accent: #2c7fb8; --accent-strong: #1f639a; --accent-soft: #e8f2fa; }
body[data-tab="mountain"] { --accent: #5b8c3e; --accent-strong: #47702f; --accent-soft: #eef5e8; }
body[data-tab="beach"]    { --accent: #e8843c; --accent-strong: #c9682a; --accent-soft: #fdf0e5; }
body[data-tab="fishing"]  { --accent: #14847d; --accent-strong: #0e6862; --accent-soft: #e5f4f3; }

html, body { height: 100%; }
body {
  display: flex; flex-direction: column;
  font-family: "Pretendard Variable", "Pretendard", "Malgun Gothic", sans-serif;
  color: var(--ink); background: var(--surface-dim);
  -webkit-font-smoothing: antialiased;
}

/* ---------- 헤더 ---------- */
header {
  position: relative; z-index: 30;
  display: flex; align-items: center; gap: 18px;
  padding: 10px 20px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}

#brand { display: flex; align-items: center; gap: 10px; }
#brand-mark {
  display: block; width: 36px; height: 36px;
  filter: drop-shadow(0 3px 8px rgba(44,127,184,.35));
}
#brand-mark svg { display: block; width: 100%; height: 100%; overflow: visible; }
#brand-text h1 { font-size: 17px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
#brand-text p { font-size: 11px; color: var(--faint); font-weight: 500; letter-spacing: .01em; }

/* 탭: 세그먼트 알약 — 활성 탭이 카테고리 색을 입는다 */
#tabs {
  display: flex; gap: 3px;
  background: var(--surface-dim); padding: 4px; border-radius: 999px;
}
.tab {
  --tc: #4a5d84;
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  padding: 7px 14px; border: none; border-radius: 999px;
  background: transparent; color: var(--muted);
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  transition: background .16s ease, color .16s ease, box-shadow .16s ease;
}
.tab[data-tab="camping"]  { --tc: #2c7fb8; }
.tab[data-tab="mountain"] { --tc: #5b8c3e; }
.tab[data-tab="beach"]    { --tc: #e8843c; }
.tab[data-tab="fishing"]  { --tc: #14847d; }
.tab:hover { color: var(--ink); }
.tab.active {
  background: var(--tc); color: #fff; font-weight: 700;
  box-shadow: 0 2px 8px rgba(15,23,42,.22);
}
.tab-ico { display: inline-flex; color: var(--tc); transition: color .16s ease; }
.tab.active .tab-ico { color: #fff; }
.tab-ico svg {
  display: block; width: 15px; height: 15px;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

/* 검색: 헤더 우측 상시 노출 */
#search-box {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  height: 38px; width: 240px; padding: 0 13px;
  background: var(--surface-dim); border: 1.5px solid transparent; border-radius: 999px;
  color: var(--faint);
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease;
}
#search-box:focus-within {
  background: var(--surface); border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft); color: var(--accent);
}
.layers-live { display: flex; justify-content: center; margin-bottom: 2px; }
.layers-live .live-badge { margin-left: 0; }

.live-badge {
  display: inline-flex; align-items: center; gap: 5px;
  margin-left: 4px; padding: 3px 0; border-radius: 11px;
  background: none; color: #e11d1d;
  font-size: 11px; font-weight: 800; letter-spacing: .8px; line-height: 1.3;
  vertical-align: 1px;
}
.live-badge::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: #e11d1d; animation: live-pulse 1.6s ease-in-out infinite;
}
@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .25; }
}

#search {
  flex: 1; min-width: 0; border: none; background: none; outline: none;
  font-family: inherit; font-size: 13.5px; color: var(--ink);
}
#search::placeholder { color: var(--faint); }
#search::-webkit-search-cancel-button { cursor: pointer; }

/* ---------- 알림 배너 ---------- */
#banner {
  padding: 9px 20px; background: #fff7e0; color: #8a6100; font-size: 13px; font-weight: 500;
  border-bottom: 1px solid #f3e3ae;
}

/* ---------- 지도 + 플로팅 컨트롤 ---------- */
#map-wrap { flex: 1; position: relative; overflow: hidden; }
#map { width: 100%; height: 100%; }

/* 필터 카드 (지도 좌상단 글래스 패널) — 보여줄 필터가 없으면 통째로 숨김 */
#controls {
  position: absolute; top: 12px; left: 12px; z-index: 12;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  max-width: min(700px, calc(100% - 92px));
  padding: 10px 12px;
  background: rgba(255,255,255,.92);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  border: 1px solid rgba(255,255,255,.6);
}
#controls:not(:has(.control-group:not([hidden]))) { display: none; }

.control-group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.control-group[hidden] { display: none; }

/* 필터 칩: 체크박스를 알약 토글로 */
.chip {
  position: relative; display: inline-flex; align-items: center;
  padding: 6px 13px; border-radius: 999px;
  background: var(--surface); border: 1.5px solid var(--line);
  font-size: 13px; font-weight: 600; color: var(--muted);
  cursor: pointer; user-select: none; white-space: nowrap;
  transition: background .14s ease, border-color .14s ease, color .14s ease;
}
.chip:hover { border-color: var(--faint); }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:has(input:checked) {
  background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong);
}

.select-chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap;
}
#min-height {
  padding: 6px 8px; border: 1.5px solid var(--line); border-radius: 10px;
  font-family: inherit; font-size: 13px; font-weight: 600; color: var(--ink-soft);
  background: var(--surface); cursor: pointer; outline: none;
}
#min-height:focus { border-color: var(--accent); }

.legend {
  flex-basis: 100%; display: flex; align-items: center; gap: 4px;
  color: var(--muted); font-size: 12px;
}
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.dot.mount { background: #5b8c3e; }
.dot.beach { background: #e8843c; }
.dot.fish { background: #14847d; }
.trail-line { display: inline-block; width: 16px; height: 3px; background: #d84b16; vertical-align: middle; margin: 0 3px; border-radius: 2px; }

/* 레이어 버튼 (지도 우상단) */
#layers {
  position: absolute; top: 12px; right: 12px; z-index: 12;
  display: flex; flex-direction: column; gap: 8px;
}
.layer-btn {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  width: 54px; height: 54px; border-radius: 15px;
  background: rgba(255,255,255,.94);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border: 1.5px solid rgba(255,255,255,.6);
  box-shadow: var(--shadow-md); cursor: pointer; user-select: none;
  transition: transform .13s ease, background .14s ease, border-color .14s ease;
}
.layer-btn:hover { transform: translateY(-1px); }
.layer-btn input { position: absolute; opacity: 0; pointer-events: none; }
#traffic-toggle { --lc: #33436a; }
#ferry-toggle { --lc: #1c6dd0; }
#flight-toggle { --lc: #ff8a00; }
.layer-ico { display: flex; color: var(--lc); transition: color .14s ease; }
.layer-ico svg {
  display: block; width: 22px; height: 22px;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.layer-label { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .02em; }
.layer-btn:has(input:checked) { background: var(--navy); border-color: var(--navy); }
.layer-btn:has(input:checked) .layer-label,
.layer-btn:has(input:checked) .layer-ico { color: #fff; }

/* 상태 필 (지도 하단 중앙) */
#status {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 12;
  padding: 7px 16px; border-radius: 999px;
  background: rgba(16,35,63,.86); color: #fff;
  font-size: 12.5px; font-weight: 600; letter-spacing: .01em; white-space: nowrap;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  box-shadow: var(--shadow-md); pointer-events: none;
}
#status:empty { display: none; }

/* ---------- 출처 ---------- */
#attribution {
  position: absolute; right: 6px; bottom: 6px; z-index: 10;
  display: flex; flex-direction: column; align-items: flex-end; gap: 4px;
}
#attribution-toggle {
  padding: 4px 11px; border: none; border-radius: 999px; cursor: pointer;
  background: rgba(255,255,255,.9); color: var(--muted); font-size: 11px; font-weight: 600;
  font-family: inherit; box-shadow: var(--shadow-sm);
}
#attribution-toggle:hover { background: #fff; color: var(--ink-soft); }
#attribution-panel {
  padding: 12px 15px; background: rgba(255,255,255,.97); border-radius: 12px;
  box-shadow: var(--shadow-lg); font-size: 11px; color: var(--ink-soft);
  max-width: 320px; line-height: 1.7;
}
#attribution-panel b { display: block; margin-bottom: 2px; font-size: 12px; color: var(--ink); }
#attribution-panel ul { list-style: none; }
#attribution-panel .attribution-note { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
#attribution a { color: var(--ink-soft); }

/* ---------- 광고 배너 ---------- */
#ad-banner {
  height: 70px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface); border-top: 1px solid var(--line);
}
#ad-banner[hidden] { display: none; }
#ad-banner .ad-placeholder {
  color: var(--faint); font-size: 12px;
  border: 1px dashed #cbd5e1; border-radius: 8px; padding: 14px 40px;
}
@media (max-width: 600px) { #ad-banner { height: 56px; } }

/* ---------- 팝업 (자체 CustomOverlay 인포윈도우) ---------- */
.custom-iw { position: relative; margin-bottom: 13px; filter: drop-shadow(0 8px 22px rgba(15,23,42,.22)); }
.custom-iw-body {
  background: #fff; border-radius: 14px; overflow: hidden;
  border-top: 3px solid var(--accent);
}
.custom-iw::after { /* 말풍선 꼬리 */
  content: ""; position: absolute; left: 50%; bottom: -8px; margin-left: -8px;
  border: 8px solid transparent; border-top-color: #fff; border-bottom: none;
}
.custom-iw-close {
  position: absolute; top: 8px; right: 8px; z-index: 1;
  display: grid; place-items: center; width: 24px; height: 24px;
  border: none; border-radius: 50%; background: var(--surface-dim); cursor: pointer;
  font-size: 15px; line-height: 1; color: var(--muted); padding: 0;
  transition: background .13s ease, color .13s ease;
}
.custom-iw-close:hover { background: var(--line); color: var(--ink); }

.popup { width: 250px; padding: 12px 14px; font-size: 13px; line-height: 1.6; color: var(--ink-soft); }
.popup b { font-size: 14.5px; font-weight: 800; color: var(--ink); letter-spacing: -.01em; }
.popup .muted { color: var(--muted); font-size: 12px; }
.popup .tag {
  display: inline-block; padding: 2px 8px; margin: 3px 3px 3px 0; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-strong); font-size: 11px; font-weight: 600;
}
.popup .height { font-weight: 700; color: #4a7532; }
.popup .top100 { background: #e8f3dd; color: #3d6128; }
.popup .park-bio { margin-top: 7px; padding-top: 7px; border-top: 1px solid var(--line); font-size: 12px; }
.popup .park-link { color: #2c7fb8; text-decoration: underline; }
.popup .ferry-sailings { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); font-size: 12px; line-height: 1.65; }
.popup .ferry-sailings .dir { color: #1c6dd0; font-weight: 700; }
.popup .ferry-sailings .wait { color: #1c6dd0; font-weight: 700; }
.popup .ferry-sailings .cancel { color: #e04545; font-size: 11px; }
.popup .train-dir { margin-top: 6px; font-weight: 700; color: #0a3d91; font-size: 12px; }

.popup .expand-toggle { color: #1c6dd0; font-weight: 700; cursor: pointer; text-decoration: underline; }
.popup .fs-scroll { max-height: 280px; overflow-y: auto; padding-right: 4px; }

.popup .ferry-sailings .delay { color: #d9820a; font-weight: 700; font-size: 11px; }
.popup .wx, .popup .wx-slot { margin-top: 7px; padding-top: 7px; border-top: 1px solid var(--line); font-size: 12px; }
.popup .wx { font-weight: 700; color: #29618f; }
.popup .wx-slot { color: var(--faint); }
.popup .wx-slot::after { content: "날씨 불러오는 중…"; }
.popup .wx-slot.empty::after { content: ""; }
.popup .wx .muted { font-weight: 400; }

.reserve-btn {
  display: block; margin-top: 9px; padding: 8px 12px; text-align: center;
  background: var(--accent); color: #fff !important; text-decoration: none;
  border-radius: 10px; font-size: 12.5px; font-weight: 700;
  box-shadow: 0 2px 6px rgba(15,23,42,.15);
  transition: background .14s ease;
}
.reserve-btn:hover { background: var(--accent-strong); }

/* ---------- 격자 집계 버블 ---------- */
.bubble {
  border-radius: 50%; text-align: center; cursor: pointer;
  background: linear-gradient(160deg, #33436a, #10233f); color: #fff;
  font-size: 13px; font-weight: 700;
  border: 2.5px solid rgba(255,255,255,.92);
  box-shadow: 0 4px 14px rgba(16,35,63,.35);
  transition: transform .12s ease;
}
.bubble:hover { transform: scale(1.08); }
.bubble-camp     { background: linear-gradient(160deg, #46a0da, #1f639a); box-shadow: 0 4px 14px rgba(44,127,184,.4); }
.bubble-mountain { background: linear-gradient(160deg, #74a850, #47702f); box-shadow: 0 4px 14px rgba(91,140,62,.4); }
.bubble-beach    { background: linear-gradient(160deg, #f09b55, #c9682a); box-shadow: 0 4px 14px rgba(232,132,60,.4); }
.bubble-fishing  { background: linear-gradient(160deg, #23a49b, #0e6862); box-shadow: 0 4px 14px rgba(20,132,125,.4); }

/* ---------- 모바일 (768px 이하) ---------- */
@media (max-width: 768px) {
  header { flex-wrap: wrap; gap: 10px; padding: 10px 12px; row-gap: 8px; }
  #brand-text p { display: none; }
  #brand-mark { width: 32px; height: 32px; font-size: 17px; border-radius: 9px; }
  #brand-text h1 { font-size: 16px; }
  #search-box { width: auto; flex: 1; min-width: 110px; height: 36px; }
  #tabs {
    order: 3; width: 100%;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  #tabs::-webkit-scrollbar { display: none; }
  .tab { padding: 7px 12px; font-size: 13px; }

  #controls {
    top: 8px; left: 8px; right: 66px; max-width: none;
    padding: 8px 10px; gap: 6px;
  }
  .chip { padding: 6px 11px; font-size: 12.5px; }
  .legend { font-size: 11px; }

  #layers { top: 8px; right: 8px; gap: 6px; }
  .layer-btn { width: 48px; height: 48px; border-radius: 13px; }
  .layer-ico svg { width: 19px; height: 19px; }

  #status { bottom: 14px; font-size: 12px; padding: 6px 14px; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis; }
}
