*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent:     #E85D3F;
  --accent-bg:  #FFF2EF;
  --text:       #1C1C1E;
  --muted:      #8E8E93;
  --bg:         #F9F9F7;
  --white:      #FFFFFF;
  --border:     #EBEBEB;
  --shadow-sm:  0 2px 8px rgba(0,0,0,0.07);
  --shadow-md:  0 8px 32px rgba(0,0,0,0.13);
  --r:          12px;
  --hh:         58px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ─── Shared header ──────────────────────────────────── */
.header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  height: var(--hh);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  background: rgba(249,249,247,0.88);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.logo { font-family: 'Pacifico', cursive; font-size: 18px; font-weight: 400; color: var(--accent); display: flex; align-items: center; gap: 8px; }
.logo-icon { width: 32px; height: 32px; flex-shrink: 0; border-radius: 6px; }
.route-count { font-size: 13px; color: var(--muted); }

/* ─── Overview map ───────────────────────────────────── */
#map {
  width: 100vw; height: 44vh; min-height: 260px;
  background: #e8e0d0;
  margin-top: var(--hh);
  cursor: default;
}

/* ─── Dot markers ────────────────────────────────────── */
.dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2.5px solid white;
  box-shadow: 0 2px 8px rgba(232,93,63,0.45);
  cursor: pointer;
  position: relative;
  transition: transform 0.15s ease;
}
.dot:hover { transform: scale(1.25); }
.dot::before {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 100%; height: 100%;
  border-radius: 50%;
  background: rgba(232,93,63,0.3);
  animation: ripple 2.4s ease-out infinite;
  transform: translate(-50%, -50%) scale(1);
}
@keyframes ripple {
  0%   { transform: translate(-50%,-50%) scale(1);   opacity: 0.8; }
  100% { transform: translate(-50%,-50%) scale(3.8); opacity: 0;   }
}

