/* snail-stage.css: the animated snail. Pair with snail-stage.js.
   The host sizes the container; the snail fits inside it, standing on the container's bottom edge.
   Theme hooks (set on the container or any ancestor):
     --snst-slime   slime trail colour            (default rgba(255,255,255,.8))
     --snst-sheen   highlight dashes in the slime (default #fff)
     --snst-shadow  ground shadow under the foot  (default rgba(20,30,40,.14))
     --snst-label   celebrate() label colour      (default currentColor)
     --snst-ground  distance from the container's bottom to the ground line (default 4%)
   Accessories (.snst-acc, drawn by SnailStage.rig) are scoped to .snst-rig, so a page that animates
   its own snail can wear them too.                                                               */

.snst { position: relative; width: 100%; height: 100%; overflow: visible; pointer-events: none; -webkit-user-select: none; user-select: none; contain: layout style; }
.snst * { box-sizing: border-box; }
.snst-floor { position: absolute; left: 0; right: 0; bottom: var(--snst-ground, 4%); height: 0; }

.snst-trail { position: absolute; left: 0; bottom: 0; overflow: hidden; opacity: 0; border-radius: 99px 0 0 99px;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 55%); mask-image: linear-gradient(90deg, transparent, #000 55%); }
.snst-trail i { position: absolute; left: 0; top: 0; bottom: 0; width: calc(100% + 140px); will-change: transform;
  background-color: var(--snst-slime, rgba(255, 255, 255, .8));
  background-image: linear-gradient(90deg, transparent 0 62px, var(--snst-sheen, #fff) 62px 92px, transparent 92px 108px, var(--snst-sheen, #fff) 108px 116px, transparent 116px);
  background-size: 140px 42%; background-repeat: repeat-x; background-position: 0 22%; }

.snst-shadow { position: absolute; left: 0; bottom: 0; border-radius: 50%; background: var(--snst-shadow, rgba(20, 30, 40, .14)); will-change: transform; transform-origin: 50% 50%; }

.snst-mover { position: absolute; left: 0; bottom: 0; will-change: transform; transform-origin: 0 100%; aspect-ratio: 1074 / 920; }
.snst-sq, .snst-stalk, .snst-mover img { position: absolute; inset: 0; }
.snst-mover img { display: block; width: 100%; height: 100%; max-width: none; border: 0; margin: 0; padding: 0; -webkit-user-drag: none; }
.snst-sq { transform-origin: 46% 98%; will-change: transform; }
/* the body layer carries leftovers of the eyes above the head: cut them off */
.snst-body { clip-path: polygon(0 0, 69.4% 0, 69.4% 25.3%, 100% 25.3%, 100% 100%, 0 100%); }
.snst-stalk { will-change: transform; }
.snst-stalk.l { transform-origin: 80.63% 25.87%; }
.snst-stalk.r { transform-origin: 88.64% 25.87%; }
.snst-ring { position: absolute; left: 70.25%; top: 1.6%; width: 10.2%; aspect-ratio: 1; border-radius: 50%; background: #F8B800; }
.snst-lid { position: absolute; width: 7%; aspect-ratio: 1; border-radius: 50%; overflow: hidden; }
.snst-stalk.l .snst-lid { left: 72.3%; top: 3.2%; }
.snst-stalk.r .snst-lid { left: 90.55%; top: 3.3%; }
.snst-lid b { position: absolute; inset: 0; background: #F8B800; box-shadow: inset 0 -4px 0 #D08A00; transform: translateY(-102%); will-change: transform; }

.snst-fx { position: absolute; left: 0; bottom: 0; width: 0; height: 0; }
.snst-bit { position: absolute; left: 0; top: 0; will-change: transform; }
.snst-bit i { display: block; will-change: transform, opacity; }
.snst-bit .coin { border-radius: 50%; background: #EC9C12; box-shadow: inset 0 0 0 2px #F5B800; }
.snst-bit .chip { border-radius: 2px; }
.snst-bit .drop { border-radius: 50% 50% 50% 0; }
.snst-bit .spark { background: #FFF6D8; clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%); }

.snst-label { position: absolute; left: 0; bottom: 0; white-space: nowrap; font-weight: 700; line-height: 1; color: var(--snst-label, currentColor); will-change: transform, opacity; opacity: 0; transform-origin: 50% 100%; }

/* ---------- trail upgrades (1em = the snail's current width) ---------- */
.snst-glints { position: absolute; left: 0; bottom: 0; width: 0; height: 0; opacity: 0; transition: opacity .5s; }
.snst-glisten .snst-glints { opacity: 1; }
.snst-glints b { position: absolute; bottom: -.012em; width: max(.06em, 7px); aspect-ratio: 1; background: var(--snst-sheen, #fff);
  clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%); animation: snst-tw 2.6s ease-in-out infinite both; }
.snst-glints b:nth-child(1) { right: .1em; }
.snst-glints b:nth-child(2) { right: .34em; animation-delay: -.9s; }
.snst-glints b:nth-child(3) { right: .6em; animation-delay: -1.7s; }
.snst-glints b:nth-child(4) { right: .9em; animation-delay: -.4s; }
.snst-glints b:nth-child(5) { right: 1.25em; animation-delay: -2.1s; }

.snst-flames { position: absolute; left: 0; bottom: 0; width: 1.25em; height: .2em; overflow: hidden; opacity: 0; transition: opacity .6s;
  -webkit-mask-image: linear-gradient(90deg, transparent 4%, #000 72%); mask-image: linear-gradient(90deg, transparent 4%, #000 72%); }
.snst-fire .snst-flames { opacity: 1; }
.snst-flames i { position: absolute; left: 0; top: 0; bottom: 0; width: calc(100% + .3em); transform-origin: 50% 100%; will-change: transform;
  background: repeat-x 0 100% / .3em 100% url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 70 40' preserveAspectRatio='none'%3E%3Cpath d='M0 40C0 24 8 20 10 6c6 10 12 12 12 24 4-8 8-14 12-30 8 14 14 20 14 32 4-6 8-10 12-20 6 10 10 16 10 28z' fill='%23F0541E'/%3E%3C/svg%3E"); }
.snst-flames i + i { top: 38%; width: calc(100% + .19em); background-size: .19em 100%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 70 40' preserveAspectRatio='none'%3E%3Cpath d='M0 40C0 24 8 20 10 6c6 10 12 12 12 24 4-8 8-14 12-30 8 14 14 20 14 32 4-6 8-10 12-20 6 10 10 16 10 28z' fill='%23FFC21A'/%3E%3C/svg%3E"); }

.snst-rainbow .snst-trail { border-radius: 0; }
.snst-rainbow .snst-trail i { background: repeat-x 0 0 / 140px 100% url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 140 42' preserveAspectRatio='none'%3E%3Cg id='a'%3E%3Cpath fill='%23E2523A' d='M0 0h70v6H0z'/%3E%3Cpath fill='%23F68A00' d='M0 6h70v6H0z'/%3E%3Cpath fill='%23F5D800' d='M0 12h70v6H0z'/%3E%3Cpath fill='%234FBF5A' d='M0 18h70v6H0z'/%3E%3Cpath fill='%233E8FE0' d='M0 24h70v6H0z'/%3E%3Cpath fill='%238A56D8' d='M0 30h70v6H0z'/%3E%3C/g%3E%3Cuse href='%23a' x='70' y='6'/%3E%3C/svg%3E"); }

/* ---------- accessories ---------- */
.snst-layer { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.snst-acc { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; display: none; pointer-events: none; }
.snst-acc.on { display: block; }
.snst-has-cosmic .snst-a-goldimg { visibility: hidden; }

.snst-a-sprout { animation: snst-sway 3.4s ease-in-out infinite alternate; }
.snst-a-lettuce { animation: snst-nibble 3.2s linear infinite; }
.snst-a-chain { animation: snst-swing 2.3s ease-in-out infinite alternate; }
.snst-a-halo { animation: snst-bob 2.8s ease-in-out infinite alternate; }
.snst-a-aura { animation: snst-pulse 2.4s ease-in-out infinite alternate; }
.snst-flap { transform-box: fill-box; transform-origin: 100% 50%; animation: snst-flap .9s ease-in-out infinite alternate; }
.snst-sweep { animation: snst-sweep 4.6s cubic-bezier(.4, 0, .5, 1) infinite; }
.snst-tw { transform-box: fill-box; transform-origin: 50% 50%; animation: snst-tw 2.8s ease-in-out infinite both; }
.snst-tw.t1 { animation-delay: -.9s; }
.snst-tw.t2 { animation-delay: -1.8s; }
.snst-tw.slow { animation-duration: 4.4s; }
.snst-bl { animation: snst-blink 2.2s steps(2, jump-none) infinite; }
.snst-bl.t1 { animation-delay: -.7s; }
.snst-bl.t2 { animation-delay: -1.5s; }
.snst-spin { transform-box: fill-box; transform-origin: 50% 50%; animation: snst-spin 46s linear infinite; }
.snst-spin.fast { animation-duration: 7s; }
.snst-neb { animation: snst-neb 9s ease-in-out infinite alternate; }
.snst-planet { display: none; }
@supports (offset-path: path("M0 0")) {
  .snst-planet { display: inline; offset-path: path("M813.5 432A420 96 0 1 1 -26.5 432A420 96 0 1 1 813.5 432"); offset-rotate: 0deg; animation: snst-orbit 6s linear infinite; }
}

@keyframes snst-sway { from { transform: rotate(-5deg); } to { transform: rotate(6deg); } }
@keyframes snst-nibble { 0%, 58%, 100% { transform: rotate(0); } 62% { transform: rotate(-5deg) translateX(-.5%); } 66% { transform: rotate(3deg); } 70% { transform: rotate(-5deg) translateX(-.5%); } 74% { transform: rotate(3deg); } 78% { transform: rotate(-4deg) translateX(-.5%); } 84% { transform: rotate(0); } }
@keyframes snst-swing { from { transform: rotate(-2.5deg); } to { transform: rotate(3deg); } }
@keyframes snst-bob { from { transform: translateY(-.8%) rotate(-1.5deg); } to { transform: translateY(1%) rotate(1.5deg); } }
@keyframes snst-pulse { from { transform: scale(.97); opacity: .75; } to { transform: scale(1.05); opacity: 1; } }
@keyframes snst-flap { from { transform: skewY(-5deg) scaleX(.96); } to { transform: skewY(5deg) scaleX(1.02); } }
@keyframes snst-sweep { 0%, 62% { transform: translateX(0); } 86%, 100% { transform: translateX(1300px); } }
@keyframes snst-tw { 0%, 55%, 100% { transform: scale(0) rotate(0deg); } 72% { transform: scale(1) rotate(45deg); } 88% { transform: scale(.25) rotate(90deg); } }
@keyframes snst-blink { from { opacity: 1; } to { opacity: .25; } }
@keyframes snst-spin { to { transform: rotate(360deg); } }
@keyframes snst-neb { from { transform: translate(-30px, 18px); } to { transform: translate(34px, -22px); } }
@keyframes snst-orbit { from { offset-distance: 0%; } to { offset-distance: 100%; } }

/* reduced motion: everything is drawn, nothing loops */
.snst-still .snst-acc, .snst-still .snst-acc *, .snst-rm .snst-glints b { animation: none !important; }
.snst-still .snst-sweep { transform: translateX(560px); }
.snst-still .snst-planet { offset-distance: 12%; }
