.avatar-interaction {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.95rem;
  margin: 2rem auto 2.4rem;
  width: fit-content;
  max-width: 100%;
}

.spin-avatar-button {
  appearance: none;
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  display: block;
  position: relative;
  cursor: pointer;
  border-radius: 50%;
  transform-origin: center;
}

.spin-avatar-button:focus-visible {
  outline: 2px solid #ff8b8b;
  outline-offset: 8px;
}

.spin-avatar {
  display: block;
  width: 176px;
  height: 176px;
  border-radius: 50%;
  object-fit: cover;
  image-rendering: pixelated;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 91, 91, 0.18);
  box-shadow:
    0 18px 42px rgba(0, 0, 0, 0.32),
    0 0 0 8px rgba(255, 91, 91, 0.05);
  animation: spin-avatar 9s linear infinite;
  transition: box-shadow 0.18s ease, filter 0.18s ease;
}

.spin-avatar-button:hover .spin-avatar {
  filter: brightness(1.05);
  box-shadow:
    0 22px 50px rgba(0, 0, 0, 0.36),
    0 0 0 10px rgba(255, 91, 91, 0.08);
}

.spin-avatar-button.is-clicked {
  animation: avatar-press 0.46s cubic-bezier(.2,.8,.2,1) 1;
}

.avatar-greeting {
  position: absolute;
  inset: -3.25rem -5rem -2.5rem;
  pointer-events: none;
  overflow: visible;
  z-index: 3;
}

.avatar-popup {
  position: absolute;
  left: 50%;
  top: 50%;
  padding: 0;
  border: none;
  background: transparent;
  color: #fffdfd;
  font-size: 2rem;
  font-weight: 700;
  white-space: nowrap;
  text-shadow:
    0 0 18px rgba(255, 91, 91, 0.24),
    0 10px 22px rgba(0, 0, 0, 0.24);
  filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.28));
  opacity: 0;
  transform: translate(
      calc(-50% + var(--x, 0px)),
      calc(-50% + var(--y, 0px))
    )
    scale(0.82)
    rotate(var(--r, 0deg));
  animation: avatar-popup 1.45s cubic-bezier(.2,.72,.22,1) forwards;
}

@keyframes spin-avatar {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes avatar-press {
  0% { transform: scale(1); }
  35% { transform: scale(0.9); }
  68% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

@keyframes avatar-popup {
  0% {
    opacity: 0;
    transform: translate(
        calc(-50% + var(--x, 0px)),
        calc(-50% + var(--y, 0px))
      )
      scale(0.82)
      rotate(var(--r, 0deg));
  }
  12% {
    opacity: 1;
  }
  40% {
    opacity: 1;
    transform: translate(
        calc(-50% + var(--x, 0px)),
        calc(-50% + var(--y, 0px) - var(--peak, 62px))
      )
      scale(1.1)
      rotate(var(--r, 0deg));
  }
  62% {
    opacity: 0.92;
    transform: translate(
        calc(-50% + var(--x, 0px)),
        calc(-50% + var(--y, 0px) - calc(var(--peak, 62px) * 0.56))
      )
      scale(1.02)
      rotate(var(--r, 0deg));
  }
  100% {
    opacity: 0;
    transform: translate(
        calc(-50% + var(--x, 0px)),
        calc(-50% + var(--y, 0px) + var(--fall, 34px))
      )
      scale(0.94)
      rotate(var(--r, 0deg));
  }
}

@media only screen and (min-width: 860px) {
  html.js #mdbook-sidebar-toggle-anchor ~ .sidebar {
    transform: none !important;
  }

  html.js #mdbook-sidebar-toggle-anchor ~ .page-wrapper {
    transform: none !important;
    margin-inline-start: calc(var(--sidebar-width) + var(--sidebar-resize-indicator-width)) !important;
  }

  html.js[dir="rtl"] #mdbook-sidebar-toggle-anchor ~ .page-wrapper {
    margin-inline-start: 0 !important;
    margin-inline-end: calc(var(--sidebar-width) + var(--sidebar-resize-indicator-width)) !important;
  }
}

