/*
  홈의 '경로 이야기' — 스크롤에 맞춰 한 달 맛집 길이 지도 위에 그려진다.
  동작은 route-story.js. JS 가 붙이는 .is-live 일 때만 섹션이 길어지고 화면에 고정된다.
  그 전(JS 없음·동작 줄이기)에는 다 그려진 지도와 요약 카드가 한 화면에 보인다.
  지도 안은 앱 라이트 테마 색(phone-demo.css 의 --map-*)을 그대로 쓴다.
*/

.route-story {
  --rs-top: 60px; /* 고정될 때 위 여백 = 머리말 높이 (site.css .site-header) */
  --rs-scroll: 380vh; /* 섹션 전체 높이. 길수록 천천히 그려진다 */
  --map-land: #f2efe8;
  --map-block: #e9e5dc;
  --map-park: #d5e8c4;
  --map-water: #bfdcf2;
  --map-road: #ffffff;
  --route: #8775bc;

  position: relative;
  padding: 0; /* 위아래 여백은 .rs-sticky 가 맡는다 */
  background: var(--bg); /* 바로 아래 '시작하기'(.section.alt)와 섞이지 않게 */
}

.route-story.is-live { height: var(--rs-scroll); }

.rs-sticky {
  padding: 56px 0;
  background: radial-gradient(50% 60% at 72% 50%, var(--brand-soft), transparent 75%); /* 지도 뒤 은은한 빛 */
}

.is-live .rs-sticky {
  position: sticky;
  top: var(--rs-top);
  height: calc(100vh - var(--rs-top));
  height: calc(100svh - var(--rs-top));
  display: flex;
  align-items: center;
  padding: 24px 0;
}

.rs-grid {
  display: grid;
  grid-template-columns: 1fr minmax(0, 1fr);
  grid-template-areas: "text map";
  gap: 56px;
  align-items: center;
  width: 100%;
}

.rs-text { grid-area: text; }
.rs-text h2 { margin-bottom: 12px; }

/* ── 날짜 눈금: 다녀온 날마다 하나씩 켜진다 ───────────── */

.rs-ticks {
  display: flex;
  gap: 6px;
  list-style: none;
  margin: 28px 0 18px;
  padding: 0;
}

.rs-ticks li {
  flex: 1;
  padding-top: 10px;
  border-top: 3px solid var(--line);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  transition: border-color 0.3s, color 0.3s;
}

.rs-ticks li.is-reached {
  border-color: var(--brand);
  color: var(--brand);
}

/* ── 장소 설명: 지금 도착한 곳 하나만 보인다 ──────────── */

.rs-captions {
  display: grid; /* 모두 같은 칸에 겹쳐 두고 바꿔 끼운다 */
  min-height: 92px;
}

.rs-caption {
  grid-area: 1 / 1;
  opacity: 0;
  translate: 0 10px;
  transition: opacity 0.35s, translate 0.45s var(--reveal-ease, ease);
}

.rs-caption.is-active,
.route-story:not(.is-live) .rs-caption:last-child {
  opacity: 1;
  translate: 0 0;
}

.rs-caption b {
  display: block;
  font-size: 13px;
  color: var(--brand);
  margin-bottom: 4px;
}

.rs-caption p {
  margin: 0;
  font-family: "Gowun Batang", serif;
  font-size: clamp(19px, 2.2vw, 24px);
  font-weight: 700;
  line-height: 1.45;
  letter-spacing: -0.4px;
}

/* ── 지도 ────────────────────────────────────────────── */

.rs-map {
  grid-area: map;
  position: relative;
  justify-self: center;
  width: 100%;
  max-width: 440px;
  aspect-ratio: 4 / 5; /* route-story.js 의 VIEW_W / VIEW_H */
  border-radius: 28px;
  overflow: hidden;
  background: var(--map-land);
  box-shadow: 0 30px 60px rgba(60, 40, 110, 0.18), 0 0 0 1px rgba(60, 40, 110, 0.06);
}

/* 화면 높이가 낮으면 지도 높이에 맞춰 폭을 줄인다 */
.is-live .rs-map { max-width: min(440px, calc((100svh - var(--rs-top) - 48px) * 0.8)); }

.rs-map > svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.rs-map .block { fill: var(--map-block); }
.rs-map .park { fill: var(--map-park); }
.rs-map .water { fill: var(--map-water); }
.rs-map .road { fill: none; stroke: var(--map-road); stroke-linecap: round; }

.rs-route-ghost {
  fill: none;
  stroke: var(--route);
  stroke-width: 3;
  stroke-dasharray: 2 9;
  stroke-linecap: round;
  opacity: 0.35;
}

.rs-route {
  fill: none;
  stroke: var(--route);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 3px rgba(135, 117, 188, 0.35));
}

/* 길 끝을 달리는 점 — 퍼지는 고리가 계속 숨 쉰다 */
.rs-head circle:first-child {
  fill: var(--route);
  opacity: 0.25;
  transform-origin: center;
  transform-box: fill-box;
  animation: rs-pulse 1.6s ease-out infinite;
}

.rs-head circle:last-child {
  fill: #fff;
  stroke: var(--route);
  stroke-width: 4;
}

.route-story:not(.is-live) .rs-head,
.route-story.is-done .rs-head { opacity: 0; }

