{# ========================================
   Scroll Swap Module Styles
   ======================================== #}

{# ========================================
   Desktop/Tablet Layout
   ======================================== #}
:root {
  {# x px from top of viewport where the media "freezes" #}
  --stick-top: 20vh;
  {# if you have a fixed footer or want a bottom cushion, set this #}
  --stick-bottom: 0px;
}

.scroll-swap-container {
  display: flex;
  position: relative;
  gap: 30px;
  width: 100%;
  min-height: 100%;
}

{# Text content on left, media on right by default #}
.scroll-swap-text-side {
  flex: 0 0 50%;
  position: relative;
  z-index: 2;
  margin-top: 100px;
  margin-bottom: 50px;
}

.scroll-swap-media-side {
  flex: 0 0 50%;
  position: relative;
  overflow: visible;
  min-height: 100%;
}

{# Swap sides when text content is on right #}
.scroll-swap-container.swap-sides {
  flex-direction: row-reverse;
}


{# ========================================
   Text Sections
   ======================================== #}

.scroll-swap-text-section {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  scroll-margin-top: var(--stick-top);
}

.scroll-swap-text-section:first-child {
  padding-top: 0;
}

.scroll-swap-text-section:last-child {
  min-height: 50vh;
}

{# Apply spacing from fields using inline styles via HubL - handled in HTML #}

{# ========================================
   Media Container
   ======================================== #}

.scroll-swap-media-container {
  position: sticky;
  top: var(--stick-top);
  max-height: calc(100vh - var(--stick-top) - var(--stick-bottom));
  align-self: flex-start;
  width: 100%;
  aspect-ratio: 1 / 1;
}

.scroll-swap-media {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.scroll-swap-background,
.scroll-swap-foreground {
  display: none;
}

.scroll-swap-background.is-active,
.scroll-swap-foreground.is-active {
  display: block;
}


.scroll-swap-background {
  position: absolute;
  width: 100%;
  height: 100%;
  overflow: hidden;
  top: 0;
  left: 0;
  opacity: 0;
  transition: opacity 0.6s ease-in-out;
}

.scroll-swap-background.active {
  opacity: 1;
}

.scroll-swap-bg-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}


.scroll-swap-foreground {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.8);
  opacity: 0;
  transition: opacity 0.6s ease-in-out, transform 0.6s ease-in-out;
  width: 80%;
  max-width: 100%;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scroll-swap-foreground.active {
  opacity: 1;
  transform: translate(-65%, -50%) scale(1);
}

.scroll-swap-media-side.right-side .scroll-swap-foreground.active {
  opacity: 1;
  transform: translate(-35%, -50%) scale(1);
}

.scroll-swap-fg-image,
.scroll-swap-fg-video {
  width: 100%;
  height: auto;
  max-height: 70vh;
  object-fit: contain;
  display: block;
}

{# ========================================
   Mobile Layout
   ======================================== #}

.scroll-swap-mobile {
  display: none;
}

{# ========================================
   Responsive - Mobile
   ======================================== #}

@media (max-width: 576px) {
  {# Hide desktop layout #}
  .scroll-swap-container {
    display: none;
  }

  {# Show mobile layout #}
  .scroll-swap-mobile {
    display: block;
  }

  .scroll-swap-mobile-section {
    margin-bottom: 40px;
  }

  .scroll-swap-mobile-section:last-child {
    margin-bottom: 0;
  }

  .scroll-swap-mobile-text {
    margin-bottom: 30px;
  }

  .scroll-swap-mobile-media {
    width: 100%;
  }

  .scroll-swap-mobile-image,
  .scroll-swap-mobile-video {
    width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
  }

  .scroll-swap-mobile-video {
    max-height: 60vh;
    object-fit: contain;
  }
}

{# ========================================
   Tablet Adjustments
   ======================================== #}

@media (min-width: 769px) and (max-width: 1024px) {
  .scroll-swap-text-side {
    padding-right: 1.5rem;
  }

  .scroll-swap-container.swap-sides .scroll-swap-text-side {
    padding-right: 0;
    padding-left: 1.5rem;
  }

  .scroll-swap-fg-image,
  .scroll-swap-fg-video {
    max-height: 70vh;
  }
}

{# ========================================
   Accessibility
   ======================================== #}

.scroll-swap-fg-video:focus,
.scroll-swap-mobile-video:focus {
  outline: 2px solid #007bff;
  outline-offset: 4px;
}

{# Reduced motion preference #}
@media (prefers-reduced-motion: reduce) {
  .scroll-swap-foreground,
  .scroll-swap-background {
    transition: opacity 0.2s ease;
  }

  .scroll-swap-foreground {
    transform: translate(-50%, -50%) scale(1) !important;
  }
}

{# ========================================
   Performance Optimizations
   ======================================== #}

.scroll-swap-background,
.scroll-swap-foreground {
  will-change: opacity, transform;
}