/* =========================================================
   TOP TRAVEL MAP V2
   Regional map states + butterfly growth + long timeline
   ========================================================= */

.map {
  transition:
    opacity 320ms ease,
    filter 320ms ease;
}

.map.map-switching {
  opacity: 0.68;
  filter: blur(1.2px);
}

/*
  During a projection change, keep the butterfly visible while
  softening the route layer. This hides the unavoidable geometry
  re-layout between the world map and China map.
*/
.route-overlay {
  transition: opacity 300ms ease;
}

body.map-bridge .route-overlay {
  opacity: 0.76;
}

body.map-transition .route-overlay {
  opacity: 0.10;
}

body.map-transition .butterfly,
body.map-bridge .butterfly {
  filter:
    drop-shadow(0 0 7px rgba(214, 177, 255, 0.98))
    drop-shadow(0 0 19px rgba(146, 87, 255, 0.64));
}

/*
  The completed international path remains visible while the camera
  approaches Beijing, then dissolves gently during the projection swap.
  This avoids the impression that the Kuala Lumpur route simply vanished.
*/
body.map-bridge .route-active {
  transition: opacity 520ms ease;
}

body.map-transition .route-active,
body.map-transition .route-base {
  transition: opacity 320ms ease;
}

.map-mode-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin-top: 18px;
  padding: 0 11px;
  border: 1px solid rgba(173, 121, 255, 0.22);
  border-radius: 999px;
  background: rgba(7, 12, 28, 0.52);
  color: rgba(205, 181, 255, 0.58);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.18em;
  backdrop-filter: blur(10px);
}

/* ---------------------------------------------------------
   Butterfly growth
   0 = juvenile, 1 = current mature butterfly
   --------------------------------------------------------- */

.butterfly {
  --butterfly-scale: 0.72;
  --butterfly-width: 0.91;
  --butterfly-opacity: 0.76;
  --butterfly-saturation: 0.72;
  --butterfly-brightness: 0.92;
  --butterfly-flap-speed: 0.58s;
  --metamorph-glow: 0;
}

.butterfly-art {
  transform:
    scale(var(--butterfly-scale))
    scaleX(var(--butterfly-width));
  transform-origin: center center;
  opacity: var(--butterfly-opacity);
  filter:
    saturate(var(--butterfly-saturation))
    brightness(var(--butterfly-brightness));
}

.butterfly-left,
.butterfly-right {
  animation-duration: var(--butterfly-flap-speed);
}

.butterfly[data-stage="juvenile"] {
  filter:
    drop-shadow(0 0 4px rgba(183, 146, 240, 0.50))
    drop-shadow(0 0 9px rgba(126, 84, 205, 0.28));
}

.butterfly[data-stage="mature"] {
  filter:
    drop-shadow(0 0 5px rgba(195, 145, 255, 0.95))
    drop-shadow(0 0 13px rgba(145, 82, 255, 0.55));
}

.butterfly[data-stage="metamorphosis"] {
  filter:
    drop-shadow(0 0 7px rgba(222, 187, 255, 0.98))
    drop-shadow(0 0 20px rgba(166, 100, 255, 0.76));
}

.butterfly::before,
.butterfly::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  pointer-events: none;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.butterfly::before {
  width: 112px;
  height: 112px;
  z-index: -1;
  opacity: var(--metamorph-glow);
  background:
    radial-gradient(
      circle,
      rgba(226, 195, 255, 0.24) 0 18%,
      rgba(171, 111, 255, 0.15) 35%,
      transparent 70%
    );
  filter: blur(5px);
}

.butterfly.same-city-pulse::after {
  width: 64px;
  height: 64px;
  z-index: -1;
  border: 1.5px solid rgba(211, 174, 255, 0.82);
  animation: sameCityButterflyPulse 1.05s ease-out both;
}

@keyframes sameCityButterflyPulse {
  0% {
    opacity: 0.95;
    transform: translate(-50%, -50%) scale(0.5);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(2.2);
  }
}

/* ---------------------------------------------------------
   Longer route timeline
   --------------------------------------------------------- */

.route-timeline {
  width: min(860px, 70vw);
}

