/* ==========================================================================
   Arkids Design Studio — 데이터 섹션 공통 스타일
   index.html의 :root 토큰을 그대로 계승. 하드코딩 컬러는 표 헤더 틴트
   rgba(64,98,12,...) 와 신호색(상승/하락)만 — 나머지는 전부 변수 사용.
   ========================================================================== */

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

:root {
  --bg: #ffffff;
  --bg-card: #f6f8f1;
  --fg: #20261a;
  --fg-mute: #5b6552;
  --accent: #40620c;
  --border: #e3e7da;
  /* 신호색 — 한국식(빨강=상승, 파랑=하락). 색만으로 정보전달 금지(화살표+텍스트 병기). */
  --up: #c0392b;
  --down: #1f5fb0;
  --flat: #5b6552;
}

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* 데이터 페이지는 표·카드 가독을 위해 920px (브랜드 홈은 720px) */
.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 0 1.5rem;
  width: 100%;
}

/* ---- 헤더 + 경량 가로 메뉴 (데이터 페이지 전용) -------------------------- */
header {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.logo {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--fg);
  text-decoration: none;
}
.logo:hover { color: var(--accent); }

.data-nav {
  display: flex;
  gap: 0.25rem 1.1rem;
  flex-wrap: wrap;
  font-size: 0.95rem;
}
.data-nav a {
  color: var(--fg-mute);
  text-decoration: none;
  padding: 0.25rem 0;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.data-nav a:hover { color: var(--fg); }
.data-nav a[aria-current="page"] {
  color: var(--accent);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 4px;
}

main { flex: 1; padding: 2.5rem 0 3.5rem; }

/* ---- 페이지 타이틀 ------------------------------------------------------- */
.page-head { margin-bottom: 2rem; }
.page-head h1 {
  font-size: clamp(1.7rem, 4vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.6rem;
}
.page-head .lead {
  color: var(--fg-mute);
  font-size: 1.05rem;
  max-width: 640px;
}

section { margin-bottom: 2.5rem; }
section > h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.9rem;
  color: var(--accent);
}
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}
.section-head h2 { margin-bottom: 0; }
.section-head .count { color: var(--fg-mute); font-size: 0.9rem; }

/* ---- 콜아웃 박스 --------------------------------------------------------- */
.callout {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  margin-bottom: 1.5rem;
  display: flex;
  gap: 0.6rem;
}
.callout .ico { color: var(--accent); flex-shrink: 0; margin-top: 2px; }
.callout p { color: var(--fg); font-size: 0.92rem; }
.callout p + p { margin-top: 0.35rem; color: var(--fg-mute); }
.callout.link { align-items: center; }
.callout.link .grow { flex: 1; }
.callout .cta {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
  font-size: 0.92rem;
  white-space: nowrap;
}
.callout .cta:hover { text-decoration: underline; }

/* ---- 필터 바 ------------------------------------------------------------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.filter-field { display: flex; flex-direction: column; gap: 0.25rem; }
.filter-field label { font-size: 0.78rem; color: var(--fg-mute); font-weight: 600; }
.filter-field select {
  font: inherit;
  font-size: 0.95rem;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  min-height: 44px;
  min-width: 150px;
  cursor: pointer;
}
.filter-field select:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(64,98,12,0.18); }

/* ---- 요약 카드 그리드 ---------------------------------------------------- */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.1rem;
}
.stat-card .label { font-size: 0.8rem; color: var(--fg-mute); }
.stat-card .value { font-size: 1.55rem; font-weight: 700; color: var(--fg); margin: 0.15rem 0; line-height: 1.2; }
.stat-card .sub { font-size: 0.8rem; color: var(--fg-mute); }

/* ---- 신호색 추세 (색 + 화살표 + 텍스트) --------------------------------- */
.trend { font-weight: 700; white-space: nowrap; }
.trend.up { color: var(--up); }
.trend.down { color: var(--down); }
.trend.flat { color: var(--flat); }
.trend .arrow { font-weight: 700; }