/* ─── Hover card ─────────────────────────────────────── */
.hover-card {
  position: fixed; z-index: 2000;
  width: 238px;
  background: var(--white);
  border-radius: var(--r);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  overflow: hidden;
  cursor: pointer;
  pointer-events: auto;
  transition: opacity 0.14s ease, transform 0.14s ease;
}
.hover-card.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(5px);
}
.country-card.hidden { display: none; }
.hover-card img {
  width: 100%; height: 136px;
  object-fit: cover; object-position: center; display: block;
}
.hover-card-body { padding: 11px 13px 14px; }
.card-name {
  font-size: 14px; font-weight: 600;
  margin-bottom: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-location { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.card-meta { display: flex; align-items: center; gap: 7px; }
.card-distance { font-size: 12px; color: var(--muted); }
.badge {
  padding: 2px 8px; border-radius: 100px;
  font-size: 11px; font-weight: 500;
  background: var(--accent-bg); color: var(--accent);
}
.badge[data-difficulty="Easy"]       { background: #EDFAF3; color: #1A7F4B; }
.badge[data-difficulty="Moderate"]   { background: #EBF2FF; color: #2B5FC4; }
.badge[data-difficulty="Challenging"]{ background: var(--accent-bg); color: var(--accent); }

/* ─── Route page header ──────────────────────────────── */
.route-header {
  position: sticky; top: 0; z-index: 100;
  height: var(--hh);
  display: flex; align-items: center; gap: 14px;
  padding: 0 28px;
  background: rgba(249,249,247,0.92);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  border-bottom: 1px solid var(--border);
}
.back-btn {
  display: flex; align-items: center; gap: 5px;
  font-size: 14px; color: var(--accent);
  text-decoration: none; font-weight: 500;
  white-space: nowrap; flex-shrink: 0;
}
.back-btn svg { flex-shrink: 0; }
.back-btn:hover { opacity: 0.7; }
.header-route-name {
  font-size: 15px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ─── Route map ──────────────────────────────────────── */
#route-map { width: 100%; height: 44vh; min-height: 280px; }

.map-pin {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2.5px solid white;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: white;
  font-family: system-ui, sans-serif;
}
.map-pin--start  { background: #1A7F4B; }
.map-pin--finish { background: #E85D3F; }

/* ─── Route points (Start / Finish links) ────────────── */
.route-title-row {
  display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap;
}
.route-title-row h1 { margin: 0; }
.route-points {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; white-space: nowrap;
}
.route-point-link {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.route-point-link:hover { color: var(--accent); }
.route-point-sep { color: var(--muted); }

/* ─── Route content ──────────────────────────────────── */
.route-content { max-width: 700px; margin: 0 auto; padding: 0 24px 80px; }

.route-meta { padding: 28px 0 24px; }
.route-meta h1 {
  font-size: 26px; font-weight: 700; letter-spacing: -0.5px; margin-bottom: 6px;
}
.route-meta-sub {
  display: flex; align-items: center; gap: 12px;
  font-size: 13px; color: var(--muted);
}
.route-meta-sub span::before { content: '·'; margin-right: 12px; }
.route-meta-sub span:first-child::before { content: ''; margin-right: 0; }

/* Stats */
.stats-bar {
  display: flex; overflow-x: auto;
  border: 1px solid var(--border); border-radius: var(--r);
  margin-bottom: 32px;
}
.stats-bar::-webkit-scrollbar { height: 0; }
.stat {
  flex: 1; min-width: 90px;
  padding: 18px 16px; text-align: center;
  border-right: 1px solid var(--border);
}
.stat:last-child { border-right: none; }
.stat-label {
  display: block; font-size: 10px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 7px;
}
.stat-value { font-size: 15px; font-weight: 650; }
.stat-value[data-difficulty="Easy"]       { color: #1A7F4B; }
.stat-value[data-difficulty="Moderate"]   { color: #2B5FC4; }
.stat-value[data-difficulty="Challenging"]{ color: var(--accent); }

/* Description */
.description {
  font-size: 16px; line-height: 1.78; color: #3A3A3C; margin-bottom: 14px;
}
.desc-zh {
  display: block; margin-top: 10px;
  font-size: 15px; color: #4A4A4E; line-height: 1.75;
}
.vibe-tag {
  font-size: 14px; line-height: 1.65;
  background: var(--accent-bg);
  padding: 12px 16px; border-radius: 9px;
  margin-bottom: 36px; color: #3A3A3C;
}
.vibe-label { font-weight: 600; color: var(--accent); margin-right: 8px; }
.vibe-zh {
  display: block; margin-top: 8px;
  font-size: 13px; color: #4A4A4E; line-height: 1.7;
}
.note-zh {
  display: block; margin-top: 3px;
  font-size: 13px; color: #4A4A4E; line-height: 1.6;
}

/* ─── Nearby places ───────────────────────────────────── */
.nearby-section { margin-bottom: 40px; }
.nearby-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none; color: inherit;
  transition: opacity 0.15s;
}
.nearby-item:first-child { border-top: 1px solid var(--border); }
.nearby-item:hover { opacity: 0.65; }
.nearby-info { flex: 1; padding-right: 16px; }
.nearby-name { font-size: 15px; font-weight: 600; margin-bottom: 3px; }
.nearby-note { font-size: 13px; color: #3A3A3C; line-height: 1.55; }
.nearby-note-zh { font-size: 12px; color: #4A4A4E; line-height: 1.55; margin-top: 2px; }
.nearby-arrow { color: var(--accent); flex-shrink: 0; }

/* Section title */
.section-title {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.9px;
  color: #3B70D6; margin-bottom: 18px;
}

/* Highlights */
.highlights-list { margin-bottom: 40px; }
.highlight-item { display: flex; gap: 14px; margin-bottom: 22px; }
.highlight-num {
  min-width: 28px; height: 28px;
  background: var(--accent); color: white;
  border-radius: 50%; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin-top: 1px; flex-shrink: 0;
}
.highlight-name { font-size: 15px; font-weight: 600; margin-bottom: 5px; }
.highlight-note { font-size: 14px; color: #3A3A3C; line-height: 1.65; }

/* Photos */
.photos-section { margin-bottom: 40px; }
.photos-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px;
}
.route-photo { width: 100%; aspect-ratio: 4/3; object-fit: cover; object-position: center; border-radius: 9px; }

/* 1 photo: full width */
.photos-grid .route-photo:first-child:last-child { grid-column: 1 / -1; aspect-ratio: 16/9; }

/* 3 photos: single row of 3 */
.photos-grid:has(.route-photo:nth-child(3):last-child) { grid-template-columns: 1fr 1fr 1fr; }

/* 5 photos: last photo spans full width */
.photos-grid:has(.route-photo:nth-child(5):last-child) .route-photo:last-child { grid-column: 1 / -1; aspect-ratio: 16/9; }

/* ─── Country multi-route card ───────────────────────── */
.country-card {
  position: absolute; z-index: 850;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.13);
  padding: 6px;
  min-width: 210px;
  pointer-events: auto;
}
.country-route-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s;
}
.country-route-item:hover { background: #F5F5F7; }
.country-route-thumb {
  width: 54px; height: 40px;
  border-radius: 6px;
  object-fit: cover; object-position: center; flex-shrink: 0;
}
.country-route-name {
  font-size: 13px; font-weight: 500;
  color: #3A3A3C; line-height: 1.3;
}

/* ─── Speed legend ────────────────────────────────────── */
.speed-legend {
  display: flex; align-items: center; gap: 8px;
  margin: 14px 0 4px;
}
.speed-legend-bar {
  flex: 1; height: 5px; border-radius: 3px;
  background: linear-gradient(to right,
    hsl(0,88%,42%), hsl(30,88%,42%), hsl(60,88%,42%), hsl(90,88%,42%), hsl(120,88%,42%)
  );
}
.speed-legend-label {
  font-size: 11px; font-weight: 500;
  color: var(--muted); letter-spacing: 0.3px;
}

/* ─── Lightbox ────────────────────────────────────────── */
.lightbox {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(0,0,0,0.88);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
}
.lightbox.open { opacity: 1; pointer-events: auto; }
.lightbox img {
  max-width: 92vw; max-height: 88vh;
  border-radius: 10px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
  transform: scale(0.96);
  transition: transform 0.2s ease;
  cursor: zoom-out;
}
.lightbox.open img { transform: scale(1); }
.lightbox-close {
  position: absolute; top: 20px; right: 24px;
  color: rgba(255,255,255,0.75); font-size: 28px; line-height: 1;
  cursor: pointer; background: none; border: none;
  transition: color 0.15s;
}
.lightbox-close:hover { color: #fff; }
.lightbox-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,0.12); border: none; border-radius: 50%;
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.75); cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.lightbox-nav:hover { background: rgba(255,255,255,0.25); color: #fff; }
.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }
.route-photo { cursor: zoom-in; }

/* Leaflet tweaks */
.leaflet-attribution-flag { display: none !important; }
.leaflet-control-attribution { font-size: 10px; }

/* ─── Continent labels ────────────────────────────────── */
.continent-label {
  display: inline-block;
  transform: translateX(-50%);
  font-size: 10px; font-weight: 600;
  letter-spacing: 1.6px;
  color: #A0A0A8;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(255,255,255,0.9);
  font-family: var(--font);
}

/* ─── Carousel section ───────────────────────────────── */
.carousel-section {
  padding: 20px 24px 60px;
}

.carousel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.carousel-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
}

.carousel-arrows {
  display: flex;
  gap: 8px;
}

.arrow-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--white);
  color: var(--text);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.18s ease, border-color 0.18s ease,
              color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
  user-select: none;
  line-height: 1;
}
.arrow-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--white);
  box-shadow: 0 4px 16px rgba(232,93,63,0.35);
  transform: scale(1.08);
}
.arrow-btn:disabled {
  opacity: 0.25;
  pointer-events: none;
  box-shadow: none;
  transform: none;
}

.carousel-wrap {
  overflow: hidden;
}

.carousel-track {
  width: 100%;
  display: flex;
  gap: 16px;
  transition: transform 0.38s cubic-bezier(0.4, 0, 0.2, 1);
  padding-bottom: 4px; /* prevent card shadow clipping */
}

.carousel-track .route-card {
  flex: 0 0 calc((100% - 64px) / 5); /* 5 visible, 4 gaps of 16px */
  min-width: 0;
}

.progress-dots {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 14px;
}

.progress-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.2s ease, width 0.2s ease, border-radius 0.2s ease;
}
.progress-dot.active {
  background: var(--accent);
  width: 18px;
  border-radius: 3px;
}

.route-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--white);
  border-radius: var(--r);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow 0.18s ease, transform 0.18s ease;
}
.route-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.route-card-img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  object-position: center;
  display: block;
}
.route-card-body {
  padding: 14px 16px 16px;
}
.route-card-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}
.route-card-location {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
}
.route-card-stats {
  display: flex;
  align-items: center;
  gap: 8px;
}
.route-card-distance {
  font-size: 13px;
  color: var(--muted);
}

/* ─── Mobile ──────────────────────────────────────────── */
@media (max-width: 600px) {
  .header, .route-header { padding: 0 16px; }
  #map { height: 36vh; }
  .carousel-section { padding: 20px 16px 60px; }
  .carousel-track .route-card { flex: 0 0 100%; }
  .route-content { padding: 0 16px 60px; }
  .route-meta h1 { font-size: 22px; }
  .photos-grid { grid-template-columns: 1fr; }
  .photos-grid .route-photo:first-child:last-child { aspect-ratio: 4/3; }
}
