/* hanh-trinh.css */

html, body {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden; /* Hide normal scrollbars */
  background-color: #0d130f; /* Deep dark green/brown for mangrove forest feel */
  font-family: 'Inter', sans-serif;
  color: var(--gold, #dcb974);
}

/* UI / HUD Overlays */
.btn-back-home {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  text-decoration: none;
  background: rgba(0, 0, 0, 0.5);
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid rgba(220, 185, 116, 0.3);
  backdrop-filter: blur(8px);
  transition: all 0.3s ease;
  font-size: 14px;
}
.btn-back-home:hover {
  background: rgba(220, 185, 116, 0.2);
  border-color: rgba(220, 185, 116, 0.8);
}

.hud-panel {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  background: rgba(10, 14, 10, 0.85);
  border: 1px solid rgba(220, 185, 116, 0.4);
  padding: 24px 32px;
  border-radius: 16px;
  text-align: center;
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

.hud-title {
  margin: 0 0 8px 0;
  font-size: 24px;
  font-weight: 600;
  color: #dcb974;
}

.hud-desc {
  margin: 0 0 20px 0;
  font-size: 14px;
  color: rgba(247, 242, 232, 0.7);
}

.hud-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.btn-start-route {
  background: #dcb974;
  color: #111;
  border: none;
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.btn-start-route:hover {
  background: #f0c980;
  transform: translateY(-2px);
}

/* Map & Camera */
.camera-viewport {
  position: absolute;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  /* Instead of native scroll, we will translate the inner map to simulate camera panning */
  overflow: hidden; 
}

.world-map {
  position: absolute;
  top: 0; left: 0;
  width: 3000px;
  height: 2000px;
  /* background image simulation */
  background-image: 
    radial-gradient(circle at center, rgba(220,185,116,0.03) 0%, transparent 70%),
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 100% 100%, 100px 100px, 100px 100px;
  transform-origin: 0 0;
  transition: transform 0.1s linear; /* Smooth camera follow */
  will-change: transform;
}

.map-routes-svg {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

.map-path {
  fill: none;
  stroke: rgba(220, 185, 116, 0.1);
  stroke-width: 4;
  stroke-dasharray: 12 12;
}

.map-path.active {
  stroke: rgba(220, 185, 116, 0.9);
  filter: drop-shadow(0 0 10px rgba(220, 185, 116, 0.6));
  animation: marchingAnts 1.5s linear infinite;
}

@keyframes marchingAnts {
  to { stroke-dashoffset: -24; }
}

/* Radar Pins */
.radar-pin {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  z-index: 20;
}

.radar-ring {
  position: absolute;
  width: 40px; height: 40px;
  border: 2px solid rgba(220, 185, 116, 0.8);
  border-radius: 50%;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  animation: radarPulse 2s infinite ease-out;
}

.radar-dot {
  width: 12px; height: 12px;
  background: #dcb974;
  border-radius: 50%;
  box-shadow: 0 0 15px rgba(220, 185, 116, 1);
  position: relative;
  z-index: 2;
}

.radar-label {
  margin-top: 15px;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid #dcb974;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: #dcb974;
  font-weight: 500;
  letter-spacing: 0.5px;
  white-space: nowrap;
  backdrop-filter: blur(4px);
  text-transform: uppercase;
}

@keyframes radarPulse {
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(2); opacity: 0; }
}

.radar-pin.pin-destination .radar-label {
  background: none;
  border: none;
  margin-top: -10px;
}
.radar-pin.pin-destination .dest-ring, .radar-pin.pin-destination .dest-dot {
  display: none;
}

/* Secondary Landmarks */
.radar-pin.pin-landmark {
  z-index: 10;
  opacity: 0.7;
}

.radar-pin.pin-landmark .radar-dot {
  width: 8px; height: 8px;
  background: rgba(247,242,232, 0.5);
  box-shadow: none;
}

.radar-pin.pin-landmark .radar-label {
  background: transparent;
  border: none;
  color: rgba(247,242,232, 0.5);
  font-size: 11px;
  margin-top: 5px;
  padding: 0;
  text-transform: none;
}

/* The Boat */
.the-boat {
  position: absolute;
  width: 80px;
  height: 40px;
  offset-distance: 0%;
  offset-rotate: auto;
  z-index: 50;
  transform-origin: center;
}

.boat-graphic {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 8px 15px rgba(0,0,0,0.9));
  /* Boat wobble animation */
  animation: wobble 2s infinite ease-in-out;
}

/* Story Bubble (Bong bóng kể chuyện) bám theo xuồng */
.story-bubble {
  position: absolute;
  /* Top và Left sẽ được JS cập nhật liên tục theo tọa độ xuồng */
  transform: translate(-50%, -100%) translateY(-60px);
  background: rgba(13, 19, 15, 0.95);
  border: 1px solid rgba(220, 185, 116, 0.8);
  padding: 16px 20px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7), 0 0 20px rgba(220, 185, 116, 0.2);
  backdrop-filter: blur(8px);
  z-index: 100;
  width: 320px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease-out; /* Không transition transform/top/left để bám mượt */
}

/* Đuôi nhọn của bong bóng (Speech Tail) */
.story-bubble::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 10px 10px 0 10px;
  border-style: solid;
  border-color: rgba(13, 19, 15, 0.95) transparent transparent transparent;
  /* Viền vàng giả bằng filter drop-shadow */
  filter: drop-shadow(0 2px 0 rgba(220, 185, 116, 0.8));
}

