@property --plant {
    syntax: "<color>";
    inherits: true;
    initial-value: #3E5A3A;
}

@property --pot {
    syntax: "<color>";
    inherits: true;
    initial-value: #D49A78;
}

@property --drawing-ink {
    syntax: "<color>";
    inherits: true;
    initial-value: #1E2B22;
}

@property --shelf {
    syntax: "<color>";
    inherits: true;
    initial-value: #1E2B22;
}

:root[data-weather="autumn"] {
    --paper: #ECE3D0;
    --ink: #291F19;
    --muted: #5A493E;
    --accent: #B0643C;
    --drawing-ink: #291F19;
    --plant: #4F6135;
    --pot: #CC8662;
}

:root[data-weather="winter"] {
    --paper: #CBD8DF;
    --ink: #1C2A32;
    --muted: #3D4D57;
    --accent: #486B7E;
    --drawing-ink: #1C2A32;
    --plant: #2F5A4F;
    --pot: #CC9479;
}

:root[data-weather="night"] {
    --paper: #162230;
    --ink: #EAEFE8;
    --muted: #93A7BA;
    --accent: #7DA2B8;
    --drawing-ink: #0A1017;
    --shelf: #7E94A8;
    --plant: #629368;
    --pot: #B88066;
}

:root[data-weather="sunshower"] {
    --paper: #e4e2ec;
    --ink: #353342;
    --accent: #6b6383;
    --muted: #575364;
    --drawing-ink: #291F19;
    --plant: #4d6861;
    --pot: #cd9a87;
}

:root[data-weather="fog"] {
    --paper: #E6E8E4;
    --ink: #29322F;
    --muted: #535E5A;
    --accent: #8D866B;
    --drawing-ink: #2B3431;
    --plant: #496557;
    --pot: #CFA189;
}

:root[data-weather="dusk"] {
    --paper: #29233B;
    --ink: #F3EDE4;
    --muted: #B2A5BE;
    --accent: #D6B86C;
    --drawing-ink: #151120;
    --shelf: #9D8FA9;
    --plant: #6C9467;
    --pot: #C4876B;
}

:root[data-weather="drizzle"] {
    --paper: #D5E2DF;
    --ink: #1F302D;
    --muted: #445A56;
    --accent: #4E7B78;
    --drawing-ink: #1F302D;
    --plant: #3A6648;
    --pot: #C88D72;
}

:root[data-weather="windy"] {
    --paper: #D6E7F2;
    --ink: #1B2D3A;
    --muted: #425969;
    --accent: #4B7C96;
    --drawing-ink: #1B2D3A;
    --plant: #3C683F;
    --pot: #D9936C;
}

:root[data-weather]:not([data-weather="sunny"]) .fp-art:not(.fp-exiting-sunny) :is(.fp-sun, .fp-cloud) {
    display: none;
}

/* Weather stages live inside .fp-art in paint order:
   back (behind plant) -> plant -> mid (settled snow behind pot rim/shelf) -> scene -> cloud -> front */
