/* Shared layout for the holiday decor layer built by /public/js/holiday-theme.mjs.
   Each holiday's own file (e.g. halloween.css) supplies colors, the bunting tile and the particle art. */

.holiday-layer {
    pointer-events: none;
    /* Where hanging decor starts: the top of the screen here, just under the navbar inside it */
    --holiday-top: env(safe-area-inset-top, 0px);
}

/* A holiday's extra pieces (its `hanging` and `decor` lists); the holiday's CSS places and draws each one */
.holiday-decor {
    position: fixed;
    z-index: 1059;
    background-size: contain;
    background-repeat: no-repeat;
    pointer-events: none;
}

/* Hanging decor inside the sticky navbar moves with it, hanging just below its bottom edge */
#navbar {
    --holiday-top: 100%;
}

#navbar > .holiday-decor {
    position: absolute;
}

/* Fixed to the top of the screen when there's no site navbar (the kiosk); below dialogs */
.holiday-bunting {
    position: fixed;
    inset: env(safe-area-inset-top, 0px) 0 auto 0;
    height: 30px;
    background-repeat: repeat-x;
    background-size: 120px 30px;
    z-index: 1060;
    filter: drop-shadow(0 1px 1px rgb(0 0 0 / 0.25));
    pointer-events: none;
}

/* In the site navbar (sticky, its own stacking context at z-index 99) the garland rides along at
   the top, above the nav backgrounds (mobile nav is 1050), and the desktop top-row items (account
   button, contact, login) sit above it */
#navbar > .holiday-bunting {
    position: absolute;
    inset: 0 0 auto 0;
    z-index: 1051;
}

#navbar .navbar-top > li {
    position: relative;
    z-index: 1052 !important; /* the <li>s carry an inline z-index: 1 */
}

.holiday-particle {
    position: fixed;
    top: var(--lane);
    left: 0;
    width: var(--size);
    z-index: 1060;
    transform: translateX(-80px);
    animation: holiday-drift 16s linear var(--delay) infinite;
}

/* The art (a holiday's CSS sets its image, and may use ::before/::after for moving parts); bobs and
   tilts gently while the particle crosses */
.holiday-art {
    position: relative;
    display: block;
    background-size: contain;
    background-repeat: no-repeat;
    filter: drop-shadow(0 2px 2px rgb(0 0 0 / 0.18));
    animation: holiday-bob 1.8s ease-in-out infinite alternate;
}

/* Site swarm: bursts out of a point mid-screen (a cave mouth), each particle flying out along its
   own --dx/--dy and growing toward the viewer, then removed at the end */
.holiday-swarm .holiday-particle {
    top: 55vh;
    left: 50vw;
    margin: calc(var(--size) / -4) 0 0 calc(var(--size) / -2);
    animation: holiday-burst var(--speed) cubic-bezier(0.45, 0, 0.9, 0.6) var(--delay) 1 both;
}

/* Quick, jittery flight and frantic wings while bursting out */
.holiday-swarm .holiday-art {
    animation-duration: 0.22s;
}

.holiday-swarm .holiday-art::before,
.holiday-swarm .holiday-art::after {
    animation-duration: 0.07s;
}

@keyframes holiday-burst {
    from {
        transform: translate(0, 0) scale(0.1);
        opacity: 0;
    }
    12% {
        opacity: 1;
    }
    /* Grow ahead of the distance covered, so they visibly rush at the viewer while still on screen */
    55% {
        transform: translate(calc(var(--dx) * 0.4), calc(var(--dy) * 0.4)) scale(calc(var(--scale) * 0.75));
    }
    to {
        transform: translate(var(--dx), var(--dy)) scale(var(--scale));
        opacity: 1;
    }
}

/* Cross the screen in the first ~third of the loop, then wait off-screen */
@keyframes holiday-drift {
    0% {
        transform: translateX(-80px);
    }
    35%,
    100% {
        transform: translateX(calc(100vw + 80px));
    }
}

@keyframes holiday-bob {
    from {
        transform: translateY(-10px) rotate(-6deg);
    }
    to {
        transform: translateY(10px) rotate(5deg);
    }
}
