/* ==========================================================================
 * 여행지도 — 3D 지구본 (_includes/travel-atlas.html, assets/js/travel-atlas.js)
 * 색은 style.css 토큰만 쓴다. 지구본 색은 아래 --globe-* 를 JS가 읽어 셰이더에 넘긴다.
 * JS 없음 / WebGL 없음: .atlas 에 is-live 가 안 붙고 여행지 · 글 목록만 보인다.
 * ========================================================================== */
.atlas {
  --globe-ocean: var(--surface);
  --globe-land: color-mix(in srgb, var(--text) 17%, var(--bg));
  --globe-border: var(--bg);
  --globe-glow: var(--text-muted);
  --globe-arc: var(--accent);
  --atlas-top: 53px;
  position: relative;
  max-width: 1120px;
  margin: 0 auto;
  padding: 56px 32px 80px;
}
[data-theme="dark"] .atlas { --globe-land: color-mix(in srgb, var(--text) 24%, var(--bg)); }
.atlas [hidden] { display: none !important; }
.atlas button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- 지구본 무대 ---------- */
.atlas-stage {
  position: relative;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
  background: radial-gradient(circle at 50% 46%, var(--surface) 0, var(--bg) 62%);
}
.atlas-stage.is-dragging { cursor: grabbing; }
.atlas-gl, .atlas-fx { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.atlas-fx { pointer-events: none; }
.atlas-pins { position: absolute; inset: 0; pointer-events: none; }

.atlas-pin {
  position: absolute;
  left: 0; top: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0;
  border: 0;
  background: none;
  pointer-events: auto;
  will-change: transform, opacity;
  transition: opacity .25s;
}
.atlas-pin-dot {
  flex: none;
  width: var(--pin, 12px);
  height: var(--pin, 12px);
  margin-left: calc(var(--pin, 12px) / -2);
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent), 0 2px 6px color-mix(in srgb, var(--text) 25%, transparent);
  transition: transform .2s;
}
.atlas-pin-label {
  padding: 4px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  color: var(--text);
  font: 600 12.5px/1.3 var(--font-body);
  letter-spacing: -.01em;
  white-space: nowrap;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity .2s, transform .2s;
}
.atlas-pin-label b { margin-left: 4px; color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.atlas-pin.show-label .atlas-pin-label { opacity: 1; transform: none; }
.atlas-pin:hover .atlas-pin-dot, .atlas-pin:focus-visible .atlas-pin-dot, .atlas-pin.is-hot .atlas-pin-dot { transform: scale(1.35); }
.atlas-pin.is-active .atlas-pin-dot { transform: scale(1.5); box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 22%, transparent), 0 2px 6px color-mix(in srgb, var(--text) 25%, transparent); }
.atlas-pin.is-active .atlas-pin-label { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.atlas-pin.is-active .atlas-pin-label b { color: inherit; }
.atlas-pin.is-dim { opacity: .28 !important; }
.atlas-pin:focus-visible { outline: none; }
.atlas-pin:focus-visible .atlas-pin-label { opacity: 1; outline: 2px solid var(--accent); outline-offset: 2px; }

.atlas-hint {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  margin: 0;
  padding: 7px 14px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12.5px;
  pointer-events: none;
  white-space: nowrap;
  transition: opacity .5s;
}
.atlas-stage.was-touched .atlas-hint { opacity: 0; }
.atlas-zoom {
  position: absolute;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg);
}
.atlas-zoom button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  background: none;
  font-size: 19px;
  line-height: 1;
}
.atlas-zoom button + button { border-top: 1px solid var(--border); }
.atlas-zoom button:hover { background: var(--surface); }
.atlas-credit { position: absolute; left: 16px; bottom: 12px; margin: 0; font-size: 10.5px; color: var(--text-muted); opacity: .7; pointer-events: none; }

