/* LOOM · stage.css — styles for LoomStage (engine/stage.js).
   Silver Drops Fall: the stage as appliqué cloth.

   The host element given to LoomStage.mount() gets class .ls-host; inside it
   live one <svg class="ls-svg"> (the whole stage) and one pointer-less
   <canvas class="ls-particles"> laid exactly over it for falling weather and
   particle effects (cheap to animate on phones; the SVG stays still). */

.ls-host { position: relative; overflow: hidden; background: #0d1226; }
.ls-host > .ls-svg,
.ls-host > .ls-particles { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; }
.ls-particles { pointer-events: none; }
.ls-svg { -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
.ls-svg text { font-family: Georgia, 'Times New Roman', serif; }

/* ---------------------------------------------------------------- the running stitch
   Cream, inset, 7-on 6-off. Puppet authors may override any part with a
   presentation attribute (stroke="…", stroke-opacity="…") or inline style. */
/* (plain class selectors on purpose: they must also reach the copies inside <use>) */
.stitch { stroke-linecap: round; stroke-linejoin: round; }
.stitch:not([fill]) { fill: none; }
.stitch:not([stroke]) { stroke: var(--stitch, #efe6d2); }
.stitch:not([stroke-opacity]) { stroke-opacity: .45; }
.stitch:not([stroke-width]) { stroke-width: 2; }
.stitch:not([stroke-dasharray]) { stroke-dasharray: 7 6; }
.stitch.dk { stroke: #0d1226; stroke-opacity: .5; }
.stitch.gd { stroke: #d9a440; stroke-opacity: .8; }
.stitch.vm { stroke: #c2412d; stroke-opacity: .7; }
.stitch.fine { stroke-width: 1.4; stroke-dasharray: 4 4; }
.stitch.faint { stroke-opacity: .2; }
.stitch.soft { stroke-opacity: .3; }

/* ---------------------------------------------------------------- puppet motion
   Used by puppets.js on animated parts. Origins default to bottom-centre of
   the part; puppets set their own pivot with an inline transform-origin. */
.ls-svg .anim-flap { transform-box: fill-box; transform-origin: 50% 100%; animation: ls-a-flap 1.35s ease-in-out infinite alternate; }
.ls-svg .anim-sway { transform-box: fill-box; transform-origin: 50% 100%; animation: ls-a-sway 4.6s ease-in-out infinite alternate; }
.ls-svg .anim-bob { animation: ls-a-bob 3.3s ease-in-out infinite alternate; }
.ls-svg .anim-flicker { transform-box: fill-box; transform-origin: 50% 100%; animation: ls-a-flicker .95s ease-in-out infinite alternate; }
@keyframes ls-a-flap { from { transform: rotate(-8deg); } to { transform: rotate(10deg); } }
@keyframes ls-a-sway { from { transform: rotate(-2.6deg); } to { transform: rotate(2.6deg); } }
@keyframes ls-a-bob { from { transform: translateY(0); } to { transform: translateY(-6px); } }
@keyframes ls-a-flicker {
  0% { transform: scale(1, 1); opacity: 1; }
  45% { transform: scale(.93, 1.08); opacity: .86; }
  100% { transform: scale(1.05, .95); opacity: 1; }
}

/* ---------------------------------------------------------------- scene ambience
   All quiet and slow (8–40 s). Each is static and still looks right when
   animation is switched off (reduced motion). */
.ls-svg .ls-drift1 { animation: ls-drift 28s ease-in-out infinite alternate; }
.ls-svg .ls-drift2 { animation: ls-drift 37s ease-in-out -11s infinite alternate-reverse; }
.ls-svg .ls-drift3 { animation: ls-drift-far 46s ease-in-out -23s infinite alternate; }
@keyframes ls-drift { from { transform: translateX(-34px); } to { transform: translateX(34px); } }
@keyframes ls-drift-far { from { transform: translateX(-18px); } to { transform: translateX(18px); } }
.ls-windy .ls-svg .ls-drift1 { animation-duration: 9s; }
.ls-windy .ls-svg .ls-drift2 { animation-duration: 12s; }

.ls-svg .ls-shim { opacity: .55; animation: ls-shim 4.6s ease-in-out infinite; }
@keyframes ls-shim { 0%, 100% { opacity: .12; } 50% { opacity: .95; } }

.ls-svg .ls-tw { animation: ls-tw 3.8s ease-in-out infinite; }
@keyframes ls-tw { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

.ls-svg .ls-flame { transform-box: fill-box; transform-origin: 50% 100%; animation: ls-flame 1.15s ease-in-out infinite alternate; }
.ls-svg .ls-flame.b { animation-duration: .83s; animation-delay: -.4s; }
.ls-svg .ls-flame.c { animation-duration: 1.37s; animation-delay: -.9s; }
@keyframes ls-flame {
  0% { transform: scale(1, 1) skewX(0deg); }
  30% { transform: scale(.94, 1.07) skewX(-2deg); }
  65% { transform: scale(1.04, .95) skewX(2deg); }
  100% { transform: scale(.97, 1.04) skewX(-1deg); }
}
.ls-svg .ls-glowp { animation: ls-glowp 3.1s ease-in-out infinite alternate; }
@keyframes ls-glowp { from { opacity: .82; } to { opacity: 1; } }

.ls-svg .ls-smoke { opacity: .0; animation: ls-smoke 11s linear infinite; }
.ls-svg .ls-smoke.b { animation-delay: -3.7s; }
.ls-svg .ls-smoke.c { animation-delay: -7.4s; }
@keyframes ls-smoke {
  0% { transform: translate(0, 40px) scale(.7, .8); opacity: 0; }
  14% { opacity: 1; }
  70% { opacity: .75; }
  100% { transform: translate(14px, -150px) scale(1.25, 1.3); opacity: 0; }
}
.ls-reduced .ls-svg .ls-smoke { opacity: .6; }

.ls-svg .ls-sway { animation: ls-sway 5.2s ease-in-out infinite alternate; }
.ls-svg .ls-sway.b { animation-duration: 6.4s; animation-delay: -2.2s; }
@keyframes ls-sway { from { transform: rotate(-1.8deg); } to { transform: rotate(2.4deg); } }
.ls-windy .ls-svg .ls-sway { animation-name: ls-sway-w; animation-duration: 1.7s; }
.ls-windy .ls-svg .ls-sway.b { animation-duration: 2.1s; }
@keyframes ls-sway-w { from { transform: rotate(-2deg); } to { transform: rotate(-9deg); } }

.ls-svg .ls-bob { animation: ls-bob 7.5s ease-in-out infinite alternate; }
.ls-svg .ls-bob.b { animation-duration: 9.5s; animation-delay: -3s; }
@keyframes ls-bob { from { transform: translate(-14px, 0); } to { transform: translate(14px, -7px); } }

.ls-svg .ls-zap { opacity: 0; animation: ls-zap 8.5s linear infinite; }
.ls-svg .ls-zap.b { animation-delay: -4.1s; animation-duration: 11s; }
@keyframes ls-zap { 0%, 86% { opacity: 0; } 87% { opacity: .95; } 88% { opacity: .1; } 89.5% { opacity: .8; } 92% { opacity: 0; } 100% { opacity: 0; } }

.ls-svg .ls-ripple { transform-box: fill-box; transform-origin: 50% 50%; animation: ls-ripple 5.5s ease-out infinite; }
.ls-svg .ls-ripple.b { animation-delay: -2.75s; }
@keyframes ls-ripple { 0% { transform: scale(.25); opacity: .8; } 100% { transform: scale(1.5); opacity: 0; } }

.ls-svg .ls-ray { animation: ls-ray 9s ease-in-out infinite alternate; }
.ls-svg .ls-ray.b { animation-delay: -4.5s; }
@keyframes ls-ray { from { opacity: .45; } to { opacity: 1; } }

.ls-svg .ls-spin { animation: ls-spin .9s linear infinite; }
@keyframes ls-spin { to { stroke-dashoffset: -52; } }

/* ---------------------------------------------------------------- shake (HTML level, composited) */
.ls-host.ls-shaking > .ls-svg,
.ls-host.ls-shaking > .ls-particles { animation: ls-shake var(--ls-shake-d, 650ms) linear both; }
@keyframes ls-shake {
  0% { transform: translate(0, 0) scale(1.035); }
  10% { transform: translate(calc(var(--ls-shake-k, 1) * -11px), calc(var(--ls-shake-k, 1) * 5px)) scale(1.035); }
  22% { transform: translate(calc(var(--ls-shake-k, 1) * 10px), calc(var(--ls-shake-k, 1) * -7px)) scale(1.035); }
  36% { transform: translate(calc(var(--ls-shake-k, 1) * -8px), calc(var(--ls-shake-k, 1) * -3px)) scale(1.035); }
  50% { transform: translate(calc(var(--ls-shake-k, 1) * 7px), calc(var(--ls-shake-k, 1) * 6px)) scale(1.03); }
  66% { transform: translate(calc(var(--ls-shake-k, 1) * -4px), calc(var(--ls-shake-k, 1) * 2px)) scale(1.02); }
  82% { transform: translate(calc(var(--ls-shake-k, 1) * 2px), calc(var(--ls-shake-k, 1) * -2px)) scale(1.01); }
  100% { transform: translate(0, 0) scale(1); }
}

/* ---------------------------------------------------------------- reduced motion
   LoomStage sets .ls-reduced on the host from prefers-reduced-motion or
   reducedMotion(true). Scenes become still; crossfades remain. */
.ls-reduced .ls-svg *,
.ls-reduced .ls-svg *::before { animation: none !important; }
.ls-reduced.ls-shaking > .ls-svg,
.ls-reduced.ls-shaking > .ls-particles { animation: none !important; }

/* ---------------------------------------------------------------- placeholders */
.ls-svg .ls-flipped .ls-ph-label { transform: scaleX(-1); }