.route-timeline-scroll {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 5px;
  scrollbar-width: none;
  mask-image: linear-gradient(
    90deg,
    transparent 0,
    black 18px,
    black calc(100% - 18px),
    transparent 100%
  );
}

.route-timeline-scroll::-webkit-scrollbar {
  display: none;
}

.route-timeline-track {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--stop-count), minmax(82px, 1fr));
  gap: 0;
}

.route-timeline-line {
  top: 6px;
}

.timeline-stop {
  min-width: 82px;
  padding-right: 12px;
}

.timeline-stop strong {
  white-space: nowrap;
}

.timeline-stop small {
  max-width: 84px;
  line-height: 1.35;
}

.timeline-stop.active strong {
  color: #ffffff;
}

.timeline-stop.active small {
  color: rgba(218, 191, 255, 0.72);
}

@media (max-width: 760px) {
  .map-mode-badge {
    margin-top: 12px;
    font-size: 7px;
    letter-spacing: 0.12em;
  }

  .route-timeline {
    width: auto;
  }

  .route-timeline-track {
    grid-template-columns: repeat(var(--stop-count), 78px);
  }

  .timeline-stop {
    min-width: 78px;
    padding-right: 8px;
  }

  .timeline-stop strong {
    font-size: 9px;
  }

  .timeline-stop small {
    font-size: 6px;
  }

  .butterfly::before {
    width: 78px;
    height: 78px;
  }
}


/* =========================================================
   JOURNEY ARCHIVE / ALL STOPS
   ========================================================= */

.map-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  pointer-events: auto;
}

.map-tools .map-mode-badge {
  margin-top: 0;
}

.journey-archive-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  padding: 0 12px;
  border: 1px solid rgba(173, 121, 255, 0.32);
  border-radius: 999px;
  background: rgba(11, 16, 35, 0.72);
  color: rgba(246, 239, 255, 0.86);
  cursor: pointer;
  backdrop-filter: blur(12px);
  transition:
    border-color 180ms ease,
    background 180ms ease,
    transform 180ms ease;
}

.journey-archive-button:hover {
  border-color: rgba(188, 139, 255, 0.68);
  background: rgba(36, 24, 67, 0.82);
  transform: translateY(-1px);
}

