/* extinction.meme · the beta bug (betabug.js): a little caterpillar lives behind the "beta" sticker.
   Everything here is drawn with plain CSS (no images, no inline styles: betabug.js only sets transforms / custom properties through CSSOM).
   It matches the site's sticker look (outline = --line, hard offset shadow = --shade), so it follows light / dark / america / halloween on its own. */

.xbb-layer { position: fixed; inset: 0; z-index: 78; pointer-events: none; overflow: hidden; } /* under the radio panel (80) and its player (81) */
.xbb-bug { position: absolute; inset: 0; pointer-events: none; }

/* the pieces are centred on their own origin (negative margins), so a translate() puts a piece's middle exactly where betabug.js says */
.xbb-seg, .xbb-head {
  position: absolute; left: 0; top: 0; box-sizing: border-box; border-radius: 50%;
  border: 2.5px solid var(--line, #2b1020); box-shadow: 2px 2px 0 var(--shade, #2b1020);
  background: #7fdc7a; pointer-events: auto; cursor: pointer; will-change: transform; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.xbb-s0 { width: 21px; height: 21px; margin: -10.5px 0 0 -10.5px; }
.xbb-s1 { width: 20px; height: 20px; margin: -10px 0 0 -10px; background: #70d06c; }
.xbb-s2 { width: 19px; height: 19px; margin: -9.5px 0 0 -9.5px; }
.xbb-s3 { width: 18px; height: 18px; margin: -9px 0 0 -9px; background: #70d06c; }
.xbb-s4 { width: 16px; height: 16px; margin: -8px 0 0 -8px; }
.xbb-s5 { width: 14px; height: 14px; margin: -7px 0 0 -7px; background: #70d06c; }
.xbb-head { width: 32px; height: 32px; margin: -16px 0 0 -16px; background: #8fe987; }
/* a shine on every piece, and tiny feet under the body segments (the segments never rotate, so the feet always point down) */
.xbb-seg::after, .xbb-head::after { content: ""; position: absolute; left: 20%; top: 14%; width: 30%; height: 20%; border-radius: 50%; background: rgba(255, 255, 255, .6); transform: rotate(-28deg); }
.xbb-seg::before { content: ""; position: absolute; left: 50%; bottom: -6px; width: 7px; height: 5px; margin-left: -3.5px; border-radius: 0 0 6px 6px; background: var(--line, #2b1020); }

/* halloween: a pumpkin caterpillar. america: red, white and blue stripes. */
:root[data-season="halloween"] .xbb-seg { background: #ffa04a; }
:root[data-season="halloween"] .xbb-s1, :root[data-season="halloween"] .xbb-s3, :root[data-season="halloween"] .xbb-s5 { background: #f07f1c; }
:root[data-season="halloween"] .xbb-head { background: #ffb870; }
:root[data-america="on"] .xbb-s0, :root[data-america="on"] .xbb-s3 { background: #ff5a6a; }
:root[data-america="on"] .xbb-s1, :root[data-america="on"] .xbb-s4 { background: #fff; }
:root[data-america="on"] .xbb-s2, :root[data-america="on"] .xbb-s5 { background: #5a8cff; }
:root[data-america="on"] .xbb-head { background: #fff; }

/* the face: --lx / --ly (set by betabug.js) nudge it toward where the bug is looking */
.xbb-face { position: absolute; left: 50%; top: 50%; width: 0; height: 0; transform: translate(var(--lx, 0px), var(--ly, 0px)); }
.xbb-eye { position: absolute; width: 10px; height: 12px; box-sizing: border-box; border-radius: 50%; background: #fff; border: 2px solid #2b1020; overflow: hidden; transform-origin: 50% 60%; }
.xbb-el { margin: -8px 0 0 -11px; }
.xbb-er { margin: -8px 0 0 1px; }
.xbb-eye b { position: absolute; left: 50%; top: 40%; width: 5px; height: 6px; margin: -1px 0 0 -2.5px; border-radius: 50%; background: #2b1020; }
.xbb-eye b::after { content: ""; position: absolute; right: 0; top: 0; width: 2px; height: 2px; border-radius: 50%; background: #fff; }
.xbb-cheek { position: absolute; width: 6px; height: 4px; border-radius: 50%; background: #ff8fbd; opacity: .95; margin-top: 3px; }
.xbb-cl { margin-left: -15px; }
.xbb-cr { margin-left: 9px; }
.xbb-mouth { position: absolute; width: 7px; height: 4px; margin: 4px 0 0 -3.5px; box-sizing: border-box; border: 0 solid #2b1020; border-bottom-width: 2px; border-radius: 0 0 7px 7px; }
.is-blink .xbb-eye { transform: scaleY(.12); }
.is-happy .xbb-eye { height: 7px; margin-top: -4px; border-radius: 10px 10px 0 0; border-bottom: 0; background: transparent; }
.is-happy .xbb-eye b { display: none; }
.is-happy .xbb-mouth { width: 9px; height: 5px; margin-left: -4.5px; background: #ff6f9f; border-bottom-width: 2px; border-radius: 0 0 9px 9px; }
.is-sad .xbb-eye { height: 10px; }
.is-sad .xbb-eye b { top: 55%; }
.is-sad .xbb-mouth { margin-top: 6px; border-bottom-width: 0; border-top-width: 2px; border-radius: 7px 7px 0 0; }

/* antennae: a stalk with a pink tip, swaying a little */
.xbb-ant { position: absolute; left: 50%; top: -11px; width: 2.5px; height: 12px; margin-left: -1.25px; border-radius: 2px; background: var(--line, #2b1020); transform-origin: 50% 100%; }
.xbb-ant b { position: absolute; left: 50%; top: -5px; width: 7px; height: 7px; box-sizing: border-box; margin-left: -3.5px; border-radius: 50%; background: #ff8fbd; border: 2px solid var(--line, #2b1020); }
.xbb-al { transform: translateX(-7px) rotate(-24deg); animation: xbb-sway-l .55s ease-in-out infinite alternate; }
.xbb-ar { transform: translateX(7px) rotate(24deg); animation: xbb-sway-r .55s .12s ease-in-out infinite alternate; }
@keyframes xbb-sway-l { from { transform: translateX(-7px) rotate(-30deg); } to { transform: translateX(-7px) rotate(-14deg); } }
@keyframes xbb-sway-r { from { transform: translateX(7px) rotate(14deg); } to { transform: translateX(7px) rotate(30deg); } }
.is-sad .xbb-al { transform: translateX(-7px) rotate(-52deg); animation: none; }
.is-sad .xbb-ar { transform: translateX(7px) rotate(52deg); animation: none; }

/* the boombox gets booped */
.xr-boombox.xbb-boop { animation: xbb-boop .55s cubic-bezier(.3, 1.5, .5, 1); }
@keyframes xbb-boop {
  0% { transform: none; }
  22% { transform: translateY(-3px) scale(1.14, .76); }
  52% { transform: translateY(2px) scale(.92, 1.14); }
  78% { transform: scale(1.04, .97); }
  100% { transform: none; }
}

/* calm mode / reduced motion: no crawling at all (betabug.js doesn't start the loop); the bug just fades in on the boombox and fades out again */
.xbb-layer.is-calm .xbb-bug { opacity: 0; transition: opacity .45s ease; }
.xbb-layer.is-calm.is-in .xbb-bug { opacity: 1; }
.xbb-layer.is-calm .xbb-ant { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .xbb-ant { animation: none; }
  .xr-boombox.xbb-boop { animation: none; }
}
:root[data-calm] .xbb-ant { animation: none; }
:root[data-calm] .xr-boombox.xbb-boop { animation: none; }
