/* Little Oven motion layer. Loads after wf.css and before hifi.css on every page, lo-fi and hi-fi.
   Real-world motion only: snow falls, steam rises, the oven window glows, the oven blinks, fairy lights blink,
   sugar sifts, tags swing on their strings, dough proves, a stamp presses, twine wraps, a snow globe shakes.
   The oven itself and the logo never float or bob. Things that appear stay, unless the real thing would go
   (steam fades, snow melts). One-off actions (twine, stamp, sugar) play once on reveal and have a replay button.
   Reduced motion: every primitive shows its final frame and nothing loops. */

/* ---------- Scroll reveals (motion.js adds the class, then .on) ---------- */
.lo-rise { opacity: 0; transform: translateY(26px); transition: opacity var(--t-reveal) var(--ease), transform var(--t-reveal) var(--ease); transition-delay: calc(var(--i, 0) * 90ms); }
.lo-rise.on { opacity: 1; transform: none; }
.lo-pop { opacity: 0; transform: scale(.86) rotate(var(--rot, -2deg)); transition: opacity 500ms var(--ease), transform 700ms var(--spring); transition-delay: calc(var(--i, 0) * 80ms); }
.lo-pop.on { opacity: 1; transform: rotate(var(--rot, -2deg)); }
.lo-draw path { stroke-dasharray: 400; stroke-dashoffset: 400; transition: stroke-dashoffset 1100ms var(--ease) 300ms; }
.lo-draw.on path { stroke-dashoffset: 0; }
/* the oven peeks up from behind an edge once, then stays put */
.lo-peekup { transform: translateY(70%); transition: transform 900ms var(--spring) 200ms; }
.lo-peekup.on { transform: none; }

/* ---------- 1. Snowfall: canvas from motion.js on any [data-snow]; this is the CSS demo ---------- */
@keyframes lo-fall { 0% { transform: translate(0, -20px); opacity: 0; } 10% { opacity: 1; } 50% { transform: translate(var(--sway, 12px), 90px); } 90% { opacity: 1; } 100% { transform: translate(0, 190px); opacity: 0; } }
.lo-flake { position: absolute; top: 0; width: var(--s, 8px); height: var(--s, 8px); border-radius: 50%; background: #fff; box-shadow: 0 0 6px rgba(255, 255, 255, .8); animation: lo-fall var(--d, 5s) linear infinite; animation-delay: var(--dl, 0s); }

/* ---------- 2. Steam rises off a warm cake, thins out and fades (real steam does) ---------- */
/* wisps dissolve by opacity and a soft blur long before any edge; nothing clips them */
@keyframes lo-steam { 0% { transform: translateY(14px) scaleX(.7); opacity: 0; filter: blur(0); } 22% { opacity: .8; } 55% { opacity: .45; filter: blur(.6px); } 85%, 100% { transform: translateY(-34px) scaleX(1.35); opacity: 0; filter: blur(2.5px); } }
@keyframes lo-steam-oven { 0% { transform: translateY(6px) scaleX(.7); opacity: 0; } 30% { opacity: .75; } 80%, 100% { transform: translateY(-5px) scaleX(1.3); opacity: 0; } }
.lo-steam path { fill: none; stroke: #fff; stroke-width: 5; stroke-linecap: round; opacity: 0; transform-box: fill-box; transform-origin: 50% 100%; }
.lo-steam.on path { animation: lo-steam 3.6s ease-out infinite; }
.lo-steam.on path:nth-child(2) { animation-delay: 1.2s; }
.lo-steam.on path:nth-child(3) { animation-delay: 2.4s; }

/* ---------- 3. Oven window glow while baking ---------- */
@keyframes lo-glow { 0%, 100% { opacity: .45; transform: scale(.96); } 50% { opacity: .95; transform: scale(1.04); } }
.lo-glow { position: absolute; border-radius: 40%; pointer-events: none; mix-blend-mode: screen;
  background: radial-gradient(ellipse at 50% 60%, rgba(255, 196, 80, .95), rgba(242, 120, 40, .55) 45%, rgba(242, 120, 40, 0) 72%); opacity: .45; }
.lo-glow.on { animation: lo-glow 2.6s ease-in-out infinite; }

/* ---------- 3b. The standalone oven (inline SVG from motion.js): window glows, cake steams, eyes blink ---------- */
@keyframes lo-ovenglow { 0%, 100% { opacity: .78; } 50% { opacity: 1; } }
@keyframes lo-blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.08); } }
@keyframes lo-wave { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-16deg); } 75% { transform: rotate(10deg); } }
.lo-oven { display: block; width: 100%; height: auto; overflow: visible; }
.lo-oven [data-part="glow"] { animation: lo-ovenglow 2.8s ease-in-out infinite; }
.lo-oven [data-part="eye-l"], .lo-oven [data-part="eye-r"] { transform-box: fill-box; transform-origin: 50% 50%; animation: lo-blink 5.2s ease-in-out infinite; }
.lo-oven .lo-steam path { stroke-width: 4; animation-name: lo-steam-oven; }
.lo-steam { overflow: visible; }
.lo-oven [data-part="arm-r"] { transform-box: view-box; transform-origin: 326px 312px; }
.lo-oven.is-waving [data-part="arm-r"] { animation: lo-wave 900ms ease-in-out 3; }

