/* ============================================
   旅行手帐风 (Travel Journal Style)
   doudan.love - 家庭旅行计划
   ============================================ */

/* --- CSS Variables --- */
:root {
  --paper: #FBF7F0;
  --paper-dark: #F0E8D8;
  --kraft: #D4C4A8;
  --ink: #3D3226;
  --ink-light: #6B5E4F;
  --stamp-red: #C44536;
  --stamp-red-light: #E8A090;
  --tape-blue: #7EC8E3;
  --tape-green: #A8D8B9;
  --tape-yellow: #F4D03F;
  --tape-pink: #F0A8B8;
  --tape-orange: #F0C878;
  --visited: #2A7F3F;
  --unvisited: #B8A99A;
  --shadow-sm: 0 2px 8px rgba(61, 50, 38, 0.08);
  --shadow-md: 0 4px 16px rgba(61, 50, 38, 0.12);
  --shadow-lg: 0 8px 32px rgba(61, 50, 38, 0.16);
  --radius: 12px;
  --radius-sm: 6px;
  --font-cn: 'Noto Serif SC', 'Source Han Serif SC', 'STSong', 'SimSun', 'KaiTi', serif;
  --font-hand: 'ZCOOL KuaiLe', 'Ma Shan Zheng', 'KaiTi', cursive;
  --font-ui: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-ui);
  color: var(--ink);
  background-color: #F5EDE0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(212, 196, 168, 0.3) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(200, 180, 150, 0.2) 0%, transparent 50%),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 23px,
      rgba(180, 160, 140, 0.08) 23px,
      rgba(180, 160, 140, 0.08) 24px
    );
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* --- Typography --- */
h1, h2, h3 { font-family: var(--font-cn); font-weight: 700; }

/* --- Navigation Bar --- */
.nav-bar {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: linear-gradient(to bottom, rgba(251, 247, 240, 0.97), rgba(251, 247, 240, 0.92));
  backdrop-filter: blur(10px);
  border-bottom: 2px solid var(--kraft);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  box-shadow: var(--shadow-sm);
}

.nav-logo {
  font-family: var(--font-hand);
  font-size: 1.4rem;
  color: var(--ink);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-logo .stamp {
  display: inline-block;
  background: var(--stamp-red);
  color: #fff;
  padding: 2px 10px;
  border-radius: 3px;
  font-size: 0.75rem;
  transform: rotate(-5deg);
  font-family: var(--font-ui);
  letter-spacing: 2px;
}

.nav-links {
  display: flex;
  gap: 4px;
  list-style: none;
}

.nav-links a {
  text-decoration: none;
  color: var(--ink-light);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  transition: all 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
  background: var(--paper-dark);
  color: var(--ink);
}

/* --- Page Container --- */
.page-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

/* --- Home Hero --- */
.hero {
  text-align: center;
  padding: 48px 24px 32px;
  position: relative;
}

.hero h1 {
  font-size: 2.4rem;
  font-family: var(--font-hand);
  color: var(--ink);
  margin-bottom: 8px;
}

.hero .subtitle {
  font-size: 1.1rem;
  color: var(--ink-light);
  letter-spacing: 2px;
}

.hero .tape-strip {
  display: inline-block;
  background: var(--tape-yellow);
  opacity: 0.7;
  padding: 4px 24px;
  transform: rotate(-2deg);
  position: relative;
  top: -8px;
}

/* --- Route Cards Grid --- */
.route-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 24px;
  margin-top: 32px;
}

.route-card {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: transform 0.25s, box-shadow 0.25s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
  position: relative;
  border: 1px solid rgba(180, 160, 140, 0.3);
}

.route-card:hover {
  transform: translateY(-4px) rotate(0.5deg);
  box-shadow: var(--shadow-lg);
}

/* Washi tape top */
.route-card::before {
  content: '';
  display: block;
  height: 8px;
  width: 80%;
  margin: -3px auto 0;
  border-radius: 2px;
  opacity: 0.7;
}

