/* The living detective-office backdrop (src/ui/art/scene.js builds the layers; index.html holds the static ones).
   Everything moves with transform or opacity only. The mood follows <html data-screen="...">:
   home / picker -> dusk, warm lamp, drifting dust; case -> night rain, lamp up; archive / file -> clear night; closed -> golden light.
   Reduced motion (the .reduced-motion class from the Parent Zone, or the OS setting) stops every animation and removes the rain. */
html {
  --m-dusk: 1; --m-night: 0; --m-gold: 0;
  --rain: 0; --lamp: .72; --lights: 1; --stars: .55; --dust: .8; --moon: .7;
  --prop-h: clamp(130px, 22vh, 230px);
}
html[data-screen="archive"], html[data-screen="file"] { --m-dusk: 0; --m-night: 1; --stars: 1; --moon: 1; --lamp: .6; --dust: .55; }
html[data-screen="case"] { --m-dusk: 0; --m-night: 1; --rain: 1; --lamp: .92; --lights: .85; --stars: .2; --moon: .35; --dust: .3; }
html[data-screen="closed"] { --m-dusk: 0; --m-night: 0; --m-gold: 1; --lamp: 1; --lights: 1; --stars: .35; --moon: .5; --dust: 1; }

#backdrop { position: absolute; inset: 0; z-index: 0; background: #060e22; overflow: hidden; contain: strict; }
#backdrop > * { position: absolute; pointer-events: none; }
.sc-sky { inset: 0; transition: opacity 1.1s ease; }
.sc-dusk { background: linear-gradient(#0a1230 0%, #1b2b66 32%, #4b4688 56%, #b4586a 78%, #ee9f62 100%); opacity: var(--m-dusk); }
.sc-night { background: linear-gradient(#050b1d 0%, #0a1a3c 42%, #14305f 78%, #1d4575 100%); opacity: var(--m-night); }
.sc-gold { background: linear-gradient(#0c2547 0%, #1d4f6e 32%, #c9854a 74%, #ffd27a 100%); opacity: var(--m-gold); }
.sc-layer { inset: 0; width: 100%; height: 100%; will-change: transform, opacity; transition: opacity 1.1s ease; }
.sc-stars { opacity: var(--stars); }
.sc-stars-a { animation: scTwinkleA 4.2s ease-in-out infinite alternate; }
.sc-stars-b { animation: scTwinkleB 5.6s ease-in-out infinite alternate; }
.sc-moon { opacity: var(--moon); }
.sc-far { transform: scale(1.05); animation: scDriftFar 170s ease-in-out infinite alternate; }
.sc-far-lights { transform: scale(1.05); opacity: var(--lights); animation: scDriftFar 170s ease-in-out infinite alternate, scTwinkleC 7s ease-in-out infinite alternate; }
.sc-near { transform: scale(1.07); animation: scDriftNear 120s ease-in-out infinite alternate; }
.sc-near-lights { transform: scale(1.07); opacity: var(--lights); animation: scDriftNear 120s ease-in-out infinite alternate, scFlick 9s steps(1) infinite; }
.sc-water { transform: scale(1.07); }
.sc-glints { transform: scale(1.07); opacity: .8; animation: scShimmer 3.2s ease-in-out infinite alternate; }
.sc-boat { animation: scBoat 150s linear infinite; }
.sc-prop { bottom: calc(var(--prop-h) * .105); height: var(--prop-h); width: auto; max-width: 24vw; filter: drop-shadow(0 6px 10px rgba(0,0,0,.45)); display: none; }
.sc-prop-left { left: 3vw; }
.sc-prop-right { right: 3vw; }
.sc-sill { left: 0; right: 0; bottom: 0; height: calc(var(--prop-h) * .105 + 6px); background: linear-gradient(#4a3322 0 5px, #2a1d14 5px); box-shadow: 0 -8px 18px rgba(0,0,0,.4); display: none; }
.sc-steam { animation: scSteam 3.6s ease-in-out infinite; }
@media (min-width: 900px) { .sc-prop, .sc-sill { display: block; } }

/* rain: two repeating streak tiles falling at different speeds (vertical translate = one tile, so the loop is seamless) */
.sc-rain { left: -60px; right: -60px; top: -240px; bottom: 0; opacity: calc(var(--rain) * .5); transition: opacity 1s ease; will-change: transform; animation: scRain .62s linear infinite;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cg stroke='%23b9d4ff' stroke-width='1.4' stroke-linecap='round' opacity='.75'%3E%3Cpath d='M20 10l-5 26M70 120l-6 30M120 50l-5 24M160 180l-6 30M210 90l-5 26M45 200l-5 24M190 20l-5 22M100 215l-4 20'/%3E%3C/g%3E%3C/svg%3E"); }
.sc-rain.r2 { opacity: calc(var(--rain) * .3); animation-duration: .9s; background-size: 160px 160px; top: -160px; }
.sc-lamp { inset: 0; opacity: var(--lamp); transition: opacity 1s ease; background: radial-gradient(70% 62% at 96% 104%, rgba(255,190,100,.42), rgba(255,170,80,.12) 48%, transparent 72%), radial-gradient(46% 44% at 2% 104%, rgba(255,190,110,.16), transparent 70%); }
.sc-lamp::before { content: ''; position: absolute; inset: 0; background: radial-gradient(50% 46% at 96% 100%, rgba(255,214,140,.3), transparent 70%); animation: scLamp 6.5s steps(1) infinite; }
.sc-frame { inset: 0; box-shadow: inset 0 0 0 clamp(5px, .9vw, 14px) #170f09, inset 0 0 0 clamp(7px, 1.15vw, 18px) #4a3322, inset 0 0 90px rgba(0,0,0,.5); }
.sc-frame::after { content: ''; position: absolute; inset: 0; background: linear-gradient(112deg, rgba(255,255,255,.07) 0 14%, transparent 14% 19%, rgba(255,255,255,.045) 19% 27%, transparent 27%); }
.sc-dust { inset: 0; opacity: var(--dust); transition: opacity 1s ease; }
.sc-dust i { position: absolute; left: var(--x); top: var(--y); width: var(--s); height: var(--s); border-radius: 50%; background: #ffe3a6; box-shadow: 0 0 8px rgba(255,214,140,.8); opacity: 0; will-change: transform, opacity; animation: scMote var(--d) linear var(--dl) infinite; }
.sc-vig { inset: 0; background: radial-gradient(120% 95% at 50% 40%, transparent 42%, rgba(3,8,20,.55)), linear-gradient(rgba(4,9,22,.5), transparent 20%, transparent 76%, rgba(4,9,22,.35)); }

@keyframes scTwinkleA { from { opacity: calc(var(--stars) * .35); } to { opacity: var(--stars); } }
@keyframes scTwinkleB { from { opacity: var(--stars); } to { opacity: calc(var(--stars) * .3); } }
@keyframes scTwinkleC { from { opacity: calc(var(--lights) * .72); } to { opacity: var(--lights); } }
@keyframes scDriftFar { from { transform: scale(1.05) translate3d(-1.1%, 0, 0); } to { transform: scale(1.05) translate3d(1.1%, 0, 0); } }
@keyframes scDriftNear { from { transform: scale(1.07) translate3d(1.8%, 0, 0); } to { transform: scale(1.07) translate3d(-1.8%, 0, 0); } }
@keyframes scFlick { 0%, 100% { opacity: var(--lights); } 38% { opacity: calc(var(--lights) * .86); } 41% { opacity: var(--lights); } 77% { opacity: calc(var(--lights) * .92); } 80% { opacity: var(--lights); } }
@keyframes scShimmer { from { opacity: .45; transform: scale(1.07) translate3d(-5px, 0, 0); } to { opacity: .9; transform: scale(1.07) translate3d(5px, 0, 0); } }
@keyframes scBoat { from { transform: translate3d(-14%, 0, 0); } to { transform: translate3d(112%, 0, 0); } }
@keyframes scRain { to { transform: translate3d(0, 240px, 0); } }
@keyframes scLamp { 0%, 100% { opacity: 1; } 22% { opacity: .82; } 25% { opacity: 1; } 61% { opacity: .9; } 63% { opacity: .78; } 66% { opacity: 1; } }
@keyframes scMote { 0% { opacity: 0; transform: translate3d(0, 0, 0); } 18% { opacity: .65; } 78% { opacity: .35; } 100% { opacity: 0; transform: translate3d(var(--dx), -150px, 0); } }
@keyframes scSteam { 0%, 100% { opacity: .15; transform: translateY(2px); } 50% { opacity: .5; transform: translateY(-4px); } }

/* calm motion: nothing moves, no rain */
.reduced-motion #backdrop *, .reduced-motion #backdrop *::before { animation: none !important; transition: none !important; }
.reduced-motion .sc-rain, .reduced-motion .sc-dust i { display: none; }
@media (prefers-reduced-motion: reduce) {
  #backdrop *, #backdrop *::before { animation: none !important; transition: none !important; }
  .sc-rain, .sc-dust i { display: none; }
}
