/* Oct 16, 2026: the Metabolic Spirit World behind Cook, Move and Scan (realm-backdrop.js).
   The same picture, crop and veil as Community (community-spirit.css), as one fixed wallpaper under the pages, plus a quiet life of
   its own (drift, breathing light, rising motes; transform and opacity only). It never takes a tap. Today/Home is not touched. */

/* ---------- the layer (wallpaper and the copy inside the Scan camera) ---------- */
.rw-layer { position: absolute; inset: 0; overflow: hidden; pointer-events: none !important; touch-action: none; background: transparent; contain: strict; }
.rw-layer * { pointer-events: none !important; }
/* no picture (task 1 rework): the live 3D world shows through, pulled out into the spirit world behind these pages */

/* breathing light: three soft glows in the picture's own colours, slowly swelling and fading out of step */
.rw-layer .rw-breath { position: absolute; inset: 0; }
.rw-layer .rw-breath b { position: absolute; border-radius: 50%; opacity: .2; animation: rwBreath 11s ease-in-out infinite alternate; will-change: opacity, transform; }
.rw-layer .rw-breath .b1 { left: -12%; top: 6%; width: 70vmax; height: 70vmax; background: radial-gradient(circle, rgba(64, 156, 255, .34), rgba(64, 156, 255, 0) 62%); }
.rw-layer .rw-breath .b2 { right: -18%; top: 34%; width: 64vmax; height: 64vmax; background: radial-gradient(circle, rgba(160, 110, 255, .28), rgba(160, 110, 255, 0) 62%); animation-duration: 15s; animation-delay: -5s; }
.rw-layer .rw-breath .b3 { left: 10%; bottom: -22%; width: 58vmax; height: 58vmax; background: radial-gradient(circle, rgba(80, 220, 170, .22), rgba(80, 220, 170, 0) 62%); animation-duration: 19s; animation-delay: -9s; }
@keyframes rwBreath { 0% { opacity: .12; transform: scale(.94); } 100% { opacity: .5; transform: scale(1.04); } }

/* motes of metabolic light rising slowly with a little sway; size, colour, path and timing come from realm-backdrop-core.js */
.rw-layer .rw-motes { position: absolute; inset: 0; }
.rw-layer .rw-motes i { position: absolute; width: var(--s, 3px); height: var(--s, 3px); margin: calc(var(--s, 3px) / -2); border-radius: 50%; opacity: 0;
    background: radial-gradient(circle, hsla(var(--h, 205), 100%, 88%, 1) 0%, hsla(var(--h, 205), 95%, 66%, .75) 45%, hsla(var(--h, 205), 90%, 60%, 0) 100%);
    animation: rwMote var(--d, 20s) linear var(--dl, 0s) infinite; will-change: transform, opacity; }
@keyframes rwMote {
    0% { opacity: 0; transform: translate3d(0, 0, 0) scale(.6); }
    18% { opacity: var(--a, .7); }
    50% { transform: translate3d(calc(var(--dx, 0px) * .6), calc(var(--dy, -40px) * .5), 0) scale(1.15); }
    82% { opacity: var(--a, .7); }
    100% { opacity: 0; transform: translate3d(var(--dx, 0px), var(--dy, -40px), 0) scale(.7); }
}

/* the veil: identical to Community's, so the two pages read as the same place and text stays readable */
.rw-layer .rw-veil { position: absolute; inset: 0;
    background: radial-gradient(120% 80% at 50% 45%, rgba(3,8,20,.18) 0%, rgba(3,8,20,.42) 70%, rgba(3,8,20,.58) 100%),
                linear-gradient(180deg, rgba(3,8,20,.5) 0%, rgba(3,8,20,0) 22%, rgba(3,8,20,0) 62%, rgba(3,8,20,.62) 100%); }
html[data-theme="light"] .rw-layer .rw-veil { background: radial-gradient(120% 80% at 50% 45%, rgba(3,8,20,.1) 0%, rgba(3,8,20,.32) 100%), linear-gradient(180deg, rgba(3,8,20,.36) 0%, rgba(3,8,20,0) 24%, rgba(3,8,20,0) 64%, rgba(3,8,20,.46) 100%); }

/* ---------- the wallpaper behind Cook, Move and Scan ---------- */
/* in #app right under #main (above the live 3D world #bw3Back); #app is the whole screen, so it fills an iPad edge to edge */
#app > #rwBack.rw-back { z-index: 0; opacity: 0; visibility: hidden; transform: translateZ(0);
    transition: opacity .45s ease, visibility 0s linear .45s; }
