/* BonBon the actor. Layers: .bba (place + walk) > .bba-sway (idle sway) > .bba-gest (gestures) > .bba-body (breathing, talking) > img */
.bba{--bba-size:56px;--bba-x:0px;--bba-walk:600ms;position:relative;display:inline-block;width:var(--bba-size);height:calc(var(--bba-size) * 1.08);flex:none;vertical-align:bottom;
  transform:translateX(var(--bba-x));transition:transform var(--bba-walk) cubic-bezier(.4,0,.2,1);-webkit-tap-highlight-color:transparent}
.bba.is-adopted{width:100%;height:100%}
.bba.is-kept .bba-img{margin:0!important;max-width:none}
.bba-sway,.bba-gest,.bba-body{display:block;width:100%;height:100%;transform-origin:50% 92%;will-change:transform}
.bba-sway{animation:bba-sway 5.6s ease-in-out var(--bba-delay,0s) infinite}
.bba-body{animation:bba-breathe 3.1s ease-in-out var(--bba-delay,0s) infinite}
.bba-img{display:block;width:100%;height:100%;object-fit:contain;filter:drop-shadow(0 5px 8px rgba(58,42,34,.2));user-select:none;-webkit-user-drag:none;animation:none!important;transform:none!important}
.bba-shadow{position:absolute;left:18%;right:18%;bottom:-2%;height:9%;border-radius:50%;background:radial-gradient(closest-side,rgba(74,25,66,.28),rgba(74,25,66,0));transform-origin:50% 50%;animation:bba-shadow 3.1s ease-in-out var(--bba-delay,0s) infinite;pointer-events:none}
.bba.no-shadow .bba-shadow{display:none}
.bba.is-paused .bba-sway,.bba.is-paused .bba-body,.bba.is-paused .bba-shadow{animation-play-state:paused}
/* Breathing: a soft squash and stretch from the feet, never a flat up-and-down bob. */
@keyframes bba-breathe{0%,100%{transform:scale(1,1)}45%{transform:translateY(-2px) scale(.985,1.03)}70%{transform:scale(1.012,.988)}}
/* Sway: weight shifts foot to foot with a small glance each way. */
@keyframes bba-sway{0%,100%{transform:rotate(0)}18%{transform:rotate(-2.6deg) translateX(-1px)}36%{transform:rotate(-1deg)}58%{transform:rotate(2.8deg) translateX(1px)}80%{transform:rotate(.6deg)}}
@keyframes bba-shadow{0%,100%{transform:scale(1)}45%{transform:scale(.93)}}

/* Typing dots and bubble pop for actor.say() */
.bba-dots{display:inline-flex;align-items:center;gap:4px;height:.8em}
.bba-dots i{width:6px;height:6px;border-radius:50%;background:currentColor;opacity:.35;animation:bba-dot 1.1s ease-in-out infinite}
.bba-dots i:nth-child(2){animation-delay:.16s}.bba-dots i:nth-child(3){animation-delay:.32s}
@keyframes bba-dot{0%,60%,100%{opacity:.3;transform:none}30%{opacity:.95;transform:translateY(-3px)}}
.bba-pop{animation:bba-pop .4s cubic-bezier(.34,1.56,.64,1) both}
@keyframes bba-pop{0%{opacity:.4;transform:scale(.9) translateY(4px)}100%{opacity:1;transform:none}}

/* The standard pair: BonBon beside his bubble (used by the builder and anywhere he narrates live). */
.bba-nar{display:flex;align-items:flex-end;gap:8px;min-height:60px}
.bba-nar.is-right{flex-direction:row-reverse}
.bba-bubble{position:relative;flex:0 1 auto;min-width:0;max-width:calc(100% - 64px);margin-bottom:10px;padding:9px 13px;border-radius:18px 18px 18px 6px;background:#FFFDF9;color:#33202F;border:1px solid #ECD7A4;box-shadow:0 6px 16px rgba(74,27,67,.1);font:500 14.5px/1.35 "DM Sans",system-ui,sans-serif;transform-origin:0 100%}
.bba-nar.is-right .bba-bubble{border-radius:18px 18px 6px 18px;transform-origin:100% 100%}
.bba-bubble:empty{display:none}
.bba-bubble.is-typing{color:#6B4A66;padding:12px 14px}

/* Existing BonBons that get adopted keep their box; their old one-note bob is switched off. */
.glz-nar-btn:has(.bba),.bbx-launch:has(.bba),.bbl-ava:has(.bba){animation:none!important}
.bbx-launch .bba{width:66px;height:66px;transform:translate(var(--bba-x),3px)}
.bbx-launch .bba .bba-shadow{display:none}
@media (max-width:640px){.bbx-launch .bba{width:58px;height:58px}}

@media (prefers-reduced-motion:reduce){.bba,.bba *{animation:none!important;transition:none!important}}
