/* Inca Trail 3D Tour — layout + trail guide UX
   Companion to 3dtour/index.php (scrollytelling single-scrollbar) */

:root {
  --tour-bg: #0a0c10;
  --tour-surface: #12151c;
  --tour-surface-2: #1a1f2a;
  --tour-border: #2a3140;
  --tour-text: #e8e6e1;
  --tour-muted: #9aa3b2;
  --tour-faint: #6b7385;
  --tour-accent: #10a5f5;
  --tour-accent-hover: #0b84c7;
  --tour-brand: #96a13a;
  --tour-brand-dark: #7cad3b;
  --tour-danger: #c45c26;
  --tour-radius: 12px;
  --tour-font: "Segoe UI", system-ui, -apple-system, Roboto, Ubuntu, sans-serif;
  --tour-serif: Georgia, "Times New Roman", serif;
  --chrome-h: 56px;
}

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  padding: 0;
  background: var(--tour-bg);
  color: var(--tour-text);
  font-family: var(--tour-font);
}

/* —— Scrollytelling stage —— */
#tour-chapter {
  position: relative;
  height: 1000vh;
  background: #000;
}

#mapcontainer {
  position: sticky;
  top: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  z-index: 5;
}

#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* UI overlay: no independent scrollbar.
   Keep pointer-events enabled so wheel events scroll the document
   (scrollytelling). Do NOT set pointer-events:none here — that would
   send wheel to the Mapbox canvas and can swallow page scroll. */
#mapcontainer1 {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 6;
}

/* —— Top chrome —— */
.tour-chrome {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: var(--chrome-h);
  padding: 0.5rem 0.85rem;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0.35) 70%, transparent 100%);
  box-sizing: border-box;
}

.tour-chrome__brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: #fff;
  flex-shrink: 0;
}

.tour-chrome__brand img {
  width: 40px;
  height: 28px;
  object-fit: contain;
  display: block;
}

.tour-chrome__title {
  font-size: 0.92rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.tour-chrome__days {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-left: auto;
}

.tour-chrome__days a {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  backdrop-filter: blur(6px);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.tour-chrome__days a:hover,
.tour-chrome__days a:focus-visible {
  background: rgba(16, 165, 245, 0.35);
  border-color: var(--tour-accent);
  outline: none;
}

.tour-chrome__guide {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  background: var(--tour-accent);
  color: #fff !important;
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none !important;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.tour-chrome__guide:hover,
.tour-chrome__guide:focus-visible {
  background: var(--tour-accent-hover);
  outline: none;
}

.tour-scroll-hint {
  position: absolute;
  left: 50%;
  bottom: 4.5rem;
  transform: translateX(-50%);
  z-index: 35;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  backdrop-filter: blur(6px);
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.4s ease;
}

.tour-scroll-hint.is-hidden {
  opacity: 0;
}

.tour-scroll-hint kbd {
  font: inherit;
  opacity: 0.85;
}

/* Up/down tour controls — absolute inside sticky stage (NOT fixed:
   fixed would overlay the trail guide after the chapter unsticks). */
.button-up,
.button-down {
  position: absolute !important;
  z-index: 50;
  margin-left: 0 !important;
  margin-top: 0 !important;
  right: 18px;
  left: auto;
}

.button-up {
  bottom: 7.5rem;
}

.button-down {
  bottom: 3.75rem;
}

#map2,
#logo {
  position: absolute !important;
  right: 16px !important;
  top: 64px !important;
  left: auto !important;
}

/* Footer over map */
#mapcontainer #footer {
  z-index: 30;
  pointer-events: auto;
}

#mapcontainer #mapattr {
  z-index: 28;
  pointer-events: auto;
}

/* —— Trail guide (SEO + human readable) —— */
#trail-guide {
  position: relative;
  z-index: 10;
  background: var(--tour-bg);
  color: var(--tour-text);
  font-family: var(--tour-font);
  padding: 3.5rem 1.25rem 4rem;
}

.trail-guide__inner {
  max-width: 920px;
  margin: 0 auto;
}

.trail-guide__intro {
  margin-bottom: 2.75rem;
}

.trail-guide__intro h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.65rem, 3vw, 2.15rem);
  font-weight: 750;
  letter-spacing: -0.02em;
  color: #fff;
  line-height: 1.2;
  font-variant: normal;
  font-family: var(--tour-font);
}

.trail-guide__lede {
  margin: 0 0 1.25rem;
  font-size: 1.08rem;
  line-height: 1.65;
  color: var(--tour-muted);
  max-width: 46rem;
}

.trail-guide__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.trail-guide__stats li {
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: var(--tour-surface);
  border: 1px solid var(--tour-border);
  color: var(--tour-text);
  font-size: 0.82rem;
  font-weight: 600;
}

.trail-day {
  margin-top: 2.75rem;
  scroll-margin-top: 1.25rem;
}

.trail-day__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-bottom: 0.65rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--tour-border);
  position: sticky;
  top: 0;
  z-index: 2;
  background: linear-gradient(to bottom, var(--tour-bg) 70%, rgba(10, 12, 16, 0.92));
  padding-top: 0.75rem;
}

