/*
  Lifetime Travel Plan — modern, cinematic, scroll-driven gallery
  Design goals:
  - Edge-to-edge images, subtle glass UI, smooth transforms
  - Avoid upscaling images; contain by intrinsic max dimensions
  - GPU-accelerated transitions and sticky typography
*/

:root {
  --bg: #0b0f14;
  --fg: #e9f1f7;
  --muted: #9fb3c8;
  --accent: #7cc4ff;
  /* Active accent color for current location (used by progress bar, title card) */
  --accent-active: rgba(255,255,255,0.9);
  --glass: rgba(12, 18, 24, 0.55);
  --glass-strong: rgba(12, 18, 24, 0.75);
  --shadow: 0 10px 40px rgba(0,0,0,0.35);
  --radius: 18px;
  /* Per-location background tints mapped to HUD title colors */
  --bg-japan: #0c1016;
  --bg-uae: #16130a;
  --bg-switzerland: #0b1411;
  --bg-iceland: #0a1116;
  --bg-canada: #140c0c;
  --bg-usa-grand-tour: #16110a;
  --bg-australia-new-zealand: #14160a;
  --bg-singapore: #120f16;
}

* { box-sizing: border-box }
html, body { height: 100% }
html {
  scroll-behavior: smooth;
  /* Hide native scrollbars at the root (Firefox/IE/Edge Legacy) */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE 10+ */
}
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  /* Use a single consistent background color */
  background: var(--bg);
  user-select: none;
  /* Make wrapper non-hit-testable so only transformed content defines hit area */
  pointer-events: none;
  /* We apply touch-action and cursor on the inner element */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE 10+ */
}

/* Hide native scrollbar (WebKit) */
body::-webkit-scrollbar { display: none; width: 0; height: 0; }
html::-webkit-scrollbar { display: none; width: 0; height: 0; }

/* Header and footer removed for a cleaner, more elegant presentation */

/* Sections */
.section {
  position: relative;
  min-height: 100svh;
  overflow: hidden;
  /* Ensure consistent background even if images don't cover */
  background: var(--bg-active, var(--bg));
}

.section .overlay {
  position: sticky;
  top: 18svh;
  z-index: 1000;
  display: inline-flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(92vw, 1200px);
  margin: 10svh clamp(12px, 5vw, 64px);
  padding: clamp(10px, 2vw, 16px) clamp(14px, 3vw, 22px);
  background: var(--glass-strong);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  backdrop-filter: blur(10px) saturate(1.3);
  box-shadow: var(--shadow);
}

.section .title {
  margin: 0;
  line-height: 1.1;
  font-size: clamp(28px, 5.5vw, 64px);
  letter-spacing: 0.2px;
}
.section .subtitle {
  margin: 0;
  color: var(--muted);
  font-size: clamp(13px, 1.8vw, 18px);
  font-weight: 700;
}

/* Canvas stage: where images animate */
.stage {
  position: relative;
  width: 100%;
  /* Remove 3D perspective so z-index strictly controls stacking order */
}

.frame {
  position: relative;
  width: 100%;
  height: 100svh;
  display: grid;
  place-items: center;
  overflow: hidden;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  /* Ensure consistent background behind images */
  background: var(--bg-active, var(--bg));
}

