/* 모두의 계곡 — 스타일
   팔레트: dataviz 검증 통과 (light/dark)
   하천: 국가하천=파랑, 지방하천=주황, 소하천=청록 / 국유지 필지=파랑 계열 */

:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --page: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --hairline: #e1e0d9;
  --border: rgba(11, 11, 11, 0.10);
  --series-national: #2a78d6;
  --series-regional: #eb6834;
  --series-small: #1baf7a;
  --parcel: #2a78d6;
  --accent: #2a78d6;
  --bar: #2a78d6;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19;
  --page: #0d0d0d;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --hairline: #2c2c2a;
  --border: rgba(255, 255, 255, 0.10);
  --series-national: #3987e5;
  --series-regional: #d95926;
  --series-small: #199e70;
  --parcel: #3987e5;
  --accent: #3987e5;
  --bar: #3987e5;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --page: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --hairline: #2c2c2a;
    --border: rgba(255, 255, 255, 0.10);
    --series-national: #3987e5;
    --series-regional: #d95926;
    --series-small: #199e70;
    --parcel: #3987e5;
    --accent: #3987e5;
    --bar: #3987e5;
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: "Pretendard Variable", Pretendard, system-ui, -apple-system, "Segoe UI", "Malgun Gothic", sans-serif;
  background: var(--page);
  color: var(--text-primary);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); line-height: 1.18; letter-spacing: -0.03em; font-weight: 800; }
h2 { font-size: clamp(1.45rem, 3vw, 1.9rem); letter-spacing: -0.02em; margin-bottom: 10px; font-weight: 700; }
h3 { font-size: 1.05rem; }

/* ── 상단바 ── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--page) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--hairline);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.brand-mark {
  width: 14px; height: 14px; border-radius: 4px;
  background: var(--accent);
  display: inline-block;
}
.topnav { display: flex; align-items: center; gap: 20px; font-size: 0.95rem; }
.topnav a { color: var(--text-secondary); }
.theme-toggle {
  background: none; border: 1px solid var(--hairline); border-radius: 8px;
  width: 32px; height: 32px; cursor: pointer; font-size: 1rem;
  color: var(--text-secondary);
}
.theme-toggle:hover { border-color: var(--text-muted); }

/* ── 히어로 ── */
.hero { padding: 88px 0 64px; }
.hero-eyebrow {
  color: var(--accent); font-weight: 600; font-size: 0.9rem;
  margin-bottom: 12px; letter-spacing: 0.02em;
}
.hero-lead {
  margin-top: 20px; max-width: 560px;
  color: var(--text-secondary); font-size: 1.05rem;
}
.hero-lead strong { color: var(--text-primary); }
.hero-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 36px; }
.hero-src { margin-top: 12px; font-size: 0.8rem; color: var(--text-muted); }

.stat-tile {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  padding: 20px 22px;
  display: flex; flex-direction: column; gap: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.stat-value { font-size: 1.9rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-unit { font-size: 1rem; font-weight: 600; color: var(--text-secondary); margin-left: 2px; }
.stat-label { font-size: 0.85rem; color: var(--text-secondary); }

/* ── 섹션 공통 ── */
section { padding: 56px 0; }
.section-lead { color: var(--text-secondary); max-width: 620px; margin-bottom: 28px; font-size: 1.02rem; }

/* ── 지도 ── */
.map-section { padding-bottom: 16px; }
.map-frame { position: relative; }
#map {
  width: 100%; height: 560px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface-1);
}
.map-panel {
  position: absolute; top: 14px; left: 34px; z-index: 10;
  display: flex; flex-direction: column; gap: 8px;
  max-width: 240px;
}
.legend {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 6px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  font-size: 0.88rem;
}
.legend-title { font-weight: 700; font-size: 0.8rem; color: var(--text-muted); }
.legend-item { display: flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; }
.legend-item input { accent-color: var(--accent); }
.legend-count { color: var(--text-muted); font-size: 0.8rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.ramp {
  width: 26px; height: 10px; border-radius: 3px; display: inline-block;
  background: linear-gradient(to right, rgba(42,120,214,0.08), rgba(42,120,214,0.7));
  border: 1px solid var(--hairline);
}
.dot-national { background: var(--series-national); }
.dot-regional { background: var(--series-regional); }
.dot-small { background: var(--series-small); }
.dot-parcel { background: var(--parcel); border-radius: 3px; }
.goto-btn {
  background: var(--accent); color: #fff;
  border: none; border-radius: 12px;
  padding: 10px 14px; font-size: 0.85rem; font-weight: 700;
  font-family: inherit; cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
  transition: transform 0.1s ease;
}
.goto-btn:active { transform: scale(0.98); }
.goto-btn:hover { filter: brightness(1.08); }
.map-note {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 12px;
  font-size: 0.78rem; color: var(--text-secondary);
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

/* 팝업 */
.maplibregl-popup-content {
  background: var(--surface-1) !important;
  color: var(--text-primary) !important;
  border-radius: 12px !important;
  border: 1px solid var(--border);
  padding: 14px 16px !important;
  font-family: inherit !important;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15) !important;
  min-width: 200px;
}
.maplibregl-popup-tip { border-top-color: var(--surface-1) !important; border-bottom-color: var(--surface-1) !important; }
.popup-title { font-weight: 700; margin-bottom: 6px; font-size: 0.95rem; }
.popup-badge {
  display: inline-block; font-size: 0.72rem; font-weight: 600;
  padding: 1px 8px; border-radius: 999px; margin-left: 6px;
  color: #fff; vertical-align: 2px;
}
.popup-row { font-size: 0.82rem; color: var(--text-secondary); margin-top: 2px; }
.popup-row b { color: var(--text-primary); font-weight: 600; }

/* ── 데이터 섹션 ── */
.callout {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  padding: 18px 22px;
  margin-bottom: 24px;
  max-width: 640px;
  color: var(--text-secondary);
  font-size: 0.95rem;
}
.callout-title { font-weight: 700; color: var(--text-primary); margin-bottom: 6px; font-size: 1.02rem; }
.callout strong { color: var(--text-primary); }

.data-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 24px; }

