/* ==========================================================================
   United Kingdom Journey — Apple 스타일 사진첩
   ========================================================================== */

:root {
  --bg: #000;
  --bg-current: #000; /* themes.js가 이 값을 바꿔서 페이지 배경을 아주 천천히 전환함 */
  --bg-soft: #0a0a0a;
  --surface: #111114;
  --text: #f5f5f7;
  --text-dim: #a1a1a6;
  --text-faint: #6e6e73;
  --accent: #2997ff;
  --divider: rgba(255, 255, 255, 0.08);
  --radius: 18px;
  --nav-h: 52px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  /* 트랜지션 속도 -> 나중에 "전환 속도를 느리게 해줘" 같은 요청은
     이 세 값만 바꾸면 사이트 전체에 반영됨 */
  --transition-fast: 200ms;
  --transition-normal: 700ms;
  --transition-slow: 1.4s;
  --bg-transition-duration: var(--transition-slow);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

/* 이미지/텍스트가 비동기로 로드되면서 위쪽 콘텐츠 높이가 바뀔 때, 브라우저가
   "보던 위치를 유지"하려고 스크롤을 살짝 아래로 밀어버리는 현상(스크롤 앵커링)을
   막음. 새로고침 시 애매하게 아래로 스크롤되는 문제의 원인 중 하나. */
html, body { overflow-anchor: none; }

body {
  margin: 0;
  background: var(--bg-current);
  transition: background-color var(--bg-transition-duration) ease;
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* 모션을 줄이고 싶은 사용자를 위한 배려: 전환 애니메이션을 사실상 끔
   (배경색 자체는 여전히 바뀌지만 순간적으로 바뀜, 튀는 모션만 제거) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  html { scroll-behavior: auto; }
}

img { display: block; max-width: 100%; }
button { font-family: inherit; }
code {
  background: rgba(255,255,255,0.08);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.9em;
}

/* ---------- 스크롤 진행률 바 ---------- */
.scroll-progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 0%;
  background: linear-gradient(90deg, #2997ff, #a463ff);
  z-index: 1000;
  transition: width 0.1s linear;
}

/* ---------- 내비게이션 ---------- */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  z-index: 900;
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  background: rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid transparent;
  transition: background 0.3s var(--ease), border-color 0.3s var(--ease);
}
.nav.is-scrolled {
  background: rgba(10, 10, 10, 0.72);
  border-bottom-color: var(--divider);
}
.nav-inner {
  max-width: 1180px;
  margin: 0 auto;
  height: 100%;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-logo {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.tabs {
  display: flex;
  gap: 2px;
  background: rgba(255, 255, 255, 0.08);
  padding: 3px;
  border-radius: 980px;
}
.tab {
  border: none;
  background: transparent;
  color: var(--text-dim);
  padding: 6px 16px;
  border-radius: 980px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.25s var(--ease), background 0.25s var(--ease);
}
.tab:hover { color: var(--text); }
.tab.is-active {
  background: var(--text);
  color: #000;
}

/* ---------- 히어로 ---------- */
.hero {
  position: relative;
  height: 100vh;
  min-height: 560px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #050506;
}
.hero-bg {
  position: absolute;
  inset: -8% -8% -8% -8%;
  background-size: cover;
  background-position: center;
  filter: brightness(0.6) saturate(1.05);
  transform: scale(1.08) translateY(0);
  transition: opacity 0.6s ease;
  background-image:
    radial-gradient(ellipse 80% 60% at 30% 20%, rgba(41,151,255,0.35), transparent 60%),
    radial-gradient(ellipse 70% 50% at 80% 80%, rgba(164,99,255,0.30), transparent 60%),
    linear-gradient(160deg, #0c0c12, #050506 60%);
}
.hero-bg.has-photo { filter: brightness(0.55) saturate(1.05); }
.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.15) 0%, rgba(0,0,0,0.10) 40%, rgba(0,0,0,0.75) 100%);
}
.hero-content {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 0 20px;
}
.hero-eyebrow {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: rgba(255,255,255,0.65);
}
.hero-title {
  margin: 0;
  /* line-height를 넉넉히(1.02 -> 1.2) 줘서 g/y처럼 아래로 내려오는
     글자(디센더)가 background-clip:text 박스에 의해 잘리지 않게 함 */
  font-size: clamp(44px, 9vw, 104px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  padding-bottom: 0.06em;
  background: linear-gradient(180deg, #fff 40%, rgba(255,255,255,0.75));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-subtitle {
  margin: 18px 0 0;
  font-size: clamp(15px, 2vw, 19px);
  color: var(--text-dim);
  font-weight: 400;
}
.hero-scroll {
  position: absolute;
  bottom: 34px;
  left: 50%;
  transform: translateX(-50%);
  width: 26px;
  height: 42px;
  border: 2px solid rgba(255,255,255,0.4);
  border-radius: 14px;
  z-index: 2;
}
.hero-scroll span {
  position: absolute;
  top: 7px; left: 50%;
  width: 4px; height: 8px;
  margin-left: -2px;
  border-radius: 2px;
  background: #fff;
  animation: scrollDot 1.6s infinite var(--ease);
}
@keyframes scrollDot {
  0% { opacity: 1; transform: translateY(0); }
  70% { opacity: 0; transform: translateY(14px); }
  100% { opacity: 0; transform: translateY(14px); }
}

/* ---------- 상태 화면(로딩/빈/에러) ---------- */
.state {
  max-width: 560px;
  margin: 90px auto;
  text-align: center;
  padding: 0 24px;
  color: var(--text-dim);
}
.state h2 { color: var(--text); font-size: 22px; margin: 14px 0 10px; letter-spacing: -0.01em; }
.state p { line-height: 1.7; font-size: 14.5px; }
.empty-icon { font-size: 44px; }
.empty-example { margin-top: 14px; }

.spinner {
  width: 30px; height: 30px;
  margin: 0 auto;
  border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,0.15);
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 갤러리 섹션 공통 ---------- */
.gallery-section {
  position: relative;
  z-index: 2;
  background: var(--bg-current);
  transition: background-color var(--bg-transition-duration) ease;
  padding: 70px 24px 40px;
  min-height: 40vh;
}
.view { max-width: 1180px; margin: 0 auto; }
.view-map { max-width: 1180px; margin: 0 auto; }

.group {
  margin: 0 0 56px;
  scroll-margin-top: 76px; /* 상단 고정 내비게이션에 가려지지 않도록 */
}
.group-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--divider);
}
.group-title {
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}
.group-count {
  font-size: 13px;
  color: var(--text-faint);
}