.story-bubble.show {
  opacity: 1;
}

.story-text {
  margin: 0;
  color: #f7f2e8;
  font-size: 15px;
  line-height: 1.6;
  font-style: italic;
  font-weight: 300;
  letter-spacing: 0.5px;
}

@keyframes wobble {
  0%, 100% { transform: rotate(-5deg); }
  50% { transform: rotate(5deg); }
}

/* Graphics Upgrades: Trees, Fog, Ripples */

/* Mangrove Trees */
.map-tree {
  position: absolute;
  font-size: 32px;
  transform-origin: bottom center;
  animation: sway 4s ease-in-out infinite alternate;
  pointer-events: none;
  filter: drop-shadow(0 5px 10px rgba(0,0,0,0.6));
  z-index: 10;
}

@keyframes sway {
  0% { transform: translate(-50%, -100%) rotate(-4deg); }
  100% { transform: translate(-50%, -100%) rotate(4deg); }
}

/* Ambient Fog */
.ambient-fog {
  position: absolute;
  top: 0; left: 0;
  width: 200%; height: 100%;
  pointer-events: none;
  background-image: radial-gradient(circle at center, rgba(255,255,255,0.02) 0%, transparent 60%);
  background-size: 400px 400px;
  opacity: 0.25;
  z-index: 5;
  animation: driftFog 60s linear infinite;
}

.ambient-fog.fog-2 {
  background-size: 600px 600px;
  opacity: 0.15;
  animation: driftFog 90s linear infinite reverse;
  top: 10%;
}

@keyframes driftFog {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* Water Ripple Wake */
.water-ripple {
  position: absolute;
  width: 20px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: rippleFade 1.5s ease-out forwards;
  z-index: 4;
}

@keyframes rippleFade {
  0% {
    width: 20px;
    height: 10px;
    opacity: 0.6;
    border: 1px solid rgba(255,255,255, 0.8);
  }
  100% {
    width: 60px;
    height: 30px;
    opacity: 0;
    border: 1px solid transparent;
  }
}

/* Arrival Card Popup */
.arrival-card {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -45%) scale(0.95);
  width: 90%;
  max-width: 440px;
  background: rgba(13, 19, 15, 0.98);
  border: 1px solid #dcb974;
  box-shadow: 0 15px 50px rgba(0, 0, 0, 0.8), 0 0 25px rgba(220, 185, 116, 0.2);
  border-radius: 16px;
  padding: 28px;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: all 0.5s cubic-bezier(0.165, 0.84, 0.44, 1);
  backdrop-filter: blur(12px);
}

.arrival-card.show {
  opacity: 1;
  pointer-events: all;
  transform: translate(-50%, -50%) scale(1);
}

.btn-close-card {
  position: absolute;
  top: 15px;
  right: 15px;
  background: none;
  border: none;
  color: rgba(247, 242, 232, 0.6);
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s;
}

.btn-close-card:hover {
  color: #dcb974;
}

.card-header {
  text-align: center;
  margin-bottom: 20px;
}

.card-logo {
  height: 36px;
  width: auto;
  margin-bottom: 10px;
}

.card-title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: #dcb974;
  letter-spacing: 0.5px;
}

.card-body {
  margin-bottom: 24px;
  background: rgba(255, 255, 255, 0.02);
  padding: 16px;
  border-radius: 8px;
  border: 1px solid rgba(220, 185, 116, 0.1);
}

.card-info {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.6;
  color: rgba(247, 242, 232, 0.85);
}
.card-info:first-child {
  margin-bottom: 8px;
}

.card-info strong {
  color: #dcb974;
}

