/* ========================================================
   西瓜音乐 (Xigua Music) - Design System & Stylesheet
   - 适配移动端 100dvh 与 Safe Area 安全区
   - 毛玻璃拟态 (Glassmorphism) 与 霓虹流光氛围
   - 拟物黑胶唱片与唱针交互动效
   ======================================================== */

:root {
  --bg-deep: #0a0b10;
  --bg-card: rgba(22, 24, 38, 0.65);
  --bg-glass: rgba(255, 255, 255, 0.06);
  --bg-glass-hover: rgba(255, 255, 255, 0.12);
  --border-glass: rgba(255, 255, 255, 0.1);
  --border-glass-glow: rgba(255, 51, 102, 0.3);

  --accent-primary: #ff2d60;       /* 西瓜亮粉红 */
  --accent-secondary: #00f298;     /* 西瓜翠绿光 */
  --accent-glow: rgba(255, 45, 96, 0.45);
  
  --text-main: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.65);
  --text-dim: rgba(255, 255, 255, 0.4);

  --radius-full: 9999px;
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 8px;

  --transition-smooth: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
  --shadow-luminous: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
  --shadow-neon: 0 0 25px var(--accent-glow);
}

/* 基础重置 & 移动端触摸优化 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Segoe UI", Roboto, sans-serif;
  touch-action: manipulation;
}

/* ================== 动态氛围背景 ================== */
.ambient-background {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.45;
  animation: floatAmbient 18s ease-in-out infinite alternate;
}

.orb-1 {
  width: 380px;
  height: 380px;
  background: radial-gradient(circle, var(--accent-primary) 0%, transparent 70%);
  top: -10%;
  right: -10%;
  animation-duration: 16s;
}

.orb-2 {
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, #7928ca 0%, transparent 70%);
  bottom: -15%;
  left: -15%;
  animation-duration: 22s;
  animation-delay: -4s;
}

.orb-3 {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, var(--accent-secondary) 0%, transparent 70%);
  top: 40%;
  left: 20%;
  opacity: 0.25;
  animation-duration: 26s;
  animation-delay: -8s;
}

.backdrop-blur-layer {
  position: absolute;
  inset: 0;
  backdrop-filter: blur(50px);
  -webkit-backdrop-filter: blur(50px);
  background: rgba(10, 11, 16, 0.6);
}

@keyframes floatAmbient {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(40px, -30px) scale(1.1); }
  100% { transform: translate(-30px, 40px) scale(0.95); }
}

/* ================== 主容器（安全区适配） ================== */
.app-container {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  height: 100%;
  height: 100dvh;
  padding: env(safe-area-inset-top, 16px) 20px env(safe-area-inset-bottom, 20px) 20px;
  justify-content: space-between;
}

/* ================== 顶部栏 ================== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 4px;
}

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

.brand-logo {
  font-size: 28px;
  filter: drop-shadow(0 0 10px rgba(255, 45, 96, 0.4));
  animation: pulseLogo 3s ease-in-out infinite alternate;
}

@keyframes pulseLogo {
  0% { transform: scale(1); }
  100% { transform: scale(1.08); }
}

.brand-title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.3px;
  background: linear-gradient(135deg, #ffffff 40%, var(--accent-primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 11px;
  color: var(--accent-secondary);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 600;
  display: block;
}

.header-action-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-full);
  color: var(--text-main);
  cursor: pointer;
  backdrop-filter: blur(12px);
  transition: var(--transition-smooth);
}

.header-action-btn:active {
  transform: scale(0.92);
  background: var(--bg-glass-hover);
}

.badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--accent-primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 8px var(--accent-glow);
}

/* ================== 中部播放器舞台 ================== */
.player-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  width: 100%;
  min-height: 0;
  padding: 8px 0;
}

/* 拟物黑胶唱盘转台 */
.turntable-container {
  position: relative;
  width: min(68vw, 270px);
  height: min(68vw, 270px);
  margin-bottom: 24px;
}