.journey-archive-button span {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.journey-archive-button small {
  color: rgba(204, 181, 241, 0.45);
  font-size: 7px;
  letter-spacing: 0.14em;
}

.journey-archive-backdrop {
  position: fixed;
  inset: 0;
  z-index: 48;
  pointer-events: none;
  opacity: 0;
  background: rgba(1, 4, 12, 0.56);
  backdrop-filter: blur(4px);
  transition: opacity 260ms ease;
}

.journey-archive-backdrop.open {
  pointer-events: auto;
  opacity: 1;
}

.journey-archive {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 49;
  width: min(560px, 92vw);
  height: 100dvh;
  padding:
    max(108px, calc(env(safe-area-inset-top) + 88px))
    30px
    30px;
  overflow-y: auto;
  transform: translateX(104%);
  border-left: 1px solid rgba(166, 130, 255, 0.19);
  background:
    radial-gradient(circle at 75% 10%, rgba(129, 78, 220, 0.13), transparent 26%),
    linear-gradient(180deg, rgba(5, 9, 22, 0.985), rgba(3, 7, 17, 0.995));
  box-shadow: -30px 0 100px rgba(0, 0, 0, 0.46);
  transition: transform 320ms cubic-bezier(.22, .82, .24, 1);
}

.journey-archive.open {
  transform: translateX(0);
}

.journey-archive-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
  padding-bottom: 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.journey-archive-eyebrow {
  color: #ae7cff;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.28em;
}

.journey-archive-header h2 {
  margin: 9px 0 7px;
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 34px;
  font-weight: 500;
}

.journey-archive-header p {
  max-width: 390px;
  margin: 0;
  color: rgba(238, 232, 249, 0.52);
  font-size: 12px;
  line-height: 1.7;
}

.journey-archive-close {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(180, 139, 244, 0.22);
  border-radius: 50%;
  background: rgba(13, 18, 38, 0.78);
  color: rgba(255, 255, 255, 0.76);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.journey-archive-years {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 22px 0;
}

.journey-year-chip {
  height: 31px;
  padding: 0 13px;
  border: 1px solid rgba(170, 130, 237, 0.18);
  border-radius: 999px;
  background: rgba(14, 19, 39, 0.74);
  color: rgba(236, 229, 247, 0.52);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

.journey-year-chip.active {
  border-color: rgba(180, 126, 255, 0.58);
  background: rgba(116, 69, 194, 0.28);
  color: #f5edff;
  box-shadow: 0 0 18px rgba(142, 84, 230, 0.13);
}

.journey-archive-list {
  display: grid;
  gap: 14px;
}

.journey-archive-card {
  display: grid;
  grid-template-columns: 154px 1fr;
  min-height: 172px;
  overflow: hidden;
  border: 1px solid rgba(164, 130, 224, 0.15);
  border-radius: 17px;
  background:
    linear-gradient(145deg, rgba(14, 20, 42, 0.82), rgba(7, 11, 25, 0.92));
}

.journey-card-photo {
  min-height: 172px;
  overflow: hidden;
  background:
    radial-gradient(circle, rgba(133, 88, 209, 0.24), transparent 52%),
    #080d1c;
}

.journey-card-photo img {
  width: 100%;
  height: 100%;
  min-height: 172px;
  display: block;
  object-fit: cover;
}

.journey-card-photo-empty {
  display: grid;
  place-items: center;
  color: rgba(184, 147, 238, 0.27);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.28em;
}

.journey-card-content {
  padding: 17px 18px 16px;
}

.journey-card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.journey-card-number {
  color: #a873ff;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.journey-card-year {
  color: rgba(210, 185, 245, 0.43);
  font-size: 9px;
  letter-spacing: 0.12em;
}

.journey-card-city {
  display: flex;
  align-items: baseline;
  gap: 9px;
  margin-top: 8px;
}

.journey-card-city strong {
  color: rgba(255, 255, 255, 0.93);
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 22px;
  font-weight: 500;
}

.journey-card-city small {
  color: rgba(225, 214, 244, 0.34);
  font-size: 8px;
  letter-spacing: 0.14em;
}

.journey-card-content h3 {
  margin: 8px 0 0;
  color: rgba(245, 240, 252, 0.72);
  font-size: 12px;
  line-height: 1.55;
}

.journey-card-meta {
  margin-top: 7px;
  color: rgba(195, 170, 229, 0.47);
  font-size: 9px;
}

.journey-card-content p {
  display: -webkit-box;
  margin: 8px 0 12px;
  overflow: hidden;
  color: rgba(231, 225, 241, 0.48);
  font-size: 10px;
  line-height: 1.65;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.journey-card-content a {
  display: inline-flex;
  gap: 7px;
  color: #bb8cff;
  font-size: 10px;
  font-weight: 700;
  text-decoration: none;
}

.journey-archive-loading,
.journey-archive-empty {
  padding: 42px 18px;
  border: 1px dashed rgba(172, 132, 235, 0.15);
  border-radius: 16px;
  color: rgba(223, 210, 241, 0.42);
  font-size: 11px;
  text-align: center;
}

body.journey-archive-open {
  overflow: hidden;
}

@media (max-width: 760px) {
  .map-tools {
    align-items: flex-start;
    flex-direction: column;
    gap: 7px;
    margin-top: 12px;
  }

  .map-tools .map-mode-badge {
    margin-top: 0;
  }

  .journey-archive-button {
    min-height: 27px;
    padding: 0 10px;
  }

  .journey-archive {
    width: 100%;
    padding:
      max(92px, calc(env(safe-area-inset-top) + 76px))
      16px
      24px;
    border-left: 0;
  }

  .journey-archive-header h2 {
    font-size: 28px;
  }

  .journey-archive-card {
    grid-template-columns: 108px 1fr;
    min-height: 148px;
  }

  .journey-card-photo,
  .journey-card-photo img {
    min-height: 148px;
  }

  .journey-card-content {
    padding: 14px;
  }

  .journey-card-city {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .journey-card-city strong {
    font-size: 19px;
  }

  .journey-card-content h3 {
    font-size: 11px;
  }
}