/* ---------- 4. Fairy lights blink in turn ---------- */
@keyframes lo-bulb { 0%, 100% { opacity: 1; filter: drop-shadow(0 0 6px var(--c)); } 45% { opacity: .35; filter: none; } }
.lo-bulb { animation: lo-bulb 2.4s ease-in-out infinite; animation-delay: calc(var(--n, 0) * -.3s); }

/* ---------- 5. Sugar sifts onto a cake once; the dusting stays ---------- */
@keyframes lo-sift { 0% { transform: translateY(-30px); opacity: 0; } 12% { opacity: 1; } 88% { opacity: 1; } 100% { transform: translateY(58px); opacity: 0; } }
@keyframes lo-dust { from { opacity: 0; } to { opacity: 1; } }
.lo-sift-grain { position: absolute; width: 4px; height: 4px; border-radius: 50%; background: #fff; opacity: 0; }
.lo-sift.on .lo-sift-grain { animation: lo-sift 1.3s ease-in 4; animation-delay: var(--dl, 0s); }
.lo-sift-top { opacity: 0; }
.lo-sift.on .lo-sift-top { animation: lo-dust 4.6s ease-out forwards; }

/* ---------- 6. Ornaments and gift tags swing on their string ---------- */
@keyframes lo-swing { 0%, 100% { transform: rotate(var(--a, 6deg)); } 50% { transform: rotate(calc(var(--a, 6deg) * -1)); } }
.lo-swing { transform-origin: 50% 0; }
.lo-swing.on { animation: lo-swing var(--d, 3.6s) ease-in-out infinite; }
.lo-swing-hover { transform-origin: 50% 0; }
.lo-swing-hover:hover, .lo-card:hover .lo-swing-hover { animation: lo-swing 1.5s ease-in-out 2; --a: 6deg; }

/* ---------- 7. Dough proves in its bowl, holds, then knocks back (a gentle loop is fine) ---------- */
@keyframes lo-proof { 0% { transform: scale(.7, .55); } 60%, 85% { transform: scale(1, 1); } 100% { transform: scale(.7, .55); } }
.lo-dough { transform-origin: 50% 100%; transform: scale(.7, .55); }
.lo-proof.on .lo-dough { animation: lo-proof 7s var(--ease) infinite; }

/* ---------- 8. "Pre-order" stamp presses once and the ink stays ---------- */
@keyframes lo-stamp { 0% { transform: scale(2.2) rotate(-18deg); opacity: 0; } 55% { transform: scale(.92) rotate(-8deg); opacity: 1; } 75%, 100% { transform: scale(1) rotate(-8deg); opacity: 1; } }
.lo-stamp { opacity: 0; }
.lo-stamp.on { animation: lo-stamp 900ms var(--ease) 400ms forwards; }

/* ---------- 9. Twine wraps a hamper and ties once; the bow gives a tiny settle ---------- */
@keyframes lo-wrap { to { stroke-dashoffset: 0; } }
@keyframes lo-bow { 0% { opacity: 0; transform: scale(.4); } 60% { opacity: 1; transform: scale(1.12); } 80% { transform: scale(.96); } 100% { opacity: 1; transform: scale(1); } }
.lo-wrap .lo-twine { stroke-dasharray: 300; stroke-dashoffset: 300; }
.lo-wrap .lo-bow { opacity: 0; transform-box: fill-box; transform-origin: 50% 100%; }
.lo-wrap.on .lo-twine { animation: lo-wrap 900ms var(--ease) forwards; }
.lo-wrap.on .lo-twine:nth-of-type(2) { animation-delay: 700ms; }
.lo-wrap.on .lo-bow { animation: lo-bow 700ms var(--ease) 1500ms forwards; }

/* ---------- 10. Snow globe: physics in motion.js; the globe tilts on a damped spring ---------- */
.lo-globe { cursor: pointer; transform-origin: 50% 92%; }

/* ---------- 11. Marquee ribbon, always moving ---------- */
@keyframes lo-marquee { to { transform: translateX(-50%); } }
.lo-ribbon-track { animation: lo-marquee 38s linear infinite; }
.lo-ribbon:hover .lo-ribbon-track { animation-play-state: paused; }

/* ---------- Pointer effects (motion.js) ---------- */
[data-tilt] { transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); }
.lo-sheen { overflow: hidden; }
.lo-sheen::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 250ms; z-index: 2;
  background: radial-gradient(circle 160px at var(--gx, 50%) var(--gy, 30%), rgba(242, 178, 58, .28), rgba(242, 178, 58, 0) 70%); }
