/* =====================================================================
   MOTION — every animation on the home page lives in this file.
   Change the feel of the whole site from the variables below.

   How elements opt in (set in index.html, run by js/motion.js):
     data-reveal                 fade + slide up once when it scrolls into view
     data-reveal="load"          same, but on page load (hero only)
     data-reveal-delay="100"     extra delay in ms
     data-reveal-stagger         on a list/grid: its children reveal one after another
     data-reveal-settle          on a stagger grid: photos also settle from 1.04 to 1
     data-reveal-from="top"      glide down from above instead of up from below
     data-scrub / data-scrub-stagger   glide down from above in step with scrolling ("What's included")
     data-reveal-off             on any element: never animate it (always visible)

   Safety:
   - Hidden starting states only apply when <html> has the "js-anim" class, which the
     inline script in <head> adds only when JavaScript runs AND the visitor hasn't
     asked for reduced motion. No JS or reduced motion = everything simply visible.
   - Only transform and opacity are animated.
   ===================================================================== */
:root {
  --motion-ease: cubic-bezier(.22, 1, .36, 1);   /* soft ease-out, no bounce */

  /* Scroll reveals */
  --reveal-duration: 700ms;
  --reveal-distance: 20px;
  --reveal-stagger: 110ms;      /* gap between cards in a row (read by motion.js) */
  --settle-zoom: 1.02;          /* card photos settle from this scale to 1 */
  --scrub-distance: 100px;      /* scroll-linked glide ("What's included"): starts this far above */

  /* Hero on load */
  --hero-duration: 750ms;
  --hero-distance: 16px;
  --hero-photo-zoom: 1.025;     /* photo settles from this scale to 1 */
  --hero-photo-duration: 1500ms;

  /* Card hover (desktop only) */
  --hover-duration: 350ms;
  --hover-lift: -2px;
  --hover-zoom: 1.015;
  --hover-shadow: 0 16px 32px -16px rgba(0, 0, 0, .45);

  /* Header */
  --header-duration: 280ms;
  --header-solid-after: 64;     /* px scrolled before the header turns solid (read by motion.js) */

  /* "How it works" scroll story */
  --story-fade: 800ms;
  --story-zoom: 1.02;           /* each new story photo settles from this scale */
  --story-stage-h: min(72vh, 620px);
  --story-travel: 90vh;          /* desktop: how much scrolling the three photos take */
}
/* Phones: shorter distances, a little faster */
@media (max-width: 767px) {
  :root {
    --reveal-duration: 550ms;
    --reveal-distance: 12px;
    --scrub-distance: 64px;
    --hero-duration: 600ms;
    --hero-distance: 12px;
  }
}

/* ---------- 1. Reveal on scroll / on load ---------- */
.js-anim [data-reveal] {
  opacity: 0;
  transform: translate3d(0, var(--reveal-distance), 0);
  transition:
    opacity var(--reveal-duration) var(--motion-ease) var(--reveal-delay, 0ms),
    transform var(--reveal-duration) var(--motion-ease) var(--reveal-delay, 0ms);
}
.js-anim [data-reveal="load"] { --reveal-distance: var(--hero-distance); --reveal-duration: var(--hero-duration); }
/* data-reveal-from="top" (on an element or a stagger list): glide DOWN into place instead of up */
.js-anim [data-reveal][data-reveal-from="top"]:not(.is-revealed),
.js-anim [data-reveal-from="top"] > [data-reveal]:not(.is-revealed) { transform: translate3d(0, calc(var(--reveal-distance) * -1), 0); }
.js-anim [data-reveal].is-revealed,
.js-anim [data-reveal][data-reveal-off] { opacity: 1; transform: none; }

/* Photos in card grids settle into place while their card fades in */
.js-anim [data-reveal-settle] > [data-reveal]:not(.is-revealed) img { transform: scale(var(--settle-zoom)); }
.js-anim [data-reveal-settle] > [data-reveal] img { transition: transform var(--reveal-duration) var(--motion-ease) var(--reveal-delay, 0ms); }
.js-anim [data-reveal-settle] > .is-revealed:not(.is-animating) img { transition-duration: var(--hover-duration); transition-delay: 0ms; }

/* Scroll-linked glide (data-scrub, or data-scrub-stagger on a list): the element moves
   down into place from above IN STEP WITH YOUR SCROLLING, instead of playing on its own.
   motion.js sets --scrub from 0 (just entered the screen) to 1 (in place), both ways. */
.js-anim [data-scrub] {
  opacity: var(--scrub-o, 0);
  transform: translate3d(0, calc((1 - var(--scrub, 0)) * var(--scrub-distance) * -1), 0);
}

@media print { .js-anim [data-reveal], .js-anim [data-scrub] { opacity: 1 !important; transform: none !important; } }

/* Hero photo: one slow, quiet zoom-out on load */
@media (prefers-reduced-motion: no-preference) {
  .hero-photo { animation: hero-settle var(--hero-photo-duration) var(--motion-ease) both; }
  @keyframes hero-settle { from { transform: scale(var(--hero-photo-zoom)); } to { transform: none; } }
}