.fp-stage-back,
.fp-stage-mid,
.fp-stage-front,
.fp-layer,
.fp-motion {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.fp-stage-back,
.fp-stage-mid,
.fp-stage-front {
    contain: layout style;
}

.fp-motion {
    background-position: center;
    background-size: contain;
    background-repeat: no-repeat;
}

.fp-enter .fp-motion,
.fp-exit .fp-motion,
.fp-entering-sunny :is(.fp-sun, .fp-cloud),
.fp-exiting-sunny :is(.fp-sun, .fp-cloud) {
    will-change: transform, opacity;
}

/* Clip falling drizzle, horizon glow, and melting snow cleanly at the shelf line (y=262). */
.fp-layer-drizzle,
.fp-layer-dusk-back,
.fp-layer-winter-rest {
    clip-path: inset(-120px -120px calc(100% * 28 / 290) -120px);
}

/* Winter snowfall: two vertically tiling sheets clipped just above the uneven shelf line at y=258. */
.fp-layer-snow {
    inset: 0 0 auto;
    height: calc(100% * 258 / 290);
    overflow: hidden;
    overflow: clip;
    -webkit-mask-image: linear-gradient(transparent, #000 8%, #000 92%, transparent);
    mask-image: linear-gradient(transparent, #000 8%, #000 92%, transparent);
}

.fp-snow-sheet {
    position: absolute;
    inset: 0 0 auto;
    aspect-ratio: 400 / 580;
    background-position: 0 0;
    background-size: 100% 50%;
    background-repeat: repeat-y;
}

/* ----------------------------------------------------- per-scene motion ---- */
@keyframes autumn-breeze {
    0%, 100% { transform: rotate(0.5deg); }
    42% { transform: rotate(3.1deg); }
    68% { transform: rotate(1.4deg); }
    86% { transform: rotate(2.6deg); }
}

@keyframes night-sway {
    0%, 100% { transform: rotate(-0.8deg); }
    50% { transform: rotate(0.8deg); }
}

@keyframes fog-sway {
    0%, 100% { transform: rotate(-0.45deg); }
    50% { transform: rotate(0.45deg); }
}

@keyframes dusk-sway {
    0%, 100% { transform: rotate(-0.7deg); }
    50% { transform: rotate(0.7deg); }
}

@keyframes drizzle-sway {
    0%, 100% { transform: rotate(-0.6deg); }
    50% { transform: rotate(0.6deg); }
}

@keyframes windy-gust {
    0%, 100% { transform: rotate(1.1deg); }
    28% { transform: rotate(2.4deg); }
    46% { transform: rotate(1.6deg); }
    66% { transform: rotate(3.3deg); }
    82% { transform: rotate(1.9deg); }
}

@keyframes snowfall {
    from { translate: 0 -50%; }
    to { translate: 0 0; }
}

@keyframes snow-drift {
    from { transform: translateX(-1.5%); }
    to { transform: translateX(1.5%); }
}

/* ------------------------------------------- physical scene transitions ---- */
/* Sunny: sun rises / dips vertically; cloud glides smoothly in / out to the left. */
@keyframes sunny-sun-enter {
    from { transform: translateY(26px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes sunny-sun-exit {
    from { transform: translateY(0); opacity: 1; }
    to { transform: translateY(22px); opacity: 0; }
}

@keyframes sunny-cloud-enter {
    from { translate: -56px 0; opacity: 0; }
    to { translate: 0 0; opacity: 1; }
}

@keyframes sunny-cloud-exit {
    from { translate: 0 0; opacity: 1; }
    to { translate: -52px 0; opacity: 0; }
}

/* Autumn: leaves & wind wisps blow in from the left and sweep off to the right. */
@keyframes autumn-enter {
    0% { transform: translate(-88px, -10px); opacity: 0; }
    35% { opacity: 1; }
    100% { transform: translate(0, 0); opacity: 1; }
}

@keyframes autumn-exit {
    0% { transform: translate(0, 0); opacity: 1; }
    60% { opacity: 0.7; }
    100% { transform: translate(94px, -10px); opacity: 0; }
}

/* Windy afternoon: gusts, cloud & dandelion sweep in from the left and blow off right. */
@keyframes windy-enter {
    0% { transform: translate(-86px, 8px); opacity: 0; }
    35% { opacity: 1; }
    100% { transform: translate(0, 0); opacity: 1; }
}

@keyframes windy-exit {
    0% { transform: translate(0, 0); opacity: 1; }
    60% { opacity: 0.7; }
    100% { transform: translate(96px, -10px); opacity: 0; }
}

/* Foggy morning: low fog banks roll gently in from the left and drift off right. */
@keyframes fog-enter {
    0% { transform: translate(-76px, 4px); opacity: 0; }
    45% { opacity: 1; }
    100% { transform: translate(0, 0); opacity: 1; }
}

@keyframes fog-exit {
    0% { transform: translate(0, 0); opacity: 1; }
    100% { transform: translate(74px, -8px); opacity: 0; }
}

/* Spring drizzle: fine rain drifts gently down from above and clears downward. */
@keyframes drizzle-enter {
    0% { transform: translate(-10px, -48px); opacity: 0; }
    35% { opacity: 1; }
    100% { transform: translate(0, 0); opacity: 1; }
}

@keyframes drizzle-exit {
    0% { transform: translate(0, 0); opacity: 1; }
    100% { transform: translate(-14px, 48px); opacity: 0; }
}

/* Sunshower: passing cloud, sun, shower & rainbow glide in from upper-left and pass on right. */
@keyframes sunshower-enter {
    0% { transform: translate(-60px, -16px); opacity: 0; }
    38% { opacity: 1; }
    100% { transform: translate(0, 0); opacity: 1; }
}

@keyframes sunshower-exit {
    0% { transform: translate(0, 0); opacity: 1; }
    100% { transform: translate(66px, -10px); opacity: 0; }
}

/* Dusk: twilight glow rises behind the shelf; fireflies drift gently in among the branches. */
@keyframes dusk-back-enter {
    0% { transform: translateY(24px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

@keyframes dusk-back-exit {
    0% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(20px); opacity: 0; }
}

@keyframes dusk-front-enter {
    0% { transform: translate(-16px, 20px) scale(0.95); opacity: 0; }
    45% { opacity: 1; }
    100% { transform: translate(0, 0) scale(1); opacity: 1; }
}

@keyframes dusk-front-exit {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(14px, -22px) scale(0.96); opacity: 0; }
}

/* Winter: snowfall drifts down from above; settled snow settles gently in and melts away. */
@keyframes winter-snow-enter {
    0% { transform: translateY(-54px); opacity: 0; }
    40% { opacity: 1; }
    100% { transform: translateY(0); opacity: 1; }
}

@keyframes winter-snow-exit {
    0% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(48px); opacity: 0; }
}

@keyframes winter-rest-enter {
    0% { transform: translateY(6px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

@keyframes winter-rest-exit {
    0% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(5px); opacity: 0; }
}

/* Night: crescent moon & stars glide gently down into the night sky and drift up on exit. */
@keyframes night-enter {
    0% { transform: translate(24px, -28px); opacity: 0; }
    45% { opacity: 1; }
    100% { transform: translate(0, 0); opacity: 1; }
}

@keyframes night-exit {
    0% { transform: translate(0, 0); opacity: 1; }
    100% { transform: translate(-18px, -24px); opacity: 0; }
}

@media (prefers-reduced-motion: no-preference) {
    :root.season-ready {
        transition: --plant 760ms cubic-bezier(0.32, 0, 0.24, 1),
                    --pot 760ms cubic-bezier(0.32, 0, 0.24, 1),
                    --drawing-ink 760ms cubic-bezier(0.32, 0, 0.24, 1),
                    --shelf 760ms cubic-bezier(0.32, 0, 0.24, 1);
    }

    .season-ready body,
    .season-ready footer,
    .season-ready a {
        transition: background-color 760ms cubic-bezier(0.32, 0, 0.24, 1),
                    color 760ms cubic-bezier(0.32, 0, 0.24, 1),
                    text-decoration-color 760ms cubic-bezier(0.32, 0, 0.24, 1);
    }

    :root[data-weather="autumn"] .fp-plant {
        animation: autumn-breeze 6.8s ease-in-out infinite;
    }

    :root[data-weather="night"] .fp-plant {
        animation: night-sway 12.5s ease-in-out infinite;
    }

    :root[data-weather="fog"] .fp-plant {
        animation: fog-sway 14s ease-in-out infinite;
    }

    :root[data-weather="dusk"] .fp-plant {
        animation: dusk-sway 11s ease-in-out infinite;
    }

    :root[data-weather="drizzle"] .fp-plant {
        animation: drizzle-sway 9.5s ease-in-out infinite;
    }

    :root[data-weather="windy"] .fp-plant {
        animation: windy-gust 5.8s ease-in-out infinite;
    }

    .fp-layer-snow-back .fp-snow-sheet {
        animation: snowfall 27s linear infinite, snow-drift 7s ease-in-out infinite alternate;
    }

    .fp-layer-snow-front .fp-snow-sheet {
        animation: snowfall 17s linear infinite, snow-drift 5.5s -2s ease-in-out infinite alternate-reverse;
    }

    /* Enter & exit triggers */
    .fp-art.fp-entering-sunny .fp-sun {
        animation: sunny-sun-enter 820ms cubic-bezier(0.22, 1, 0.36, 1) both;
    }
    .fp-art.fp-entering-sunny .fp-cloud {
        animation: fp-drift 18s ease-in-out infinite, sunny-cloud-enter 840ms cubic-bezier(0.22, 1, 0.36, 1) both;
    }
    .fp-art.fp-exiting-sunny .fp-sun {
        animation: sunny-sun-exit 620ms cubic-bezier(0.45, 0, 0.75, 0.35) both;
    }
    .fp-art.fp-exiting-sunny .fp-cloud {
        animation: fp-drift 18s ease-in-out infinite, sunny-cloud-exit 620ms cubic-bezier(0.45, 0, 0.75, 0.35) both;
    }

    .fp-layer-autumn.fp-enter .fp-motion { animation: autumn-enter 880ms cubic-bezier(0.22, 1, 0.36, 1) both; }
    .fp-layer-autumn.fp-exit .fp-motion { animation: autumn-exit 640ms cubic-bezier(0.45, 0, 0.75, 0.35) both; }

    .fp-layer-windy.fp-enter .fp-motion { animation: windy-enter 880ms cubic-bezier(0.22, 1, 0.36, 1) both; }
    .fp-layer-windy.fp-exit .fp-motion { animation: windy-exit 640ms cubic-bezier(0.45, 0, 0.75, 0.35) both; }

    .fp-layer-fog.fp-enter .fp-motion { animation: fog-enter 940ms cubic-bezier(0.22, 1, 0.36, 1) both; }
    .fp-layer-fog.fp-exit .fp-motion { animation: fog-exit 660ms cubic-bezier(0.45, 0, 0.75, 0.35) both; }

    .fp-layer-drizzle.fp-enter .fp-motion { animation: drizzle-enter 820ms cubic-bezier(0.22, 1, 0.36, 1) both; }
    .fp-layer-drizzle.fp-exit .fp-motion { animation: drizzle-exit 620ms cubic-bezier(0.45, 0, 0.75, 0.35) both; }

    .fp-layer-sunshower.fp-enter .fp-motion { animation: sunshower-enter 860ms cubic-bezier(0.22, 1, 0.36, 1) both; }
    .fp-layer-sunshower.fp-exit .fp-motion { animation: sunshower-exit 640ms cubic-bezier(0.45, 0, 0.75, 0.35) both; }

    .fp-layer-dusk-back.fp-enter .fp-motion { animation: dusk-back-enter 880ms cubic-bezier(0.22, 1, 0.36, 1) both; }
    .fp-layer-dusk-back.fp-exit .fp-motion { animation: dusk-back-exit 620ms cubic-bezier(0.45, 0, 0.75, 0.35) both; }
    .fp-layer-dusk-front.fp-enter .fp-motion { animation: dusk-front-enter 900ms cubic-bezier(0.22, 1, 0.36, 1) both; }
    .fp-layer-dusk-front.fp-exit .fp-motion { animation: dusk-front-exit 620ms cubic-bezier(0.45, 0, 0.75, 0.35) both; }

    .fp-layer-snow.fp-enter .fp-motion { animation: winter-snow-enter 880ms cubic-bezier(0.22, 1, 0.36, 1) both; }
    .fp-layer-snow.fp-exit .fp-motion { animation: winter-snow-exit 640ms cubic-bezier(0.45, 0, 0.75, 0.35) both; }
    .fp-layer-winter-rest.fp-enter .fp-motion { animation: winter-rest-enter 840ms cubic-bezier(0.22, 1, 0.36, 1) both; }
    .fp-layer-winter-rest.fp-exit .fp-motion { animation: winter-rest-exit 600ms cubic-bezier(0.45, 0, 0.75, 0.35) both; }

    .fp-layer-night.fp-enter .fp-motion { animation: night-enter 880ms cubic-bezier(0.22, 1, 0.36, 1) both; }
    .fp-layer-night.fp-exit .fp-motion { animation: night-exit 620ms cubic-bezier(0.45, 0, 0.75, 0.35) both; }
}