.lo-sheen:hover::after { opacity: 1; }
.lo-crumb { position: fixed; z-index: 50; pointer-events: none; width: 7px; height: 7px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px rgba(23, 63, 44, .15); }

/* ---------- Demo frames on the design-system board ---------- */
.lo-demo { position: relative; height: 250px; border-radius: 20px; overflow: hidden; display: grid; place-items: center; }
.lo-demo--night { background: var(--pine) url(night.svg); }
.lo-demo--butter { background: var(--butter) url(flour.svg); }
.lo-demo--flour { background: var(--flour) url(flour.svg); }
.lo-demo--red { background: var(--red); }

@media (prefers-reduced-motion: reduce) {
  .lo-rise, .lo-pop, .lo-peekup { opacity: 1; transform: none; transition: none; }
  .lo-pop { transform: rotate(var(--rot, -2deg)); }
  .lo-draw path { stroke-dashoffset: 0; transition: none; }
  .lo-flake, .lo-bulb, .lo-ribbon-track, .lo-swing.on, .lo-swing-hover:hover, .lo-card:hover .lo-swing-hover { animation: none; }
  .lo-flake { opacity: .8; transform: translateY(var(--rest, 60px)); }
  .lo-steam path, .lo-steam.on path { animation: none; opacity: .5; transform: none; }
  .lo-glow.on { animation: none; opacity: .8; }
  .lo-oven [data-part], .lo-oven.is-waving [data-part="arm-r"] { animation: none; }
  .lo-sift.on .lo-sift-grain { animation: none; }
  .lo-sift-top, .lo-sift.on .lo-sift-top { animation: none; opacity: 1; }
  .lo-proof.on .lo-dough { animation: none; transform: none; }
  .lo-stamp, .lo-stamp.on { animation: none; opacity: 1; transform: rotate(-8deg); }
  .lo-wrap .lo-twine, .lo-wrap.on .lo-twine { animation: none; stroke-dashoffset: 0; }
  .lo-wrap .lo-bow, .lo-wrap.on .lo-bow { animation: none; opacity: 1; transform: none; }
  [data-tilt] { transform: none; }
}
