/**
 * Driftwood motion — SEO-safe: content is fully visible until JS adds
 * html.dw-animations-ready. Reduced motion disables all effects.
 */

:root {
  --dw-reveal-distance: 18px;
  --dw-reveal-duration: 520ms;
  --dw-reveal-stagger: 80ms;
  --dw-filter-duration: 260ms;
  --dw-ease-out: cubic-bezier(0.4, 0, 0.2, 1);
  --dw-ease-spring: cubic-bezier(0.34, 1.2, 0.64, 1);
}

@media (max-width: 767px) {
  :root {
    --dw-reveal-duration: 420ms;
    --dw-reveal-stagger: 60ms;
    --dw-reveal-distance: 12px;
  }
}

/* --- Scroll reveals (only after JS + not reduced motion) --- */

html.dw-animations-ready:not(.dw-reduced-motion) .dw-reveal {
  opacity: 0;
  transform: translateY(var(--dw-reveal-distance));
  transition:
    opacity var(--dw-reveal-duration) var(--dw-ease-out),
    transform var(--dw-reveal-duration) var(--dw-ease-out);
  will-change: opacity, transform;
}

html.dw-animations-ready:not(.dw-reduced-motion) .dw-reveal.dw-reveal--left {
  transform: translateX(calc(var(--dw-reveal-distance) * -1));
}

html.dw-animations-ready:not(.dw-reduced-motion) .dw-reveal.dw-reveal--right {
  transform: translateX(var(--dw-reveal-distance));
}

html.dw-animations-ready:not(.dw-reduced-motion) .dw-reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* Featured trips stagger */
html.dw-animations-ready:not(.dw-reduced-motion) body.dw-anim-featured-trips .dw-section-featured-trips .trip-card.dw-reveal.is-visible:nth-child(1) { transition-delay: 0ms; }
html.dw-animations-ready:not(.dw-reduced-motion) body.dw-anim-featured-trips .dw-section-featured-trips .trip-card.dw-reveal.is-visible:nth-child(2) { transition-delay: var(--dw-reveal-stagger); }
html.dw-animations-ready:not(.dw-reduced-motion) body.dw-anim-featured-trips .dw-section-featured-trips .trip-card.dw-reveal.is-visible:nth-child(3) { transition-delay: calc(var(--dw-reveal-stagger) * 2); }
html.dw-animations-ready:not(.dw-reduced-motion) body.dw-anim-featured-trips .dw-section-featured-trips .trip-card.dw-reveal.is-visible:nth-child(n+4) { transition-delay: calc(var(--dw-reveal-stagger) * 3); }

/* Departures slide-in stagger */
html.dw-animations-ready:not(.dw-reduced-motion) body.dw-anim-departures .departure-strip__item.dw-reveal {
  transform: translateY(var(--dw-reveal-distance));
}

html.dw-animations-ready:not(.dw-reduced-motion) body.dw-anim-departures .departure-strip__item.dw-reveal.is-visible:nth-child(1) { transition-delay: 0ms; }
html.dw-animations-ready:not(.dw-reduced-motion) body.dw-anim-departures .departure-strip__item.dw-reveal.is-visible:nth-child(2) { transition-delay: 60ms; }
html.dw-animations-ready:not(.dw-reduced-motion) body.dw-anim-departures .departure-strip__item.dw-reveal.is-visible:nth-child(3) { transition-delay: 120ms; }
html.dw-animations-ready:not(.dw-reduced-motion) body.dw-anim-departures .departure-strip__item.dw-reveal.is-visible:nth-child(4) { transition-delay: 180ms; }
html.dw-animations-ready:not(.dw-reduced-motion) body.dw-anim-departures .departure-strip__item.dw-reveal.is-visible:nth-child(n+5) { transition-delay: 240ms; }

/* Departures marquee (desktop only, skipped when manual scroll is enabled) */
@media (min-width: 768px) {
  body.dw-anim-departures-marquee .departure-strip:not([data-departure-scroll]) {
    overflow: hidden;
  }

  body.dw-anim-departures-marquee .departure-strip:not([data-departure-scroll]) .departure-strip__inner.dw-marquee-track {
    display: flex;
    flex-wrap: nowrap;
    width: max-content;
    gap: var(--space-2);
    animation: dw-departures-marquee 45s linear infinite;
  }

  body.dw-anim-departures-marquee .departure-strip:not([data-departure-scroll]) .departure-strip__inner.dw-marquee-track:hover {
    animation-play-state: paused;
  }

  body.dw-anim-departures-marquee .departure-strip:not([data-departure-scroll]) .departure-strip__inner.dw-marquee-track .departure-strip__item {
    flex: 0 0 auto;
    min-width: 14rem;
  }
}