.trail-day__header h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 750;
  color: var(--tour-accent);
  font-family: var(--tour-font);
  font-variant: normal;
  line-height: 1.25;
}

.trail-day__tag {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--tour-brand);
}

.trail-stop {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 1.15rem;
  margin: 0 0 1.15rem;
  padding: 1rem;
  border-radius: var(--tour-radius);
  background: var(--tour-surface);
  border: 1px solid var(--tour-border);
  scroll-margin-top: 4.5rem;
}

.trail-stop__media {
  margin: 0;
  border-radius: 10px;
  overflow: hidden;
  background: var(--tour-surface-2);
  aspect-ratio: 1;
  align-self: start;
}

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

.trail-stop__body h3 {
  margin: 0 0 0.35rem;
  font-size: 1.08rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
  font-family: var(--tour-font);
}

.trail-stop__meta {
  margin: 0 0 0.65rem;
  font-size: 0.8rem;
  color: var(--tour-faint);
  font-weight: 600;
}

.trail-stop__body p {
  margin: 0 0 0.65rem;
  font-size: 0.98rem;
  line-height: 1.6;
  color: var(--tour-muted);
  font-family: var(--tour-serif);
}

.trail-stop__body p:last-child {
  margin-bottom: 0;
}

.trail-stop__link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.25rem;
  color: var(--tour-accent) !important;
  font-size: 0.92rem !important;
  font-weight: 650;
  text-decoration: none !important;
  font-family: var(--tour-font) !important;
}

.trail-stop__link:hover,
.trail-stop__link:focus-visible {
  color: #fff !important;
  text-decoration: underline !important;
  outline: none;
}

.trail-note {
  margin: 0.5rem 0 0;
  padding: 0.65rem 0.8rem;
  border-left: 3px solid var(--tour-danger);
  background: rgba(196, 92, 38, 0.12);
  border-radius: 0 8px 8px 0;
  color: #f0d2c4 !important;
  font-size: 0.9rem !important;
}

.trail-cta {
  margin-top: 3rem;
  padding: 2rem 1.5rem;
  border-radius: var(--tour-radius);
  background: linear-gradient(145deg, var(--tour-surface-2), var(--tour-surface));
  border: 1px solid var(--tour-border);
  text-align: center;
}

.trail-cta h2 {
  margin: 0 0 0.5rem;
  color: #fff;
  font-size: 1.4rem;
  font-family: var(--tour-font);
  font-variant: normal;
}

.trail-cta p {
  margin: 0 0 1.25rem;
  color: var(--tour-muted);
  font-size: 1rem;
}

.trail-cta__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: center;
}

.trail-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.35rem;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none !important;
  transition: background 0.15s ease, transform 0.15s ease;
}

.trail-btn:hover {
  transform: translateY(-1px);
}

.trail-btn--primary {
  background: var(--tour-accent);
  color: #fff !important;
}

.trail-btn--primary:hover {
  background: var(--tour-accent-hover);
}

.trail-btn--ghost {
  background: transparent;
  color: #fff !important;
  border: 1px solid var(--tour-border);
}

.trail-btn--ghost:hover {
  border-color: var(--tour-accent);
  background: rgba(16, 165, 245, 0.12);
}

.trail-guide__foot {
  margin-top: 2rem;
  text-align: center;
  color: var(--tour-faint);
  font-size: 0.82rem;
}

.trail-guide__foot a {
  color: var(--tour-faint) !important;
  text-decoration: underline;
}

.trail-guide__foot a:hover {
  color: var(--tour-accent) !important;
}

/* Page footer below guide */
.site-footer {
  background: #050608;
  border-top: 1px solid var(--tour-border);
  padding: 1.25rem 1rem 2rem;
  text-align: center;
  color: var(--tour-faint);
  font-size: 0.85rem;
}

.site-footer ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  justify-content: center;
}

.site-footer a {
  color: #c1c1c1;
  text-decoration: none;
}

.site-footer a:hover {
  color: #fff;
  text-decoration: underline;
}

/* —— Responsive —— */
@media (max-width: 720px) {
  .tour-chrome {
    flex-wrap: wrap;
    row-gap: 0.4rem;
    padding-bottom: 0.75rem;
  }

  .tour-chrome__title {
    display: none;
  }

  .tour-chrome__days {
    order: 3;
    width: 100%;
    margin-left: 0;
  }

  .tour-chrome__days a {
    flex: 1 1 auto;
    justify-content: center;
  }

  .tour-scroll-hint {
    bottom: 5.5rem;
    font-size: 0.72rem;
    max-width: 90vw;
    text-align: center;
  }

  .trail-stop {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  .trail-stop__media {
    aspect-ratio: 16 / 10;
    max-height: 200px;
  }
}

@media (max-width: 600px) {
  /* legacy JS hides #map2 and shows #logo — keep chrome brand visible */
  .tour-chrome__brand img {
    width: 36px;
    height: 24px;
  }
}

/* Mapbox attribution readable on dark UI */
.mapboxgl-ctrl-attrib {
  font-size: 10px;
  opacity: 0.85;
  background: rgba(0, 0, 0, 0.45) !important;
  color: #ddd !important;
}

.mapboxgl-ctrl-attrib a {
  color: #eee !important;
}
