/**
 * 拾光音乐 SGMusic – 播放器样式
 * 自动适配站点风格（主色变量 + 深色模式）
 */

.sgm-player {
  --sgm-accent: #4a7bf7;
  --sgm-bg: #ffffff;
  --sgm-bg-soft: rgba(125, 125, 125, .08);
  --sgm-fg: #22252a;
  --sgm-fg-soft: #7b828e;
  --sgm-border: rgba(125, 125, 125, .18);
  --sgm-shadow: 0 12px 34px rgba(0, 0, 0, .14);
  --sgm-radius: 14px;

  position: relative;
  box-sizing: border-box;
  color: var(--sgm-fg);
  font-size: 14px;
  line-height: 1.5;
  font-family: inherit;
  text-align: left;
  -webkit-font-smoothing: antialiased;
}

.sgm-player *,
.sgm-player *::before,
.sgm-player *::after {
  box-sizing: border-box;
}

.sgm-player.sgm-dark {
  --sgm-bg: rgba(30, 31, 34, .94);
  --sgm-bg-soft: rgba(255, 255, 255, .08);
  --sgm-fg: #eceef2;
  --sgm-fg-soft: #9aa1ad;
  --sgm-border: rgba(255, 255, 255, .12);
  --sgm-shadow: 0 14px 40px rgba(0, 0, 0, .45);
}

/* ---------------- 内联卡片 ---------------- */

.sgm-player.sgm-inline {
  background: var(--sgm-bg);
  border: 1px solid var(--sgm-border);
  border-radius: var(--sgm-radius);
  padding: 14px;
  margin: 18px 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .04);
}

.sgm-player.sgm-inline .sgm-launcher {
  display: none;
}

.sgm-player.sgm-inline .sgm-panel {
  display: block !important;
  opacity: 1 !important;
  transform: none !important;
  box-shadow: none;
  border: 0;
  padding: 0;
  background: none;
}

.sgm-player.sgm-inline .sgm-collapse {
  display: none;
}

/* ---------------- 悬浮 ---------------- */

.sgm-player.sgm-float {
  position: fixed;
  bottom: var(--sgm-bottom, 22px);
  z-index: 99998;
  width: 320px;
  max-width: calc(100vw - 28px);
  /* 关键：根容器本身不接收点击，避免遮挡主题的底部悬浮按钮（投稿/发布等） */
  pointer-events: none;
}

.sgm-player.sgm-float.sgm-float-left { left: calc(22px + var(--sgm-side, 0px)); }
.sgm-player.sgm-float.sgm-float-right { right: calc(22px + var(--sgm-side, 0px)); }

.sgm-player.sgm-float .sgm-launcher {
  position: relative;
  z-index: 2;
  pointer-events: auto;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  color: #fff;
  background: var(--sgm-accent);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .22);
  transition: transform .25s ease, opacity .25s ease;
  padding: 0;
}

.sgm-player.sgm-float .sgm-launcher:hover { transform: scale(1.06); }

.sgm-player.sgm-float.is-open .sgm-launcher { opacity: 1; }

.sgm-player.sgm-float.is-playing:not(.is-open) .sgm-launcher,
.sgm-player.sgm-float:not(.is-open) .sgm-launcher {
  opacity: .9;
}

.sgm-player.sgm-float .sgm-panel {
  position: absolute;
  bottom: 60px;
  left: 0;
  width: 320px;
  max-width: calc(100vw - 28px);
  background: var(--sgm-bg);
  border: 1px solid var(--sgm-border);
  border-radius: var(--sgm-radius);
  box-shadow: var(--sgm-shadow);
  padding: 14px;
  overflow: hidden;
  transform-origin: bottom left;
  transition: opacity .22s ease, transform .22s ease, visibility .22s;
  /* 默认收起：即使 JS 未执行也不会铺开遮挡页面 */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(12px) scale(.96);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
}

.sgm-float-right .sgm-panel { left: auto; right: 0; transform-origin: bottom right; }

.sgm-player.sgm-float.is-open .sgm-panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
}

/* ---------------- 头部 ---------------- */

.sgm-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sgm-cover {
  position: relative;
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--sgm-bg-soft);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sgm-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sgm-player.is-playing .sgm-cover img {
  animation: sgm-rotate 18s linear infinite;
  border-radius: 50%;
}

@keyframes sgm-rotate { to { transform: rotate(360deg); } }

.sgm-meta { flex: 1 1 auto; min-width: 0; }

.sgm-title {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--sgm-fg);
}

