/* Mad Logic Labs — Crazy Egg roaming characters (overlay only, never affects layout).
   All motion uses transforms on nested wrappers, origin at the feet:
   .ceg (translateX path) > .ceg-fx (entrances/exits) > .ceg-tilt (lean) > .ceg-body (gait / personality) > img */
.eggs-layer{position:fixed;inset:0;z-index:40;pointer-events:none;overflow:hidden;contain:strict;transition:opacity .35s ease}
.eggs-layer.eggs-away{opacity:0}
.eggs-layer.eggs-away .ceg-body{pointer-events:none}
.eggs-spice{position:absolute;inset:0;width:100%;height:100%;pointer-events:none}
.ceg{position:absolute;left:0;bottom:var(--eb,14px);width:var(--ew);height:var(--eh);will-change:transform}
.ceg-fx,.ceg-tilt,.ceg-body{width:100%;height:100%;transform-origin:50% 100%}
.ceg-fx{position:relative;z-index:1}
.ceg-tilt{transition:transform .3s ease}
.ceg-tilt.look{scale:-1 1;transition:scale .08s}
.ceg-body{pointer-events:auto;cursor:pointer;-webkit-tap-highlight-color:transparent;user-select:none;-webkit-user-select:none}
.ceg-body{position:relative}
.ceg-body img{position:absolute;left:50%;bottom:0;width:auto;height:100%;max-width:none;transform:translateX(-50%);display:block;filter:drop-shadow(0 5px 7px rgba(28,18,11,.35));-webkit-user-drag:none;pointer-events:none}
/* walk clips (sprite sheets stepped from JS): same height and baseline as the still pose, centred on the same axis */
.ceg-clip{position:absolute;left:50%;bottom:0;height:100%;background-repeat:no-repeat;visibility:hidden;pointer-events:none;filter:drop-shadow(0 5px 7px rgba(28,18,11,.35))}
.ceg.clip-on .ceg-clip{visibility:visible}
.ceg.clip-on .ceg-s{visibility:hidden}
.ceg-shadow{position:absolute;left:14%;right:14%;bottom:-6px;height:10px;border-radius:50%;background:rgba(28,18,11,.26);filter:blur(2.5px)}

/* ---- gaits (walking) ----
   With the walk clips on (.clip-on) the video-generated cycle carries all the motion: no extra rock, lean or rotation.
   Fallback (clip not decoded yet / no WebP): a smooth glide with a gentle bob, never a side-to-side wobble. */
.ceg.walk.clip-on .ceg-body,.ceg.panic.clip-on .ceg-body,.ceg.charge.clip-on .ceg-body{animation:none}
.ceg.walk:not(.clip-on) .ceg-body{animation:ceg-glide .5s ease-in-out infinite}
.ceg.walk:not(.clip-on)[data-n=alfonso] .ceg-body{animation-duration:.62s}
.ceg.walk:not(.clip-on)[data-n=eggjun] .ceg-body{animation-duration:.6s}
.ceg.panic:not(.clip-on) .ceg-body,.ceg.charge:not(.clip-on) .ceg-body{animation:ceg-glide .3s ease-in-out infinite}
/* ---- idles (gentle breathing, no sway) ---- */
.ceg.idle .ceg-body{animation:ceg-breathe 1.8s ease-in-out infinite}
.ceg.idle[data-n=tamir] .ceg-body{animation-duration:1.1s}
/* ---- one-shot actions (override gait) ---- */
.ceg .ceg-body[data-act=jump]{animation:ceg-jump .7s cubic-bezier(.3,.7,.4,1) 1!important}
.ceg .ceg-body[data-act=hop]{animation:ceg-hop .42s cubic-bezier(.3,.7,.4,1) 1!important}
.ceg .ceg-body[data-act=dance]{animation:ceg-dance 1.3s ease-in-out 1!important}
.ceg[data-n=eggjun] .ceg-body[data-act=dance]{animation-name:ceg-dance-nf!important}   /* no mirror flip: keeps his headband text readable */
.ceg .ceg-body[data-act=pop]{animation:ceg-pop .45s ease-out 1!important}
.ceg .ceg-body[data-act=spin]{animation:paco-spin .6s ease-in-out 1!important}
.ceg .ceg-body[data-act=tip]{animation:paco-tip .9s ease-in-out 1!important}
.ceg .ceg-body[data-act=pose]{animation:alf-pose 1.5s ease-in-out 1!important}
.ceg .ceg-body[data-act=wiggle]{animation:tam-wiggle .75s linear 1!important}
.ceg .ceg-body[data-act=shake]{animation:ej-shake .85s ease-in-out 1!important}

