/*
 * Usage: Image widget → Advanced → CSS Classes: parallax-img
 * Optional strength modifiers: parallax-subtle | parallax-strong
 * Override per widget via custom CSS: --parallax-frame / --parallax-height
 *
 * Modern browsers: pure CSS scroll-driven animation (no JS, no init jump).
 * Older browsers: JS fallback in parallax-img.js.
 */
.parallax-img {
  --parallax-frame: 400px;   /* visible height (must be a length, not %) */
  --parallax-height: 200%;   /* image height = strength */
  width: 100%;
  height: var(--parallax-frame);
  /* clip instead of hidden: hidden would make this a scroll container and break the view timeline */
  overflow: clip;
  view-timeline: --parallax-img block;
}

.parallax-img.parallax-subtle { --parallax-height: 140%; }
.parallax-img.parallax-strong { --parallax-height: 250%; }

.parallax-img > .elementor-widget-container {
  width: 100%;
  height: 100%;
  overflow: clip;
}

.elementor .parallax-img img {
  display: block;
  width: 100% !important;
  max-width: none !important;
  height: var(--parallax-height) !important;
  object-fit: cover;
  will-change: transform;
  /* No transitions: theme/Elementor transitions cause sliding or fading */
  transition: none !important;
}

/* Native scroll-driven parallax: frame enters at the bottom → exits at the top */
@supports (animation-timeline: view()) {
  .elementor .parallax-img img {
    animation: parallax-img-scroll linear both;
    animation-timeline: --parallax-img;
    animation-range: cover 0% cover 100%;
  }
}

@keyframes parallax-img-scroll {
  /* 100% = image height, so this shifts by (image height - frame height) */
  from { transform: translateY(calc(var(--parallax-frame) - 100%)); }
  to   { transform: translateY(0); }
}

/* JS fallback: hidden until the script has set the initial position (not in the Elementor editor) */
html.parallax-img-js body:not(.elementor-editor-active) .parallax-img img:not(.is-parallax-ready) {
  opacity: 0;
  /* Failsafe: show anyway if the script never runs */
  animation: parallax-img-reveal 0s linear 2s forwards;
}

@keyframes parallax-img-reveal {
  to { opacity: 1; }
}

@media (max-width: 767px) {
  .parallax-img { --parallax-frame: 250px; }
}