.sgm-artist {
  font-size: 12px;
  color: var(--sgm-fg-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sgm-icon {
  border: 0;
  background: none;
  color: var(--sgm-fg-soft);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color .18s, background .18s;
}

.sgm-icon:hover { color: var(--sgm-accent); background: var(--sgm-bg-soft); }
.sgm-icon:focus { outline: none; }

/* ---------------- 歌词 ---------------- */

.sgm-lyric {
  margin: 10px 0 6px;
  height: 68px;
  overflow: hidden;
  position: relative;
  mask-image: linear-gradient(180deg, transparent, #000 22%, #000 72%, transparent);
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 22%, #000 72%, transparent);
  overflow-y: auto;
  scroll-behavior: smooth;
  font-size: 13px;
  text-align: center;
}

.sgm-lyric-inner { padding: 24px 0; }

.sgm-lyric-line {
  margin: 0;
  padding: 5px 0;
  color: var(--sgm-fg-soft);
  transition: color .2s, transform .2s;
}

.sgm-lyric-line.is-current {
  color: var(--sgm-accent);
  font-weight: 600;
  transform: scale(1.04);
}

/* ---------------- 进度条 ---------------- */

.sgm-progress { margin: 4px 0 8px; }

.sgm-bar {
  position: relative;
  height: 4px;
  border-radius: 4px;
  background: var(--sgm-bg-soft);
  cursor: pointer;
}

.sgm-bar i {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  border-radius: 4px;
  display: block;
}

.sgm-buffer { background: var(--sgm-border); width: 0; }

.sgm-played {
  background: var(--sgm-accent);
  width: 0;
}

.sgm-played b {
  position: absolute;
  right: -5px;
  top: 50%;
  width: 10px;
  height: 10px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--sgm-accent);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, .06);
  opacity: 0;
  transition: opacity .18s;
}

.sgm-bar:hover .sgm-played b { opacity: 1; }

.sgm-time {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--sgm-fg-soft);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

/* ---------------- 控制区 ---------------- */

.sgm-controls {
  display: flex;
  align-items: center;
  gap: 2px;
}

.sgm-play {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--sgm-accent);
  color: #fff;
  margin: 0 4px;
}

.sgm-play:hover { background: var(--sgm-accent); color: #fff; filter: brightness(1.08); }

.sgm-play .i-pause { display: none; }
.sgm-player.is-playing .sgm-play .i-pause { display: inline; }
.sgm-player.is-playing .sgm-play .i-play { display: none; }

.sgm-volume { margin-left: auto; display: flex; align-items: center; gap: 4px; }

.sgm-vol {
  width: 62px;
  height: 3px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--sgm-bg-soft);
  border-radius: 3px;
  outline: none;
}

.sgm-vol::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--sgm-accent);
  cursor: pointer;
}

.sgm-vol::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border: 0;
  border-radius: 50%;
  background: var(--sgm-accent);
  cursor: pointer;
}

/* ---------------- 列表 ---------------- */

.sgm-list {
  max-height: 0;
  overflow: hidden;
  transition: max-height .28s ease;
  border-top: 1px solid transparent;
}

.sgm-player.is-list .sgm-list {
  max-height: 280px;
  overflow-y: auto;
  margin-top: 10px;
  border-top: 1px solid var(--sgm-border);
  padding-top: 8px;
}

.sgm-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--sgm-fg-soft);
  margin-bottom: 6px;
}

.sgm-pl-select {
  font-size: 12px;
  max-width: 140px;
  padding: 2px 4px;
  border-radius: 6px;
  border: 1px solid var(--sgm-border);
  background: var(--sgm-bg);
  color: var(--sgm-fg);
}

.sgm-list-ul { list-style: none; margin: 0; padding: 0; }

.sgm-list-ul li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}

.sgm-list-ul li:hover { background: var(--sgm-bg-soft); }

.sgm-list-ul li.is-active { background: var(--sgm-bg-soft); color: var(--sgm-accent); }

.sgm-li-idx { width: 18px; color: var(--sgm-fg-soft); font-size: 12px; }

.sgm-li-title {
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sgm-li-artist { font-size: 11px; color: var(--sgm-fg-soft); max-width: 74px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sgm-li-time { font-size: 11px; color: var(--sgm-fg-soft); font-variant-numeric: tabular-nums; }

/* ---------------- 迷你样式 ---------------- */

.sgm-player.sgm-mini .sgm-head .sgm-cover,
.sgm-player.sgm-mini .sgm-lyric,
.sgm-player.sgm-mini .sgm-list { display: none !important; }

.sgm-player.sgm-mini .sgm-head { padding-bottom: 6px; }

/* ---------------- 骨架屏 ---------------- */

.sgm-skeleton {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px;
  color: var(--sgm-fg-soft);
  font-size: 13px;
}

.sgm-spin {
  width: 16px;
  height: 16px;
  border: 2px solid var(--sgm-border);
  border-top-color: var(--sgm-accent);
  border-radius: 50%;
  display: inline-block;
  animation: sgm-spin .8s linear infinite;
}

@keyframes sgm-spin { to { transform: rotate(360deg); } }

/* ---------------- 响应式 ---------------- */

@media (max-width: 640px) {
  .sgm-player.sgm-float {
    width: min(320px, calc(100vw - 24px));
    /* 移动端优先用独立的上移值，避开主题底部悬浮按钮 */
    bottom: var(--sgm-m-bottom, var(--sgm-bottom, 16px));
  }
  .sgm-player.sgm-float.sgm-float-left { left: calc(12px + var(--sgm-side, 0px)); }
  .sgm-player.sgm-float.sgm-float-right { right: calc(12px + var(--sgm-side, 0px)); }
  .sgm-player.sgm-float .sgm-panel {
    width: min(320px, calc(100vw - 24px));
    /* 手机上限制面板高度，避免展开后盖住页面底部大片区域 */
    max-height: min(58vh, 420px);
    overflow-y: auto;
  }
  .sgm-lyric { height: 52px; }
  .sgm-vol { width: 46px; }
  .sgm-player.sgm-float .sgm-launcher { width: 42px; height: 42px; }
}

@media (prefers-reduced-motion: reduce) {
  .sgm-player * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* 断点续播提示 */

.sgm-resume-tip {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 64px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.4;
  text-align: center;
  color: #fff;
  background: rgba(0, 0, 0, .72);
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 5;
}

.sgm-resume-tip.is-show {
  opacity: 1;
  transform: translateY(0);
}
