/* 背景音乐悬浮按钮。 */

.yn-bgm-btn {
  position: fixed;
  /* 初始位置；用户拖拽后由本机记录覆盖。 */
  top: calc(66px + env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right, 14px)); /* 避开横屏安全区。 */
  z-index: 290;

  /* 胶囊按钮比纯图标更容易识别。 */
  min-width: 44px;
  height: 40px;
  padding: 0 12px 0 10px;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;

  background: rgba(12, 12, 18, 0.72);
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);

  border: 1px solid rgba(232, 200, 107, 0.36);
  border-radius: 999px; /* 胶囊 */
  color: rgba(232, 200, 107, 0.9);

  cursor: grab;
  touch-action: none;              /* 拖拽时接管触摸手势。 */
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;

  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.28),
    inset 0 0 0 1px rgba(245, 223, 160, 0.06);

  transition:
    background 0.25s ease,
    border-color 0.25s ease,
    color 0.25s ease,
    box-shadow 0.25s ease,
    transform 0.12s ease;
}

.yn-bgm-btn:active,
.yn-bgm-btn.yn-bgm-btn--dragging {
  cursor: grabbing;
}

.yn-bgm-btn.yn-bgm-btn--dragging {
  transform: scale(1.08);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.45),
    0 0 0 6px rgba(232, 200, 107, 0.08);
  transition: none;
}

.yn-bgm-btn:active:not(.yn-bgm-btn--dragging) {
  transform: scale(0.94);
}

/* 隐藏旧版条形音频控件。 */
.yn-bgm-bars,
.yn-bgm-bar,
.yn-bgm-label { display: none !important; }

/* 音符图标。 */
.yn-bgm-btn .yn-bgm-icon {
  width: 20px;
  height: 20px;
  color: inherit;
  pointer-events: none;
  flex-shrink: 0;
}

/* “音乐”文字标签。 */
.yn-bgm-btn .yn-bgm-label {
  font-family: 'Noto Serif SC', 'LXGW WenKai', serif;
  font-size: 12.5px;
  letter-spacing: 0.16em;
  line-height: 1;
  color: inherit;
  pointer-events: none;
  white-space: nowrap;
}

/* 图标和文字横向排列。 */
.yn-bgm-btn .yn-bgm-inner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

/* 静音斜线默认显示。 */
.yn-bgm-mute-slash {
  stroke: currentColor;
  opacity: 1;
  transition: opacity 200ms ease;
}
/* 播放时隐藏斜线。 */
.yn-bgm-btn--playing .yn-bgm-mute-slash,
.yn-bgm-btn--loading .yn-bgm-mute-slash { opacity: 0; }

/* 其他页面激活时隐藏按钮。 */
.yn-bgm-btn--hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.85);
}

/* 状态样式。 */
.yn-bgm-btn--idle,
.yn-bgm-btn--paused {
  color: rgba(232, 200, 107, 0.72);
}

.yn-bgm-btn--loading {
  color: rgba(232, 200, 107, 0.88);
  animation: yn-bgm-pulse 1.6s ease-in-out infinite;
}

.yn-bgm-btn--playing {
  background: linear-gradient(180deg, rgba(232, 200, 107, 0.24) 0%, rgba(232, 200, 107, 0.12) 100%);
  border-color: rgba(232, 200, 107, 0.68);
  color: #f5dfa0;
  box-shadow:
    0 0 18px rgba(232, 200, 107, 0.32),
    0 4px 14px rgba(0, 0, 0, 0.3),
    inset 0 0 0 1px rgba(245, 223, 160, 0.08);
}

.yn-bgm-btn--playing .yn-bgm-icon {
  animation: yn-bgm-bob 1.2s ease-in-out infinite;
}

.yn-bgm-btn--error {
  color: rgba(232, 200, 107, 0.4);
  border-color: rgba(232, 200, 107, 0.18);
}

@keyframes yn-bgm-pulse {
  0%, 100% { box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28), 0 0 0 0 rgba(232, 200, 107, 0.32); }
  50%      { box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28), 0 0 0 10px rgba(232, 200, 107, 0); }
}

@keyframes yn-bgm-bob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50%      { transform: translateY(-2px) rotate(3deg); }
}

@media (prefers-reduced-motion: reduce) {
  .yn-bgm-btn--playing .yn-bgm-icon,
  .yn-bgm-btn--loading { animation: none; }
}

/* 音乐轻提示。 */
.yn-bgm-toast {
  position: fixed;
  top: calc(18px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  z-index: 310;
  padding: 10px 16px;
  background: rgba(10, 10, 15, 0.92);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(232, 200, 107, 0.32);
  border-radius: 10px;
  color: #f5dfa0;
  font-family: 'LXGW WenKai', 'Noto Serif SC', serif;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.26s ease, transform 0.26s ease;
  pointer-events: none;
  max-width: 80vw;
  white-space: nowrap;
}

.yn-bgm-toast--on {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* 音乐首次发现提示。 */
.yn-bgm-tip {
  position: fixed;
  z-index: 295;
  width: 180px;
  padding: 10px 14px;
  background: rgba(10, 10, 15, 0.94);
  border: 1px solid rgba(232, 200, 107, 0.38);
  border-radius: 12px;
  color: #f5dfa0;
  font-family: 'LXGW WenKai', 'Noto Serif SC', serif;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-align: center;
  line-height: 1.45;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translateY(4px) scale(0.96);
  transition: opacity 0.32s ease, transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  animation: ynBgmTipBreath 2.6s ease-in-out infinite 0.6s;
}
.yn-bgm-tip--on {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.yn-bgm-tip-arrow {
  position: absolute;
  right: -6px;
  top: 50%;
  margin-top: -6px;
  width: 12px;
  height: 12px;
  background: rgba(10, 10, 15, 0.94);
  border-top: 1px solid rgba(232, 200, 107, 0.38);
  border-right: 1px solid rgba(232, 200, 107, 0.38);
  transform: rotate(45deg);
}
@keyframes ynBgmTipBreath {
  0%, 100% { box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 0 0 rgba(232, 200, 107, 0.0); }
  50%      { box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 0 6px rgba(232, 200, 107, 0.12); }
}

/* 雅集主题下使用米纸色调。 */
html.theme-yaji .yn-bgm-tip {
  background: rgba(243, 236, 217, 0.98);
  border: 0.5px solid rgba(27, 22, 17, 0.38);
  color: #1b1611;
  font-family: 'Noto Serif SC', 'LXGW WenKai', serif;
}
html.theme-yaji .yn-bgm-tip-arrow {
  background: rgba(243, 236, 217, 0.98);
  border-top-color: rgba(27, 22, 17, 0.38);
  border-right-color: rgba(27, 22, 17, 0.38);
}

@media (prefers-reduced-motion: reduce) {
  .yn-bgm-tip { animation: none; }
}
