/* ===================== GLOBAL ===================== */
/* ====== Universal Layout & Overflow Fix ====== */
/* ====== Universal Layout & Overflow Fix (Final Responsive Version) ====== */
html {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

*, *::before, *::after {
  box-sizing: inherit;
}

body {
  margin: 0 auto;
  padding: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: #f0f2f5;
  color: #222;
  -webkit-text-size-adjust: 100%; /* Prevent iOS zoom font bug */
}

/* Prevent any child from exceeding viewport width */
body > * {
  max-width: 100%;
  overflow-x: clip; /* ✅ avoids side scroll while allowing map/compass to render */
}

/* Restore correct behavior for Google Maps & Compass */
#map,
#compass,
#compass-controls,
#arrow-container,
#arrow {
  overflow: visible !important; /* ✅ allows map tiles and compass rotation */
}

/* Ensure banner fits within viewport and centers properly */
#banner {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 160px;
  object-fit: cover;
  border-bottom: 3px solid #0057b8;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  margin: 0 auto;
}

/* Mobile-safe adjustments */
@media (max-width: 480px) {
  html, body {
    overflow-x: hidden;
  }
  #banner {
    height: 120px;
    max-width: 100%;
  }
  #map {
    height: 300px;
  }
}

/* Reset default margins for headings and paragraphs */
h1, h2, h3, p {
  margin: 0;
}

/* Normalize buttons */
button {
  -webkit-appearance: none;
  appearance: none;
  border-radius: 5px;
  font-family: inherit;
}

/* ===================== HEADER & BANNER ===================== */
/* ===================== HEADER & BANNER (Fixed Width Alignment) ===================== */
#top-wrap,
#trailList,
#nearest,
#controls,
#compass-controls {
  width: 100%;
  max-width: 800px;
  margin: 20px auto;
  text-align: center;
}

/* Banner image — perfectly aligned to map width */
#banner {
  display: block;
  width: 100%;
  max-width: 800px;          /* ✅ match map & content width */
  height: auto;
  max-height: 160px;
  object-fit: cover;
  margin: 0 auto;
  border-bottom: 3px solid #0057b8;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  border-radius: 0 0 6px 6px;
}

/* Title bar directly under banner */
#title-bar {
  width: 100%;
  max-width: 800px;
  margin: 0 auto 10px auto;
  background: #003366;
  color: #fff;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  text-align: center;
  padding: 12px 10px;
  border-bottom: 2px solid #0057b8;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  border-radius: 0 0 6px 6px;
}

/* ===================== MAP (Aligned & Responsive – Final Fixed Version) ===================== */

/* Wrapper to keep the map perfectly aligned with banner/title width */
#map-wrap {
  width: 100%;
  max-width: 800px;              /* ✅ match banner/title/trail width */
  margin: 0 auto 10px auto;      /* center on page */
  box-sizing: border-box;
  overflow: hidden;              /* prevent map tile overflow */
  transition: none !important;   /* stop “slide” after layout settles */
}

/* Actual map fills its wrapper */
#map {
  display: block;
  width: 100%;
  height: 380px;
  border: 2px solid #ddd;
  border-radius: 6px;
  background: #e9eef5;           /* fallback before tiles load */
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  overflow: hidden;
  transition: none !important;
}

/* Responsive adjustments for mobile */
@media (max-width: 480px) {
  #map-wrap {
    max-width: 95%;              /* small edge padding on mobile */
  }
  #map {
    height: 300px;               /* lower height for small screens */
  }
  #banner {
    max-height: 120px;
  }
  #title-bar {
    font-size: 1.1rem;
    padding: 10px;
  }
}

/* ===================== COMPASS & CONTROLS ===================== */
/* ===================== COMPASS & CONTROLS (SIDE-BY-SIDE) ===================== */
#compass-controls {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 40px;
  flex-wrap: wrap; /* stack on small screens */
  max-width: 800px;
  margin: 20px auto;
  padding: 10px 0;
  text-align: center;
}

/* --- Left: Compass --- */
#compass-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 180px;
}

/* Arrow container */
#arrow-container {
  position: relative;
  width: 84px;
  height: 84px;
  margin-bottom: 6px;
}

/* Base arrow */
#arrow {
  width: 100%;
  height: 100%;
  transition: transform 0.25s linear;
  transform-origin: 50% 50%;
  opacity: 0.5;
  filter: grayscale(100%);
}

/* Red X overlay */
#cross-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: red;
  font-size: 64px;
  font-weight: bold;
  opacity: 0.85;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

/* When compass active */
#arrow.active {
  opacity: 1;
  filter: none;
}
#arrow.active + #cross-overlay {
  opacity: 0;
}

/* Button under compass */
#startCompassBtn {
  background: #0057b8;
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  margin-top: 6px;
}
#startCompassBtn:disabled {
  background: #ccc;
  color: #555;
  cursor: not-allowed;
}