/* 唱针臂 */
.needle-arm {
  position: absolute;
  top: -14px;
  right: -4px;
  width: 70px;
  height: 100px;
  z-index: 15;
  transform-origin: 56px 14px;
  transform: rotate(-32deg);
  transition: transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.needle-pivot {
  position: absolute;
  top: 4px;
  right: 6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle, #e6e6e6 30%, #555 100%);
  box-shadow: 0 2px 6px rgba(0,0,0,0.6);
  border: 1px solid #777;
}

.needle-rod {
  position: absolute;
  top: 18px;
  right: 14px;
  width: 4px;
  height: 60px;
  background: linear-gradient(to right, #ccc, #888, #bbb);
  border-radius: 2px;
  transform: rotate(18deg);
}

.needle-head {
  position: absolute;
  bottom: 18px;
  left: 20px;
  width: 12px;
  height: 18px;
  background: #333;
  border-radius: 2px;
  border-top: 3px solid var(--accent-primary);
  box-shadow: 0 2px 4px rgba(0,0,0,0.5);
  transform: rotate(20deg);
}

/* 正在播放时，唱针摆动到黑胶唱片上 */
.needle-arm.active {
  transform: rotate(3deg);
}

/* 黑胶唱片本体 */
.vinyl-disc-wrapper {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  padding: 6px;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), inset 0 0 20px rgba(0, 0, 0, 0.8);
  border: 1px solid var(--border-glass);
}

.vinyl-disc {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(circle, #25262c 0%, #0e0f14 60%, #06070a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 10px rgba(0,0,0,0.9);
  animation: spinVinyl 18s linear infinite;
  animation-play-state: paused;
}

.vinyl-disc.playing {
  animation-play-state: running;
}

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

/* 黑胶唱片纹路光泽 */
.vinyl-groove {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.05);
  pointer-events: none;
}

.groove-1 {
  width: 82%;
  height: 82%;
}

.groove-2 {
  width: 64%;
  height: 64%;
}

.vinyl-center-label {
  position: relative;
  width: 44%;
  height: 44%;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.8);
  border: 2px solid rgba(255, 255, 255, 0.2);
}

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

.disc-center-hole {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--bg-deep);
  border: 2px solid #555;
  box-shadow: inset 0 0 4px #000;
}

/* ================== 歌曲元数据与律动波形 ================== */
.song-meta-section {
  text-align: center;
  width: 100%;
  margin-bottom: 20px;
}

.song-title-wrapper {
  overflow: hidden;
  white-space: nowrap;
  padding: 0 10px;
}

.song-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text-main);
  text-overflow: ellipsis;
  overflow: hidden;
}

.song-artist {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
  font-weight: 400;
}

/* 律动音波小动效 */
.equalizer-bars {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3.5px;
  height: 18px;
  margin-top: 10px;
}

.equalizer-bars .bar {
  width: 3px;
  height: 4px;
  border-radius: 2px;
  background: var(--accent-secondary);
  transition: height 0.2s ease;
}

.equalizer-bars.playing .bar {
  animation: eqPulse 0.9s ease-in-out infinite alternate;
}

.equalizer-bars.playing .bar-1 { animation-delay: 0.1s; }
.equalizer-bars.playing .bar-2 { animation-delay: 0.3s; }
.equalizer-bars.playing .bar-3 { animation-delay: 0.15s; }
.equalizer-bars.playing .bar-4 { animation-delay: 0.4s; }
.equalizer-bars.playing .bar-5 { animation-delay: 0.25s; }

@keyframes eqPulse {
  0% { height: 4px; background: var(--accent-secondary); }
  50% { height: 16px; background: var(--accent-primary); }
  100% { height: 6px; background: var(--accent-secondary); }
}

/* ================== 进度条（针对移动端指尖优化） ================== */
.progress-section {
  width: 100%;
  margin-bottom: 18px;
}

.time-display {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  margin-bottom: 8px;
  padding: 0 2px;
}

.progress-bar-container {
  width: 100%;
  padding: 10px 0; /* 增大手指点击/触摸热区 */
  cursor: pointer;
}

.progress-track {
  position: relative;
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-full);
  overflow: visible;
}

.progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-primary), #ff6b8b);
  border-radius: var(--radius-full);
  box-shadow: 0 0 10px var(--accent-glow);
  pointer-events: none;
}

.progress-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #ffffff;
  transform: translate(-50%, -50%) scale(0.9);
  box-shadow: 0 1px 6px rgba(0,0,0,0.6), 0 0 8px var(--accent-primary);
  transition: transform 0.15s ease;
  pointer-events: none;
}

.progress-bar-container:hover .progress-thumb,
.progress-bar-container:active .progress-thumb {
  transform: translate(-50%, -50%) scale(1.3);
}

/* ================== 核心控制器 ================== */
.player-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0 10px;
}

.control-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-main);
  cursor: pointer;
  border-radius: var(--radius-full);
  width: 48px;
  height: 48px;
  transition: var(--transition-smooth);
}

.control-btn:active {
  transform: scale(0.9);
}

.control-btn.secondary {
  color: var(--text-muted);
}

.control-btn.secondary.active-mode {
  color: var(--accent-primary);
  text-shadow: 0 0 10px var(--accent-glow);
}

