/*
 * Seasonal look. functions.php adds body classes by date:
 *   kausi-talvi  1.12.–28./29.2.  cooler colours,
 *                                 snow drift on the footer, snowfall on
 *                                 the front page hero image
 *   kausi-joulu  1.12.–26.12.     string of Christmas lights under the
 *                                 menu
 * Preview any time with ?kausi=talvi, ?kausi=joulu or ?kausi=ei.
 */

/* ---------- Winter ---------- */

body.kausi-talvi {
    --site-chrome-bg: #e3eaef;
    --site-chrome-border: #c8d5de;
    --section-band-bg: #eff4f7;
    --snow-drift: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='22' viewBox='0 0 240 22' preserveAspectRatio='none'%3E%3Cpath fill='%23ffffff' d='M0 0H240V8C220 16 200 18 180 12S140 6 120 12 80 20 60 13 20 4 0 8Z'/%3E%3C/svg%3E");
}

/* style.css colours both template parts from --site-chrome-bg, set on :root.
   Re-declaring it on body is enough, but the fixed header sets its own. */
body.kausi-talvi header.wp-block-template-part,
body.kausi-talvi footer.wp-block-template-part,
body.kausi-talvi .header-fixed {
    background: var(--site-chrome-bg);
}

body.kausi-talvi header.wp-block-template-part > .wp-block-group,
body.kausi-talvi footer.wp-block-template-part > .wp-block-group {
    background: var(--site-chrome-bg) !important;
}

/* .header-fixed must keep position: fixed, so only the static header is relative */
body.kausi-talvi header.wp-block-template-part:not(.header-fixed) {
    position: relative;
    z-index: 20;
}

/* Snow drift along the top of the footer */
body.kausi-talvi footer.wp-block-template-part {
    position: relative;
}

body.kausi-talvi footer.wp-block-template-part::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: -1px;
    height: 24px;
    z-index: 1;
    background: var(--snow-drift) repeat-x left top / 520px 24px;
    filter: drop-shadow(0 2px 2px rgba(40, 70, 95, 0.12));
    pointer-events: none;
}

/* Gentle snowfall over the front page hero image */
.kausi-talvi.home .entry-content > .wp-block-group.alignwide:first-child > .wp-block-cover {
    overflow: hidden;
}

.kausi-talvi.home .entry-content > .wp-block-group.alignwide:first-child > .wp-block-cover::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    opacity: 0.85;
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='360' height='360'%3E%3Cg fill='%23fff'%3E%3Ccircle cx='40' cy='60' r='3.4'/%3E%3Ccircle cx='150' cy='20' r='2.8' opacity='.85'/%3E%3Ccircle cx='260' cy='110' r='3.6'/%3E%3Ccircle cx='330' cy='250' r='3' opacity='.9'/%3E%3Ccircle cx='90' cy='200' r='3.2'/%3E%3Ccircle cx='200' cy='300' r='2.6' opacity='.8'/%3E%3Ccircle cx='300' cy='30' r='2.4' opacity='.8'/%3E%3C/g%3E%3C/svg%3E"),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cg fill='%23fff'%3E%3Ccircle cx='20' cy='30' r='1.6' opacity='.8'/%3E%3Ccircle cx='70' cy='110' r='1.2' opacity='.7'/%3E%3Ccircle cx='120' cy='50' r='1.8' opacity='.9'/%3E%3Ccircle cx='180' cy='150' r='1.4' opacity='.75'/%3E%3Ccircle cx='220' cy='70' r='1.2' opacity='.7'/%3E%3Ccircle cx='40' cy='190' r='1.7' opacity='.85'/%3E%3Ccircle cx='140' cy='210' r='1.3' opacity='.7'/%3E%3Ccircle cx='200' cy='10' r='1.5' opacity='.8'/%3E%3Ccircle cx='100' cy='160' r='1.1' opacity='.65'/%3E%3C/g%3E%3C/svg%3E");
    background-size: 360px 360px, 240px 240px;
    animation: kausi-lumisade 18s linear infinite;
}

@keyframes kausi-lumisade {
    from { background-position: 0 0, 0 0; }
    to   { background-position: 0 360px, 0 240px; }
}

/* ---------- Christmas (on top of winter) ---------- */

body.kausi-joulu {
    --joulu-valot: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='26' viewBox='0 0 96 26'%3E%3Cpath d='M0 4Q48 20 96 4' fill='none' stroke='%2324412f' stroke-width='1.6'/%3E%3Crect x='14.5' y='7.4' width='3' height='3' rx='.6' fill='%2324412f'/%3E%3Cellipse cx='16' cy='14.4' rx='3.3' ry='4.6' fill='%23c8322b'/%3E%3Crect x='46.5' y='11' width='3' height='3' rx='.6' fill='%2324412f'/%3E%3Cellipse cx='48' cy='18' rx='3.3' ry='4.6' fill='%23e6b422'/%3E%3Crect x='78.5' y='7.4' width='3' height='3' rx='.6' fill='%2324412f'/%3E%3Cellipse cx='80' cy='14.4' rx='3.3' ry='4.6' fill='%232f8a57'/%3E%3C/svg%3E");
    --joulu-hehku: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='26' viewBox='0 0 96 26'%3E%3Cdefs%3E%3CradialGradient id='g'%3E%3Cstop offset='0' stop-color='%23fff6d8' stop-opacity='.95'/%3E%3Cstop offset='1' stop-color='%23fff6d8' stop-opacity='0'/%3E%3C/radialGradient%3E%3C/defs%3E%3Ccircle cx='16' cy='14.4' r='7' fill='url(%23g)'/%3E%3Ccircle cx='80' cy='14.4' r='7' fill='url(%23g)'/%3E%3C/svg%3E");
    --joulu-hehku-2: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='26' viewBox='0 0 96 26'%3E%3Cdefs%3E%3CradialGradient id='g'%3E%3Cstop offset='0' stop-color='%23fff6d8' stop-opacity='.95'/%3E%3Cstop offset='1' stop-color='%23fff6d8' stop-opacity='0'/%3E%3C/radialGradient%3E%3C/defs%3E%3Ccircle cx='48' cy='18' r='7' fill='url(%23g)'/%3E%3C/svg%3E");
}

/* The lights hang inside the bottom of the header, so they slide away with it */
body.kausi-joulu header.wp-block-template-part {
    padding-bottom: 18px;
}

body.kausi-joulu header.wp-block-template-part::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 26px;
    background: var(--joulu-valot) repeat-x left bottom / 96px 26px;
    pointer-events: none;
}

body.kausi-joulu header.wp-block-template-part::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 26px;
    z-index: 1;
    pointer-events: none;
    background:
        var(--joulu-hehku) repeat-x left bottom / 96px 26px,
        var(--joulu-hehku-2) repeat-x left bottom / 96px 26px;
    animation: kausi-tuike 2.4s ease-in-out infinite alternate;
}

@keyframes kausi-tuike {
    from { opacity: 0.25; }
    to   { opacity: 0.9; }
}

/* Keep the bulbs above the twinkle layer */
body.kausi-joulu header.wp-block-template-part::after {
    z-index: 2;
}

/* ---------- Less motion ---------- */

@media (prefers-reduced-motion: reduce) {
    .kausi-talvi.home .entry-content > .wp-block-group.alignwide:first-child > .wp-block-cover::after,
    body.kausi-joulu header.wp-block-template-part::before {
        animation: none;
    }
}