.route-card:nth-child(1)::before { background: var(--tape-blue); }
.route-card:nth-child(2)::before { background: var(--tape-pink); }
.route-card:nth-child(3)::before { background: var(--tape-green); }
.route-card:nth-child(4)::before { background: var(--tape-yellow); }
.route-card:nth-child(5)::before { background: var(--tape-orange); }

.card-header {
  padding: 24px 24px 12px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.card-icon {
  font-size: 2rem;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper-dark);
  border-radius: 50%;
  flex-shrink: 0;
}

.card-title h3 {
  font-size: 1.2rem;
  margin-bottom: 2px;
}

.card-title .sub {
  font-size: 0.82rem;
  color: var(--ink-light);
}

.card-body {
  padding: 0 24px 20px;
  font-size: 0.88rem;
  color: var(--ink-light);
  line-height: 1.7;
}

.card-footer {
  padding: 14px 24px;
  border-top: 1px dashed rgba(180, 160, 140, 0.4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--ink-light);
}

/* Progress bar */
.progress-bar {
  flex: 1;
  height: 8px;
  background: var(--paper-dark);
  border-radius: 4px;
  margin-right: 12px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}

/* Small stamp badge */
.stamp-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  padding: 3px 10px;
  border: 1.5px solid var(--visited);
  color: var(--visited);
  border-radius: 3px;
  transform: rotate(-2deg);
  font-family: var(--font-hand);
}

.stamp-badge.pending {
  border-color: var(--unvisited);
  color: var(--unvisited);
}

/* --- Overview Map Section --- */
.overview-map-section {
  margin-top: 48px;
}

.overview-map-section h2 {
  font-size: 1.5rem;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.overview-map-section h2 .tape {
  font-family: var(--font-hand);
  font-size: 1rem;
  color: var(--stamp-red);
}

#overview-map {
  height: 420px;
  border-radius: var(--radius);
  border: 3px solid var(--paper-dark);
  box-shadow: var(--shadow-md);
  margin-top: 16px;
}

/* --- Route Detail Page --- */
.route-detail {
  display: none;
}

.route-detail.active {
  display: block;
}

.route-detail-header {
  text-align: center;
  padding: 32px 0 8px;
}

.route-detail-header h1 {
  font-size: 2rem;
  font-family: var(--font-hand);
}

.route-detail-header .subtitle {
  font-size: 1rem;
  color: var(--ink-light);
  margin-top: 4px;
}

.route-detail-header .divider {
  width: 60px;
  height: 3px;
  margin: 16px auto;
  border-radius: 2px;
}

/* Progress card */
.progress-card {
  background: var(--paper);
  border-radius: var(--radius);
  border: 1px solid rgba(180, 160, 140, 0.3);
  padding: 16px 20px;
  margin: 20px 0;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 16px;
}

.progress-card .label {
  font-size: 0.85rem;
  color: var(--ink-light);
  white-space: nowrap;
}

.progress-card .bar-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-card .bar {
  flex: 1;
  height: 10px;
  background: var(--paper-dark);
  border-radius: 5px;
  overflow: hidden;
}

.progress-card .bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.6s ease;
}

.progress-card .stat {
  font-family: var(--font-hand);
  font-size: 1.1rem;
  font-weight: 700;
  white-space: nowrap;
}

/* Route map */
.route-map-wrap {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
  margin: 24px 0;
}

#route-map {
  height: 520px;
  border-radius: var(--radius);
  border: 3px solid var(--paper-dark);
  box-shadow: var(--shadow-md);
}

/* City list sidebar */
.city-list {
  background: var(--paper);
  border-radius: var(--radius);
  border: 1px solid rgba(180, 160, 140, 0.3);
  box-shadow: var(--shadow-md);
  max-height: 520px;
  overflow-y: auto;
  position: relative;
}

/* Washi tape decoration on city list */
.city-list::before {
  content: '';
  display: block;
  height: 6px;
  width: 50%;
  margin: 8px auto 0;
  border-radius: 2px;
  opacity: 0.6;
  background: var(--tape-blue);
}