/* ---------- 옆 패널 ---------- */
.atlas-kicker { margin: 0 0 10px; font-size: 11px; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: var(--accent); }
.atlas-intro h1 { margin: 0 0 12px; font: 700 clamp(30px, 3.2vw, 40px)/1.2 var(--font-body); letter-spacing: -.045em; }
.atlas-lede { margin: 0; color: var(--text-muted); font-size: 14.5px; line-height: 1.75; }
.atlas-stats {
  display: grid;
  grid-template-columns: repeat(4, auto);
  justify-content: start;
  gap: 4px 26px;
  margin: 26px 0 0;
  padding: 18px 0 0;
  border-top: 1px solid var(--border);
}
.atlas-stats div { margin: 0; }
.atlas-stats dt { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; }
.atlas-stats dd { margin: 2px 0 0; font-size: 24px; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.atlas-stats dd small { margin-left: 2px; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.atlas-tour {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 22px;
  padding: 10px 16px 10px 13px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: none;
  color: var(--accent) !important;
  font-size: 13.5px !important;
  font-weight: 600 !important;
  transition: background .2s, color .2s;
}
.atlas-tour:hover, .atlas-tour[aria-pressed="true"] { background: var(--accent); color: var(--bg) !important; }

.atlas-filter { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 26px 0 6px; padding-bottom: 2px; }
.atlas-filter::-webkit-scrollbar { display: none; }
.atlas-filter button {
  flex: none;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: none;
  font-size: 13px !important;
  color: var(--text-muted) !important;
  transition: background .2s, color .2s, border-color .2s;
}
.atlas-filter button:hover { color: var(--text) !important; border-color: var(--text-muted); }
.atlas-filter button[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg) !important; }

.atlas-places { margin-top: 10px; }
.atlas-place { border-top: 1px solid var(--border); }
.atlas-place:first-child { border-top: 0; }
.atlas-place-head {
  display: grid;
  grid-template-columns: 56px 1fr;
  align-items: center;
  gap: 14px;
  padding: 12px 8px;
  margin: 0 -8px;
  border-radius: 12px;
  color: var(--text);
  text-decoration: none;
  transition: background .2s;
}
.atlas-place-head:hover, .atlas-place.is-hot .atlas-place-head { background: var(--surface); }
.atlas-place-head img { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; background: var(--surface); }
.atlas-place-text { display: grid; gap: 1px; min-width: 0; }
.atlas-place-text small { font-size: 11.5px; color: var(--text-muted); }
.atlas-name { font-size: 16px; font-weight: 650; letter-spacing: -.025em; }
.atlas-place-meta { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.atlas-place-body { padding: 4px 0 24px; }
.atlas-minimap { display: none; }
.atlas-maplink { display: none; }
.atlas-stories { list-style: none; margin: 0; padding: 0; }
.atlas-stories li + li { border-top: 1px solid var(--border); }
.atlas-stories a { display: grid; grid-template-columns: 64px 1fr; gap: 14px; align-items: center; padding: 12px 0; color: var(--text); text-decoration: none; }
.atlas-stories a:hover strong { color: var(--accent); }
.atlas-stories img { width: 64px; height: 48px; object-fit: cover; border-radius: 8px; background: var(--surface); }
.atlas-stories span { display: grid; gap: 3px; min-width: 0; }
.atlas-stories strong { font-size: 14px; font-weight: 600; line-height: 1.5; letter-spacing: -.02em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; transition: color .2s; }
.atlas-stories small { font-size: 11.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ---------- 지구본이 켜진 상태 ---------- */
.atlas.is-live .atlas-place-body { display: none; }
.atlas.is-live.is-detail .atlas-intro,
.atlas.is-live.is-detail .atlas-filter,
.atlas.is-live.is-detail .atlas-place:not(.is-active),
.atlas.is-live .atlas-place.is-filtered { display: none; }
.atlas.is-live.is-detail .atlas-place.is-active { border: 0; }
.atlas.is-live.is-detail .atlas-place-body { display: block; animation: atlas-in .35s ease both; }

/* 선택한 도시: 대표 사진 위에 이름 */
.atlas.is-detail .atlas-place.is-active .atlas-place-head {
  position: relative;
  display: block;
  margin: 0 0 18px;
  padding: 0;
  border-radius: 18px;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  background: var(--surface);
  pointer-events: none;
  animation: atlas-in .35s ease both;
}
.atlas.is-detail .atlas-place.is-active .atlas-place-head img { width: 100%; height: 100%; border-radius: 0; }
.atlas.is-detail .atlas-place.is-active .atlas-place-head::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.72), rgba(0,0,0,0) 62%);
}
.atlas.is-detail .atlas-place.is-active .atlas-place-text {
  position: absolute;
  z-index: 1;
  left: 22px;
  right: 22px;
  bottom: 18px;
  color: #fff;
}
.atlas.is-detail .atlas-place.is-active .atlas-place-text small,
.atlas.is-detail .atlas-place.is-active .atlas-place-meta { color: rgba(255,255,255,.82); }
.atlas.is-detail .atlas-place.is-active .atlas-name { font-size: 28px; font-weight: 700; letter-spacing: -.04em; line-height: 1.25; }
.atlas.is-detail .atlas-minimap {
  display: block;
  height: 170px;
  margin-bottom: 8px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
  z-index: 0;
}
.atlas.is-detail .atlas-maplink { display: inline-block; margin-bottom: 14px; font-size: 12.5px; color: var(--text-muted); text-decoration: none; }
.atlas.is-detail .atlas-maplink:hover { color: var(--accent); }
[data-theme="dark"] .atlas-minimap .leaflet-tile { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9) saturate(.4); }
.atlas-minimap .leaflet-control-attribution { font-size: 9.5px; }

