/* Motor compartido de temas. Estructura y animaciones (solo transform/opacity/translate/rotate,
   todo en el compositor). Cada tema aporta únicamente colores y arte en su theme.css.
   Todo se apaga con prefers-reduced-motion. */

/* Partículas (nieve, confeti, hojas, pétalos, burbujas…): spans creados una vez por fx.js. */
.fx-field {
    position: fixed;
    inset: 0;
    z-index: 30;
    overflow: hidden;
    pointer-events: none;
    contain: strict;
}
.fx-p {
    position: absolute;
    top: -24px;
    left: var(--x);
    width: var(--s);
    height: var(--s);
    opacity: var(--o);
    background-size: contain;
    background-repeat: no-repeat;
    animation: fx-fall var(--d) linear var(--w) infinite, fx-sway var(--sd) ease-in-out var(--w) infinite alternate;
}
.fx-rise .fx-p { top: auto; bottom: -24px; animation-name: fx-rise, fx-sway; }
.fx-spin .fx-p { animation: fx-fall var(--d) linear var(--w) infinite, fx-sway var(--sd) ease-in-out var(--w) infinite alternate, fx-spin var(--r) linear var(--w) infinite; }
.fx-spin.fx-rise .fx-p { animation-name: fx-rise, fx-sway, fx-spin; }
@keyframes fx-fall { to { transform: translate3d(0, calc(100vh + 48px), 0); } }
@keyframes fx-rise { to { transform: translate3d(0, calc(-100vh - 48px), 0); } }
@keyframes fx-sway { from { translate: 0 0; } to { translate: var(--sw) 0; } }
@keyframes fx-spin { to { rotate: 360deg; } }

/* Franja bajo el encabezado (luces, banderines, guirnaldas). Alto 0: no mueve el diseño. */
.fx-strip { position: relative; z-index: 35; height: 0; pointer-events: none; }
.fx-strip > i {
    position: absolute;
    inset: 0 0 auto 0;
    height: var(--fx-strip-h, 30px);
    background-repeat: repeat-x;
    background-position: 0 0;
    background-size: var(--fx-strip-w, 160px) var(--fx-strip-h, 30px);
}

/* Elemento que cruza la pantalla una vez por ciclo (trineo, quetzal, bruja…). */
.fx-flyer {
    position: fixed;
    top: var(--fx-ft, 92px);
    left: 0;
    z-index: 29;
    width: var(--fx-fw, clamp(190px, 24vw, 340px));
    pointer-events: none;
    transform: translate3d(-110%, 0, 0);
    animation: fx-fly var(--fx-period, 90s) linear var(--fx-delay, 8s) infinite;
    contain: layout paint;
}
.fx-flyer img { display: block; width: 100%; height: auto; animation: fx-bob 1.4s ease-in-out infinite alternate; }
@keyframes fx-fly {
    0% { transform: translate3d(-110%, 0, 0); }
    13% { transform: translate3d(calc(100vw + 10%), 0, 0); }
    100% { transform: translate3d(calc(100vw + 10%), 0, 0); }
}
@keyframes fx-bob { from { transform: translateY(-4px) rotate(-1.5deg); } to { transform: translateY(5px) rotate(1deg); } }

.fx-paused .fx-p, .fx-paused .fx-flyer, .fx-paused .fx-flyer img,
.fx-paused .fx-strip::before, .fx-paused .fx-strip::after { animation-play-state: paused; }

/* Decoración estática por zonas (el tema pone las imágenes). */
[data-store-theme][data-theme-scene="1"] [data-slot="logo"] { position: relative; }
[data-store-theme][data-theme-scene="1"] [data-slot="logo"]::after {
    content: "";
    position: absolute;
    left: -9px;
    top: -12px;
    width: 28px;
    height: 24px;
    background: center / contain no-repeat;
    transform: rotate(-18deg);
    pointer-events: none;
}
[data-store-theme][data-theme-scene="1"] [data-slot="hero"]::before,
[data-store-theme][data-theme-scene="1"] [data-slot="hero"]::after {
    content: "";
    display: none;
    position: absolute;
    bottom: 0;
    z-index: 1;
    width: 15vw;
    max-width: 240px;
    aspect-ratio: 220 / 150;
    background: center bottom / contain no-repeat;
    pointer-events: none;
}
[data-store-theme][data-theme-scene="1"] [data-slot="hero"]::before { left: 1.5vw; }
[data-store-theme][data-theme-scene="1"] [data-slot="hero"]::after { right: 1.5vw; }
@media (min-width: 1100px) {
    [data-store-theme][data-theme-scene="1"] [data-slot="hero"]::before,
    [data-store-theme][data-theme-scene="1"] [data-slot="hero"]::after { display: block; }
}

/* Suelo (nieve, pasto, arena…) sobre el pie de página: máscara + color del tema. */
[data-store-theme][data-theme-scene="1"] [data-slot="footer"] { position: relative; margin-top: 18px; }
[data-store-theme][data-theme-scene="1"] [data-slot="footer"]::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% - 1px);
    height: 22px;
    background: var(--fx-ground, #f4f8fc);
    -webkit-mask: url("drift-mask.svg") repeat-x 0 0 / 160px 22px;
    mask: url("drift-mask.svg") repeat-x 0 0 / 160px 22px;
    pointer-events: none;
}
.dark[data-store-theme][data-theme-scene="1"] [data-slot="footer"]::before { background: var(--fx-ground-dark, var(--fx-ground, #94a3b8)); }

@media (prefers-reduced-motion: reduce) {
    .fx-field, .fx-flyer { display: none; }
    .fx-strip::before, .fx-strip::after { animation: none; }
}
