/*
 * Painted backdrop shared by the landing page and the pages it links to.
 * assets/js/scene_background.js appends the canvas to #bg, beneath the
 * template's overlay, and toggles bg-canvas / bg-photo on <body>.
 */

/* Pointer parallax, shared by the painting and its moving layer. The values
   are set from JavaScript (0 at rest), the same way the portal page does it. */
:root {
	--px: 0;
}

/* The picture is scaled just enough that the parallax shift never uncovers
   an edge; the overflow is cropped here rather than on the page. The dark
   base fills the first frame, before a scene or a photo has painted, so the
   page never flashes the browser's white canvas. */
#bg {
	overflow: hidden;
	background-color: #0a1118;
}

#sceneBg {
	display: block;
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	z-index: 0;
	opacity: 1;
	transform: translate3d(calc(var(--px) * 0.8%), 0, 0) scale(1.03);
	transition: opacity 0.6s ease-in-out;
}

/* Transparent layer holding the moving parts (glitter, foam, fog, birds).
   It uses the same world aspect as the painting, so object-fit lines the
   two up exactly. */
#sceneBgFx {
	display: block;
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	z-index: 1;
	pointer-events: none;
	opacity: 1;
	/* Same transform as the painting, so the two stay in register. */
	transform: translate3d(calc(var(--px) * 0.8%), 0, 0) scale(1.03);
	transition: opacity 0.6s ease-in-out;
}

/* The photo layer is hidden while a drawn scene is showing, but keeps its
   own transform/filter transitions for when it comes back. */
body.bg-canvas #bg:after {
	opacity: 0;
	-moz-transition: opacity 0.6s ease-in-out, -moz-transform 0.325s ease-in-out, -moz-filter 0.325s ease-in-out;
	-webkit-transition: opacity 0.6s ease-in-out, -webkit-transform 0.325s ease-in-out, -webkit-filter 0.325s ease-in-out;
	transition: opacity 0.6s ease-in-out, transform 0.325s ease-in-out, filter 0.325s ease-in-out;
}

body.bg-photo #sceneBg,
body.bg-photo #sceneBgFx {
	opacity: 0;
}

/* The black preload veil covers the gap before the photo has arrived. A
   drawn backdrop puts its stand-in on the canvas in the first frame, before
   the scene shader has even compiled, so there is nothing left to cover:
   leaving the veil on would turn the compile time back into a black screen.
   The photo mode keeps it. */
body.bg-canvas.is-preload #bg:before {
	background-color: transparent;
}

body.is-preload #sceneBg,
body.is-preload #sceneBgFx,
body.is-preload #bg:after {
	transition: none;
}

/* The system setting wins: no ambient motion at all. The painting itself
   is untouched, so nothing is lost but the movement. */
@media (prefers-reduced-motion: reduce) {
	#sceneBgFx {
		display: none;
	}
}