@keyframes rs-pulse {
  from { scale: 0.6; opacity: 0.45; }
  to { scale: 2.2; opacity: 0; }
}

/* 영상 화면 표시 — 위: 이름표, 아래: 날짜·거리 */
.rs-label,
.rs-meter {
  position: absolute;
  left: 14px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: #393939;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(42, 42, 50, 0.1);
}

.rs-label { top: 14px; }
.rs-label i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #e5484d;
  animation: rs-rec 1.2s steps(2, jump-none) infinite;
}

.rs-meter {
  bottom: 14px;
  font-variant-numeric: tabular-nums;
}
.rs-meter span { color: #8a8494; font-weight: 600; }

@keyframes rs-rec { 50% { opacity: 0.25; } }

/* ── 핀과 사진 카드 ──────────────────────────────────── */

.rs-pins {
  position: absolute;
  inset: 0;
}

.rs-stop {
  position: absolute;
  width: 0;
  height: 0;
}

.rs-pin {
  position: absolute;
  left: -20px;
  bottom: 0;
  width: 40px;
  height: 48px;
  transform-origin: 50% 100%;
  transition: scale 0.45s var(--pop-ease, ease), opacity 0.25s;
  filter: drop-shadow(0 4px 6px rgba(42, 42, 50, 0.2));
}

.rs-pin svg { width: 100%; height: 100%; display: block; }

.rs-pin i {
  position: absolute;
  top: 8px;
  left: 0;
  right: 0;
  text-align: center;
  font-style: normal;
  font-size: 16px;
  line-height: 1;
}

.is-live .rs-stop:not(.is-reached) .rs-pin { scale: 0.2; opacity: 0; }

/* 도착하면 핀 위로 사진 카드가 살짝 커지며 뜬다 */
.rs-photo {
  position: absolute;
  left: 0;
  bottom: 58px;
  z-index: 1;
  width: 132px;
  padding: 6px 6px 8px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 14px 30px rgba(42, 42, 50, 0.22);
  translate: var(--card-shift, -50%) 0;
  transform-origin: 50% 100%;
  opacity: 0;
  scale: 0.6;
  transition: opacity 0.3s, scale 0.45s var(--pop-ease, ease);
  pointer-events: none;
}

.rs-photo img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 9px;
}

.rs-photo span {
  display: block;
  padding: 6px 2px 0;
  font-size: 10.5px;
  color: #8a8494;
  line-height: 1.3;
}

.rs-photo b {
  display: block;
  font-family: "Gowun Batang", serif;
  font-size: 12.5px;
  color: #393939;
}

/* 위쪽 장소: 핀 아래로 */
.is-card-below .rs-photo {
  bottom: auto;
  top: 12px;
  transform-origin: 50% 0;
}

/* 말풍선 꼬리 — 카드를 비켜 세워도 핀을 가리킨다 */
.rs-photo::after {
  content: "";
  position: absolute;
  left: calc(var(--card-shift, -50%) * -1);
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 2px;
  translate: -50% 0;
  rotate: 45deg;
}

.is-card-below .rs-photo::after { bottom: auto; top: -6px; }

.rs-stop.is-current .rs-photo { opacity: 1; scale: 1; }
.rs-stop.is-current .rs-pin { scale: 1.18; }

/* ── 요약 카드: 다 그리고 나면 지도 아래에서 올라온다 ───── */

.rs-summary {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 3;
  padding: 16px 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.96);
  color: #393939;
  box-shadow: 0 18px 40px rgba(60, 40, 110, 0.2);
  transition: opacity 0.4s, translate 0.55s var(--pop-ease, ease);
}

.is-live:not(.is-done) .rs-summary {
  opacity: 0;
  translate: 0 30px;
  pointer-events: none;
}

.rs-summary b {
  display: block;
  font-family: "Gowun Batang", serif;
  font-size: 17px;
  margin-bottom: 10px;
}

.rs-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0;
}

.rs-stats div {
  padding: 8px 6px;
  border-radius: 12px;
  background: #f4effa;
  text-align: center;
}

.rs-stats dt { font-size: 11px; color: #8a8494; }
.rs-stats dd { margin: 2px 0 0; font-size: 17px; font-weight: 800; color: #8775bc; }

.rs-note {
  margin: 10px 0 0;
  font-size: 12px;
  color: #8a8494;
}

/* ── 모바일: 지도 위, 글 아래 ─────────────────────────── */

@media (max-width: 860px) {
  .rs-grid {
    grid-template-columns: 1fr;
    grid-template-areas: "text" "map";
    gap: 20px;
  }

  .is-live .rs-grid {
    grid-template-areas: "map" "text";
    gap: 16px;
  }

  /* 고정 화면 높이가 빠듯해 소제목·설명은 감춘다 (제목은 남긴다) */
  .is-live .rs-text .eyebrow,
  .is-live .rs-text .lead { display: none; }
  .is-live .rs-text h2 { font-size: 20px; margin: 0 0 4px; }
  .is-live .rs-ticks { margin: 10px 0 10px; }
  .rs-captions { min-height: 76px; }

  .is-live .rs-map {
    max-width: min(400px, calc((100svh - var(--rs-top) - 250px) * 0.8));
  }

  .rs-photo { width: 112px; }
  .rs-summary { padding: 12px 14px; }
  .rs-note { display: none; }
  .rs-stats dd { font-size: 15px; }
}
