/* ========================================
   ❄ CHRISTMAS SNOW (IB-2061)
   Calm snow over the front-page hero. Loaded only while Christmas is active,
   the switch is on, and on the front page (body.japebo-xmas-snow).

   Performance: the layer is one pseudo-element, one tile taller than the
   hero, drawn once. Only `transform` is animated, so the browser moves a
   finished layer on the GPU and never repaints. The layer moves exactly one
   tile, so the loop has no visible jump.

   Which pseudo-element: banner.css uses ::before for the seasonal pattern
   (only without a banner image) and ::after for the dark/light text veil
   (only with a banner image). Snow takes whichever one is free: ::before
   with an image (the pattern is switched off there), ::after without an
   image (there is no veil). With an image the veil is painted after the
   snow, so snow never makes light text harder to read.

   Never in the way: pointer-events none, kept under text and buttons,
   clipped to the hero, still (no movement) for prefers-reduced-motion.
   ======================================== */
body.japebo-xmas-snow {
    --jp-snow-w: 300px;
    --jp-snow-h: 600px;
    --jp-snow-flake: rgba(255, 255, 255, 0.85);
}

/* The hero: the plugin's own banner, or the first Flatsome section/banner. */
body.japebo-xmas-snow .japebo-dynamic-banner:not(.japebo-dynamic-banner--deal),
body.japebo-xmas-snow #content > .section:first-child,
body.japebo-xmas-snow #content > .banner:first-child {
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

/* The snow layer (same four selectors in the media queries below, so the
   later rules win on order, never on specificity) */
body.japebo-xmas-snow .japebo-dynamic-banner--has-image:not(.japebo-dynamic-banner--deal)::before,
body.japebo-xmas-snow .japebo-dynamic-banner:not(.japebo-dynamic-banner--has-image):not(.japebo-dynamic-banner--deal)::after,
body.japebo-xmas-snow #content > .section:first-child::after,
body.japebo-xmas-snow #content > .banner:first-child::after {
    content: "";
    display: block !important;
    position: absolute;
    top: calc(-1 * var(--jp-snow-h));
    left: calc(-1 * var(--jp-snow-w));
    width: calc(100% + var(--jp-snow-w));
    height: calc(100% + var(--jp-snow-h));
    z-index: 0;
    pointer-events: none;
    opacity: 0.75;
    background-image:
        radial-gradient(circle at 40px 70px, var(--jp-snow-flake) 0 2.5px, transparent 3px),
        radial-gradient(circle at 210px 150px, var(--jp-snow-flake) 0 1.5px, transparent 2px),
        radial-gradient(circle at 120px 260px, var(--jp-snow-flake) 0 3px, transparent 3.5px),
        radial-gradient(circle at 270px 330px, var(--jp-snow-flake) 0 2px, transparent 2.5px),
        radial-gradient(circle at 70px 430px, var(--jp-snow-flake) 0 1.5px, transparent 2px),
        radial-gradient(circle at 180px 520px, var(--jp-snow-flake) 0 2.5px, transparent 3px),
        radial-gradient(circle at 250px 580px, var(--jp-snow-flake) 0 1.5px, transparent 2px);
    background-size: var(--jp-snow-w) var(--jp-snow-h);
    background-repeat: repeat;
    animation: japeboXmasSnowFall 45s linear infinite;
    will-change: transform;
}

/* Text and buttons stay above the snow */
body.japebo-xmas-snow .japebo-dynamic-banner:not(.japebo-dynamic-banner--deal) > *,
body.japebo-xmas-snow #content > .section:first-child > .section-content,
body.japebo-xmas-snow #content > .banner:first-child .banner-layers {
    position: relative;
    z-index: 1;
}

/* One tile down and one tile to the right = seamless loop */
@keyframes japeboXmasSnowFall {
    from {
        transform: translate3d(0, 0, 0);
    }

    to {
        transform: translate3d(300px, 600px, 0);
    }
}

@keyframes japeboXmasSnowFallSmall {
    from {
        transform: translate3d(0, 0, 0);
    }

    to {
        transform: translate3d(200px, 400px, 0);
    }
}

@media (max-width: 549px) {
    body.japebo-xmas-snow {
        --jp-snow-w: 200px;
        --jp-snow-h: 400px;
    }

    body.japebo-xmas-snow .japebo-dynamic-banner--has-image:not(.japebo-dynamic-banner--deal)::before,
    body.japebo-xmas-snow .japebo-dynamic-banner:not(.japebo-dynamic-banner--has-image):not(.japebo-dynamic-banner--deal)::after,
    body.japebo-xmas-snow #content > .section:first-child::after,
    body.japebo-xmas-snow #content > .banner:first-child::after {
        opacity: 0.6;
        animation-name: japeboXmasSnowFallSmall;
    }
}

@media (prefers-reduced-motion: reduce) {
    body.japebo-xmas-snow .japebo-dynamic-banner--has-image:not(.japebo-dynamic-banner--deal)::before,
    body.japebo-xmas-snow .japebo-dynamic-banner:not(.japebo-dynamic-banner--has-image):not(.japebo-dynamic-banner--deal)::after,
    body.japebo-xmas-snow #content > .section:first-child::after,
    body.japebo-xmas-snow #content > .banner:first-child::after {
        animation: none;
        will-change: auto;
        transform: translate3d(var(--jp-snow-w), var(--jp-snow-h), 0);
    }
}
