/* Gummy and his speech bubble */

.gummy {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 1000;
  width: 120px;
  will-change: transform;
  pointer-events: none;
}

.gummy-body {
  display: block;
  width: 100%;
  padding: 0;
  cursor: pointer;
  background: none;
  border: 0;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}

.gummy-body:focus-visible {
  outline: 2px dashed var(--cyan);
  outline-offset: 2px;
  border-radius: 12px;
}

.gummy svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.55));
  animation: gm-bob 3.2s ease-in-out infinite;
  transform-origin: 50% 90%;
}

.gummy.jitter svg {
  animation: gm-bob 3.2s ease-in-out infinite, gm-jitter 0.35s steps(2) infinite;
}

.gummy.poked svg {
  animation: gm-squish 0.35s ease-out;
}

.gm-led {
  animation: gm-pulse 2.4s ease-in-out infinite;
}

.gm-antenna-tip {
  filter: drop-shadow(0 0 4px #6ff3ff);
  animation: gm-pulse 1.8s ease-in-out infinite;
}

.gm-brows {
  transition: transform 0.2s;
}

.gummy.talking .gm-brows {
  transform: translateY(-4px);
}

.gummy.talking .gm-grille {
  animation: gm-flicker 0.18s steps(2) infinite;
}

.gummy.talking .gm-mouth {
  animation: gm-talk 0.3s ease-in-out infinite alternate;
  transform-box: fill-box;
  transform-origin: center;
}

.gummy.talking .gm-antenna-tip {
  animation-duration: 0.4s;
}

.gummy[data-level="5"] .gm-led {
  animation-duration: 0.6s;
}

@keyframes gm-bob {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-6px) rotate(1.5deg); }
}

@keyframes gm-jitter {
  0% { translate: -1.5px 0; }
  100% { translate: 1.5px 0.5px; }
}

@keyframes gm-squish {
  0% { transform: scale(1, 1); }
  30% { transform: scale(1.18, 0.82); }
  60% { transform: scale(0.92, 1.1); }
  100% { transform: scale(1, 1); }
}

@keyframes gm-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

@keyframes gm-flicker {
  0% { opacity: 0.25; }
  100% { opacity: 1; }
}

@keyframes gm-talk {
  from { transform: scaleY(0.6); }
  to { transform: scaleY(1.3); }
}

/* bubble: yellow tooltip, grey bevelled buttons, the classic look */

.gummy-bubble {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 1001;
  width: min(290px, calc(100vw - 16px));
  padding: 0.9rem 1rem 0.8rem;
  color: #1a1a1a;
  font: 14px/1.45 Tahoma, Verdana, "Segoe UI", sans-serif;
  background: #fffbd1;
  border: 1px solid #1a1a1a;
  border-radius: 10px;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.45);
  opacity: 0;
  scale: 0.92;
  transition: opacity 0.18s, scale 0.18s;
  will-change: transform;
}

.gummy-bubble.show {
  opacity: 1;
  scale: 1;
}

.gummy-bubble::after {
  content: "";
  position: absolute;
  bottom: -9px;
  right: 34px;
  width: 16px;
  height: 16px;
  background: #fffbd1;
  border-right: 1px solid #1a1a1a;
  border-bottom: 1px solid #1a1a1a;
  transform: rotate(45deg);
}

.gummy-bubble[data-side="right"]::after {
  right: auto;
  left: 34px;
}

.gb-text {
  margin: 0 1rem 0.75rem 0;
}

.gb-x {
  position: absolute;
  top: 4px;
  right: 6px;
  width: 22px;
  height: 22px;
  padding: 0;
  color: #444;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  background: none;
  border: 0;
}

.gb-x:hover {
  color: #000;
}

.gb-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
}

.gb-actions.swap {
  flex-direction: row-reverse;
  justify-content: flex-start;
}

.gb-actions button {
  min-width: 70px;
  padding: 4px 10px;
  color: #000;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  background: #d4d0c8;
  border: 0;
  border-radius: 0;
  box-shadow:
    inset -1px -1px #0a0a0a,
    inset 1px 1px #ffffff,
    inset -2px -2px #808080,
    inset 2px 2px #dfdfdf;
}

.gb-actions button:active {
  box-shadow:
    inset 1px 1px #0a0a0a,
    inset -1px -1px #ffffff,
    inset 2px 2px #808080,
    inset -2px -2px #dfdfdf;
}

.gb-actions button:focus-visible {
  outline: 1px dotted #000;
  outline-offset: -5px;
}

.gb-actions button[data-action="stop"] {
  color: #8a0000;
}

/* whatever Gummy is pointing at */

.gummy-pointed {
  outline: 2px solid var(--cyan);
  outline-offset: 6px;
  border-radius: 4px;
  animation: gm-point 1s ease-in-out infinite;
}

@keyframes gm-point {
  0%, 100% { outline-color: rgba(111, 243, 255, 0.9); }
  50% { outline-color: rgba(111, 243, 255, 0.2); }
}

/* the sulking tab */

.gummy-tab {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.85rem 0.45rem 0.55rem;
  color: #2a0d1b;
  font: 500 0.8rem var(--body);
  cursor: pointer;
  background: var(--pink);
  border: 0;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.gummy-tab[hidden],
.gummy-bubble[hidden] {
  display: none;
}

.gummy-tab-icon {
  width: 8px;
  height: 18px;
  background: linear-gradient(90deg, #ffa6cf 50%, #b8c0c8 50%);
  border-radius: 2px;
}

/* Fingers need bigger targets than the classic look allows. */
@media (pointer: coarse) {
  .gb-x {
    top: 0;
    right: 0;
    width: 44px;
    height: 44px;
  }

  .gb-text {
    margin-right: 1.75rem;
  }

  .gb-actions {
    gap: 0.5rem;
  }

  .gb-actions button {
    min-height: 44px;
    padding: 6px 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gummy svg,
  .gummy.jitter svg,
  .gm-led,
  .gm-antenna-tip,
  .gummy.talking .gm-grille,
  .gummy.talking .gm-mouth,
  .gummy-pointed {
    animation: none;
  }

  .gummy-bubble {
    transition: none;
  }
}