@keyframes dw-departures-marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* Pull quote */
html.dw-animations-ready:not(.dw-reduced-motion) body.dw-anim-pull-quote .pull-quote.dw-reveal {
  transform: translateY(var(--dw-reveal-distance));
  border-left-color: transparent;
  transition:
    opacity var(--dw-reveal-duration) var(--dw-ease-out),
    transform var(--dw-reveal-duration) var(--dw-ease-out),
    border-color 700ms var(--dw-ease-out) 120ms;
}

html.dw-animations-ready:not(.dw-reduced-motion) body.dw-anim-pull-quote .pull-quote.dw-reveal.is-visible {
  border-left-color: var(--color-terracotta);
}

/* Blog cards — scroll + hover */
html.dw-animations-ready:not(.dw-reduced-motion) body.dw-anim-blog-cards .blog-card.dw-reveal.is-visible:nth-child(1) { transition-delay: 0ms; }
html.dw-animations-ready:not(.dw-reduced-motion) body.dw-anim-blog-cards .blog-card.dw-reveal.is-visible:nth-child(2) { transition-delay: var(--dw-reveal-stagger); }

body.dw-anim-blog-cards .blog-card {
  transition:
    transform 220ms var(--dw-ease-out),
    box-shadow 220ms var(--dw-ease-out),
    color 220ms ease;
}

@media (hover: hover) {
  body.dw-anim-blog-cards .blog-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(28, 27, 25, 0.08);
  }
}

/* About page team stagger */
html.dw-animations-ready:not(.dw-reduced-motion) body.dw-anim-about .team-member.dw-reveal.is-visible:nth-child(1) { transition-delay: 0ms; }
html.dw-animations-ready:not(.dw-reduced-motion) body.dw-anim-about .team-member.dw-reveal.is-visible:nth-child(2) { transition-delay: var(--dw-reveal-stagger); }
html.dw-animations-ready:not(.dw-reduced-motion) body.dw-anim-about .team-member.dw-reveal.is-visible:nth-child(3) { transition-delay: calc(var(--dw-reveal-stagger) * 2); }
html.dw-animations-ready:not(.dw-reduced-motion) body.dw-anim-about .team-member.dw-reveal.is-visible:nth-child(n+4) { transition-delay: calc(var(--dw-reveal-stagger) * 3); }

/* Trip filter transitions */
body.dw-anim-filter-results .trip-card[data-trip-card] {
  transition:
    opacity var(--dw-filter-duration) var(--dw-ease-out),
    transform var(--dw-filter-duration) var(--dw-ease-out);
}

body.dw-anim-filter-results .trip-card.dw-filter-leaving {
  opacity: 0;
  transform: scale(0.97);
  pointer-events: none;
}

body.dw-anim-filter-results .trip-card.dw-filter-entering {
  opacity: 0;
  transform: scale(0.97);
}

body.dw-anim-filter-results .trip-card.dw-filter-visible {
  opacity: 1;
  transform: none;
}

/* Gallery lightbox */
body.dw-anim-gallery .gallery-lightbox:not([hidden]) {
  display: flex;
}

body.dw-anim-gallery .gallery-lightbox:not([hidden]) .gallery-lightbox__backdrop {
  opacity: 0;
  transition: opacity 320ms var(--dw-ease-out);
}

body.dw-anim-gallery .gallery-lightbox.is-open .gallery-lightbox__backdrop {
  opacity: 1;
}

body.dw-anim-gallery .gallery-lightbox:not([hidden]) .gallery-lightbox__panel {
  opacity: 0;
  transform: scale(0.96);
  transition:
    opacity 320ms var(--dw-ease-out),
    transform 320ms var(--dw-ease-out);
}

body.dw-anim-gallery .gallery-lightbox.is-open .gallery-lightbox__panel {
  opacity: 1;
  transform: scale(1);
}

body.dw-anim-gallery .gallery-lightbox__image {
  transition: opacity 220ms var(--dw-ease-out);
}

body.dw-anim-gallery .gallery-lightbox__image.is-crossfading {
  opacity: 0;
}

/* Itinerary accordion */
body.dw-anim-itinerary .itinerary__day {
  position: relative;
  border-left: 3px solid transparent;
  margin-left: 0;
  padding-left: var(--space-2);
  transition:
    border-color 320ms var(--dw-ease-out),
    background-color 320ms var(--dw-ease-out),
    opacity var(--dw-reveal-duration) var(--dw-ease-out),
    transform var(--dw-reveal-duration) var(--dw-ease-out);
}

html.dw-animations-ready:not(.dw-reduced-motion) body.dw-anim-itinerary .itinerary__day.dw-reveal {
  opacity: 0;
  transform: translateY(14px);
}

html.dw-animations-ready:not(.dw-reduced-motion) body.dw-anim-itinerary .itinerary__day.dw-reveal.is-visible {
  opacity: 1;
  transform: none;
  transition-delay: var(--dw-itinerary-stagger, 0ms);
}

html.dw-animations-ready:not(.dw-reduced-motion) body.dw-anim-itinerary .itinerary #itinerary-heading.dw-reveal.is-visible {
  transition-delay: 0ms;
}