/* 그리드 (CSS Grid, 행 우선 배치)
   -> 신문 컬럼 방식(CSS columns)은 왼쪽 칸을 끝까지 채운 뒤 다음 칸으로
      넘어가서, 사진이 실제로는 시간순인데도 눈으로 왼쪽->오른쪽으로 읽으면
      순서가 뒤죽박죽으로 보임. 그리드는 왼쪽 위 -> 오른쪽, 다음 줄 순서로
      채워져서 항상 정렬 순서 = 눈으로 읽는 순서가 일치함. */
.masonry {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  /* 기본값(stretch)이면 카드가 같은 줄의 가장 긴 사진 높이까지 늘어나서
     짧은 사진 카드 아래에 배경색 여백이 남음. start로 바꾸면 각 카드는
     사진 실제 높이만큼만 차지하고, 줄 높이(다음 줄이 시작되는 지점)는
     그리드가 자동으로 그 줄의 가장 긴 카드 기준으로 그대로 계산해줌. */
  align-items: start;
}
@media (min-width: 460px)  { .masonry { gap: 14px; } }
@media (min-width: 700px)  { .masonry { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 980px)  { .masonry { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1360px) { .masonry { grid-template-columns: repeat(5, 1fr); } }

.photo-card {
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  background: var(--surface);
  cursor: zoom-in;
  opacity: 0;
  transform: translateY(26px) scale(0.98);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}
.photo-card.in-view {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.photo-card img {
  width: 100%;
  height: auto; /* 크롭 없이 원본 비율 그대로 표시 */
  display: block;
  transition: transform 0.6s var(--ease), filter 0.6s var(--ease);
}
.photo-card:hover img {
  transform: scale(1.045);
}
.photo-card .card-shade {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 22px 14px 12px;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,0.62));
  opacity: 0;
  transition: opacity 0.35s var(--ease);
  font-size: 12.5px;
  color: rgba(255,255,255,0.9);
  pointer-events: none;
}
.photo-card:hover .card-shade { opacity: 1; }

/* 이미지 로딩 스켈레톤 느낌 */
.photo-card img.is-loading { background: linear-gradient(100deg, #141416 30%, #1c1c1f 50%, #141416 70%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- 라이트박스 ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s var(--ease);
  /* 모바일에서 사진 위 드래그가 뒤쪽 페이지 스크롤이나 iOS의 "가장자리
     스와이프로 뒤로가기" 제스처로 새어나가지 않도록, 라이트박스가 열려
     있는 동안은 터치 제스처를 온전히 JS(스와이프 넘기기)가 처리함 */
  touch-action: none;
  overscroll-behavior: contain;
}
.lightbox.is-open { opacity: 1; visibility: visible; }
.lb-figure {
  margin: 0;
  max-width: 90vw;
  max-height: 86vh;
  text-align: center;
}
.lb-figure img {
  max-width: 90vw;
  max-height: 78vh;
  border-radius: 10px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.6);
  transform: scale(0.96);
  transition: transform 0.35s var(--ease);
}
.lightbox.is-open .lb-figure img { transform: scale(1); }
.lb-figure figcaption {
  margin-top: 14px;
  color: var(--text-dim);
  font-size: 13.5px;
}
.lb-close, .lb-prev, .lb-next {
  position: absolute;
  background: rgba(255,255,255,0.08);
  border: none;
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s var(--ease);
}
.lb-close:hover, .lb-prev:hover, .lb-next:hover { background: rgba(255,255,255,0.18); }
.lb-close { top: 22px; right: 22px; width: 42px; height: 42px; font-size: 17px; }
.lb-prev, .lb-next { top: 50%; transform: translateY(-50%); width: 52px; height: 52px; font-size: 26px; }
.lb-prev { left: 18px; }
.lb-next { right: 18px; }

/* ---------- 빠른 이동 인덱스 (날짜/장소 사이드 슬라이더) ---------- */
/* 데스크톱/모바일 공통: 화면 오른쪽 가장자리에 붙는 세로 인덱스.
   (iOS 연락처 앱의 A-Z 인덱스와 같은 자리 — 좌우 스크롤 없이 손가락으로
   위아래로 훑기만 하면 되는, 모바일에서 가장 자연스러운 방식) */
.tab-index {
  position: fixed;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  max-height: 76vh;
  overflow-y: auto;
  scrollbar-width: none;
  padding: 8px 4px;
  touch-action: none; /* 드래그로 스크럽하는 동안 페이지 스크롤과 충돌 방지 */
  user-select: none;
  background: rgba(10, 10, 11, 0.35);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 16px;
}
.tab-index::-webkit-scrollbar { display: none; }
.tab-index:empty { display: none; } /* 지도 탭 등 인덱스가 필요 없을 땐 빈 박스를 아예 숨김 */

.tab-index-item {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-faint);
  padding: 5px 8px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s var(--ease), background 0.2s var(--ease), transform 0.2s var(--ease);
  min-height: 26px; /* 터치하기 충분한 크기 확보 -> 오탭 방지 */
  box-sizing: border-box;
}
.tab-index-item:hover,
.tab-index-item.is-near {
  color: var(--text);
  background: rgba(255, 255, 255, 0.12);
  transform: translateX(-2px);
}