/* Heading text under compass */
#headingText {
  margin-top: 4px;
  font-size: 0.9rem;
  color: #333;
}

/* --- Right: Status panel --- */
#status-section {
  flex: 1;
  min-width: 200px;
  text-align: left;
  font-size: 1rem;
}

#status-section p {
  margin: 8px 0;
  line-height: 1.4;
}

#progressText {
  font-weight: 600;
  color: #0057b8;
}

#nearestName {
  color: #333;
  font-weight: 500;
}

/* --- Responsive (stack vertically on mobile) --- */
@media (max-width: 600px) {
  #compass-controls {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  #status-section {
    text-align: center;
  }
}

/* ===================== PROGRESS BAR ===================== */
#progressContainer {
  width: 100%;
  max-width: 800px;
  height: 14px;
  background: #ddd;
  border-radius: 8px;
  margin: 10px auto 5px auto;
  overflow: hidden;
}

#progressBarFill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #0057b8, #00b2ff);
  transition: width 0.4s ease;
}

/* ===================== USER DOT ===================== */
.user-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: radial-gradient(circle, #fff700 40%, #ffcc00 80%);
  box-shadow: 0 0 12px rgba(255, 230, 0, 0.8);
  animation: pulse-user 1.8s infinite ease-in-out;
}

@keyframes pulse-user {
  0% {
    transform: scale(1);
    box-shadow: 0 0 10px rgba(255, 230, 0, 0.7);
  }
  50% {
    transform: scale(1.25);
    box-shadow: 0 0 25px rgba(255, 255, 0, 0.9);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 10px rgba(255, 230, 0, 0.7);
  }
}
/* =====================WELCOME CARD ====================*/
.welcome-card {
  background: #e8f0ff;
}
.welcome-card .trail-header {
  background: #0057b8;
}
/* ===================== TRAIL LIST ===================== */
#trailList {
  max-width: 800px;
  margin: 0 auto;
  padding: 10px;
}

/* ---- Trail Card ---- */
.trail-item {
  border-radius: 10px;
  margin: 10px 0;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  background: #f5f5f5;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.trail-item:hover {
  transform: scale(1.01);
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

/* ---- Header ---- */
.trail-header {
  background: #bbb;
  color: #fff;
  padding: 6px 12px;
  font-weight: 600;
  text-align: left;
}
.trail-header.visited {
  background: #0057b8;
}

/* ---- Body ---- */
.trail-body {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px;
  flex-wrap: nowrap;
}

.trail-image {
  flex-shrink: 0;
}

.trail-image img {
  width: 80px;
  height: 80px;
  border-radius: 8px;
  object-fit: cover;
  display: block;
}

.trail-text {
  flex: 1;
  text-align: left;
  overflow: hidden;
}

.trail-snippet {
  font-size: 0.9rem;
  color: #333;
  margin: 0 0 4px;
}
.trail-dist {
  font-size: 0.85rem;
  color: #666;
}




/* ---- Buttons (UPDATED) ---- */
.trail-buttons {
  display: flex;
  justify-content: flex-end;   /* RIGHT-JUSTIFY buttons */
  align-items: center;
  gap: 10px;                    /* spacing between buttons */
  padding: 10px;
  border-top: 1px solid #ddd;
  background: #fafafa;
}

.trail-buttons button {
  padding: 6px 12px;
  border-radius: 5px;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

/* Skip button (unchanged) */
.trail-buttons .skip-btn {
  background: #888;
  color: #fff;
}
.trail-buttons .skip-btn:hover {
  background: #666;
}

/* NEW unified Found – Read More button (green) */


/* New unified “Found – Read More” button */
.found-readmore {
  background: #4caf50;
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.2s ease;
}

.found-readmore:hover {
  background: #3d8f42;;
}

/* Welcome modal read-more button */
.welcome-readmore {
  background: #0057b8;     /* Blue */
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.2s ease;
}

.welcome-readmore:hover {
  background: #003f80;      /* Darker blue on hover */
}

/* Responsive trail list adjustments */
/* ===================== TRAIL LIST RESPONSIVE FIX ===================== */

/* Default (desktop + landscape) stays as-is */
.trail-body {
  display: flex;
  gap: 12px;
}

/* ===== Trail List — Portrait Mode (Two-column fixed layout) ===== */
@media (max-width: 480px) {

  .trail-body {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 10px;

    /* Prevent text dropping under the image */
    flex-wrap: nowrap;
  }

  .trail-image {
    flex-shrink: 0;      /* Image keeps width */
  }

  .trail-image img {
    width: 70px;         /* small thumbnail */
    height: 70px;
    object-fit: cover;
    border-radius: 8px;
    display: block;
  }

  .trail-text {
    flex: 1;             /* Text uses the remaining width */
    min-width: 0;        /* <-- prevents overflow */
  }

  .trail-snippet,
  .trail-dist {
    white-space: normal;
    overflow-wrap: break-word;
  }
}

/* Style tweaks for Found/Skipped buttons */
.trail-buttons .skip-btn:disabled {
  background: #4caf50; /* green for found */
  color: #fff;
  cursor: default;
}

.trail-item.skipped .skip-btn:disabled {
  background: #999;    /* greyed-out if skipped */
  color: #fff;
}

/* ---- States ---- */
.trail-item.visited {
  background: #e8f4ff;
}
.trail-item.skipped {
  background: #eee;
  opacity: 0.7;
}

/* ===================== RESET WRAPPER ===================== */
#reset-wrapper {
  width: 100%;
  max-width: 800px;
  margin: 25px auto;
  text-align: center;
}

#resetBtn {
  background: #b00020;
  color: #fff;
  border: none;
  padding: 12px 18px;
  border-radius: 6px;
  cursor: pointer;
}

