/* ==========================================
   MusicBox - QQ音乐风格 H5播放器样式
   ========================================== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --primary: #31c27c;
  --primary-dark: #1db065;
  --accent: #ff6b35;
  --bg-dark: #0f0f1a;
  --bg-card: rgba(255,255,255,0.08);
  --text-primary: #ffffff;
  --text-secondary: rgba(255,255,255,0.6);
  --text-muted: rgba(255,255,255,0.35);
  --border: rgba(255,255,255,0.12);
  --glass: rgba(255,255,255,0.06);
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --header-h: 56px;
  --footer-h: 170px;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* ==========================================
   加载页
   ========================================== */
.loading-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 50%, #0d1117 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.5s ease;
}

.loading-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loading-logo {
  text-align: center;
}

.loading-icon {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, var(--primary), #4facfe);
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 36px;
  color: white;
  box-shadow: 0 0 40px rgba(49,194,124,0.4);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 40px rgba(49,194,124,0.4); }
  50% { transform: scale(1.05); box-shadow: 0 0 60px rgba(49,194,124,0.6); }
}

.loading-title {
  font-size: 24px;
  font-weight: 700;
  color: white;
  letter-spacing: 2px;
  margin-bottom: 32px;
}

.loading-bar {
  width: 160px;
  height: 3px;
  background: rgba(255,255,255,0.15);
  border-radius: 3px;
  overflow: hidden;
}

.loading-progress {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #4facfe);
  border-radius: 3px;
  animation: loadProgress 1.5s ease-in-out forwards;
}

@keyframes loadProgress {
  0% { width: 0%; }
  70% { width: 80%; }
  100% { width: 100%; }
}

/* ==========================================
   主应用
   ========================================== */
.app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app.hidden { display: none; }
.hidden { display: none !important; }

/* 背景模糊层 */
.bg-blur {
  position: absolute;
  inset: -50px;
  background-size: cover;
  background-position: center;
  background-image: url('images/default-cover.svg');
  filter: blur(40px) brightness(0.3) saturate(1.5);
  transform: scale(1.1);
  transition: background-image 0.8s ease;
  z-index: 0;
}

/* ==========================================
   顶部导航
   ========================================== */
.top-bar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  padding: 0 16px;
  padding-top: env(safe-area-inset-top, 0px);
  background: rgba(0,0,0,0.2);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.top-title {
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: center;
  padding: 0 12px;
}

.playlist-title-btn {
  max-width: 100%;
  height: 36px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
  border-radius: 18px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  transition: background 0.2s ease, transform 0.2s ease;
}

.playlist-title-btn i {
  color: var(--primary);
  font-size: 14px;
  flex-shrink: 0;
}

.playlist-title-btn:active {
  background: rgba(255,255,255,0.14);
  transform: scale(0.96);
}

.top-song-total {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  flex-shrink: 0;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.icon-btn:active {
  background: rgba(255,255,255,0.1);
  transform: scale(0.92);
}

/* ==========================================
   主内容区
   ========================================== */
.main-content {
  position: relative;
  flex: 1;
  overflow: hidden;
  z-index: 1;
}

/* 封面视图 */
.view-cover {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 24px 0;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
  cursor: default;
}

.view-cover.slide-left {
  transform: translateX(-100%);
  opacity: 0;
}

/* 歌词视图 — 初始在右侧屏幕外，.show 时滑入 */
.view-lyrics {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  transform: translateX(100%);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
}

.view-lyrics.show {
  transform: translateX(0);
  opacity: 1;
}

/* ==========================================
   唱片封面
   ========================================== */
.cover-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}

.cover-disc {
  position: relative;
  width: min(86vw, calc(100vh - var(--header-h) - var(--footer-h) - 120px), 480px);
  height: min(86vw, calc(100vh - var(--header-h) - var(--footer-h) - 120px), 480px);
}

/* 唱针 */
.cover-needle {
  position: absolute;
  top: -30px;
  right: 20px;
  width: 4px;
  height: 90px;
  background: linear-gradient(to bottom, #d4a843, #8b6914);
  border-radius: 2px;
  transform-origin: top center;
  transform: rotate(-25deg);
  z-index: 10;
  transition: transform 0.5s ease;
  box-shadow: 2px 2px 8px rgba(0,0,0,0.5);
}

.cover-needle::before {
  content: '';
  position: absolute;
  top: -6px;
  left: -6px;
  width: 16px;
  height: 16px;
  background: radial-gradient(circle, #e8c547, #b8891f);
  border-radius: 50%;
}

.cover-needle.playing {
  transform: rotate(-5deg);
}

/* 唱片 */
.disc-container {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  animation: none;
}

.disc-container.spinning {
  animation: discSpin 12s linear infinite;
}

@keyframes discSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.disc-ring {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%,
    #1a1a2e 0%,
    #16213e 20%,
    #0f3460 30%,
    #1a1a2e 35%,
    #222 40%,
    #333 42%,
    #1a1a2e 44%,
    #333 48%,
    #1a1a2e 52%,
    #333 56%,
    #1a1a2e 58%,
    #333 60%,
    #2a2a2a 62%,
    #1a1a2e 65%,
    #333 70%,
    #1a1a2e 75%,
    #444 80%,
    #1a1a2e 85%,
    #333 90%,
    #1a1a2e 100%
  );
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 0 0 4px rgba(255,255,255,0.05),
    0 20px 60px rgba(0,0,0,0.6),
    inset 0 0 20px rgba(0,0,0,0.5);
}

.disc-center {
  width: 92%;
  height: 92%;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.18);
  box-shadow: 0 0 0 5px rgba(0,0,0,0.24);
}

.cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.5s ease;
}

/* 歌曲信息 */
.song-info {
  text-align: center;
  width: 100%;
  padding: 0 32px;
}

.song-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
  margin-left: auto;
  margin-right: auto;
}

/* 长标题滚动动画 */
.song-title.marquee {
  animation: marqueeScroll 8s linear infinite;
}

@keyframes marqueeScroll {
  0%, 20% { transform: translateX(0); }
  80%, 100% { transform: translateX(-100%); }
}

.song-artist {
  font-size: 14px;
  color: var(--text-secondary);
}

/* 视图切换提示点 */
.view-switch-hint {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  padding-bottom: 8px;
  justify-content: center;
  flex-shrink: 0;
}

.hint-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  transition: all 0.3s ease;
}

.hint-dot.active {
  background: var(--primary);
  width: 18px;
  border-radius: 3px;
}

/* ==========================================
   歌词视图顶部歌曲信息
   ========================================== */
.lyrics-song-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px 8px;
  width: 100%;
  flex-shrink: 0;
}

.lyrics-mini-cover {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.15);
  flex-shrink: 0;
}

.lyrics-mini-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.lyrics-song-text {
  flex: 1;
  overflow: hidden;
}

.lyrics-song-title {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.lyrics-song-artist {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ==========================================
   歌词区域
   ========================================== */
.lyrics-container {
  flex: 1;
  width: 100%;
  overflow: hidden;
  position: relative;
  min-height: 0;
  mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(0,0,0,0.5) 10%,
    black 20%,
    black 80%,
    rgba(0,0,0,0.5) 90%,
    transparent 100%
  );
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(0,0,0,0.5) 10%,
    black 20%,
    black 80%,
    rgba(0,0,0,0.5) 90%,
    transparent 100%
  );
}

.lyrics-inner {
  padding: 40% 24px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.lyric-line {
  text-align: center;
  font-size: 15px;
  line-height: 1.8;
  color: var(--text-muted);
  padding: 8px 0;
  transition: all 0.4s ease;
  cursor: pointer;
}

.lyric-line.active {
  color: var(--primary);
  font-size: 18px;
  font-weight: 700;
  text-shadow: 0 0 20px rgba(49,194,124,0.5);
}

.lyric-line.near-active {
  color: var(--text-secondary);
  font-size: 16px;
}

.lyrics-placeholder {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 0;
}

.lyrics-placeholder i {
  font-size: 48px;
  margin-bottom: 12px;
  display: block;
  opacity: 0.4;
}

.lyrics-placeholder p {
  font-size: 14px;
  opacity: 0.6;
}

/* ==========================================
   播放控制
   ========================================== */
.player-controls {
  position: relative;
  z-index: 10;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border-top: 1px solid var(--border);
  padding: 16px 20px calc(16px + var(--safe-bottom));
}

/* 进度条 */
.progress-section {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.time-current, .time-total {
  font-size: 11px;
  color: var(--text-secondary);
  min-width: 32px;
  font-variant-numeric: tabular-nums;
}

.time-total { text-align: right; }

.progress-bar-wrap {
  flex: 1;
  padding: 10px 0;
  cursor: pointer;
  touch-action: none;
}

.progress-bar-bg {
  position: relative;
  height: 3px;
  background: rgba(255,255,255,0.15);
  border-radius: 3px;
  overflow: visible;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #4facfe);
  border-radius: 3px;
  width: 0%;
  transition: width 0.1s linear;
}

.progress-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 14px;
  height: 14px;
  background: white;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  transition: left 0.1s linear, transform 0.2s ease;
  z-index: 2;
}

.progress-thumb:active,
.progress-thumb.dragging {
  transform: translate(-50%, -50%) scale(1.4);
}

/* 控制按钮行 */
.controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.ctrl-btn {
  border: none;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.ctrl-btn:active {
  transform: scale(0.88);
}

.mode-btn, .like-btn {
  width: 40px;
  height: 40px;
  font-size: 18px;
  color: var(--text-secondary);
}

.mode-btn.active {
  color: var(--primary);
}

.prev-btn, .next-btn {
  width: 48px;
  height: 48px;
  font-size: 22px;
}

.play-btn {
  width: 64px;
  height: 64px;
  font-size: 26px;
  background: linear-gradient(135deg, var(--primary), #4facfe);
  border-radius: 50%;
  box-shadow: 0 4px 20px rgba(49,194,124,0.5);
  color: white;
}

.play-btn:active {
  transform: scale(0.92);
  box-shadow: 0 2px 10px rgba(49,194,124,0.3);
}

.like-btn.liked {
  color: #ff4757;
}

.like-btn.liked i::before {
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  content: "\f004";
}

/* 音量条 */
.volume-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.volume-icon {
  font-size: 14px;
  color: var(--text-muted);
}

.volume-bar-wrap {
  flex: 1;
  padding: 8px 0;
  cursor: pointer;
  touch-action: none;
}

/* ==========================================
   播放列表面板
   ========================================== */
.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(4px);
}

.panel-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.playlist-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 101;
  background: linear-gradient(180deg, rgba(20,20,35,0.98) 0%, rgba(10,10,20,0.99) 100%);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--border);
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--safe-bottom);
}