.tab-index-count {
  font-size: 9.5px;
  font-weight: 600;
  color: inherit;
  opacity: 0.6;
  background: rgba(255, 255, 255, 0.12);
  padding: 1px 6px;
  border-radius: 999px;
  min-width: 16px;
  text-align: center;
}
.tab-index-item.is-near .tab-index-count,
.tab-index-item:hover .tab-index-count {
  opacity: 0.9;
}

.tab-index-bubble {
  position: fixed;
  top: 50%;
  right: 68px;
  transform: translateY(-50%);
  background: rgba(18, 18, 20, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  z-index: 600;
  white-space: nowrap;
}

/* 좁은 화면(모바일)에서는 자리를 아끼되, 자리는 그대로 오른쪽 세로 —
   가로 스크롤이 필요 없어지고, 갤러리 콘텐츠에 오른쪽 여백을 줘서
   인덱스와 사진이 겹쳐 오탭되는 일이 없도록 함 */
@media (max-width: 780px) {
  .tab-index {
    right: 2px;
    max-height: 70vh;
    padding: 6px 3px;
    gap: 0;
  }
  .tab-index-item {
    font-size: 10px;
    padding: 4px 6px;
    gap: 4px;
    min-height: 24px;
  }
  .tab-index-count {
    font-size: 8.5px;
    padding: 0 4px;
  }
  .tab-index-bubble {
    right: auto;
    left: 50%;
    top: 18px;
    transform: translateX(-50%);
  }
  /* 인덱스 폭만큼 갤러리 콘텐츠 오른쪽에 여유를 둬서 카드가 그 아래 깔리지 않게 함 */
  .gallery-section { padding-right: 46px; }
  .nav-inner { padding-right: 12px; }
}

/* ---------- 지도(MAP) 뷰 ---------- */
#mapContainer {
  width: 100%;
  height: 72vh;
  min-height: 420px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.leaflet-container {
  background: #0a0a0c;
  font-family: inherit;
}
/* Leaflet 기본 컨트롤/팝업을 사이트 다크 톤에 맞게 재도색 */
.leaflet-control-zoom a {
  background: rgba(20, 20, 22, 0.9) !important;
  color: var(--text) !important;
  border-color: var(--divider) !important;
}
.leaflet-control-attribution {
  background: rgba(10, 10, 11, 0.6) !important;
  color: var(--text-faint) !important;
}
.leaflet-control-attribution a { color: var(--text-dim) !important; }

/* 커스텀 마커: 기본 핀 대신 앨범 썸네일 원형 마커 */
.map-marker {
  display: flex;
  align-items: center;
  justify-content: center;
}
.map-marker-thumb {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  transition: transform 0.2s var(--ease);
}
.map-marker:hover .map-marker-thumb { transform: scale(1.08); }
.map-marker-count {
  position: absolute;
  right: -2px;
  bottom: -2px;
  background: var(--text);
  color: #000;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* 팝업(장소 이름 + 대표 사진 + 사진 보기) */
.leaflet-popup-content-wrapper {
  background: rgba(18, 18, 20, 0.96);
  backdrop-filter: blur(14px);
  color: var(--text);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
}
.leaflet-popup-tip { background: rgba(18, 18, 20, 0.96); }
.leaflet-popup-content { margin: 12px 14px; }
.leaflet-popup-close-button { color: var(--text-dim) !important; }

.map-popup {
  display: flex;
  gap: 12px;
  align-items: center;
}
.map-popup-thumb {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}
.map-popup-title { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.map-popup-count { font-size: 12.5px; color: var(--text-faint); margin-top: 2px; }
.map-popup-btn {
  margin-top: 8px;
  border: none;
  background: var(--text);
  color: #000;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 980px;
  cursor: pointer;
  transition: transform 0.15s var(--ease);
}
.map-popup-btn:hover { transform: scale(1.04); }

@media (max-width: 640px) {
  #mapContainer { height: 62vh; min-height: 360px; }
}

/* ---------- 뷰 전환(모프/FLIP) ----------
   장소별<->시간순: 화면에 보이던 사진 카드가 같은 사진끼리 매칭되어
   새 위치로 실제로 미끄러지듯 이동합니다 (View Transitions API,
   named element morph). 별도 라이브러리 없이 브라우저 내장 기능만 사용.
   지도 전환: 살짝 축소/확대되며 자연스럽게 넘어가도록 별도 애니메이션. */
::view-transition-group(*) {
  animation-duration: var(--transition-normal);
  animation-timing-function: var(--ease); /* 바운스 없는 차분한 easing */
}

html.vt-map::view-transition-old(root) {
  animation: vt-map-out var(--transition-normal) var(--ease) both;
}
html.vt-map::view-transition-new(root) {
  animation: vt-map-in var(--transition-normal) var(--ease) both;
}
@keyframes vt-map-out {
  to { opacity: 0; transform: scale(0.97); }
}
@keyframes vt-map-in {
  from { opacity: 0; transform: scale(1.03); }
  to { opacity: 1; transform: scale(1); }
}

/* ---------- 푸터 ---------- */
.site-footer {
  text-align: center;
  padding: 40px 20px 60px;
  color: var(--text-faint);
  font-size: 12.5px;
}

.br-desktop { display: none; }
@media (min-width: 640px) { .br-desktop { display: inline; } }

@media (max-width: 640px) {
  .tabs { gap: 0; }
  .tab { padding: 6px 12px; font-size: 12.5px; }
  .lb-prev, .lb-next { width: 40px; height: 40px; font-size: 20px; }
}