/* ===================== MODAL POPUP ===================== */
dialog#spotModal {
  border: none;
  border-radius: 12px;
  padding: 0;
  max-width: 420px;
  width: 90%;
  max-height: 85vh;             /* limit popup height to 85% of screen */
  overflow: hidden;             /* prevent outer scrollbars */
  box-shadow: 0 5px 20px rgba(0,0,0,0.4);
}

/* Scrollable inner body */
#spotBody {
  max-height: 65vh;             /* leave room for title and button */
  overflow-y: auto;             /* enable internal scroll if needed */
  padding: 14px;
  background: #fff;
  font-size: 0.95rem;
  color: #333;
}

/* Images inside spot descriptions */
.info-img {
  width: 100%;
  border-radius: 10px;
  margin: 12px 0;
  display: block;
}

/* Title bar with close button on the right */
#spotTitle {
  background: #0057b8;
  color: white;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: 12px 12px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#spotTitleText {
  flex: 1;
  text-align: left;
}

/* Close “X” button (always visible) */
#closeModal {
  background: transparent;
  color: #ffffff !important;      /* ensure it stays white */
  border: none;
  font-size: 1.6rem;
  cursor: pointer;
  margin: 0;
  padding: 0 6px;
  line-height: 1;
  transition: color 0.2s ease;
}

#closeModal:hover {
  color: #ffcc00;                 /* soft yellow highlight */
}

#spotBody {
  padding: 14px;
  background: #fff;
  font-size: 0.95rem;
  color: #333;
  text-align: left;
}

/* ===================== AUDIO IN MODAL ===================== */
.audio-section {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid #ddd;
}

.audio-section h4 {
  margin-bottom: 6px;
  font-size: 1rem;
  color: #0057b8;
}

.audio-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
}

.audio-btn {
  background: #0057b8;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s ease;
}

.audio-btn:hover {
  background: #003f80;
}

/* ===================== FIREWORK OVERLAY ===================== */
#fireworksOverlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  display: none;
  z-index: 9999; /* must be above dialog */
}

.firework {
  width: 6px;
  height: 6px;
  background: radial-gradient(circle, #fff, rgba(255,255,255,0));
  border-radius: 50%;
  position: absolute;
  animation: explode 900ms ease-out forwards;
}

@keyframes explode {
  0% { transform: scale(0.2); opacity: 1; }
  80% { opacity: 1; }
  100% { transform: scale(12); opacity: 0; }
}

/* ===================== FOOTER ===================== */
#resetBtn {
  display: block;
  margin: 20px auto;
  background: #d32f2f;
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 6px;
  cursor: pointer;
}
#resetBtn:hover {
  background: #b71c1c;
}

/* ===================== FOOTER (bullet-proof mobile centering) ===================== */
#trailFooter {
  width: 100%;
  max-width: 800px;
  margin: 30px auto 50px auto;

  display: block !important;     /* override parent flex rules */
  text-align: center !important; /* enforce centering on all devices */

  font-size: 0.75rem;
  color: #555;
  padding: 0 20px;
  line-height: 1.4;

  flex: none !important;         /* stop flex parents affecting it */
  align-self: center !important; /* centre it inside flex parents */
}

#trailFooter p {
  margin: 0 auto;
  max-width: 95%;
  display: block;
}

#trailFooter a {
  color: #0057b8;
  text-decoration: none;
  font-weight: 600;
}

#trailFooter a:hover {
  text-decoration: underline;
}

@media (max-width: 600px) {
  #top-wrap, #map, #trailList, #nearest, #controls, #compass {
    width: 95%;
    margin: 10px auto;
  }

   #banner {
    aspect-ratio: 16 / 7;
    border-bottom-width: 2px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  }
  
  #title-bar {
    font-size: 1.1rem;
    padding: 10px;
  }

  .trail-body {
  flex-direction: row !important;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: nowrap;
}
  
  .trail-image img {
    width: 70px;
    height: 70px;
  }

  .trail-snippet {
    font-size: 0.85rem;
  }
}

/* ===================== REMOVE THIS FOR TESTING ===================== */
#testSelect {
  display: none !important;
}