.card-footer {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn-card-primary, .btn-card-secondary {
  display: block;
  text-align: center;
  padding: 14px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.3s ease;
}

.btn-card-primary {
  background: #dcb974;
  color: #111;
  box-shadow: 0 4px 15px rgba(220, 185, 116, 0.2);
}

.btn-card-primary:hover {
  background: #f0c980;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(220, 185, 116, 0.3);
}

.btn-card-secondary {
  background: transparent;
  color: #dcb974;
  border: 1px solid rgba(220, 185, 116, 0.4);
}

.btn-card-secondary:hover {
  background: rgba(220, 185, 116, 0.1);
  border-color: #dcb974;
  transform: translateY(-2px);
}

/* Audio Toggle Button CSS */
.btn-audio-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 100;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(220, 185, 116, 0.3);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  letter-spacing: .05em;
  backdrop-filter: blur(8px);
  transition: all 0.3s ease;
}

.btn-audio-toggle:hover {
  background: rgba(220, 185, 116, 0.2);
  border-color: rgba(220, 185, 116, 0.8);
}

.audio-wave {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  width: 16px;
  height: 12px;
}

.audio-wave .bar {
  width: 2px;
  background: #dcb974;
  height: 3px;
  transition: height 0.3s ease;
}

.btn-audio-toggle.playing .bar {
  animation: bounce 0.8s ease-in-out infinite alternate;
}

.btn-audio-toggle.playing .bar-1 { animation-delay: 0.1s; height: 100%; }
.btn-audio-toggle.playing .bar-2 { animation-delay: 0.4s; height: 70%; }
.btn-audio-toggle.playing .bar-3 { animation-delay: 0.2s; height: 90%; }
.btn-audio-toggle.playing .bar-4 { animation-delay: 0.5s; height: 60%; }

@keyframes bounce {
  0% { height: 20%; }
  100% { height: 100%; }
}

.audio-toggle-label {
  opacity: 0.8;
  transition: opacity 0.3s;
}

.btn-audio-toggle:hover .audio-toggle-label {
  opacity: 1;
}

/* Radar Scanline overlay */
.map-scanline {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    to bottom,
    rgba(220, 185, 116, 0) 0%,
    rgba(220, 185, 116, 0.015) 10%,
    rgba(220, 185, 116, 0.03) 50%,
    rgba(220, 185, 116, 0.015) 90%,
    rgba(220, 185, 116, 0) 100%
  );
  pointer-events: none;
  z-index: 5;
  animation: scanline-sweep 15s linear infinite;
}

/* Vignette Shadow Overlay */
.map-vignette {
  position: absolute; /* Thay đổi từ fixed sang absolute để ăn khớp với viewport */
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(0, 0, 0, 0) 50%, rgba(13, 19, 15, 0.8) 100%);
  pointer-events: none;
  z-index: 6;
}

@keyframes scanline-sweep {
  0% {
    transform: translateY(-100%);
  }
  100% {
    transform: translateY(100%);
  }
}

/* ── MOBILE OPTIMIZATIONS (Dưới 768px) ── */
@media (max-width: 768px) {
  /* Tắt các hiệu ứng đồ họa cực nặng gây tốn pin & giật lag */
  .ambient-fog {
    display: none !important;
  }
  .map-scanline {
    display: none !important;
  }
  
  /* Điều chỉnh bảng điều khiển HUD vừa vặn màn hình */
  .hud-panel {
    width: 90%;
    padding: 16px 20px;
    bottom: 15px;
    border-radius: 12px;
  }
  
  .hud-title {
    font-size: 18px;
  }
  
  .hud-desc {
    display: none; /* Ẩn mô tả dài để tiết kiệm diện tích */
  }
  
  .hud-actions {
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }
  
  .btn-start-route {
    width: 100%;
    font-size: 12px;
    padding: 10px 14px;
  }
  
  /* Tối ưu kích thước bong bóng kể chuyện */
  .story-bubble {
    width: 270px;
    padding: 12px 16px;
    transform: translate(-50%, -100%) translateY(-50px);
  }
  
  .story-text {
    font-size: 13px;
    line-height: 1.5;
  }
  
  /* Thu nhỏ các nút chức năng góc trên */
  .btn-back-home,
  .btn-audio-toggle {
    top: 12px;
    padding: 8px 12px;
    font-size: 11px;
    border-radius: 6px;
  }
  
  .btn-back-home {
    left: 12px;
  }
  
  .btn-audio-toggle {
    right: 12px;
  }

  /* Thu nhỏ tấm bảng đích đến lúc cập bến */
  .arrival-card {
    width: 90%;
    padding: 20px;
    bottom: 20px;
  }
}