.city-list h3 {
  padding: 16px 20px 8px;
  font-size: 1rem;
  font-family: var(--font-hand);
  position: sticky;
  top: 0;
  background: var(--paper);
  z-index: 2;
}

.city-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid rgba(180, 160, 140, 0.15);
  transition: background 0.2s;
  cursor: pointer;
  font-size: 0.88rem;
}

.city-item:hover {
  background: var(--paper-dark);
}

.city-item:last-child {
  border-bottom: none;
}

.city-marker {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
  border: 2px solid;
}

.city-marker.visited {
  background: var(--visited);
  border-color: var(--visited);
  color: #fff;
}

.city-marker.unvisited {
  background: #fff;
  border-color: var(--unvisited);
  color: var(--unvisited);
}

.city-info {
  flex: 1;
  min-width: 0;
}

.city-info .name {
  font-weight: 600;
}

.city-info .province {
  font-size: 0.75rem;
  color: var(--ink-light);
}

.city-note {
  font-size: 0.72rem;
  color: var(--stamp-red);
  white-space: nowrap;
  font-family: var(--font-hand);
}

/* --- Photo Wall --- */
.photo-section {
  margin-top: 40px;
}

.photo-section h2 {
  font-size: 1.4rem;
  margin-bottom: 6px;
  font-family: var(--font-hand);
  display: flex;
  align-items: center;
  gap: 8px;
}

.photo-section h2 .icon {
  font-size: 1.6rem;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.photo-card {
  background: var(--paper);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(180, 160, 140, 0.3);
  transition: transform 0.2s;
}

.photo-card:hover {
  transform: rotate(1deg) scale(1.02);
  box-shadow: var(--shadow-md);
}

/* Simulate polaroid with different rotations */
.photo-card:nth-child(odd) { transform: rotate(-1deg); }
.photo-card:nth-child(even) { transform: rotate(1.5deg); }
.photo-card:nth-child(odd):hover { transform: rotate(0deg) scale(1.03); }
.photo-card:nth-child(even):hover { transform: rotate(0deg) scale(1.03); }

.photo-card .img-placeholder {
  width: 100%;
  height: 160px;
  background: var(--paper-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-light);
  font-size: 2rem;
}

.photo-card .caption {
  padding: 10px 14px;
  font-size: 0.8rem;
  color: var(--ink-light);
  text-align: center;
}

/* Empty state */
.empty-photos {
  text-align: center;
  padding: 48px 24px;
  background: var(--paper);
  border-radius: var(--radius);
  border: 2px dashed var(--kraft);
  color: var(--ink-light);
}

.empty-photos .icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.empty-photos p {
  font-size: 0.9rem;
}

/* --- Footer --- */
.site-footer {
  text-align: center;
  padding: 40px 24px;
  color: var(--ink-light);
  font-size: 0.82rem;
  border-top: 1px solid rgba(180, 160, 140, 0.3);
  margin-top: 48px;
}

.site-footer .heart {
  color: var(--stamp-red);
  font-size: 1rem;
}

/* --- Custom Leaflet Marker (pseudo, via JS) --- */
.custom-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 50%;
  border: 3px solid;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}


/* --- Photo Thumbnail Map Markers --- */
.photo-marker-wrapper {
  background: transparent !important;
  border: none !important;
}

.photo-marker {
  border-radius: 50%;
  overflow: hidden;
  border: 2.5px solid #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  background: #e8e4df;
}

.photo-marker img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-marker:hover {
  transform: scale(1.8);
  box-shadow: 0 6px 24px rgba(0,0,0,0.4);
  z-index: 999 !important;
}

.marker-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #fff;
  border-radius: 50%;
}
/* --- Utility --- */
.text-center { text-align: center; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

/* --- Back to top button --- */
.back-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  background: var(--paper);
  border: 2px solid var(--kraft);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: all 0.2s;
  z-index: 999;
  font-size: 1.2rem;
}

.back-top:hover {
  background: var(--paper-dark);
  transform: translateY(-2px);
}

/* --- Photo Lightbox --- */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 25, 18, 0.92);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(8px);
}

