/*
 * Animated sky behind the dashboard. One modifier per scene (condition + day/night),
 * set on .weather by the server; the layers are rendered by templates/station/_sky.html.twig.
 * Only transform/opacity/background-position are animated – cheap enough for old tablets.
 */

/* ---------------------------------------------------------------- backgrounds */

.weather { background: linear-gradient(180deg, #2f6fbf 0%, #5d9be0 100%); }

.scene--clear-day { background: linear-gradient(180deg, #1f6fd1 0%, #4f9ae8 55%, #8cc3f2 100%); }
.scene--partly-cloudy-day { background: linear-gradient(180deg, #3a75bb 0%, #6a9fd6 60%, #9cc0e4 100%); }
.scene--cloudy-day { background: linear-gradient(180deg, #5d6d7f 0%, #7d8c9c 60%, #9ba7b3 100%); }
.scene--fog-day { background: linear-gradient(180deg, #8b96a1 0%, #a9b2bb 60%, #c6ccd2 100%); }
.scene--light-rain-day,
.scene--rain-day,
.scene--heavy-rain-day { background: linear-gradient(180deg, #3f4a58 0%, #5a6676 60%, #75808e 100%); }
.scene--sleet-day,
.scene--snow-day { background: linear-gradient(180deg, #66768b 0%, #8494a7 60%, #9eabbb 100%); }

.scene--clear-night,
.scene--partly-cloudy-night { background: linear-gradient(180deg, #070e22 0%, #142349 60%, #22386a 100%); }
.scene--cloudy-night,
.scene--fog-night,
.scene--light-rain-night,
.scene--rain-night,
.scene--heavy-rain-night,
.scene--sleet-night,
.scene--snow-night { background: linear-gradient(180deg, #11161f 0%, #1f2734 60%, #2d3645 100%); }

.scene--stats { background: linear-gradient(180deg, #1c3a6b 0%, #2f5c99 60%, #3f74b5 100%); }

/* Dawn and dusk: warm glow at the horizon */
.is-twilight::before {
    content: "";
    position: absolute;
    inset: 40% 0 0;
    z-index: 0;
    background: linear-gradient(0deg, rgb(255 150 80 / 0.45) 0%, rgb(255 120 90 / 0.15) 45%, transparent 100%);
    pointer-events: none;
}

/* ---------------------------------------------------------------- layers */

.sky {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.sky > * { position: absolute; }

/* Sun */
.sky__sun {
    top: -6rem;
    right: -4rem;
    width: 22rem;
    height: 22rem;
    border-radius: 50%;
    background: radial-gradient(circle, #fff7c8 0%, #ffe38a 14%, rgb(255 214 102 / 0.55) 22%, rgb(255 214 102 / 0.12) 45%, transparent 68%);
    animation: sun-pulse 6s ease-in-out infinite;
}

.sky__sun-rays {
    position: absolute;
    inset: -30%;
    border-radius: 50%;
    background: repeating-conic-gradient(rgb(255 240 190 / 0.16) 0deg 4deg, transparent 4deg 18deg);
    -webkit-mask-image: radial-gradient(circle, #000 18%, transparent 62%);
    mask-image: radial-gradient(circle, #000 18%, transparent 62%);
    animation: spin 90s linear infinite;
}

/* Moon (crescent) */
.sky__moon {
    top: 3.5rem;
    right: 12%;
    width: 4.5rem;
    height: 4.5rem;
    border-radius: 50%;
    box-shadow: -1.1rem 0.6rem 0 0 #f2efd5;
    filter: drop-shadow(0 0 1.2rem rgb(242 239 213 / 0.35));
    transform: rotate(-20deg);
}

/* Stars */
.sky__stars {
    inset: 0 0 35%;
    background-image: url("../images/stars-QtsBnG5.svg");
    background-size: 400px 400px;
    -webkit-mask-image: linear-gradient(180deg, #000 30%, transparent 100%);
    mask-image: linear-gradient(180deg, #000 30%, transparent 100%);
    animation: twinkle 5s ease-in-out infinite alternate;
}

.sky__stars--dim { opacity: 0.25; animation: none; }

/* Clouds */
.sky__cloud {
    width: 20rem;
    height: 11rem;
    fill: rgb(255 255 255 / 0.7);
    filter: drop-shadow(0 0.6rem 1.2rem rgb(0 0 0 / 0.08));
    animation: drift 70s linear infinite;
}

.sky__cloud--grey { fill: rgb(214 222 232 / 0.55); }
.scene--light-rain-night .sky__cloud--grey,
.scene--rain-night .sky__cloud--grey,
.scene--heavy-rain-night .sky__cloud--grey,
.scene--cloudy-night .sky__cloud--grey,
.scene--fog-night .sky__cloud--grey,
.scene--sleet-night .sky__cloud--grey,
.scene--snow-night .sky__cloud--grey { fill: rgb(120 132 150 / 0.4); }

.sky__cloud--a { top: 4%; left: -22rem; animation-duration: 75s; }
.sky__cloud--b { top: 16%; left: -22rem; width: 15rem; animation-duration: 105s; animation-delay: -45s; opacity: 0.8; }
.sky__cloud--c { top: 0; left: -22rem; width: 26rem; height: 14rem; animation-duration: 120s; animation-delay: -80s; }
.sky__cloud--d { top: 26%; left: -22rem; width: 18rem; animation-duration: 90s; animation-delay: -20s; opacity: 0.7; }

/* Fog */
.sky__fog {
    left: -50%;
    width: 200%;
    height: 40%;
    background: radial-gradient(ellipse at center, rgb(255 255 255 / 0.5) 0%, transparent 65%);
    filter: blur(10px);
    animation: fog-drift 40s ease-in-out infinite alternate;
}

.sky__fog--a { top: 30%; }
.sky__fog--b { top: 55%; animation-duration: 55s; animation-direction: alternate-reverse; opacity: 0.7; }

/* Rain */
.sky__rain {
    inset: -240px 0 0;
    background-image: url("../images/rain-ZNz7_L9.svg");
    background-size: 240px 240px;
    animation: fall 0.55s linear infinite;
    transform: rotate(8deg) scale(1.2);
}

.sky__rain--far {
    opacity: 0.45;
    background-size: 160px 160px;
    animation-duration: 0.8s;
    animation-name: fall-far;
}

.scene--light-rain-day .sky__rain,
.scene--light-rain-night .sky__rain { opacity: 0.55; animation-duration: 0.75s; }

.scene--heavy-rain-day .sky__rain--near,
.scene--heavy-rain-night .sky__rain--near { animation-duration: 0.4s; background-size: 180px 180px; animation-name: fall-heavy; }

/* Snow */
.sky__snow {
    inset: -240px 0 0;
    background-image: url("../images/snow-_AUfchk.svg");
    background-size: 240px 240px;
    animation: snow 9s linear infinite;
}

.sky__snow--far {
    opacity: 0.6;
    background-size: 150px 150px;
    animation-duration: 14s;
    animation-name: snow-far;
}

/* Wind gusts */
.sky__wind {
    left: -40%;
    width: 40%;
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(90deg, transparent, rgb(255 255 255 / 0.45), transparent);
    animation: gust 3.5s ease-in infinite;
}

.sky__wind--a { top: 38%; }
.sky__wind--b { top: 52%; animation-delay: -1.8s; width: 30%; }

/* ---------------------------------------------------------------- keyframes */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes sun-pulse { 50% { transform: scale(1.04); } }
@keyframes twinkle { from { opacity: 0.65; } to { opacity: 1; } }
@keyframes drift { from { transform: translateX(0); } to { transform: translateX(calc(100vw + 30rem)); } }
@keyframes fog-drift { from { transform: translateX(-8%); } to { transform: translateX(8%); } }
@keyframes fall { from { background-position: 0 0; } to { background-position: -40px 240px; } }
@keyframes fall-far { from { background-position: 0 0; } to { background-position: -27px 160px; } }
@keyframes fall-heavy { from { background-position: 0 0; } to { background-position: -30px 180px; } }
@keyframes snow { from { background-position: 0 0; } to { background-position: 60px 240px; } }
@keyframes snow-far { from { background-position: 0 0; } to { background-position: -40px 150px; } }
@keyframes gust {
    0% { transform: translateX(0); opacity: 0; }
    20% { opacity: 1; }
    100% { transform: translateX(350%); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .sky *, .sky { animation: none !important; }
}