/* 播放大按钮 */
.control-btn.primary {
  width: 66px;
  height: 66px;
  background: linear-gradient(135deg, var(--accent-primary), #d91b4c);
  color: #fff;
  box-shadow: 0 8px 24px rgba(255, 45, 96, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.control-btn.primary:active {
  transform: scale(0.93);
  box-shadow: 0 4px 14px rgba(255, 45, 96, 0.3);
}

/* ================== 快捷音量控制弹出层 ================== */
.volume-popover {
  position: absolute;
  bottom: 85px;
  right: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  backdrop-filter: blur(20px);
  padding: 10px 16px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-luminous);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: var(--transition-smooth);
  z-index: 20;
}

.volume-popover.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.volume-popover input[type="range"] {
  width: 100px;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

#volume-value {
  font-size: 11px;
  color: var(--text-muted);
  width: 28px;
}

/* ================== 移动端底部播放列表抽屉 (Bottom Sheet) ================== */
.playlist-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 480px;
  margin: 0 auto;
  background: rgba(18, 20, 31, 0.95);
  border-top: 1px solid var(--border-glass);
  border-radius: 28px 28px 0 0;
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.7);
  z-index: 100;
  padding: 12px 20px env(safe-area-inset-bottom, 24px) 20px;
  transform: translateY(105%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: 70dvh;
  display: flex;
  flex-direction: column;
}

.playlist-drawer.open {
  transform: translateY(0);
}

.drawer-handle {
  width: 36px;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  margin: 0 auto 12px auto;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.drawer-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.drawer-title-group h3 {
  font-size: 17px;
  font-weight: 700;
}

.loop-status-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(0, 242, 152, 0.15);
  color: var(--accent-secondary);
  border: 1px solid rgba(0, 242, 152, 0.3);
}

.drawer-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.drawer-close-btn:active {
  background: var(--bg-glass);
}

.playlist-content {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 0;
  flex: 1;
}

.playlist-items {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.playlist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg-glass);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.playlist-item:active {
  transform: scale(0.98);
  background: var(--bg-glass-hover);
}

.playlist-item.active {
  background: rgba(255, 45, 96, 0.12);
  border-color: rgba(255, 45, 96, 0.35);
}

.item-left {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
}

.item-index {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  width: 20px;
}

.playlist-item.active .item-index {
  color: var(--accent-primary);
}

.item-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.item-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-main);
}

.playlist-item.active .item-name {
  color: var(--accent-primary);
  font-weight: 600;
}

.item-tag {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.item-playing-icon {
  display: none;
  width: 14px;
  height: 14px;
}

.playlist-item.active .item-playing-icon {
  display: block;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

/* ================== 首次进入自动播放解锁引导遮罩 ================== */
.unlock-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(8, 9, 14, 0.85);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.5s ease;
  cursor: pointer;
}

.unlock-overlay.faded {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.unlock-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 320px;
  background: var(--bg-card);
  border: 1px solid var(--border-glass-glow);
  box-shadow: var(--shadow-luminous), var(--shadow-neon);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
}

.unlock-icon-wrapper {
  position: relative;
  width: 76px;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.unlock-emoji {
  font-size: 42px;
  position: relative;
  z-index: 2;
}

.pulse-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--accent-primary);
  animation: pulseOut 2s ease-out infinite;
}

@keyframes pulseOut {
  0% { transform: scale(0.8); opacity: 0.8; }
  100% { transform: scale(1.6); opacity: 0; }
}

.unlock-card h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
}

.unlock-tip {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.5;
}

.unlock-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 24px;
  background: linear-gradient(135deg, var(--accent-primary), #ff4d79);
  border: none;
  border-radius: var(--radius-full);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(255, 45, 96, 0.4);
  transition: transform 0.2s ease;
}

.unlock-btn:active {
  transform: scale(0.96);
}

/* 工具辅助类 */
.hidden {
  display: none !important;
}

/* ================== 记忆恢复 Toast 浮动通知 ================== */
.resume-toast {
  position: fixed;
  top: max(env(safe-area-inset-top, 16px) + 60px, 70px);
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(18, 20, 31, 0.88);
  border: 1px solid var(--border-glass-glow);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 15px rgba(255, 45, 96, 0.25);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 8px 18px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  font-size: 13px;
  color: #fff;
  white-space: nowrap;
}

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

.resume-toast .toast-icon {
  font-size: 14px;
}

/* ================== PC端/平板宽屏响应式增强 ================== */
@media (min-width: 768px) {
  .app-container {
    max-width: 720px;
    padding-top: 36px;
    padding-bottom: 36px;
  }

  .turntable-container {
    width: 320px;
    height: 320px;
  }

  .needle-arm {
    width: 85px;
    height: 120px;
    top: -18px;
    right: -8px;
  }

  .needle-rod {
    height: 75px;
  }

  .song-title {
    font-size: 24px;
  }

  .control-btn {
    width: 52px;
    height: 52px;
  }

  .control-btn.primary {
    width: 72px;
    height: 72px;
  }

  .playlist-drawer {
    border-radius: 28px;
    bottom: 24px;
    max-height: 60vh;
    border: 1px solid var(--border-glass);
  }
}
