/* 온누리상품권 피부과 지도 — '담(淡)' 브랜드 스타일
 *
 * 디자인 토큰 원본(SSOT): /Users/hosax/Documents/Homepage/src/styles/global.css @theme 블록.
 * 값을 여기로 복사 이식(포크 아님) — 원본 갱신 시 이 파일도 동기화한다.
 * 웹폰트: Noto Serif KR(제목, Google Fonts) + Pretendard Variable(본문, jsDelivr) — index.html head에서 로드.
 */

/* ---- 담 토큰 ---- */
:root {
  --paper: #FAF8F4;       /* 한지 — 페이지 배경 */
  --surface: #FFFFFF;     /* 백자 — 카드/모달/입력 */
  --pine: #1E4D43;        /* 송연 — 주 브랜드색/버튼/활성 */
  --pine-dark: #163A33;   /* 제목/hover */
  --pine-deep: #0F2A25;   /* 최대 강조(드묾) */
  --sage: #E8EFEA;        /* 연송 — 섹션 틴트/배지 배경 */
  --sage-dark: #C9D8CF;   /* 경계 강조/비활성 경계 */
  --apricot: #D98E73;     /* 살구 — 포인트 전용(텍스트 금지) */
  --apricot-dark: #A05536;/* 살구 계열 텍스트용(본문 대비 확보) */
  --ink: #22302C;         /* 먹 — 본문 기본 */
  --muted: #5A6B64;       /* 보조/메타 텍스트 */
  --line: #E2DED6;        /* 카드/입력/구분선 경계 */

  --font-display: 'Noto Serif KR', 'Pretendard Variable', serif;
  --font-sans: 'Pretendard Variable', Pretendard, -apple-system, 'Apple SD Gothic Neo', 'Noto Sans KR', 'Segoe UI', sans-serif;

  --radius: 0.75rem;
  --radius-sm: 0.5rem;
  --shadow-panel: 0 1px 3px rgba(15, 42, 37, 0.06), 0 6px 20px rgba(15, 42, 37, 0.08);
  --tap-min: 44px;
}

/* ---- 리셋 · 기본 ---- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  word-break: keep-all;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  color: var(--pine-dark);
  line-height: 1.35;
  text-wrap: balance;
  margin: 0;
}

a {
  color: var(--pine);
}

/* ---- 카드 ---- */
.clinic-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  transition: border-color 0.15s ease;
}

.clinic-card:hover {
  border-color: var(--pine); /* hover = 경계색만(그림자/배경 전환 없음) */
}

.clinic-card.is-selected {
  border-color: var(--pine);
  box-shadow: inset 0 0 0 1px var(--pine);
}

.clinic-card h3 {
  font-size: 1.05rem;
  margin-bottom: 0.25rem;
}

.clinic-address {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0.15rem 0;
}

.clinic-phone {
  color: var(--ink);
  font-size: 0.9rem;
  margin: 0.15rem 0;
}

.clinic-distance {
  color: var(--apricot-dark);
  font-weight: 600;
  font-size: 0.85rem;
}

/* ---- 배지 ---- */
.payment-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin: 0.5rem 0 0;
}

.payment-badge {
  background: var(--sage);
  color: var(--pine-dark);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}

/* ---- 버튼 ---- */
.btn {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--pine-dark);
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  min-height: var(--tap-min);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.btn:hover {
  border-color: var(--pine);
}

.btn-primary {
  background: var(--pine);
  color: var(--surface);
  border-color: var(--pine);
}

.btn-primary:hover {
  background: var(--pine-dark);
  border-color: var(--pine-dark);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---- 폼 · 입력 ---- */
input[type="search"],
input[type="text"] {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  min-height: var(--tap-min);
}

input[type="search"]:focus,
input[type="text"]:focus {
  border-color: var(--pine);
  outline: none;
}

select {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.65rem;
  min-height: var(--tap-min);
}

/* ---- 고지 · 안내 ---- */
#freshness-notice {
  color: var(--muted);
  font-size: 0.82rem;
}

#map-fallback-banner {
  background: var(--sage);
  color: var(--pine-dark);
  border: 1px solid var(--sage-dark);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  font-size: 0.88rem;
}

/* ---- 포커스 가시성(담 규칙: 살구 3px outline) ---- */
:focus-visible {
  outline: 3px solid var(--apricot);
  outline-offset: 2px;
}

/* ---- 모션 축소 존중 ---- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---- 모바일 기본(360px~) 반응형 앵커 ---- */
@media (min-width: 360px) {
  body {
    font-size: 16px;
  }
}

/* ============================================================
   레이아웃 — 데스크탑 좌 사이드바 + 우 지도 / 모바일 풀스크린 지도 + 바텀시트
   ============================================================ */

.app {
  height: 100vh;
  height: 100dvh;
  position: relative;
  overflow: hidden;
}

/* ---- 상단 바(검색 + 폴백 배너) ---- */
.topbar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
}

.app-title {
  font-size: 1.05rem;
  font-weight: 700;
}

.search-form {
  display: flex;
  gap: 0.4rem;
}

.search-input {
  flex: 1;
  min-width: 0;
}

.fallback-banner {
  margin: 0;
}

/* ---- 지도 ---- */
.map-pane {
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
  background: var(--sage);
}