#app > #rwBack.rw-back.rw-show { opacity: 1; visibility: visible; transition: opacity .45s ease, visibility 0s; }
#app > #rwBack.rw-back.rw-instant { transition: none !important; }
/* from Today: it comes into view from a little further away, settling as the page arrives */
#app > #rwBack.rw-back.rw-show.rw-arrive { animation: rwArrive .65s cubic-bezier(.22, .8, .24, 1) both; transition: visibility 0s; }
@keyframes rwArrive { 0% { opacity: 0; transform: scale(1.08); } 100% { opacity: 1; transform: scale(1); } }
/* nothing animates while the layer is hidden or covered by the camera layer */
.rw-layer.rw-still *, #app > #rwBack.rw-under * { animation-play-state: paused !important; }
#app > #rwBack.rw-back.rw-still { visibility: hidden; }
/* Oct 28 2026 (item 29, iPhone memory): while the wallpaper is not shown (Today, Community) its three 70vmax breathing lights and
   the motes keep no compositing layer of their own (will-change) and stand still; they get both back the moment it shows */
#app > #rwBack.rw-back:not(.rw-show) * { will-change: auto !important; animation-play-state: paused !important; }

/* ---------- Scan: the camera screen in the same living world as Community, Cook and Move ----------
   E-man (Oct 16): "our background for Scan a barcode should be the metabolic world, the same as every other page". While the
   camera is open full screen (html.rw-scanworld, realm-backdrop.js) the camera screen is see-through: under it are this
   wallpaper layer (#rwBack) and the live 3D world pulled out into the spirit world (body-world-3d.js), exactly as behind Cook and
   Move. The page that lies under the camera is hidden (its dock stays), so only the world shows until the feed fades in. */
html.rw-scanworld .b3-cam.rw-scan { background: transparent !important; background-image: none !important; }
html.rw-scanworld.b3-camon body, html.rw-scanworld.g2f-gap.b3-camon body { background: #02060f !important; }
html.rw-scanworld #app #main > :not(.lg-in):not(.lg-peek):not(.lg-out) { visibility: hidden !important; opacity: 0 !important; pointer-events: none !important; }   /* Oct 21: no menu bar to keep visible */
/* iPad held sideways: the side rail is not the flat dock, so the camera covers it as before; it is not shown through it either
   (opacity, not visibility: scan-glass.js reads visibility to decide whether the dock is flat) */
/* the herb world's own camera keeps its copy of the layer (it sits in Misty's sheet, away from the 3D world) */
.b3-cam.rw-scan > .rw-cam { z-index: 0; transition: opacity .8s ease; }
.b3-cam.rw-scan.rw-feed.live > .rw-cam { opacity: .0; }
.b3-cam.rw-scan.rw-feed.live > .rw-cam * { animation-play-state: paused !important; }
.b3-cam.rw-scan video { transition: opacity .8s cubic-bezier(.25, .8, .25, 1) !important; }
/* the feed shows only once a frame really plays; until then (and after it stops) the world is what you see */
.b3-cam.rw-scan:not(.rw-feed) video { opacity: 0 !important; }
.b3-cam.rw-scan.rw-feed video { opacity: 1 !important; }
/* the camera's darkening (vignette and top fade) is for the feed: before it plays the world looks exactly as on Cook and Move */
html.rw-scanworld .b3-cam.rw-scan .b3-shade { transition: opacity .8s ease; }
html.rw-scanworld .b3-cam.rw-scan:not(.rw-feed) .b3-shade { opacity: 0; }
html.rw-scanworld .b3-cam.rw-scan:not(.rw-feed) .b3-ctop { background: none !important; }

/* ---------- reduced motion / transparency ---------- */
@media (prefers-reduced-motion: reduce) {
    .rw-layer .rw-breath b { animation: none !important; opacity: .28; transform: none; will-change: auto; }
    .rw-layer .rw-motes { display: none; }
    #app > #rwBack.rw-back.rw-show.rw-arrive { animation: none !important; }
    #app > #rwBack.rw-back, #app > #rwBack.rw-back.rw-show { transition-duration: .2s, 0s; }
    .b3-cam.rw-scan video { transition-duration: .25s !important; }
}