.chart-card, .table-card {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: 18px;
  padding: 24px 26px;
  margin-bottom: 20px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.chart-sub { font-weight: 400; color: var(--text-muted); font-size: 0.85rem; }

/* 막대 그래프 (단일 시리즈) */
.bar-chart { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 90px 1fr 64px; align-items: center; gap: 10px; font-size: 0.88rem; }
.bar-name { color: var(--text-secondary); text-align: right; }
.bar-track { height: 16px; position: relative; }
.bar-fill {
  height: 100%; background: var(--bar);
  border-radius: 0 4px 4px 0;
  min-width: 2px;
}
.bar-val { color: var(--text-secondary); font-variant-numeric: tabular-nums; }

/* 표 */
.table-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
#tableFilter {
  background: var(--page); color: var(--text-primary);
  border: 1px solid var(--hairline); border-radius: 10px;
  padding: 8px 12px; font-size: 0.9rem; font-family: inherit;
  width: 220px;
}
#tableFilter:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.table-scroll { overflow-x: auto; max-height: 420px; overflow-y: auto; border: 1px solid var(--hairline); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
thead th {
  position: sticky; top: 0; background: var(--surface-1);
  text-align: left; padding: 10px 12px; color: var(--text-muted);
  font-weight: 600; border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}
tbody td { padding: 8px 12px; border-bottom: 1px solid var(--hairline); color: var(--text-secondary); }
tbody td:first-child { color: var(--text-primary); }
tbody tr:last-child td { border-bottom: none; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-note { margin-top: 10px; font-size: 0.78rem; color: var(--text-muted); }

/* ── 위치 도구 · 토스트 ── */
.map-actions { display: flex; flex-direction: column; gap: 6px; }
.btn-secondary {
  background: var(--surface-1);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { filter: none; border-color: var(--text-muted); }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 12px);
  background: var(--text-primary); color: var(--page);
  padding: 11px 18px; border-radius: 12px;
  font-size: 0.88rem; font-weight: 600;
  box-shadow: 0 6px 24px rgba(0,0,0,0.22);
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 200; max-width: min(90vw, 420px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── 신고 안내 ── */
.report-cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}
.report-card {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  padding: 20px 22px;
  font-size: 0.9rem; color: var(--text-secondary);
  display: flex; flex-direction: column; gap: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
  transition: border-color 0.15s ease;
}
.report-card:hover { border-color: var(--text-muted); }
.report-card-title { font-weight: 700; color: var(--text-primary); font-size: 1rem; }
.report-card a { font-weight: 600; font-size: 0.88rem; margin-top: auto; }
.report-tip {
  margin-top: 18px; padding: 14px 18px;
  background: var(--surface-1); border: 1px solid var(--border);
  border-left: 4px solid var(--series-small);
  border-radius: 12px; font-size: 0.88rem; color: var(--text-secondary);
  max-width: 640px;
}

/* ── 로드맵 ── */
.roadmap { list-style: none; display: flex; flex-direction: column; gap: 14px; max-width: 640px; }
.roadmap li {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 20px 16px 48px;
  position: relative;
  color: var(--text-secondary);
  font-size: 0.95rem;
}
.roadmap li strong { color: var(--text-primary); }
.roadmap li::before {
  content: "○";
  position: absolute; left: 20px; top: 16px;
  color: var(--text-muted); font-weight: 700;
}
.roadmap li.done::before { content: "●"; color: var(--series-small); }
.roadmap li.doing::before { content: "◐"; color: var(--accent); }

/* ── 출처 ── */
.sources { list-style: none; display: flex; flex-direction: column; gap: 8px; color: var(--text-secondary); font-size: 0.95rem; }
.sources li::before { content: "—"; color: var(--text-muted); margin-right: 8px; }
.disclaimer {
  margin-top: 20px; padding: 14px 18px;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 12px; font-size: 0.85rem; color: var(--text-secondary);
  max-width: 640px;
}

/* ── 푸터 ── */
.footer {
  border-top: 1px solid var(--hairline);
  padding: 28px 0 40px; margin-top: 24px;
  font-size: 0.82rem; color: var(--text-muted);
}

@media (max-width: 640px) {
  #map { height: 420px; }
  .map-panel { max-width: 180px; left: 28px; }
  .bar-row { grid-template-columns: 72px 1fr 52px; }
}