/* ---------- 2. Card hover (mouse only) ---------- */
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .tour-card, .fleet-photo {
    transition: transform var(--hover-duration) var(--motion-ease), box-shadow var(--hover-duration) var(--motion-ease);
  }
  .tour-card img, .fleet-photo img { transition: transform var(--hover-duration) var(--motion-ease); }
  .tour-card:hover, .fleet-item:hover .fleet-photo { transform: translateY(var(--hover-lift)); box-shadow: var(--hover-shadow); }
  .tour-card:hover img, .fleet-item:hover .fleet-photo img { transform: scale(var(--hover-zoom)); }
}

/* Excursions page: a bigger hover — the card lifts higher, the photo zooms in more,
   and the name rises a little with its lime underline */
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .tour-grid--page .tour-card { transition: transform .45s var(--motion-ease), box-shadow .45s var(--motion-ease); }
  .tour-grid--page .tour-card img { transition: transform .7s var(--motion-ease), filter .45s ease; }
  .tour-grid--page .tour-card .tour-name { transition: transform .45s var(--motion-ease); }
  .tour-grid--page .tour-card:hover { transform: translateY(-10px); box-shadow: 0 26px 48px -20px rgba(0, 0, 0, .6); }
  .tour-grid--page .tour-card:hover img { transform: scale(1.1); filter: brightness(calc(var(--image-dim) * 1.06)); }
  .tour-grid--page .tour-card:hover .tour-name { transform: translateY(-6px); }
}

/* ---------- 3. Header: transparent over the hero, solid once you scroll ----------
   motion.js adds .is-fixed (so without JS the header stays as it was),
   .is-solid after a short scroll, and .is-hidden while scrolling down. */
.site-header.is-fixed { position: fixed; isolation: isolate; transition: transform var(--header-duration) var(--motion-ease), color var(--header-duration) ease; }
.site-header.is-fixed::before {
  content: ""; position: absolute; inset: 0 0 calc(var(--header-top, 0px) * -.6) 0; z-index: -1; pointer-events: none;   /* a little room under the contents too */
  /* 60% see-through, with the page blurred behind it (frosted glass) */
  background: color-mix(in srgb, var(--surface) 60%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 8px 24px -16px rgba(0, 0, 0, .5);
  opacity: 0; transition: opacity var(--header-duration) ease;
}
.site-header.is-solid { color: var(--text); text-shadow: none; }
.site-header.is-solid::before { opacity: 1; }
.site-header.is-solid .main-nav a { color: var(--text); }
.site-header.is-solid .theme-toggle { color: var(--text); border-color: var(--border); }
.site-header.is-solid .theme-toggle:hover { background: var(--surface-sunken); }
.site-header.is-hidden { transform: translate3d(0, -100%, 0); }
@media (prefers-reduced-motion: reduce) { .site-header.is-fixed { transition: none; } }

/* ---------- 4. "How it works" scroll story ----------
   Desktop (768px+): the text and one large rounded photo stay pinned while you scroll
   through the section; the photo crossfades three times (thirds of the scroll).
   Phones: no animation. The text, then the photos in a row you swipe sideways. */
.story-lede { font-size: var(--fs-lead, 1.125rem); line-height: 1.6; color: var(--text-muted); max-width: 44ch; }

.story-stage { border-radius: 16px; overflow: hidden; background: var(--surface-sunken); position: relative; }
.story-stage img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  filter: brightness(var(--image-dim));
  opacity: 0; transform: scale(var(--story-zoom));
  transition: opacity var(--story-fade) var(--motion-ease), transform var(--story-fade) var(--motion-ease);
}
.story-stage img.is-active { opacity: 1; transform: none; }

/* Phones: the text, then a swipeable row of photos */
@media (max-width: 767px) {
  /* Each photo snaps to the centre with a quarter of the next (and previous) photo showing:
     screen = photo + 2 × (gap + photo/4)  →  photo = (screen − 2 × gap) / 1.5 */
  /* sized from the section's own width (container units), not 100vw, which iPhones can misreport */
  .story-grid { container-type: inline-size; }
  .story-stage {
    --strip-gap: 12px;
    --strip-w: calc(100cqi + 2 * var(--gutter));                 /* full screen width */
    --strip-photo: calc((var(--strip-w) - 2 * var(--strip-gap)) / 1.5);
    display: flex; gap: var(--strip-gap); margin: 28px calc(var(--gutter) * -1) 0;
    padding: 0 calc((var(--strip-w) - var(--strip-photo)) / 2);
    overflow-x: auto; overflow-y: hidden; border-radius: 0; background: none;
    scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;                               /* a swipe at the end doesn't move the page */
    scrollbar-width: none;
  }
  .story-stage::-webkit-scrollbar { display: none; }
  .story-stage img, .story-stage img.is-active {
    position: static; flex: 0 0 var(--strip-photo); height: auto; aspect-ratio: 9 / 10; border-radius: 16px;
    background: var(--surface-sunken); scroll-snap-align: center;
    opacity: 1; transform: none; transition: none;
  }
}

/* Desktop: text left, photo right, both pinned while you scroll through --story-travel */
@media (min-width: 768px) {
  .story-grid {
    display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); column-gap: clamp(40px, 6vw, 88px);
    align-items: center;
  }
  .story-stage { height: var(--story-stage-h); }
  .js .story-grid { position: sticky; top: calc((100vh - var(--story-stage-h)) / 2); }
  .js .story::after { content: ""; display: block; height: var(--story-travel); }   /* scroll room while pinned */
}
@media (prefers-reduced-motion: reduce) {
  .story-stage img { transform: none !important; transition: opacity 300ms linear !important; }
}