/* Paco: swagger + shimmy */
@keyframes paco-tip{0%{transform:none}30%{transform:rotate(-11deg) translateY(3px) scale(1.03,.95)}55%{transform:rotate(-11deg) translateY(3px) scale(1.03,.95)}80%{transform:translateY(-10px) rotate(3deg)}100%{transform:none}}
@keyframes paco-spin{0%{transform:scale(1,1)}20%{transform:translateY(-14px) scale(.4,1.04)}40%{transform:translateY(-20px) scale(-1,1)}60%{transform:translateY(-14px) scale(-.4,1.04)}85%{transform:translateY(0) scale(1.08,.92)}100%{transform:none}}
/* Alfonso: smooth glide, lean back, cool pose */
@keyframes alf-pose{0%{transform:none}25%{transform:rotate(-8deg) skewX(5deg) scale(1.03)}70%{transform:rotate(-8deg) skewX(5deg) scale(1.03)}82%{transform:rotate(-6deg) translateY(2px) skewX(3deg)}100%{transform:none}}
/* Tamir: skip / gallop */
@keyframes tam-wiggle{0%,100%{transform:none}12%{transform:rotate(-8deg)}25%{transform:rotate(8deg)}37%{transform:rotate(-8deg)}50%{transform:rotate(8deg) translateY(-5px)}62%{transform:rotate(-6deg)}75%{transform:rotate(6deg)}87%{transform:rotate(-3deg)}}
/* Eggjun: grumpy heavy stomp */
@keyframes ej-shake{0%,100%{transform:scale(1.03,.97)}15%{transform:rotate(-6deg) scale(1.03,.97)}30%{transform:rotate(6deg) scale(1.03,.97)}45%{transform:rotate(-5deg) scale(1.03,.97)}60%{transform:rotate(5deg) scale(1.03,.97)}75%{transform:rotate(-2deg) scale(1.03,.97)}}
/* chase */
/* shared */
@keyframes ceg-glide{0%,100%{transform:translateY(0)}50%{transform:translateY(-3px)}}
@keyframes ceg-breathe{0%,100%{transform:scale(1,1)}50%{transform:scale(1.015,.985)}}
@keyframes ceg-jump{0%{transform:translateY(0) scale(1.12,.86)}35%{transform:translateY(-54px) scale(.93,1.08) rotate(-8deg)}60%{transform:translateY(-58px) rotate(8deg)}85%{transform:translateY(0) scale(1.14,.85)}100%{transform:none}}
@keyframes ceg-dance-nf{0%,100%{transform:none}12%{transform:translateY(-14px) rotate(-10deg)}25%{transform:translateY(0) scale(1.08,.92)}37%{transform:translateY(-14px) rotate(10deg)}50%{transform:translateY(0) scale(1.08,.92)}62%{transform:translateY(-18px) rotate(-6deg)}75%{transform:translateY(0) scale(1.08,.92)}87%{transform:translateY(-12px) rotate(6deg)}}
@keyframes ceg-hop{0%{transform:translateY(0) scale(1.08,.9)}45%{transform:translateY(-26px) scale(.96,1.05)}80%{transform:translateY(0) scale(1.08,.92)}100%{transform:none}}
@keyframes ceg-dance{0%,100%{transform:none}12%{transform:translateY(-14px) rotate(-10deg)}25%{transform:translateY(0) rotate(0) scale(1.08,.92)}37%{transform:translateY(-14px) rotate(10deg)}50%{transform:translateY(0) scale(1.08,.92)}62%{transform:translateY(-18px) scale(-1,1)}75%{transform:translateY(0) scale(-1.08,.92)}87%{transform:translateY(-12px) scale(1,1) rotate(-6deg)}}
@keyframes ceg-pop{0%{transform:scale(1.15,.82)}45%{transform:translateY(-10px) scale(.94,1.08)}100%{transform:none}}