/* ---- 데이터 표 (데스크탑) ------------------------------------------------ */
.data-table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
table.data-table thead th {
  text-align: left;
  background: rgba(64,98,12,0.07);
  color: var(--fg);
  font-weight: 700;
  padding: 0.6rem 0.7rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data-table tbody td {
  padding: 0.6rem 0.7rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.data-table .sub { display: block; font-size: 0.8rem; color: var(--fg-mute); }
table.data-table .num { text-align: right; white-space: nowrap; }

/* ---- 모바일 카드 리스트 (표 대체) --------------------------------------- */
.deal-cards { display: none; }
.deal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  margin-bottom: 0.75rem;
}
.deal-card .top { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; }
.deal-card .date { font-size: 0.8rem; color: var(--fg-mute); }
.deal-card .price { font-size: 1.1rem; font-weight: 700; }
.deal-card .name { font-weight: 600; margin: 0.2rem 0; }
.deal-card .detail { font-size: 0.85rem; color: var(--fg-mute); }

/* ---- 지도 모듈 (정적 미니맵 — 교체 쉽게 분리) --------------------------- */
/* === MAP MODULE START === 추후 Leaflet 등으로 교체 시 이 블록만 손대면 됨 */
.map-module {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 1.5rem;
  background: var(--bg-card);
}
.map-module .map-canvas {
  width: 100%;
  height: 360px;
  display: block;
  object-fit: cover;
}
.map-module .map-foot {
  padding: 0.55rem 0.9rem;
  font-size: 0.78rem;
  color: var(--fg-mute);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}
/* === MAP MODULE END === */

/* ---- 업종 카드 그리드 ---------------------------------------------------- */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.cat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}
.cat-card .ico { color: var(--accent); margin-bottom: 0.5rem; }
.cat-card .name { font-size: 0.9rem; color: var(--fg-mute); }
.cat-card .count { font-size: 1.4rem; font-weight: 700; line-height: 1.2; margin: 0.1rem 0; }
.cat-card .pct { font-size: 0.85rem; color: var(--fg-mute); }
.cat-card .bar { height: 4px; border-radius: 2px; background: var(--border); margin-top: 0.6rem; overflow: hidden; }
.cat-card .bar > span { display: block; height: 100%; background: var(--accent); }

/* ---- 공모전 카드 -------------------------------------------------------- */
.comp-list { display: flex; flex-direction: column; gap: 0.9rem; }
.comp-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.1rem 1.2rem;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: border-color 0.15s ease;
}
.comp-card:hover { border-color: var(--accent); }
.comp-card .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.comp-card h3 { font-size: 1.05rem; margin-bottom: 0.3rem; }
.comp-card .meta { font-size: 0.85rem; color: var(--fg-mute); }
.comp-card .summary { font-size: 0.9rem; color: var(--fg); margin-top: 0.4rem; }
.comp-card .more { display: inline-block; margin-top: 0.6rem; color: var(--accent); font-weight: 600; font-size: 0.9rem; }
.comp-card.expired { opacity: 0.55; }

/* D-day 배지 */
.dday {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--fg-mute);
}
.dday.soon { color: var(--accent); }
.dday.soon .ico { color: var(--accent); }
.dday.expired { color: var(--fg-mute); }

/* ---- 배지 (index.html 계승) --------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  background: var(--accent);
  color: var(--bg);
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  vertical-align: middle;
}
.badge.soft { background: transparent; color: var(--accent); border: 1px solid var(--accent); }

/* ---- 필터 탭 (pill) ----------------------------------------------------- */
.tabs { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.tabs button {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  min-height: 40px;
}
.tabs button[aria-pressed="true"] { background: var(--accent); color: var(--bg); }

/* ---- 출처표시 ----------------------------------------------------------- */
.source-note {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  border-radius: 0 0 8px 8px;
  padding: 0.75rem 0.9rem;
  font-size: 0.8rem;
  color: var(--fg-mute);
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.source-note .ico { flex-shrink: 0; margin-top: 1px; }

/* ---- 푸터 (index.html 계승) --------------------------------------------- */
footer {
  padding: 2rem 0;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.85rem;
  color: var(--fg-mute);
}
footer nav { margin-bottom: 0.75rem; }
footer a { color: var(--fg-mute); text-decoration: none; margin: 0 0.6rem; }
footer a:hover { color: var(--fg); text-decoration: underline; }

/* ---- 반응형 ------------------------------------------------------------- */
@media (max-width: 768px) {
  .cat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .summary-grid { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; }
  .filter-field { width: 100%; }
  .filter-field select { width: 100%; min-width: 0; }
  /* 표 숨기고 카드 리스트 노출 */
  .data-table-wrap { display: none; }
  .deal-cards { display: block; }
  .map-module .map-canvas { height: 260px; }
  /* 모바일 가로 오버플로 안전망(잘림 방지) */
  body { overflow-x: hidden; }
}

/* 가로 넘침 방지: 미디어 폭 제한 + 긴 문자열 줄바꿈 */
img, svg, .map-canvas svg, .map-module svg { max-width: 100%; height: auto; }
.lead, .callout p, .stat-card .value, .stat-card .sub,
.deal-card, .cat-card, table.data-table td, p { overflow-wrap: break-word; word-break: break-word; }

/* 좁은 폭: 헤더 로고 아래로 메뉴 줄바꿈 (가로 오버플로 방지) */
@media (max-width: 640px) {
  .header-inner { flex-direction: column; align-items: flex-start; gap: 0.4rem; }
  .data-nav { gap: 0 1rem; }
  .data-nav a { min-height: 36px; }
}

@media (max-width: 380px) {
  .cat-grid { grid-template-columns: 1fr; }
}