/* When HUD tells us the current section/location via data-loc, tint bg accordingly */
/* The tint is subtle and dark to avoid distraction; adjust as desired */
body:has(#hud[data-loc="japan"]) { --bg-active: var(--bg-japan); }
body:has(#hud[data-loc="uae"]) { --bg-active: var(--bg-uae); }
body:has(#hud[data-loc="switzerland"]) { --bg-active: var(--bg-switzerland); }
body:has(#hud[data-loc="iceland"]) { --bg-active: var(--bg-iceland); }
body:has(#hud[data-loc="canada"]) { --bg-active: var(--bg-canada); }
body:has(#hud[data-loc="usa-grand-tour"]) { --bg-active: var(--bg-usa-grand-tour); }
body:has(#hud[data-loc="australia-new-zealand"]) { --bg-active: var(--bg-australia-new-zealand); }
body:has(#hud[data-loc="singapore"]) { --bg-active: var(--bg-singapore); }

/* Map active accent color to the HUD title color per location */
body:has(#hud[data-loc="japan"]) { --accent-active: #f2f6ff; }
body:has(#hud[data-loc="uae"]) { --accent-active: #ffe7a8; }
body:has(#hud[data-loc="switzerland"]) { --accent-active: #d7fff1; }
body:has(#hud[data-loc="iceland"]) { --accent-active: #bfe3ff; }
body:has(#hud[data-loc="canada"]) { --accent-active: #ffd6d6; }
body:has(#hud[data-loc="usa-grand-tour"]) { --accent-active: #ffd08a; }
body:has(#hud[data-loc="australia-new-zealand"]) { --accent-active: #e9ffbf; }
body:has(#hud[data-loc="singapore"]) { --accent-active: #d6c2ff; }

/* Fixed HUD (top-right) that updates only when section changes */
.hud {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 2500;
  color: rgba(255,255,255,0.94);
  letter-spacing: 0.2px;
  line-height: 1.15;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255,255,255,0.1);
  backdrop-filter: blur(6px) saturate(1.2);
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
  pointer-events: none;
  white-space: nowrap;
  text-align: right;
  opacity: 0; transform: translateY(-6px);
  transition: opacity 220ms ease, transform 280ms cubic-bezier(.2,.7,0,.99);
}
.hud.show { opacity: 1; transform: translateY(0); }

.hud__title {
  font-size: clamp(22px, 3.4vw, 40px);
  font-weight: 800;
  line-height: 1.05;
}
.hud__meta {
  margin-top: 6px;
  font-size: clamp(12px, 1.4vw, 16px);
  color: var(--muted);
  font-weight: 700;
  font-family: 'Sora', 'Plus Jakarta Sans', 'Montserrat', Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

/* Bottom-right description */
.desc {
  position: fixed;
  right: 16px;
  bottom: 12px;
  z-index: 2500;
  max-width: min(44ch, 36vw);
  padding: 10px 14px;
  border-radius: 12px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.9);
  backdrop-filter: none;
  box-shadow: none;
  line-height: 1.45;
  letter-spacing: 0.2px;
  text-align: right;
  opacity: 0; transform: translateY(6px);
  transition: opacity 220ms ease, transform 280ms cubic-bezier(.2,.7,0,.99);
  font-family: 'Playfair Display', Georgia, 'Times New Roman', serif;
  font-size: clamp(18px, 2.3vw, 28px);
  font-style: italic;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.desc.show { opacity: 1; transform: translateY(0); }

/* Per-location modern font mapping for HUD and section overlay titles */
.hud[data-loc="japan"] .hud__title { font-family: 'Shippori Mincho', 'Noto Sans JP', 'Yu Gothic UI', 'Meiryo', serif; color: #f2f6ff; }
.section[data-name="Japan"] .title { font-family: 'Shippori Mincho', 'Noto Sans JP', 'Yu Gothic UI', 'Meiryo', serif; }
.hud[data-loc="uae"] .hud__title { font-family: 'El Messiri', 'Tajawal', 'Cairo', 'Urbanist', sans-serif; color: #ffe7a8; }
.section[data-name="UAE"] .title { font-family: 'El Messiri', 'Tajawal', 'Cairo', 'Urbanist', sans-serif; }
.hud[data-loc="switzerland"] .hud__title { font-family: 'Gloock', 'Bodoni Moda', 'Playfair Display', serif; color: #d7fff1; }
.section[data-name="Switzerland"] .title { font-family: 'Gloock', 'Bodoni Moda', 'Chivo', serif; }
.hud[data-loc="iceland"] .hud__title { font-family: 'Cormorant Garamond', 'Playfair Display', 'Bodoni Moda', Georgia, serif; color: #bfe3ff; letter-spacing: 0.3px; font-weight: 700; }
.section[data-name="Iceland"] .title { font-family: 'Cormorant Garamond', 'Playfair Display', 'Bodoni Moda', Georgia, serif; letter-spacing: 0.3px; font-weight: 700; }
.hud[data-loc="canada"] .hud__title { font-family: 'Sora', 'Plus Jakarta Sans', 'Montserrat', sans-serif; color: #ffd6d6; }
.section[data-name="Canada"] .title { font-family: 'Sora', 'Plus Jakarta Sans', 'Montserrat', sans-serif; }
.hud[data-loc="usa-grand-tour"] .hud__title { font-family: 'Playfair Display', 'Bodoni Moda', 'Georgia', serif; color: #ffd08a; text-transform: uppercase; font-weight: 800; letter-spacing: 0.6px; }
.section[data-name="USA Grand Tour"] .title { font-family: 'Playfair Display', 'Bodoni Moda', 'Georgia', serif; text-transform: uppercase; font-weight: 800; letter-spacing: 0.6px; }
.hud[data-loc="australia-new-zealand"] .hud__title { font-family: 'Syne', 'Urbanist', 'Poppins', 'Segoe UI', sans-serif; color: #e9ffbf; }
.section[data-name="Australia & New Zealand"] .title { font-family: 'Syne', 'Urbanist', 'Poppins', 'Segoe UI', sans-serif; }

/* Singapore unique font and color */
.hud[data-loc="singapore"] .hud__title { font-family: 'Marcellus', 'DM Serif Display', 'Poppins', serif; color: #d6c2ff; }
.section[data-name="Singapore"] .title { font-family: 'Marcellus', 'DM Serif Display', 'Poppins', serif; }

/* Removed old sibling overrides to avoid conflicts; HUD uses data-loc now */

/* Fallback font for others */
.hud, .section .title { font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif; }

.group {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  /* Ensure custom gestures receive events on Firefox mobile */
  touch-action: none;
  /* Keep each group in its own stacking context so z-index is stable */
  isolation: isolate;
}

.img {
  position: absolute;
  will-change: transform, opacity, filter;
  transform-origin: center;
  filter: saturate(1.02) contrast(1.02);
  cursor: grab;
  user-select: none;
  /* Allow our custom drag + pinch to receive pointer events */
  touch-action: none;
}

/* Inner wrapper for transform-based pan+zoom */
.img-inner {
  width: 100%;
  height: 100%;
  /* Pan+zoom are applied here via CSS variables */
  transform: translate3d(var(--ux-tx, 0px), var(--ux-ty, 0px), 0) scale(var(--ux-scale, 1));
  transform-origin: 0 0; /* simplifies math for anchored scaling */
  will-change: transform;
  /* Ensure transformed content remains hit-testable */
  pointer-events: auto;
  /* Inner is the gesture surface */
  touch-action: none;
  cursor: grab;
  /* Always show subtle image shadow */
  box-shadow: 0 10px 24px rgba(0,0,0,0.35);
}

/* Also disable native touch actions on the img element itself (Firefox mobile quirk) */
.img img { touch-action: none; }

/* Subtle vignette for depth */
.frame::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(120% 100% at 50% 50%, transparent 60%, rgba(0,0,0,0.35) 100%);
  pointer-events: none;
}

/* Visual state while dragging (shadow is always on) */
.img.dragging .img-inner { cursor: grabbing; }

/* Motion presets */
.fade-in { opacity: 0; transform: translate3d(0, 6vh, 0) scale(0.98); transition: transform 900ms cubic-bezier(.2,.7,0,.99), opacity 900ms ease; }
.fade-in.active { opacity: 1; transform: translate3d(0, 0, 0) scale(1); transition: transform 900ms cubic-bezier(.2,.7,0,.99), opacity 900ms ease; transition-delay: var(--d, 0ms); }

.float-in { opacity: 0; transform: translate3d(0, 6vh, 0) scale(0.96) rotateZ(0.4deg); transition: transform 1000ms cubic-bezier(.2,.7,0,.99), opacity 1000ms ease; }
/* Keep it purely 2D to avoid depth sorting overriding z-index */
.float-in.active { opacity: 1; transform: translate3d(0, 0, 0) scale(1) rotateZ(0); transition: transform 1000ms cubic-bezier(.2,.7,0,.99), opacity 1000ms ease; transition-delay: var(--d, 0ms); }

.slide-l { opacity: 0; transform: translate3d(-8vw, 0, 0) scale(0.99); transition: transform 850ms cubic-bezier(.2,.7,0,.99), opacity 850ms ease; }
.slide-l.active { opacity: 1; transform: translate3d(0, 0, 0) scale(1); transition: transform 850ms cubic-bezier(.2,.7,0,.99), opacity 850ms ease; transition-delay: var(--d, 0ms); }

.slide-r { opacity: 0; transform: translate3d(8vw, 0, 0) scale(0.99); transition: transform 850ms cubic-bezier(.2,.7,0,.99), opacity 850ms ease; }
.slide-r.active { opacity: 1; transform: translate3d(0, 0, 0) scale(1); transition: transform 850ms cubic-bezier(.2,.7,0,.99), opacity 850ms ease; transition-delay: var(--d, 0ms); }

.zoom-soft { opacity: 0; transform: translate3d(0, 0, 0) scale(1.02); transition: transform 1200ms ease, opacity 900ms ease; }
.zoom-soft.active { opacity: 1; transform: translate3d(0, 0, 0) scale(1); transition: transform 1200ms ease, opacity 900ms ease; transition-delay: var(--d, 0ms); }

/* New entrance variants */
.slide-u { opacity: 0; transform: translate3d(0, 8vh, 0) scale(0.99); transition: transform 850ms cubic-bezier(.2,.7,0,.99), opacity 850ms ease; }
.slide-u.active { opacity: 1; transform: translate3d(0, 0, 0) scale(1); transition: transform 850ms cubic-bezier(.2,.7,0,.99), opacity 850ms ease; transition-delay: var(--d, 0ms); }

.slide-d { opacity: 0; transform: translate3d(0, -8vh, 0) scale(0.99); transition: transform 850ms cubic-bezier(.2,.7,0,.99), opacity 850ms ease; }
.slide-d.active { opacity: 1; transform: translate3d(0, 0, 0) scale(1); transition: transform 850ms cubic-bezier(.2,.7,0,.99), opacity 850ms ease; transition-delay: var(--d, 0ms); }

.tilt-l { opacity: 0; transform: translate3d(-6vw, 0, 0) rotateZ(-2.5deg) scale(0.985); transition: transform 950ms cubic-bezier(.2,.7,0,.99), opacity 950ms ease; }
.tilt-l.active { opacity: 1; transform: translate3d(0, 0, 0) rotateZ(0) scale(1); transition: transform 950ms cubic-bezier(.2,.7,0,.99), opacity 950ms ease; transition-delay: var(--d, 0ms); }

.tilt-r { opacity: 0; transform: translate3d(6vw, 0, 0) rotateZ(2.5deg) scale(0.985); transition: transform 950ms cubic-bezier(.2,.7,0,.99), opacity 950ms ease; }
.tilt-r.active { opacity: 1; transform: translate3d(0, 0, 0) rotateZ(0) scale(1); transition: transform 950ms cubic-bezier(.2,.7,0,.99), opacity 950ms ease; transition-delay: var(--d, 0ms); }

/* Ribbon drift: diagonal entrance with subtle tilt */
.drift-l { opacity: 0; transform: translate3d(-18vw, 12vh, 0) rotateZ(-4deg) scale(1); transition: transform 1000ms cubic-bezier(.2,.7,0,.99), opacity 850ms ease; }
.drift-l.active { opacity: 1; transform: translate3d(0, 0, 0) rotateZ(0) scale(1); transition-delay: var(--d, 0ms); }
.drift-r { opacity: 0; transform: translate3d(18vw, 12vh, 0) rotateZ(4deg) scale(1); transition: transform 1000ms cubic-bezier(.2,.7,0,.99), opacity 850ms ease; }
.drift-r.active { opacity: 1; transform: translate3d(0, 0, 0) rotateZ(0) scale(1); transition-delay: var(--d, 0ms); }

/* Photo stack: shrink and fade into place with slight rotation */
.stack { opacity: 0; transform: translate3d(var(--tx, 0px), var(--ty, 0px), 0) rotateZ(var(--rot, 0deg)) scale(1.12); transition: transform 900ms cubic-bezier(.2,.7,0,.99), opacity 900ms ease; }
.stack.active { opacity: 1; transform: translate3d(var(--tx, 0px), var(--ty, 0px), 0) rotateZ(var(--rot, 0deg)) scale(1); transition-delay: var(--d, 0ms); }

/* Image sizing helpers: never upscale */
.img[data-fit="cover"] img,
.img[data-fit="contain"] img {
  width: 100%; height: 100%; object-fit: contain; object-position: center;
}

/* Apply 10% transparency to all images */
.img img { opacity: 0.9; }

/* Layering */
.bg { z-index: 1; }
.mid { z-index: 2; }
.fg { z-index: 3; }

/* Smooth scrolling hint */
html:has(.frame) { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  .fade-in, .float-in, .slide-l, .slide-r, .zoom-soft, .slide-u, .slide-d, .tilt-l, .tilt-r {
    transition: none !important; transform: none !important; opacity: 1 !important;
  }
}

/* Minimal progress bar at the bottom */
.progress {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 4px;
  background: transparent;
  z-index: 2000;
  pointer-events: none;
}
.progress__bar {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--accent-active, rgba(255,255,255,0.9));
  box-shadow: 0 0 12px rgba(255,255,255,0.35);
  transform-origin: left center;
  transition: width 120ms linear;
}

/* Title card — large central location info frame */
.title-card {
  display: grid;
  place-items: center;
  text-align: center;
  padding: 6vh 4vw;
}
.title-card__inner { max-width: min(92vw, 1100px); }
.title-card__title {
  margin: 0 0 12px;
  font-size: clamp(40px, 9vw, 120px);
  line-height: 0.95;
  font-weight: 900;
  letter-spacing: 0.5px;
  color: var(--accent-active);
  text-shadow: 0 4px 22px rgba(0,0,0,0.35);
}
.title-card__meta {
  margin: 0;
  color: rgba(255,255,255,0.85);
  font-size: clamp(16px, 2.6vw, 28px);
  letter-spacing: 0.3px;
  font-weight: 700;
  font-family: 'Sora', 'Plus Jakarta Sans', 'Montserrat', Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

/* Ensure the title card uses the same font as the HUD per location */
.section[data-name="Japan"] .title-card__title { font-family: 'Shippori Mincho', 'Noto Sans JP', 'Yu Gothic UI', 'Meiryo', serif; }
.section[data-name="UAE"] .title-card__title { font-family: 'El Messiri', 'Tajawal', 'Cairo', 'Urbanist', sans-serif; }
.section[data-name="Switzerland"] .title-card__title { font-family: 'Gloock', 'Bodoni Moda', 'Playfair Display', serif; }
.section[data-name="Iceland"] .title-card__title { font-family: 'Cormorant Garamond', 'Playfair Display', 'Bodoni Moda', Georgia, serif; letter-spacing: 0.3px; font-weight: 700; }
.section[data-name="Canada"] .title-card__title { font-family: 'Sora', 'Plus Jakarta Sans', 'Montserrat', sans-serif; }
.section[data-name="USA Grand Tour"] .title-card__title { font-family: 'Playfair Display', 'Bodoni Moda', 'Georgia', serif; text-transform: uppercase; font-weight: 800; letter-spacing: 0.6px; }
.section[data-name="Australia & New Zealand"] .title-card__title { font-family: 'Syne', 'Urbanist', 'Poppins', 'Segoe UI', sans-serif; }
.section[data-name="Singapore"] .title-card__title { font-family: 'Marcellus', 'DM Serif Display', 'Poppins', serif; }

/* Increase spacing between name and meta */
.title-card__title { margin-bottom: clamp(18px, 4vh, 36px); }

.title-card__desc {
  margin: clamp(14px, 2.6vh, 24px) auto 0;
  max-width: 60ch;
  color: rgba(255,255,255,0.8);
  font-style: italic;
  font-size: clamp(14px, 2.1vw, 20px);
  line-height: 1.5;
}

@media (prefers-reduced-motion: no-preference) {
  .title-card__inner { opacity: 0; transform: translateY(8px); transition: opacity 420ms ease, transform 520ms cubic-bezier(.2,.7,0,.99); }
  /* activation handled by IntersectionObserver adding .active */
  .frame:has(.title-card__inner) .title-card__inner.active,
  .title-card .title-card__inner.active { opacity: 1; transform: translateY(0); }
}

/* Mobile nav buttons (shown on narrow/touch screens) */
.mobile-nav { position: fixed; right: 12px; bottom: 12px; z-index: 4000; display: flex; gap: 8px; flex-direction: column; pointer-events: auto; }
.mobile-nav__btn {
  appearance: none; border: 1px solid rgba(255,255,255,0.18);
  background: rgba(0,0,0,0.35); color: #fff;
  width: 46px; height: 46px; border-radius: 12px;
  font-size: 18px; line-height: 1; cursor: pointer;
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
  backdrop-filter: blur(8px) saturate(1.2);
  pointer-events: auto;
}
.mobile-nav__btn:active { transform: translateY(1px); }
.mobile-nav__btn[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
  filter: grayscale(60%);
}

@media (pointer: coarse), (max-width: 768px) {
  /* Disable natural scrolling feel on mobile */
  body { overscroll-behavior: contain; }
}

/* Temporarily hide descriptions while keeping the code available */
.desc { display: none !important; }