/* ---- egg shell (hatch) ---- */
.ceg-shell{position:absolute;left:50%;bottom:-2px;width:var(--sw);height:var(--sh);margin-left:calc(var(--sw) / -2);z-index:2;transform-origin:50% 100%;pointer-events:none}
.ceg-shell svg{position:absolute;inset:0;width:100%;height:100%;overflow:visible;transform-origin:50% 70%}
.ceg-shell .crack{fill:none;stroke:#6b4a2b;stroke-width:2.2;stroke-linejoin:round;stroke-linecap:round}

/* ---- speech bubble (sits above the head; lifts with jumps) ---- */
.ceg-bubble{position:absolute;bottom:calc(100% + 12px);left:50%;z-index:3;transform:translate(-50%,6px) scale(.6);opacity:0;transform-origin:50% 100%;
  background:#faf4e8;color:#2b1a10;border:2px solid #c8924a;border-radius:16px;padding:8px 14px;white-space:nowrap;
  font:italic 700 19px/1.15 'Playfair Display',Georgia,serif;box-shadow:0 6px 16px rgba(28,18,11,.28);transition:opacity .2s ease,transform .28s cubic-bezier(.3,1.6,.5,1),translate .3s ease}
.ceg-bubble::after{content:"";position:absolute;top:100%;left:50%;margin-left:-7px;border:7px solid transparent;border-top-color:#c8924a}
.ceg-bubble::before{content:"";position:absolute;top:100%;left:50%;margin-left:-5px;margin-top:-1px;border:5px solid transparent;border-top-color:#faf4e8;z-index:1}
.ceg-bubble.to-r{left:40%;transform:translate(0,6px) scale(.6);transform-origin:10% 100%}
.ceg-bubble.to-r::after{left:16px}.ceg-bubble.to-r::before{left:16px}
.ceg-bubble.to-l{left:auto;right:40%;transform:translate(0,6px) scale(.6);transform-origin:90% 100%}
.ceg-bubble.to-l::after{left:auto;right:9px;margin-left:0}.ceg-bubble.to-l::before{left:auto;right:11px;margin-left:0}
.ceg-bubble.show{opacity:1;transform:translate(-50%,0) scale(1)}
.ceg-bubble.to-r.show,.ceg-bubble.to-l.show{transform:translate(0,0) scale(1)}
.ceg.lift .ceg-bubble{translate:0 -58px}

/* ---- sound toggle ---- */
.eggs-sound{position:fixed;left:16px;bottom:16px;z-index:41;width:46px;height:46px;border-radius:50%;border:2px solid #c8924a;background:#2b1a10;color:#e8c48a;
  display:flex;align-items:center;justify-content:center;cursor:pointer;padding:0;box-shadow:0 6px 18px rgba(28,18,11,.35);transition:transform .15s ease,background .2s ease}
.eggs-sound:hover{transform:scale(1.06)}
.eggs-sound:focus-visible{outline:3px solid #e8c48a;outline-offset:3px}
.eggs-sound svg{width:22px;height:22px}
.eggs-sound .on{display:none}
.eggs-sound[aria-pressed="true"]{background:linear-gradient(135deg,#8a5a2b,#e8b878 50%,#b87333);color:#1c120b}
.eggs-sound[aria-pressed="true"] .on{display:block}
.eggs-sound[aria-pressed="true"] .off{display:none}

@media (max-width:700px){
  .ceg-bubble{font-size:15px;padding:6px 12px;border-radius:13px;bottom:calc(100% + 8px)}
  .eggs-sound{width:40px;height:40px;left:12px;bottom:12px}
  .eggs-sound svg{width:19px;height:19px}
}
@media (prefers-reduced-motion:reduce){.eggs-layer{display:none}}