.playlist-panel.show {
  transform: translateY(0);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-title {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}

.panel-title i {
  color: var(--primary);
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.song-count {
  font-size: 13px;
  color: var(--text-muted);
}

.panel-song-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.panel-song-list::-webkit-scrollbar {
  display: none;
}

.playlist-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  cursor: pointer;
  transition: background 0.2s;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.playlist-item:active {
  background: rgba(255,255,255,0.06);
}

.playlist-item.active {
  background: rgba(49,194,124,0.08);
}

.playlist-item.active .pli-title {
  color: var(--primary);
}

.pli-index {
  width: 28px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  flex-shrink: 0;
}

.pli-playing {
  display: none;
}

.playlist-item.active .pli-index {
  display: none;
}

.playlist-item.active .pli-playing {
  display: block;
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}

.pli-playing i {
  color: var(--primary);
  font-size: 14px;
  animation: eq 0.6s infinite alternate;
}

@keyframes eq {
  from { transform: scaleY(0.5); }
  to { transform: scaleY(1); }
}

.pli-cover {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  margin: 0 12px;
  background: rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.pli-info {
  flex: 1;
  overflow: hidden;
}

.pli-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.pli-artist {
  font-size: 12px;
  color: var(--text-muted);
}

.pli-duration {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 12px;
  flex-shrink: 0;
}

/* ==========================================
   搜索面板
   ========================================== */
.search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,10,20,0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 200;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
}

.search-box-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.search-input-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.search-input-row i {
  color: var(--text-muted);
  font-size: 16px;
}

.search-input-row input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 16px;
  color: var(--text-primary);
  caret-color: var(--primary);
}

.search-input-row input::placeholder {
  color: var(--text-muted);
}

#btn-search-cancel {
  background: transparent;
  border: none;
  color: var(--primary);
  font-size: 15px;
  cursor: pointer;
  padding: 4px 8px;
}

.search-results {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.search-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-muted);
  gap: 12px;
}

.search-empty i {
  font-size: 40px;
  opacity: 0.3;
}

.search-result-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  gap: 12px;
  transition: background 0.2s;
}

.search-result-item:active {
  background: rgba(255,255,255,0.06);
}

.search-result-item img {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  background: rgba(255,255,255,0.08);
}

.sri-info {
  flex: 1;
  overflow: hidden;
}

.sri-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sri-artist {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ==========================================
   Toast 提示
   ========================================== */
.toast {
  position: fixed;
  bottom: calc(190px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(30,30,50,0.95);
  color: white;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 13px;
  z-index: 9000;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  white-space: nowrap;
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

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

/* ==========================================
   触摸滑动支持
   ========================================== */
.swipe-container {
  position: relative;
  width: 200%;
  height: 100%;
  display: flex;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================
   响应式适配
   ========================================== */
@media (min-height: 700px) {
  .cover-disc {
    width: min(88vw, calc(100vh - var(--header-h) - var(--footer-h) - 130px), 520px);
    height: min(88vw, calc(100vh - var(--header-h) - var(--footer-h) - 130px), 520px);
  }
}

@media (max-height: 600px) {
  .cover-disc {
    width: min(78vw, calc(100vh - var(--header-h) - var(--footer-h) - 100px), 320px);
    height: min(78vw, calc(100vh - var(--header-h) - var(--footer-h) - 100px), 320px);
  }
  
  .song-info {
    margin: 8px 0;
  }
  
  .play-btn {
    width: 56px;
    height: 56px;
    font-size: 22px;
  }
}

/* ==========================================
   动画
   ========================================== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.animate-in {
  animation: slideUp 0.4s ease forwards;
}

/* 高亮关键词 */
.highlight {
  color: var(--primary);
  font-weight: 600;
}