body.dw-anim-itinerary .itinerary__day.is-accordion-open,
body.dw-anim-itinerary .itinerary__day[open]:not(.is-accordion-closing) {
  border-left-color: var(--color-terracotta);
  background: rgba(255, 255, 255, 0.55);
}

body.dw-anim-itinerary .itinerary summary {
  transition: color 220ms var(--dw-ease-out);
}

body.dw-anim-itinerary .itinerary__day.is-accordion-open summary,
body.dw-anim-itinerary .itinerary__day[open]:not(.is-accordion-closing) summary {
  color: var(--color-ink);
}

body.dw-anim-itinerary .itinerary__day-num,
body.dw-anim-itinerary .activity-list__time {
  transition:
    color 280ms var(--dw-ease-out),
    transform 280ms var(--dw-ease-out);
}

body.dw-anim-itinerary .itinerary__day.is-accordion-open .itinerary__day-num,
body.dw-anim-itinerary .itinerary__day.is-accordion-open .activity-list__time,
body.dw-anim-itinerary .itinerary__day[open]:not(.is-accordion-closing) .itinerary__day-num,
body.dw-anim-itinerary .itinerary__day[open]:not(.is-accordion-closing) .activity-list__time {
  color: var(--color-terracotta);
  transform: translateX(3px);
}

body.dw-anim-itinerary .itinerary details .itinerary__content {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 360ms var(--dw-ease-out);
  padding-top: 0;
  padding-bottom: 0;
}

body.dw-anim-itinerary .itinerary details.is-accordion-open .itinerary__content,
body.dw-anim-itinerary .itinerary details[open]:not(.is-accordion-closing) .itinerary__content {
  grid-template-rows: 1fr;
  padding-top: var(--space-2);
  padding-bottom: var(--space-2);
}

body.dw-anim-itinerary .itinerary details .itinerary__content-inner {
  overflow: hidden;
  min-height: 0;
}

body.dw-anim-itinerary .itinerary details .itinerary__content-inner > * {
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 300ms var(--dw-ease-out) 90ms,
    transform 300ms var(--dw-ease-out) 90ms;
}

body.dw-anim-itinerary .itinerary details.is-accordion-open .itinerary__content-inner > *,
body.dw-anim-itinerary .itinerary details[open]:not(.is-accordion-closing) .itinerary__content-inner > * {
  opacity: 1;
  transform: none;
}

body.dw-anim-itinerary .itinerary summary::before {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35em;
  height: 1.35em;
  border: 1px solid rgba(196, 101, 74, 0.35);
  border-radius: 999px;
  font-size: 0.95em;
  line-height: 1;
  transition:
    transform 320ms var(--dw-ease-out),
    background-color 280ms var(--dw-ease-out),
    border-color 280ms var(--dw-ease-out),
    color 280ms var(--dw-ease-out);
}

body.dw-anim-itinerary .itinerary details.is-accordion-open summary::before,
body.dw-anim-itinerary .itinerary details[open]:not(.is-accordion-closing) summary::before {
  transform: rotate(45deg);
  background: var(--color-terracotta);
  border-color: var(--color-terracotta);
  color: var(--color-white);
  content: "+";
}

body.dw-anim-itinerary .itinerary details.is-accordion-closing .itinerary__content-inner > * {
  opacity: 0;
  transform: translateY(-4px);
  transition-delay: 0ms;
}

/* Booking price flash */
body.dw-anim-booking-flash .pricing-calculator__row--total span:last-child {
  display: inline-block;
  border-radius: var(--radius-sm);
  transition: background-color 280ms ease, color 280ms ease;
}

body.dw-anim-booking-flash .pricing-calculator__row--total.is-price-flash span:last-child {
  background: var(--color-sage-light);
  color: var(--color-sage);
}

/* Mobile booking sheet spring */
body.dw-anim-booking-sheet .booking-sheet__backdrop {
  opacity: 0;
  transition: opacity 280ms var(--dw-ease-out);
}

body.dw-anim-booking-sheet .booking-sheet.is-open .booking-sheet__backdrop {
  opacity: 1;
}

body.dw-anim-booking-sheet .booking-sheet__content {
  transform: translateY(100%);
  transition: transform 420ms var(--dw-ease-spring);
}

body.dw-anim-booking-sheet .booking-sheet.is-open .booking-sheet__content {
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  html.dw-reduced-motion .dw-reveal,
  html.dw-reduced-motion .departure-strip__inner.dw-marquee-track,
  body.dw-anim-filter-results .trip-card[data-trip-card],
  body.dw-anim-gallery .gallery-lightbox__panel,
  body.dw-anim-gallery .gallery-lightbox__backdrop,
  body.dw-anim-itinerary .itinerary details .itinerary__content,
  body.dw-anim-itinerary .itinerary__day {
  body.dw-anim-booking-sheet .booking-sheet__content {
    transition: none !important;
    animation: none !important;
    transform: none !important;
    opacity: 1 !important;
  }
}
