/*
 * scene.css — the live monsoon sky behind body.mx pages (static/scene.js paints it; templates/_backdrop.html).
 *
 * The backdrop stays fixed behind everything (z-index 0, aria-hidden). Inside it a "stage" is laid exactly over the
 * page's .band (the sky area) and scrolls with it; nothing is painted anywhere else. Motion here is transform /
 * opacity only (canvas drawing for the rain). html.still and prefers-reduced-motion: one still frame.
 *
 * Theme tokens come from Core (monsoon.css): --band-top --band-mid --band-mist --band-ink --cloud-lit --cloud-shade
 * --band-glow (or --glow when it is a plain colour) --drop (r, g, b) --lantern, and when present --sun --storm-base
 * --band-after. The --sc-* values below are only fallbacks (values from docs/options/v3/tokens.json), used while
 * a Core token is missing or is not a plain colour. --scene-sun is Scene's own fallback for the sun disc.
 */
html[data-theme="day"] {
    --sc-band-top: #A8CAE6; --sc-band-mid: #CFE4EE; --sc-band-mist: #F5D6BE; --sc-band-ink: #0F242B;
    --sc-cloud-lit: #F7F9F6; --sc-cloud-shade: #B5C8D3; --sc-glow: #FBE4CE; --sc-drop: 62, 92, 116; --sc-lantern: #F2B63C;
    --scene-sun: #FFF4D0;
}
html[data-theme="evening"] {
    --sc-band-top: #3E2E27; --sc-band-mid: #7A4F37; --sc-band-mist: #C9A678; --sc-band-ink: #F7EAD3;
    --sc-cloud-lit: #B58463; --sc-cloud-shade: #4A342B; --sc-glow: #F0A650; --sc-drop: 232, 216, 192; --sc-lantern: #F3B84B;
    --scene-sun: #FFD58A;
}
html[data-theme="night"] {
    --sc-band-top: #0E1220; --sc-band-mid: #262B44; --sc-band-mist: #5C4B66; --sc-band-ink: #ECEAF3;
    --sc-cloud-lit: #4A4362; --sc-cloud-shade: #151A2C; --sc-glow: #7A6483; --sc-drop: 174, 185, 214; --sc-lantern: #E9B24C;
    --scene-sun: #DCE4E1;
}

/* the fixed layer behind the page: a plain sky colour wherever the stage is not (rubber-band overscroll, gaps) */
body.mx .backdrop.scene { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; filter: none;
    background: linear-gradient(180deg, var(--band-top, var(--sc-band-top)) 0, var(--band-mid, var(--sc-band-mid)) 70%); }
.scene .sc-stage { position: absolute; left: 0; top: 0; width: 100%; height: 0; overflow: hidden; contain: strict; }
.scene .sc-stage > *, .scene .sc-par > * { position: absolute; left: 0; top: 0; }
.scene .sc-base, .scene .sc-glow, .scene .sc-after, .scene .sc-flash, .scene .sc-par { inset: 0; }
.scene .sc-after { opacity: 0; transition: opacity 2400ms cubic-bezier(.215, .61, .355, 1); }
.scene.is-after .sc-after { opacity: 1; }
.scene .sc-sun { width: 132px; height: 132px; margin: -66px 0 0 -66px; border-radius: 50%; opacity: 0; }
.scene .sc-sun.on { opacity: var(--sun-o, 1); }
.scene .sc-mist { left: 0; right: 0; bottom: 0; top: auto; }
.scene .sc-mist i { position: absolute; left: -30%; width: 160%; height: 70px; top: 10px; border-radius: 50%;
                    opacity: var(--mist-o, .6); }
.scene .sc-mist i + i { top: 30px; left: -50%; }
.scene .sc-flash { opacity: 0; }
/* the moon (scene.js places it, only when it is up): its dark side a shade of the sky, the lit side the moon token */
.scene .sc-moon { width: 40px; height: 40px; opacity: 0; overflow: visible;
                  filter: drop-shadow(0 0 10px color-mix(in srgb, var(--moon, #EFEBD6) 45%, transparent)); }
.scene .sc-moon.on { opacity: 1; }
.scene .sc-moon-dark { fill: var(--moon-dark, #222844); opacity: .8; }
.scene .sc-moon-lit { fill: var(--moon, #EFEBD6); }
/* the future video loop (empty slot, docs/research/v3/ASSETS.md): fills the stage under the clouds */
.scene .sc-video { inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .9; }
.scene .sc-grain { opacity: .5; }
.scene .sc-ring { width: 56px; height: 12px; margin: -6px 0 0 -28px; border-radius: 50%; opacity: 0; transform: scale(.2);
                  border: 1.5px solid rgba(var(--ring, var(--sc-drop)), .85); }
.scene .sc-ring::after { content: ""; position: absolute; inset: 2px 13px; border-radius: 50%; border: 1px solid rgba(var(--ring, var(--sc-drop)), .55); }
.scene canvas { display: block; }

/* phones and login (band in the page flow): the backdrop sits at the top of the document and scrolls natively with
   the band (scene.js sets its height); desktop (sticky band): fixed. Cloud parallax only as a scroll-driven
   animation (off the main thread); scene.js sets --sc-smax (how far the page can scroll). */
body.mx .backdrop.scene.sc-doc { position: absolute; top: 0; left: 0; right: 0; bottom: auto; }
@keyframes sc-par { to { transform: translate3d(0, calc(var(--sc-smax, 0) * .14px), 0); } }
@supports (animation-timeline: scroll()) {
    .scene.sc-css-par.sc-live .sc-par { animation: sc-par 1s linear both; animation-timeline: scroll(root block); }
}

/* clouds drift with the wind (speed and direction set by scene.js from the forecast), the mist breathes */
@keyframes sc-drift { from { transform: translate3d(var(--from, 0), 0, 0); } to { transform: translate3d(var(--to, 0), 0, 0); } }
@keyframes sc-mist { to { transform: translate3d(14%, 0, 0); } }
.scene.sc-live .sc-drift { animation: sc-drift var(--dur, 60s) linear infinite; }
.scene.sc-live .sc-mist i { animation: sc-mist 18s ease-in-out infinite alternate; }
.scene.sc-live .sc-mist i + i { animation-duration: 14s; animation-direction: alternate-reverse; }
.scene.sc-paused .sc-drift, .scene.sc-paused .sc-mist i { animation-play-state: paused; }

/* screenshots and "Reduce motion": one calm frame (scene.js draws it; nothing here moves) */
html.still .scene .sc-drift, html.still .scene .sc-mist i { animation: none; }
html.still .scene .sc-after { transition: none; }
html.still .scene .sc-ring { display: none; }
@media (prefers-reduced-motion: reduce) {
    .scene .sc-drift, .scene .sc-mist i, .scene .sc-par { animation: none; }
    .scene .sc-after { transition: none; }
    .scene .sc-ring { display: none; }
}
