/* 내 주변 AED 찾기 · 정식 스타일
   기준: b2 brand/tokens.md 닫힌 팔레트 + 제품 UI 상태색 3종(가안, 오너 승인 전)
   모바일 세로 360~430px 우선. 데스크톱은 QR 안내 화면(?preview=1일 때만 프레임 미리보기). */

:root {
  --deep-earth: #1F2A37;
  --corelite-red: #C84A2E;
  --gold-mine: #B89B5E;
  --stone-gray: #6B6661;
  --ink: #17202A;
  --muted: #9CA3AF;
  --bg: #FFFFFF;
  --base: #F8F5F0;
  --surface: #EDEEF0;
  --border: #D9DDE3;
  /* 제품 UI 상태색 (가안, 오너 승인 전 — 명세 §0) */
  --ok: #087F5B;
  --warn: #B45309;
  --alert: #C62828;
  --font: "Pretendard Variable", Pretendard, "Apple SD Gothic Neo", "Noto Sans KR", -apple-system, system-ui, sans-serif;
  --radius: 10px;
  --tap: 48px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  word-break: keep-all;
  overflow-wrap: break-word;
}
a { color: inherit; }
button { font: inherit; }
[hidden] { display: none !important; }

.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.title[tabindex="-1"]:focus, .detail__place[tabindex="-1"]:focus { outline: none; }

/* 건너뛰기 링크(개선점 17) */
.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 4000;
  background: var(--deep-earth); color: #fff; padding: 10px 16px; border-radius: 8px;
  text-decoration: none; font-weight: 700; transition: top 150ms ease;
}
.skip-link:focus { top: 8px; }

.frame { min-height: 100dvh; display: flex; flex-direction: column; background: var(--bg); }

/* 상단 고정 119 */
.topbar {
  position: sticky; top: 0; z-index: 1000;
  display: flex; gap: 8px; align-items: stretch;
  padding: 8px 12px;
  padding-top: calc(8px + env(safe-area-inset-top));
  background: var(--deep-earth);
}
.btn-119 {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 56px; border-radius: var(--radius);
  background: var(--corelite-red); color: #fff; text-decoration: none;
  font-weight: 700; letter-spacing: 0.02em;
}
.btn-119__num { font-size: 28px; line-height: 1; }
.btn-119__txt { font-size: 18px; }
.topbar__help {
  min-width: 96px; min-height: 56px; border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.35); background: transparent; color: #F4F1EC;
  font-weight: 600;
}

/* 화면 */
.app { flex: 1; }
.screen { padding: 20px 16px 24px; display: flex; flex-direction: column; gap: 14px; }
.title { margin: 0; font-size: 26px; line-height: 1.25; font-weight: 700; }
.title--sm { font-size: 20px; }
.lead { margin: 0; font-size: 16px; color: var(--stone-gray); }
.notice { margin: 0; font-size: 14px; color: var(--stone-gray); }
.row { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap); padding: 10px 16px; border-radius: var(--radius);
  border: 1px solid transparent; cursor: pointer; font-weight: 600; font-size: 17px;
  text-decoration: none; text-align: center;
  transition: background-color 200ms linear, color 200ms linear;
}
.btn[disabled] { opacity: 0.6; cursor: not-allowed; }
.btn--xl { min-height: 64px; font-size: 20px; }
.btn--primary { background: var(--deep-earth); color: #fff; }
.btn--secondary { background: var(--base); color: var(--deep-earth); border-color: var(--border); }
.btn--ghost { background: transparent; color: var(--stone-gray); border-color: var(--border); }
.btn--small { min-height: 40px; font-size: 14px; padding: 6px 12px; background: #fff; border-color: var(--border); }
.btn--back { align-self: flex-start; }
.btn:focus-visible, .btn-119:focus-visible, .chip:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid var(--gold-mine); outline-offset: 2px;
}

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; min-height: 40px; padding: 6px 14px;
  border-radius: 999px; border: 1px solid var(--border); background: #fff;
  font-size: 14px; text-decoration: none; color: var(--deep-earth);
}

.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--stone-gray); }
.field select {
  min-height: var(--tap); font: inherit; font-size: 17px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius); background: #fff; color: var(--ink);
}

