/* ============================================================
 * 看板娘（Live2D）样式
 * 移植自 poetize / stevenjoezhang/live2d-widget 的 waifu.css
 * 改写：适配 Butterfly 主题变量与暗黑模式、FontAwesome 6 图标
 * 配套：source/js/butterfly/live2d.js
 * ============================================================ */

/* 左下角开关（收起状态下露出半截） */
#waifu-toggle {
  align-items: center;
  background: var(--btn-bg, #49b1f5);
  border-radius: 5px;
  bottom: 66px;
  color: var(--btn-color, #fff);
  cursor: pointer;
  display: flex;
  font-size: 12px;
  justify-content: center;
  left: 0;
  margin-left: -60px;
  padding: 6px 12px;
  position: fixed;
  transition: margin-left 1s, background 0.3s, box-shadow 0.3s;
  user-select: none;
  z-index: 1000;
}

#waifu-toggle:hover {
  background: var(--btn-hover-color, #ff7242);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
}

#waifu-toggle.waifu-toggle-active {
  margin-left: -36px;
}

#waifu-toggle.waifu-toggle-active:hover {
  margin-left: -12px;
}

/* 看板娘主体（底部滑入） */
#waifu {
  bottom: -500px;
  left: 0;
  position: fixed;
  transform: translateY(25px);
  transition: transform 0.3s ease-in-out, bottom 3s ease-in-out;
  z-index: 999;
}

#waifu:hover {
  transform: translateY(20px);
}

/* 对话气泡 */
#waifu-tips {
  animation: waifu-shake 50s ease-in-out 5s infinite;
  background-color: rgba(236, 217, 188, 0.5);
  border: 1px solid rgba(224, 186, 140, 0.62);
  border-radius: 12px;
  box-shadow: 0 3px 15px 2px rgba(191, 158, 118, 0.2);
  font-size: 14px;
  line-height: 24px;
  margin: -30px 20px;
  min-height: 70px;
  opacity: 0;
  overflow: hidden;
  padding: 5px 10px;
  position: absolute;
  text-overflow: ellipsis;
  transition: opacity 1s;
  width: 220px;
  word-break: break-all;
}

#waifu-tips.waifu-tips-active {
  opacity: 1;
  transition: opacity 0.2s;
}

#waifu-tips span {
  color: #0099cc;
}

/* 模型画布 */
#live2d {
  cursor: grab;
  height: 220px;
  position: relative;
  width: 220px;
}

#live2d:active {
  cursor: grabbing;
}

/* 鼠标悬停在看板娘上时，提示画布可点击（默认 grab 是拖拽暗示） */
#waifu:hover #live2d {
  cursor: pointer;
}

/* 右侧工具栏（hover 显示） */
#waifu-tool {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
  opacity: 0;
  position: absolute;
  right: -10px;
  top: 70px;
  transition: opacity 1s;
}

#waifu:hover #waifu-tool {
  opacity: 1;
}

#waifu-tool i {
  border-radius: 50%;
  color: var(--font-color, #4c4948);
  cursor: pointer;
  display: block;
  font-size: 16px;
  height: 26px;
  line-height: 26px;
  text-align: center;
  transition: background 0.3s, color 0.3s;
  width: 26px;
}

#waifu-tool i:hover {
  background: rgba(73, 177, 245, 0.15);
  color: var(--btn-bg, #49b1f5);
}

/* 点击文字上浮动画（富强民主文明和谐…） */
.live2d-click-text {
  color: #ff6651;
  font-weight: bold;
  pointer-events: none;
  position: absolute;
  z-index: 1000;
  animation: live2d-text-float 1.5s ease-out forwards;
}

@keyframes live2d-text-float {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
    transform: translateY(-160px);
  }
}

/* 暗黑模式适配 */
[data-theme='dark'] #waifu-toggle {
  background: var(--btn-bg, #49b1f5);
}

[data-theme='dark'] #waifu-tips {
  background-color: rgba(50, 48, 46, 0.85);
  border: 1px solid rgba(90, 90, 90, 0.62);
  box-shadow: 0 3px 15px 2px rgba(0, 0, 0, 0.3);
  color: var(--font-color, #e8e6e3);
}

[data-theme='dark'] #waifu-tips span {
  color: #7cc7ff;
}

[data-theme='dark'] #waifu-tool i {
  color: var(--font-color, #e8e6e3);
}

