/* magic.css: magic all along the way (owned by the magic and game builder).
   Layers (tokens.css): the world (--z-world 0) < coloured light (4) < #petals canvas (5) < the page (main, --z-station)
   < the sparkle trail (#mg-front, --z-magic) < the game locket (--z-game) < sound button and menu. */

/* the page sits above the magic back layer (the builders' contract: main is the --z-station layer) */
main#main{position:relative;z-index:var(--z-station)}
/* the shared magic canvas now floats just above the journey's world, behind the page */
#petals{position:fixed;inset:0;width:100%;height:100%;z-index:5;pointer-events:none}

/* ---------- coloured light from the stained glass: soft pools, very subtle ---------- */
.mg-glow{position:fixed;inset:0;z-index:4;pointer-events:none;overflow:hidden;opacity:calc(.85 - var(--night, 0) * .55)}
.mg-glow i{position:absolute;width:70vmax;height:70vmax;border-radius:50%;opacity:.16;will-change:transform;
  background:radial-gradient(closest-side, var(--c) 0%, var(--c2) 45%, transparent 100%);
  animation:mg-drift 46s ease-in-out infinite alternate}
.mg-glow i:nth-child(1){--c:rgba(143,170,208,1);--c2:rgba(143,170,208,.4);left:-30vmax;top:-10vmax}
.mg-glow i:nth-child(2){--c:rgba(201,186,224,1);--c2:rgba(201,186,224,.4);right:-34vmax;top:30vh;animation-duration:58s;animation-delay:-20s}
.mg-glow i:nth-child(3){--c:rgba(233,214,166,1);--c2:rgba(233,214,166,.4);left:-10vmax;bottom:-46vmax;animation-duration:64s;animation-delay:-35s;opacity:.2}
.mg-glow.mg-still i{animation:none}
@keyframes mg-drift{0%{transform:translate3d(0,0,0) scale(1)}50%{transform:translate3d(14vmax,10vmax,0) scale(1.12)}100%{transform:translate3d(-6vmax,22vmax,0) scale(.94)}}

/* ---------- the golden sparkle trail (above the page; never takes a tap) ---------- */
#mg-front{position:fixed;inset:0;width:100%;height:100%;z-index:var(--z-magic);pointer-events:none;visibility:hidden}

/* ---------- fairy lights and paper lanterns ---------- */
.mg-festoon{position:absolute;left:-12px;right:-12px;top:-40px;height:68px;z-index:0;pointer-events:none}
.mg-festoon svg{position:absolute;inset:0;width:100%;height:100%;overflow:visible}
.mg-festoon path{fill:none;stroke:rgba(94,100,112,.5);stroke-width:1}
@media (min-width:1100px){.mg-festoon{left:0;right:0;top:-46px;height:80px}}
.mg-bulb{position:absolute;width:6px;height:8px;margin:-1px 0 0 -3px;border-radius:50% 50% 50% 50% / 40% 40% 60% 60%;
  background:radial-gradient(circle at 40% 35%, #fff 0 1px, #EEEAE0 2px, #CFC7B6 4px);box-shadow:inset 0 0 0 .6px rgba(94,100,112,.55), inset 0 2px 0 -.5px rgba(94,100,112,.45)}
.mg-bulb::after{content:"";position:absolute;left:50%;top:55%;width:30px;height:30px;margin:-15px 0 0 -15px;border-radius:50%;opacity:0;
  background:radial-gradient(circle, rgba(255,246,214,.95) 0, rgba(240,212,140,.5) 25%, rgba(233,200,120,0) 65%);transition:opacity .9s var(--ease-out)}
.mg-bulb.on{background:radial-gradient(circle at 45% 45%, #FFFDF2 0 1.5px, #F6E2A8 3px, #E3C27A 5px)}
.mg-bulb.on::after{opacity:1}
.mg-lantern{position:absolute;width:24px;margin-left:-12px;isolation:isolate}
.mg-lantern::before{content:"";position:absolute;left:50%;bottom:100%;width:1px;height:12px;background:rgba(94,100,112,.5)}
.mg-lantern img{display:block;width:100%;height:auto;margin-top:10px}
.mg-lantern::after{content:"";position:absolute;left:50%;top:55%;width:90px;height:90px;margin:-45px 0 0 -45px;border-radius:50%;z-index:-1;opacity:0;
  background:radial-gradient(circle, rgba(255,240,200,.9) 0, rgba(240,206,130,.42) 30%, rgba(233,200,120,0) 68%);transition:opacity 1.6s var(--ease-out)}
.mg-lantern.on::after{opacity:1}
@media (min-width:1100px){.mg-lantern:nth-of-type(1){left:14%!important}.mg-lantern:nth-of-type(2){left:86%!important}.mg-lantern{width:30px;margin-left:-15px}}

/* ---------- butterflies taking off from the flowers ---------- */
.mg-bfly{position:absolute;width:26px;margin:-9px 0 0 -13px;z-index:3;pointer-events:none;will-change:transform,opacity}
.mg-bfly img{display:block;width:100%;height:auto;transform-origin:50% 50%;animation:mg-flap .17s ease-in-out infinite alternate}
.mg-bfly.mg-lilac img{filter:hue-rotate(30deg) saturate(.7) brightness(1.06)}
.mg-bfly.mg-ivory img{filter:saturate(.25) brightness(1.2)}
@keyframes mg-flap{from{transform:scaleX(1)}to{transform:scaleX(.22)}}

@media (prefers-reduced-motion: reduce){
  .mg-glow i{animation:none}
  .mg-bulb::after, .mg-lantern::after{transition:none}
}