/* 내 주변 */
.screen--nearby { padding-top: 12px; gap: 10px; }
.nearby-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.origin-tag { font-size: 13px; color: var(--stone-gray); }
.map { height: 220px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.map-actions { display: flex; justify-content: flex-end; }
.expand-note { margin: 0; font-size: 14px; color: var(--warn); }

.results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.result {
  display: grid; grid-template-columns: 40px 1fr; gap: 6px 10px;
  padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff;
  scroll-margin: 90px;
}
.result--highlight { outline: 3px solid var(--gold-mine); outline-offset: 2px; }
.result__num {
  grid-row: 1 / span 3; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; background: var(--deep-earth); color: #fff; font-weight: 700; font-size: 18px;
}
.result__dist { font-size: 22px; font-weight: 700; line-height: 1.2; }
.result__dist small { font-size: 14px; font-weight: 500; color: var(--stone-gray); margin-left: 6px; }
.result__place { font-size: 19px; font-weight: 600; line-height: 1.3; }
.result__org { font-size: 14px; color: var(--stone-gray); }
.result__status { grid-column: 2; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.result__actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.result__group { grid-column: 2; font-size: 13px; color: var(--gold-mine); font-weight: 600; }

.status { display: inline-flex; align-items: center; gap: 6px; }
.status::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.status--ok::before { background: var(--ok); }
.status--ok { color: var(--ok); }
.status--warn::before { background: var(--warn); }
.status--warn { color: var(--warn); }
.status--unknown { color: var(--stone-gray); }
.status--big { font-size: 16px; }

/* 상세 */
.detail__place { margin: 0; font-size: 28px; line-height: 1.2; font-weight: 700; }
.detail__org { margin: 4px 0 0; font-size: 17px; color: var(--stone-gray); }
.detail__dist { font-size: 20px; font-weight: 700; margin-top: 10px; }
.detail__dist small { font-size: 14px; font-weight: 500; color: var(--stone-gray); margin-left: 6px; }
.detail__addr { margin: 8px 0 0; font-size: 15px; }
.detail__status { margin: 12px 0 4px; font-size: 16px; }
.detail__actions { display: grid; gap: 8px; margin: 14px 0; }
.detail__actions .btn { width: 100%; }
.hours { width: 100%; border-collapse: collapse; font-size: 15px; margin-top: 8px; }
.hours th, .hours td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--border); }
.hours th { width: 64px; font-weight: 600; color: var(--stone-gray); }
.hours tr.today th, .hours tr.today td { font-weight: 700; color: var(--deep-earth); }
.hours .na { color: var(--muted); }
.section-label { font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold-mine); font-weight: 700; margin: 16px 0 4px; }
.sibling { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); margin-top: 8px; }
.sibling button { margin-top: 6px; }
.detail__meta { font-size: 13px; color: var(--stone-gray); margin-top: 14px; }

/* 응급 안내 */
.steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 10px; font-size: 17px; }

/* 데이터 신선도 배지(개선점 8) */
.stale-badge {
  display: inline-block; margin-left: 4px; padding: 2px 8px; border-radius: 999px;
  background: var(--warn); color: #fff; font-size: 11px; font-weight: 700; vertical-align: middle;
}

/* 푸터 */
.foot { padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--base); }
.foot p { margin: 0 0 6px; }
.foot__notice { font-size: 14px; font-weight: 600; color: var(--deep-earth); }
.foot__meta { font-size: 12px; color: var(--stone-gray); }
.foot__meta a { color: var(--deep-earth); text-decoration: underline; }

/* Leaflet 번호 핀 */
.pin {
  width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: var(--deep-earth); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.35);
  display: grid; place-items: center;
}
.pin span { transform: rotate(45deg); color: #fff; font-weight: 700; font-size: 13px; }
.pin--me { background: var(--corelite-red); border-radius: 50%; transform: none; width: 18px; height: 18px; }
.leaflet-container { font-family: var(--font); }

/* 데스크톱(768px 이상): QR/링크 안내 화면 (개선점 9). main.js가 노출 여부를 결정한다 */
.desktop-gate {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 40px 20px; background: var(--base);
}
.desktop-gate__card {
  max-width: 460px; width: 100%; background: #fff; border: 1px solid var(--border);
  border-radius: 16px; padding: 36px 28px; text-align: center; box-shadow: 0 8px 32px rgba(0,0,0,0.10);
}
.desktop-gate__card .btn { margin: 14px auto 0; }
.desktop-gate__url {
  display: block; margin: 16px 0; padding: 14px; background: var(--base);
  border-radius: var(--radius); font-size: 17px; font-weight: 700; color: var(--deep-earth);
  word-break: break-all;
}

/* 데스크톱 프레임 미리보기(?preview=1일 때만 main.js가 .frame을 노출) */
@media (min-width: 768px) {
  body { background: #E6E3DE; }
  .frame:not([hidden]) {
    max-width: 430px; margin: 24px auto; min-height: calc(100dvh - 48px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.18); border-radius: 12px; overflow: hidden;
  }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media (prefers-contrast: more) {
  .result, .chip, .btn--secondary, .btn--ghost, .desktop-gate__card { border-color: var(--ink); }
}

/* 데스크톱 안내 QR (pipeline/make_qr.sh 생성물. 없으면 onerror로 숨김) */
.desktop-gate__qr { display: block; width: 220px; height: 220px; margin: 8px auto 4px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; padding: 8px; }