.lightbox-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.lightbox-overlay.closing {
  opacity: 0;
}

.lightbox-img-wrap {
  position: relative;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.lightbox-overlay.open .lightbox-img-wrap {
  transform: scale(1);
}

.lightbox-img-wrap img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
  border: 3px solid rgba(255,255,255,0.1);
}

.lightbox-caption {
  position: absolute;
  bottom: -40px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.85);
  font-size: 0.9rem;
  font-family: var(--font-hand);
  white-space: nowrap;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: absolute;
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  z-index: 1;
  font-size: 1.2rem;
}

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
  background: rgba(255,255,255,0.25);
}

.lightbox-close {
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  font-size: 1.5rem;
}

.lightbox-prev {
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
}

.lightbox-next {
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
}

.lightbox-counter {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.6);
  font-size: 0.82rem;
  letter-spacing: 2px;
}

/* --- Page Transition --- */
#home-page,
#route-detail {
  transition: opacity 0.35s ease, transform 0.35s ease;
}

#home-page.fade-out {
  opacity: 0;
  transform: translateY(-8px);
}

#route-detail.fade-in {
  opacity: 1;
  transform: translateY(0);
}

/* --- Skeleton Loading --- */
.skeleton {
  background: linear-gradient(90deg, var(--paper-dark) 25%, #e8dcc8 50%, var(--paper-dark) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* --- Stats Panel --- */
.stats-panel {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 32px 0 16px;
}

.stat-card {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 20px 28px;
  text-align: center;
  min-width: 120px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(180, 160, 140, 0.3);
  transition: transform 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card .num {
  font-family: var(--font-hand);
  font-size: 2rem;
  color: var(--stamp-red);
  line-height: 1.2;
}

.stat-card .label {
  font-size: 0.78rem;
  color: var(--ink-light);
  margin-top: 4px;
}

/* Progress ring */
.progress-ring-wrap {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}


/* --- Responsive --- */
@media (max-width: 900px) {
  .route-map-wrap {
    grid-template-columns: 1fr;
  }

  #route-map {
    height: 360px;
  }

  .city-list {
    max-height: 360px;
  }

  .route-cards {
    grid-template-columns: 1fr;
  }

  .hero h1 {
    font-size: 1.6rem;
  }

  .nav-bar {
    padding: 0 16px;
    height: 52px;
  }

  .nav-logo {
    font-size: 1.1rem;
  }

  .nav-links a {
    padding: 4px 8px;
    font-size: 0.78rem;
  }

  .stats-panel {
    gap: 12px;
  }

  .stat-card {
    padding: 14px 18px;
    min-width: 90px;
  }

  .stat-card .num {
    font-size: 1.5rem;
  }
}

@media (max-width: 480px) {
  .nav-bar {
    height: auto;
    min-height: 48px;
    padding: 8px 10px;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
  }

  .nav-logo {
    font-size: 1rem;
    white-space: nowrap;
  }

  .nav-links {
    gap: 2px;
    flex-wrap: wrap;
    justify-content: center;
  }

  .nav-links a {
    padding: 3px 6px;
    font-size: 0.72rem;
    white-space: nowrap;
  }

  .hero {
    padding: 32px 16px 20px;
  }

  .hero h1 {
    font-size: 1.3rem;
  }

  .hero .subtitle {
    font-size: 0.9rem;
  }

  .page-container {
    padding: 20px 12px 40px;
  }

  #overview-map {
    height: 300px;
  }

  #route-map {
    height: 280px;
  }

  .city-list {
    max-height: 280px;
  }

  .route-detail-header h1 {
    font-size: 1.4rem;
  }

  .photo-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
  }

  .photo-card .img-placeholder {
    height: 120px;
  }

  .stats-panel {
    gap: 8px;
  }

  .stat-card {
    padding: 12px 14px;
    min-width: 70px;
  }

  .stat-card .num {
    font-size: 1.3rem;
  }

  .stat-card .label {
    font-size: 0.7rem;
  }

  .progress-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .back-top {
    bottom: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }

  .site-footer {
    padding: 28px 16px;
  }
}
