.zcs-holiday {
  /* Core customizable CSS variables */
  --zcs-flight-duration: 13s;
  --zcs-flight-top: clamp(40px, 5.55cqw, 120px);
  --zcs-sleigh-width: clamp(142px, 17.4cqw, 352px);
  --zcs-sleigh-scale: 1;
  --zcs-sleigh-x: 0px;
  --zcs-sleigh-y: 0px;
  --zcs-sleigh-flip: 1;
  --zcs-overlay-x: 0px;
  --zcs-overlay-y: 0px;
  --zcs-overlay-width: 100%;
  --zcs-overlay-height: 100vh;
  --zcs-snow-color: #85aac4;
  --zcs-snow-opacity: 1;
  --zcs-snow-speed: 1;
  --zcs-z-index: 30;
  --zcs-flight-edge: max(12cqw, calc(var(--zcs-sleigh-width) * var(--zcs-sleigh-scale, 1) * .60));

  /* Non-sticky positioning: stays anchored to top of homepage / parent section and scrolls naturally */
  position: absolute;
  top: var(--zcs-overlay-y, 0px);
  left: var(--zcs-overlay-x, 0px);
  width: var(--zcs-overlay-width, 100%);
  height: var(--zcs-overlay-height, 100vh);
  max-width: 100%;
  z-index: var(--zcs-z-index, 30);
  overflow: hidden;
  isolation: isolate;
  container-type: inline-size;
  pointer-events: none;
}

/* Contained mode: fills parent Elementor Container / Section (non-sticky) */
.zcs-holiday.zcs-holiday--contained {
  --zcs-overlay-height: 100%;
  position: absolute;
}

