/* Christmas Mode — Christmas decorations. Only linked Dec 1 - Jan 6 (see
   tracker/seasonal.py); static/js/christmas.js builds most of what this styles.
   Everything decorative carries .christmas-fx so one rule can hide it all. */

.christmas-off .christmas-fx { display: none !important; }

@media print {
    .christmas-fx, .christmas-toggle { display: none !important; }
}

/* Room at the top of the nav for the string lights. */
html:not(.christmas-off) .top-nav { padding-top: 28px; }

/* ---------- Banner (server-rendered under the top nav) ---------- */
.xm-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    align-self: stretch;
    padding: 7px 16px;
    background: #173a2b;
    color: #f6efe2;
    font-size: 14px;
    line-height: 1.4;
    text-align: center;
}
.xm-banner strong { color: #e8b949; font-weight: 800; }
.xm-banner svg { width: 26px; height: 20px; flex: none; }

/* The login page centres everything in a flex column, so pin its banner to
   the top, below the lights. base.html pages start with the nav instead. */
body > .xm-banner:first-child { position: absolute; top: 30px; left: 0; right: 0; }

/* ---------- Footer switch (not .christmas-fx: it has to stay to turn back on) ---------- */
footer .christmas-toggle {
    display: inline;
    margin: 4px 0 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    color: #007bff;
    font-size: 13px;
    text-decoration: underline;
    cursor: pointer;
}
footer .christmas-toggle:hover { background: none; color: #0056b3; }

/* ---------- String lights ---------- */
.xm-lights {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 30px;
    overflow: visible;
    pointer-events: none;
    z-index: 5;
}
.xm-lights .bulb { animation: xm-twinkle var(--tw, 2.2s) steps(1, end) infinite; animation-delay: var(--dl, 0s); }
@keyframes xm-twinkle { 0% { opacity: 1; } 45% { opacity: .5; } 55% { opacity: 1; } 80% { opacity: .75; } }

/* ---------- Footer scene ---------- */
.xm-scene-wrap { text-align: center; margin-bottom: 6px; }
.xm-scene {
    position: relative;
    display: inline-flex;
    justify-content: center;
    align-items: flex-end;
    gap: 12px;
    padding: 0 24px 8px;
    isolation: isolate;
}
.xm-scene::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 18px;
    z-index: -1;
    background: #eef4f9;
    border-top: 1px solid #d3e1ec;
    border-radius: 50% 50% 8px 8px / 100% 100% 8px 8px;
}
footer .xm-prop {
    position: relative;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: none;
    line-height: 0;
    cursor: pointer;
}
footer .xm-prop:hover { background: none; }
footer .xm-prop:focus-visible { outline: 2px solid #007bff; outline-offset: 2px; }
.xm-prop svg { width: 100%; height: auto; overflow: visible; }
.xm-prop.bop { animation: xm-bop .5s ease-out; }
@keyframes xm-bop {
    0% { transform: none; }
    35% { transform: translateY(-8px) scale(1.05, .96); }
    70% { transform: scale(.97, 1.03); }
    100% { transform: none; }
}
.xm-prop .hat, .xm-prop .lid { transform-box: fill-box; transform-origin: 50% 100%; transition: transform .25s ease-out; }
.xm-prop.hop .hat { transform: translateY(-7px) rotate(-10deg); }
.xm-prop.open .lid { transform: translateY(-9px) rotate(-14deg); }
.xm-prop .star { transform-box: fill-box; transform-origin: center; }
.xm-prop.spin .star { animation: xm-spin .8s ease-in-out; }
@keyframes xm-spin { to { transform: rotate(360deg) scale(1.15); } }
.xm-prop .orn { animation: xm-twinkle 2.4s steps(1, end) infinite; animation-delay: var(--dl, 0s); }

/* The nativity's Star of Bethlehem glows, and brightens when clicked. */
.xm-prop .glory {
    transform-box: fill-box;
    transform-origin: center;
    filter: drop-shadow(0 0 4px #ffd96a);
    animation: xm-glory 2.8s ease-in-out infinite alternate;
}
.xm-prop.shine .glory { filter: drop-shadow(0 0 9px #ffe38a) drop-shadow(0 0 3px #fff4c2); }
@keyframes xm-glory { from { opacity: .82; } to { opacity: 1; } }

.xm-bubble {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translate(-50%, 4px);
    padding: 4px 10px;
    border-radius: 10px;
    background: #0f2a1f;
    color: #f6efe2;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.4;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s, transform .2s;
}
.xm-bubble::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -6px;
    border: 6px solid transparent;
    border-top-color: #0f2a1f;
}
.xm-bubble.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Things that fall, fly and slide ---------- */
.xm-snow { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 35; }
.xm-layer { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 40; }

.xm-sleigh { position: absolute; left: 0; top: 0; width: 210px; height: 67px; transform-origin: 0 0; will-change: transform; }
.xm-sleigh .rig { display: block; width: 100%; height: 100%; overflow: visible; }
.xm-sleigh.left .rig { transform: scaleX(-1); }
.xm-sleigh .xm-bubble,
.xm-penguin .xm-bubble {
    background: #fff;
    color: #1d2126;
    font-weight: 400;
    border: 1px solid #e1e5e8;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
}
.xm-sleigh .xm-bubble::after,
.xm-penguin .xm-bubble::after { border-top-color: #fff; }
.xm-sleigh .xm-bubble { left: 30%; bottom: calc(100% + 2px); }
.xm-sleigh.left .xm-bubble { left: 70%; }
.xm-sleigh .legs-f,
.xm-sleigh .legs-b { transform-box: fill-box; transform-origin: 50% 0; animation: xm-gallop-f .45s ease-in-out infinite alternate; }
.xm-sleigh .legs-b { animation-name: xm-gallop-b; }
@keyframes xm-gallop-f { from { transform: rotate(-24deg); } to { transform: rotate(14deg); } }
@keyframes xm-gallop-b { from { transform: rotate(20deg); } to { transform: rotate(-22deg); } }
.xm-sleigh .rudolph { filter: drop-shadow(0 0 3px #ff3b3b); animation: xm-glow 1.1s ease-in-out infinite alternate; }
@keyframes xm-glow { from { opacity: .75; } to { opacity: 1; } }
.xm-spark {
    position: absolute;
    left: 0;
    top: 0;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #e8b949;
    box-shadow: 0 0 6px 1px rgba(232, 185, 73, .8);
    animation: xm-spark 1.1s ease-out forwards;
}
@keyframes xm-spark { to { opacity: 0; transform: translate(var(--sx), var(--sy)) scale(.2); } }

.xm-penguin { position: absolute; left: 0; bottom: 4px; width: 56px; height: 66px; will-change: transform; }
.xm-penguin .rig { display: block; width: 100%; height: 100%; overflow: visible; }
.xm-penguin.left .rig { transform: scaleX(-1); }
.xm-penguin .p-body {
    transform-box: view-box;
    transform-origin: 30px 66px;
    animation: xm-waddle .5s ease-in-out infinite alternate;
    transition: transform .35s ease-out;
}
@keyframes xm-waddle { from { transform: rotate(-8deg); } to { transform: rotate(8deg); } }
.xm-penguin.sliding .p-body { animation: none; transform-origin: 30px 40px; transform: translate(4px, 14px) rotate(82deg); }

.xm-magi { position: absolute; left: 0; bottom: 2px; width: 150px; height: 80px; will-change: transform; }
.xm-magi .rig { display: block; width: 100%; height: 100%; overflow: visible; }
.xm-magi.left .rig { transform: scaleX(-1); }
.xm-magi .king { animation: xm-stride 1.1s ease-in-out infinite; }
.xm-magi .king:nth-of-type(2) { animation-delay: -.37s; }
.xm-magi .king:nth-of-type(3) { animation-delay: -.74s; }
@keyframes xm-stride { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
.xm-magi .lead-star { filter: drop-shadow(0 0 5px #ffd96a); animation: xm-glory 1.6s ease-in-out infinite alternate; }
.xm-magi .xm-bubble {
    background: #fff;
    color: #1d2126;
    font-weight: 400;
    border: 1px solid #e1e5e8;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
}
.xm-magi .xm-bubble::after { border-top-color: #fff; }

.xm-confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }

/* Reduced motion: decorations stay, nothing moves. christmas.js also never
   starts the snow, wise men, sleigh, penguin or candy canes. */
@media (prefers-reduced-motion: reduce) {
    .xm-lights .bulb,
    .xm-prop .orn,
    .xm-prop .glory,
    .xm-prop.bop,
    .xm-prop.spin .star { animation: none; }
}

@media (max-width: 640px) {
    .xm-sleigh { width: 150px; height: 48px; }
    .xm-penguin { width: 44px; height: 52px; }
    .xm-magi { width: 116px; height: 62px; }
    .xm-prop.extra { display: none; }
    .xm-scene { gap: 8px; padding-inline: 12px; }
}
