/* Live2D waifu widget + cat-rope back-to-top (ported from the Aurora blog). */

#waifu-wrap {
  position: fixed;
  left: 0;
  bottom: -10px;
  width: 280px;
  z-index: 100;
  transition: transform 0.3s ease;
}

#waifu-wrap canvas {
  display: block;
  cursor: pointer;
}

/* Speech bubble */
.waifu-tips {
  position: absolute;
  top: -60px;
  left: 20px;
  width: 240px;
  min-height: 50px;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 0.8rem;
  line-height: 1.5;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  background: rgba(255, 255, 255, 0.92);
  color: #444;
  border: 1px solid rgba(232, 74, 39, 0.35);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}

.waifu-tips-active { opacity: 1; }

.waifu-tips-from {
  display: block;
  font-size: 0.72rem;
  opacity: 0.7;
  text-align: right;
}

body:not(.light-mode) .waifu-tips {
  background: rgba(30, 32, 40, 0.92);
  color: #eee;
  border-color: rgba(232, 74, 39, 0.5);
}

/* Tool menu (shown on hover) */
.waifu-tool {
  position: absolute;
  right: 4px;
  top: 30px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

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

.waifu-tool button {
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  line-height: 28px;
  text-align: center;
  color: #fff;
  background: rgba(232, 74, 39, 0.75);
  transition: background 0.2s ease, transform 0.2s ease;
}

.waifu-tool button:hover {
  background: #e84a27;
  transform: scale(1.12);
}

/* Cat hanging on a rope — back to top */
#cat-rope {
  position: fixed;
  top: 0;
  right: 20px;
  width: 70px;
  height: 950px;
  z-index: 100;
  will-change: transform;
  transform: translateY(-950px);
  transition: transform 0.3s ease-out;
  pointer-events: none;
}

.cat-rope-inner {
  width: 100%;
  height: 100%;
  pointer-events: auto;
  cursor: pointer;
  background-image: url('/assets/img/back-top.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  animation: catFloat 3s linear infinite;
}

@keyframes catFloat {
  0%   { transform: translateY(0); }
  50%  { transform: translateY(-6px); }
  100% { transform: translateY(0); }
}

/* White Album 2 corner widgets: Setsuna right, Kazusa left */
#wa2-widget {
  position: fixed;
  right: 100px;
  bottom: 14px;
  z-index: 99;
  width: 170px;
  text-align: center;
}

#wa2-widget-left {
  position: fixed;
  left: 20px;
  bottom: 14px;
  z-index: 99;
  width: 170px;
  text-align: center;
}

.wa2-chara {
  display: block;
  margin: 0 auto;
  height: 280px;
  width: auto;
  cursor: pointer;
  animation: wa2Breath 6s ease-in-out infinite;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.35));
  transition: transform 0.3s ease;
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
  /* Some game sprites bleed off the top edge (esp. Kazusa); fade the
   * top out softly instead of showing a hard cut line. */
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 26px);
  mask-image: linear-gradient(to bottom, transparent 0, #000 26px);
}

.wa2-chara:hover { transform: scale(1.04); }

@keyframes wa2Breath {
  0%   { transform: translateY(0) scale(1); }
  50%  { transform: translateY(-6px) scale(1.012); }
  100% { transform: translateY(0) scale(1); }
}
.wa2-chara:hover { animation-play-state: paused; }

.wa2-tips {
  position: absolute;
  top: -46px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 150px;
  max-width: 220px;
  padding: 7px 11px;
  border-radius: 10px;
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  background: rgba(30, 32, 40, 0.92);
  color: #eee;
  border: 1px solid rgba(176, 196, 222, 0.45);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

body.light-mode .wa2-tips {
  background: rgba(255, 255, 255, 0.94);
  color: #444;
  border-color: rgba(100, 130, 180, 0.4);
}

.wa2-tips-active { opacity: 1; }

.wa2-tools {
  position: absolute;
  top: -14px;
  right: 4px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.wa2-box:hover .wa2-tools { opacity: 1; }

.wa2-tools button {
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  line-height: 28px;
  color: #fff;
  background: rgba(100, 130, 180, 0.8);
  transition: transform 0.2s ease, background 0.2s ease;
}

.wa2-tools button:hover { transform: scale(1.12); background: #6482b4; }

/* Keep the fixed BGM player clear of the Live2D waifu (280px wide, left). */
.aplayer.aplayer-fixed { left: 290px; right: auto; }
.aplayer.aplayer-fixed .aplayer-body { left: 290px; right: auto; width: 360px; }

@media screen and (max-width: 767px) {
  #waifu-wrap, #cat-rope, #wa2-widget, #wa2-widget-left, .aplayer.aplayer-fixed { display: none; }
}