.elementor-widget-zcs-holiday-overlay:has(.zcs-holiday--contained),
.elementor-widget-zcs-holiday-overlay:has(.zcs-holiday--contained) > .elementor-widget-container {
  position: static !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Automatically ensure parent Elementor Container/Section clips contained snow & sleigh */
.e-con:has(> .elementor-widget-zcs-holiday-overlay .zcs-holiday--contained),
.e-con:has(> .e-con-inner > .elementor-widget-zcs-holiday-overlay .zcs-holiday--contained),
.elementor-section:has(.elementor-widget-zcs-holiday-overlay .zcs-holiday--contained) {
  position: relative;
  overflow: hidden;
}

/* Fallback min-height if user drops widget into a brand-new standalone empty Container */
.e-con:has(> .elementor-widget-zcs-holiday-overlay:only-child .zcs-holiday--contained),
.e-con:has(> .e-con-inner > .elementor-widget-zcs-holiday-overlay:only-child .zcs-holiday--contained) {
  min-height: 480px;
}

/* ==========================================================================
 * Sleigh Element — Forced Infinite Loop
 * ========================================================================== */
.zcs-holiday .zcs-holiday__sleigh {
  display: block;
  position: absolute;
  top: calc(var(--zcs-flight-top) + var(--zcs-sleigh-y, 0px));
  left: var(--zcs-sleigh-x, 0px);
  width: calc(var(--zcs-sleigh-width) * var(--zcs-sleigh-scale, 1));
  max-width: none !important;
  height: auto;
  transform-origin: center;
  will-change: transform, translate;
  scale: var(--zcs-sleigh-flip, 1) 1;
  translate: calc(-50% - var(--zcs-flight-edge)) 0;
  animation-name: zcs-holiday-crossing-seamless, zcs-holiday-flight-seamless !important;
  animation-duration: var(--zcs-flight-duration), var(--zcs-flight-duration) !important;
  animation-timing-function: linear, linear !important;
  animation-delay: 0s, 0s !important;
  animation-iteration-count: infinite, infinite !important;
  animation-direction: normal, normal !important;
  animation-play-state: running, running !important;
}

/* Loop Style: Paused (brief off-screen breather between passes) */
.zcs-holiday.zcs-holiday--loop-paused .zcs-holiday__sleigh {
  animation-name: zcs-holiday-crossing-paused, zcs-holiday-flight-paused !important;
}

/* Right-to-Left (Seamless Continuous Loop) */
.zcs-holiday.zcs-holiday--rtl .zcs-holiday__sleigh {
  scale: calc(var(--zcs-sleigh-flip, 1) * -1) 1;
  translate: calc(-50% + 100cqw + var(--zcs-flight-edge)) 0;
  animation-name: zcs-holiday-crossing-rtl-seamless, zcs-holiday-flight-seamless !important;
}

/* Right-to-Left (Paused Loop) */
.zcs-holiday.zcs-holiday--rtl.zcs-holiday--loop-paused .zcs-holiday__sleigh {
  animation-name: zcs-holiday-crossing-rtl-paused, zcs-holiday-flight-paused !important;
}

/* Ping-Pong (Back & Forth Continuous Loop: Left -> Right -> Flip -> Right -> Left) */
.zcs-holiday.zcs-holiday--pingpong .zcs-holiday__sleigh {
  animation-name: zcs-holiday-crossing-pingpong, zcs-holiday-flight-seamless !important;
  animation-duration: calc(var(--zcs-flight-duration) * 2), var(--zcs-flight-duration) !important;
}

/* Float-in-Place (Hover) mode: centers on 50% + sleigh-x and bobs on an infinite loop */
.zcs-holiday.zcs-holiday--hover .zcs-holiday__sleigh {
  left: calc(50% + var(--zcs-sleigh-x, 0px));
  translate: -50% -50%;
  animation-name: zcs-holiday-hover !important;
  animation-duration: calc(var(--zcs-flight-duration) * 0.35) !important;
  animation-timing-function: ease-in-out !important;
  animation-iteration-count: infinite !important;
  animation-play-state: running !important;
}

/* Static mode: pinned at 50% + sleigh-x and sleigh-y (reindeer GIF still loops) */
.zcs-holiday.zcs-holiday--static .zcs-holiday__sleigh {
  left: calc(50% + var(--zcs-sleigh-x, 0px));
  translate: -50% -50%;
  animation: none !important;
}

/* ==========================================================================
 * Seamless Non-Stop Loop Keyframes (0% -> 100% active flight, zero dead gap)
 * ========================================================================== */
@keyframes zcs-holiday-crossing-seamless {
  0% {
    translate: calc(-50% - var(--zcs-flight-edge)) 0;
  }
  100% {
    translate: calc(-50% + 100cqw + var(--zcs-flight-edge)) 0;
  }
}

@keyframes zcs-holiday-crossing-rtl-seamless {
  0% {
    translate: calc(-50% + 100cqw + var(--zcs-flight-edge)) 0;
  }
  100% {
    translate: calc(-50% - var(--zcs-flight-edge)) 0;
  }
}

@keyframes zcs-holiday-crossing-pingpong {
  0% {
    translate: calc(-50% - var(--zcs-flight-edge)) 0;
    scale: var(--zcs-sleigh-flip, 1) 1;
  }
  49.99% {
    translate: calc(-50% + 100cqw + var(--zcs-flight-edge)) 0;
    scale: var(--zcs-sleigh-flip, 1) 1;
  }
  50% {
    translate: calc(-50% + 100cqw + var(--zcs-flight-edge)) 0;
    scale: calc(var(--zcs-sleigh-flip, 1) * -1) 1;
  }
  100% {
    translate: calc(-50% - var(--zcs-flight-edge)) 0;
    scale: calc(var(--zcs-sleigh-flip, 1) * -1) 1;
  }
}

@keyframes zcs-holiday-flight-seamless {
  0% {
    transform: translateY(calc(-50% + 13cqw)) rotate(-6deg) scale(1.04);
  }
  11.11% {
    transform: translateY(calc(-50% + 10.3cqw)) rotate(-8deg) scale(1.03);
  }
  22.22% {
    transform: translateY(calc(-50% + 5.2cqw)) rotate(-9deg) scale(.99);
  }
  33.33% {
    transform: translateY(calc(-50% + 1.27cqw)) rotate(-6deg) scale(.91);
  }
  44.44% {
    transform: translateY(calc(-50% - .25cqw)) rotate(-2deg) scale(.84);
  }
  55.56% {
    transform: translateY(calc(-50% - .18cqw)) rotate(1deg) scale(.79);
  }
  66.67% {
    transform: translateY(calc(-50% + 1.55cqw)) rotate(5deg) scale(.76);
  }
  77.78% {
    transform: translateY(calc(-50% + 5.6cqw)) rotate(8deg) scale(.74);
  }
  88.89% {
    transform: translateY(calc(-50% + 10.4cqw)) rotate(7deg) scale(.73);
  }
  100% {
    transform: translateY(calc(-50% + 13cqw)) rotate(5deg) scale(.73);
  }
}

/* ==========================================================================
 * Paused Loop Keyframes (0% -> 72% crossing, 72% -> 100% off-screen gap)
 * ========================================================================== */
@keyframes zcs-holiday-crossing-paused {
  0% {
    translate: calc(-50% - var(--zcs-flight-edge)) 0;
  }
  72%, 100% {
    translate: calc(-50% + 100cqw + var(--zcs-flight-edge)) 0;
  }
}

@keyframes zcs-holiday-crossing-rtl-paused {
  0% {
    translate: calc(-50% + 100cqw + var(--zcs-flight-edge)) 0;
  }
  72%, 100% {
    translate: calc(-50% - var(--zcs-flight-edge)) 0;
  }
}

@keyframes zcs-holiday-flight-paused {
  0% {
    transform: translateY(calc(-50% + 13cqw)) rotate(-6deg) scale(1.04);
  }
  8% {
    transform: translateY(calc(-50% + 10.3cqw)) rotate(-8deg) scale(1.03);
  }
  16% {
    transform: translateY(calc(-50% + 5.2cqw)) rotate(-9deg) scale(.99);
  }
  24% {
    transform: translateY(calc(-50% + 1.27cqw)) rotate(-6deg) scale(.91);
  }
  32% {
    transform: translateY(calc(-50% - .25cqw)) rotate(-2deg) scale(.84);
  }
  40% {
    transform: translateY(calc(-50% - .18cqw)) rotate(1deg) scale(.79);
  }
  48% {
    transform: translateY(calc(-50% + 1.55cqw)) rotate(5deg) scale(.76);
  }
  56% {
    transform: translateY(calc(-50% + 5.6cqw)) rotate(8deg) scale(.74);
  }
  64% {
    transform: translateY(calc(-50% + 10.4cqw)) rotate(7deg) scale(.73);
  }
  72%, 100% {
    transform: translateY(calc(-50% + 13cqw)) rotate(5deg) scale(.73);
  }
}

@keyframes zcs-holiday-hover {
  0%, 100% {
    transform: translateY(-8px) rotate(-2deg);
  }
  50% {
    transform: translateY(8px) rotate(2deg);
  }
}

/* ==========================================================================
 * Falling Snow — Forced Infinite Loop
 * ========================================================================== */
.zcs-holiday__snow {
  position: absolute;
  inset: 0;
  overflow: hidden;
  mask-image: linear-gradient(transparent, #000 6%, #000 94%, transparent);
}

.zcs-holiday .zcs-holiday__flake {
  position: absolute;
  display: block;
  top: -12px;
  left: var(--x);
  height: calc(100% + 24px);
  width: var(--size);
  will-change: transform;
  animation-name: zcs-holiday-snow !important;
  animation-duration: calc(var(--fall) / var(--zcs-snow-speed, 1)) !important;
  animation-timing-function: linear !important;
  animation-delay: var(--delay) !important;
  animation-iteration-count: infinite !important;
  animation-play-state: running !important;
}

.zcs-holiday__flake::before {
  content: "";
  display: block;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: var(--zcs-snow-color);
  opacity: calc(var(--opacity) * var(--zcs-snow-opacity, 1));
}

@keyframes zcs-holiday-snow {
  0%   { transform: translate3d(0, 0, 0); }
  18%  { transform: translate3d(calc(var(--drift) * .45), 18%, 0); }
  40%  { transform: translate3d(calc(var(--drift) * .65), 40%, 0); }
  58%  { transform: translate3d(calc(var(--drift) * .31), 58%, 0); }
  78%  { transform: translate3d(calc(var(--drift) * .47), 78%, 0); }
  100% { transform: translate3d(var(--drift), 100%, 0); }
}

@media (max-width: 640px) {
  .zcs-holiday {
    --zcs-flight-top: 55px;
    --zcs-sleigh-width: clamp(138px, 34cqw, 196px);
  }

  .zcs-holiday__flake:nth-child(n+22) {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .zcs-holiday.zcs-holiday--respect-motion:not(.zcs-holiday--static) {
    display: none;
  }
}

/* Make Elementor widget wrapper clickable via editor badge while overlay stays pointer-events: none */
.elementor-widget-zcs-holiday-overlay .zcs-holiday-editor-badge {
  position: relative;
  z-index: 10000;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(18, 38, 58, 0.85);
  color: #ffffff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 12px;
  line-height: 1.4;
  border-radius: 6px;
  border: 1px dashed rgba(133, 170, 196, 0.8);
  pointer-events: auto;
  cursor: pointer;
}