[data-theme='dark'] #waifu-tool i:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* 气泡轻微摇晃动画（原版） */
@keyframes waifu-shake {
  2% {
    transform: translate(0.5px, -1.5px) rotate(-0.5deg);
  }

  4% {
    transform: translate(0.5px, 1.5px) rotate(1.5deg);
  }

  6% {
    transform: translate(1.5px, 1.5px) rotate(1.5deg);
  }

  8% {
    transform: translate(2.5px, 1.5px) rotate(0.5deg);
  }

  10% {
    transform: translate(0.5px, 2.5px) rotate(0.5deg);
  }

  12% {
    transform: translate(1.5px, 1.5px) rotate(0.5deg);
  }

  14% {
    transform: translate(0.5px, 0.5px) rotate(0.5deg);
  }

  16% {
    transform: translate(-1.5px, -0.5px) rotate(1.5deg);
  }

  18% {
    transform: translate(0.5px, 0.5px) rotate(1.5deg);
  }

  20% {
    transform: translate(2.5px, 2.5px) rotate(1.5deg);
  }

  22% {
    transform: translate(0.5px, -1.5px) rotate(1.5deg);
  }

  24% {
    transform: translate(-1.5px, 1.5px) rotate(-0.5deg);
  }

  26% {
    transform: translate(1.5px, 0.5px) rotate(1.5deg);
  }

  28% {
    transform: translate(-0.5px, -0.5px) rotate(-0.5deg);
  }

  30% {
    transform: translate(1.5px, -0.5px) rotate(-0.5deg);
  }

  32% {
    transform: translate(2.5px, -1.5px) rotate(1.5deg);
  }

  34% {
    transform: translate(2.5px, 2.5px) rotate(-0.5deg);
  }

  36% {
    transform: translate(0.5px, -1.5px) rotate(0.5deg);
  }

  38% {
    transform: translate(2.5px, -0.5px) rotate(0.5deg);
  }

  40% {
    transform: translate(-0.5px, 2.5px) rotate(0.5deg);
  }

  42% {
    transform: translate(-1.5px, 2.5px) rotate(0.5deg);
  }

  44% {
    transform: translate(-1.5px, 1.5px) rotate(0.5deg);
  }

  46% {
    transform: translate(1.5px, -0.5px) rotate(-0.5deg);
  }

  48% {
    transform: translate(2.5px, -0.5px) rotate(0.5deg);
  }

  50% {
    transform: translate(-1.5px, 1.5px) rotate(0.5deg);
  }

  52% {
    transform: translate(-0.5px, 1.5px) rotate(0.5deg);
  }

  54% {
    transform: translate(-1.5px, 1.5px) rotate(0.5deg);
  }

  56% {
    transform: translate(0.5px, 2.5px) rotate(1.5deg);
  }

  58% {
    transform: translate(2.5px, 2.5px) rotate(0.5deg);
  }

  60% {
    transform: translate(2.5px, -1.5px) rotate(1.5deg);
  }

  62% {
    transform: translate(-1.5px, 0.5px) rotate(1.5deg);
  }

  64% {
    transform: translate(-1.5px, 1.5px) rotate(1.5deg);
  }

  66% {
    transform: translate(0.5px, 2.5px) rotate(1.5deg);
  }

  68% {
    transform: translate(2.5px, -1.5px) rotate(1.5deg);
  }

  70% {
    transform: translate(2.5px, 2.5px) rotate(0.5deg);
  }

  72% {
    transform: translate(-0.5px, -1.5px) rotate(1.5deg);
  }

  74% {
    transform: translate(-1.5px, 2.5px) rotate(1.5deg);
  }

  76% {
    transform: translate(-1.5px, 2.5px) rotate(1.5deg);
  }

  78% {
    transform: translate(-1.5px, 2.5px) rotate(0.5deg);
  }

  80% {
    transform: translate(-1.5px, 0.5px) rotate(-0.5deg);
  }

  82% {
    transform: translate(-1.5px, 0.5px) rotate(-0.5deg);
  }

  84% {
    transform: translate(-0.5px, 0.5px) rotate(1.5deg);
  }

  86% {
    transform: translate(2.5px, 1.5px) rotate(0.5deg);
  }

  88% {
    transform: translate(-1.5px, 0.5px) rotate(1.5deg);
  }

  90% {
    transform: translate(-1.5px, -0.5px) rotate(-0.5deg);
  }

  92% {
    transform: translate(-1.5px, -1.5px) rotate(1.5deg);
  }

  94% {
    transform: translate(0.5px, 0.5px) rotate(-0.5deg);
  }

  96% {
    transform: translate(2.5px, -0.5px) rotate(-0.5deg);
  }

  98% {
    transform: translate(-1.5px, -1.5px) rotate(1.5deg);
  }

  0%,
  100% {
    transform: translate(0, 0) rotate(0);
  }
}