/* ---- 패널(리스트) ---- */
.panel {
  background: var(--paper);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-scroll {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-height: 0;
}

.panel-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.region-select select {
  max-width: 100%;
}

.search-notice {
  background: var(--sage);
  color: var(--pine-dark);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.7rem;
  font-size: 0.85rem;
}

.freshness-notice {
  padding: 0 0.15rem;
}

.clinic-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}


.card-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.card-select-btn {
  flex: 1;
}

/* ---- 외부 지도 링크(카드 상세 + 오버레이) ---- */
.external-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.external-link {
  display: inline-flex;
  align-items: center;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--pine-dark);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
  background: var(--surface);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.external-link:hover {
  border-color: var(--pine);
  background: var(--sage);
}

.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 1.5rem 0.5rem;
}

/* ---- 바텀시트 핸들(모바일 전용, 데스크탑 숨김) ---- */
.sheet-handle {
  display: none;
}

/* ---- 지도 위 커스텀 오버레이(선택 의원 정보) ---- */
.map-overlay {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-panel);
  padding: 0.75rem 0.85rem;
  min-width: 200px;
  font-size: 0.88rem;
  position: relative;
}

.map-overlay h3 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
  padding-right: 1.25rem;
}

.map-overlay .clinic-address,
.map-overlay .clinic-phone {
  font-size: 0.82rem;
}

.overlay-close {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  width: 1.6rem;
  height: 1.6rem;
  min-height: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.overlay-close:hover {
  background: var(--sage);
  color: var(--pine-dark);
}

.overlay-tail {
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid var(--surface);
}

/* 클러스터 숫자 배지 */
.cluster-badge {
  background: var(--pine);
  color: var(--surface);
  border-radius: 999px;
  font-weight: 700;
  text-align: center;
  line-height: 34px;
  width: 34px;
  height: 34px;
  border: 2px solid var(--surface);
  box-shadow: var(--shadow-panel);
}

/* ============================================================
   데스크탑 ≥768px — 좌 사이드바(검색 상단 + 리스트) + 우 풀 지도
   ============================================================ */
@media (min-width: 768px) {
  .app {
    display: grid;
    grid-template-columns: 380px 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "search map"
      "list   map";
  }
  .topbar {
    grid-area: search;
    border-bottom: 1px solid var(--line);
    background: var(--paper);
  }
  .map-pane {
    grid-area: map;
  }
  .panel {
    grid-area: list;
    border-right: 1px solid var(--line);
    min-height: 0;
    overflow: hidden;
  }
  .panel-scroll {
    flex: 1;
  }
}

/* ============================================================
   모바일 <768px — 풀스크린 지도 + 끌어올리는 바텀시트
   ============================================================ */
@media (max-width: 767.98px) {
  .map-pane,
  #map {
    position: absolute;
    inset: 0;
  }
  .topbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 20;
    background: linear-gradient(var(--paper) 70%, rgba(250, 248, 244, 0));
    padding-bottom: 1rem;
  }
  .app-title {
    display: none;
  }

  .panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    height: 86vh;
    background: var(--surface);
    border-top-left-radius: 1rem;
    border-top-right-radius: 1rem;
    box-shadow: var(--shadow-panel);
    transform: translateY(calc(86vh - var(--sheet-peek, 42vh)));
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
    touch-action: none;
  }
  .panel.is-expanded {
    transform: translateY(0);
  }
  /* U2: 최소 고정 — 핸들('목록')만 보인다. */
  .panel.is-minimized {
    transform: translateY(calc(86vh - 2.75rem));
  }
  .panel.is-minimized .sheet-label {
    font-weight: 700;
    color: var(--pine, #1e4d43);
  }
  .panel.is-dragging {
    transition: none;
  }

  .sheet-handle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    width: 100%;
    background: transparent;
    border: none;
    padding: 0.5rem 0 0.35rem;
    cursor: grab;
    color: var(--muted);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    min-height: 0;
    touch-action: none;
  }
  .sheet-grip {
    width: 40px;
    height: 4px;
    border-radius: 999px;
    background: var(--sage-dark);
  }
  .panel-scroll {
    flex: 1;
    overscroll-behavior: contain;
  }

  @media (prefers-reduced-motion: reduce) {
    .panel {
      transition: none;
    }
  }
}

/* U9: 검색/위치 안내문의 \n 줄바꿈을 살린다. */
.search-notice {
  white-space: pre-line;
}

/* U10: 오버레이의 긴 주소가 정보창을 넘지 않도록 줄바꿈. */
.map-overlay {
  max-width: min(320px, 78vw);
}
.map-overlay .clinic-address {
  word-break: keep-all;
  overflow-wrap: anywhere;
  white-space: normal;
}

/* U1: scope-all 안내문 */
.list-guide {
  color: var(--muted, #5f6b66);
  font-size: 0.95rem;
  line-height: 1.6;
  padding: 0.75rem 0.25rem;
}

/* U6: 카드 액션의 외부 지도 링크를 버튼形으로 정렬 */
.card-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.card-actions .card-map-links {
  display: flex;
  gap: 0.5rem;
  margin: 0;
}

/* 출처·정정 채널 안내(scope-all) */
.list-provenance {
  color: var(--muted, #5f6b66);
  font-size: 0.8rem;
  line-height: 1.6;
  padding: 0 0.25rem 0.75rem;
  word-break: keep-all;
}
.list-provenance a {
  color: inherit;
  text-decoration: underline;
}