.atlas-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0 0 16px -6px;
  padding: 6px 10px 6px 4px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--text-muted) !important;
  font-size: 13.5px !important;
}
.atlas-back:hover { color: var(--text) !important; background: var(--surface); }

@keyframes atlas-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* 넓은 화면: 왼쪽 패널 + 오른쪽 지구본이 화면 높이를 채운다 */
@media (min-width: 901px) {
  .atlas.is-live {
    display: grid;
    grid-template-columns: minmax(360px, 420px) 1fr;
    grid-template-areas: "side stage";
    max-width: none;
    height: calc(100svh - var(--atlas-top));
    min-height: 560px;
    padding: 0;
  }
  .atlas.is-live .atlas-stage { grid-area: stage; }
  .atlas.is-live .atlas-side {
    grid-area: side;
    overflow-y: auto;
    scrollbar-width: thin;
    padding: 44px 32px 40px 40px;
    border-right: 1px solid var(--border);
  }
}

/* 휴대폰 · 태블릿: 지구본 위, 목록 아래 */
@media (max-width: 900px) {
  .atlas { padding: 32px 20px 56px; }
  .atlas.is-live { padding: 0 0 56px; }
  .atlas.is-live .atlas-stage { height: 58svh; min-height: 320px; max-height: 560px; touch-action: pan-y; }
  .atlas.is-live .atlas-side { padding: 22px 20px 0; }
  .atlas-intro h1 { font-size: 28px; }
  .atlas-stats { grid-template-columns: repeat(4, auto); gap: 4px 18px; margin-top: 20px; padding-top: 16px; }
  .atlas-stats dd { font-size: 20px; }
  .atlas-hint { bottom: 14px; font-size: 12px; }
  .atlas-zoom { right: 12px; bottom: 12px; }
  .atlas-zoom button { width: 34px; height: 34px; }
  .atlas-pin-label { font-size: 12px; padding: 3px 8px; }
  .atlas.is-detail .atlas-place.is-active .atlas-name { font-size: 24px; }
}
@media (max-width: 340px) {
  .atlas-stats { grid-template-columns: repeat(2, auto); gap: 10px 28px; }
}

@media (prefers-reduced-motion: reduce) {
  .atlas *, .atlas *::after { animation: none !important; transition: none !important; }
}
