/* ==========================================================================
   野菩萨 · 角色歌单播放器
   共享样式：首页 + 8 个歌单页
   ========================================================================== */

:root {
  --bg: #07070a;
  --panel: #101014;
  --ink: #f4f4f6;
  --muted: rgba(244, 244, 246, 0.62);
  --dim: rgba(244, 244, 246, 0.4);
  --accent: #2f4bff;
  --accent-2: #8fa3ff;
  --line: rgba(255, 255, 255, 0.1);
  --radius: 18px;
  --font-sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", "STSong", "SimSun", serif;
}

* { box-sizing: border-box; }

html {
  background: var(--bg);
}

body {
  margin: 0;
  padding: 0;
  /* 透明：让 z-index 为负的整页背景层能露出来 */
  background: transparent;
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { min-height: 100dvh; }

img { display: block; max-width: 100%; }

a { color: inherit; }

button { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 3px;
  border-radius: 8px;
}

/* SVG 不认 HTML 的 hidden 属性，这里补一条，避免播放/暂停图标叠在一起 */
[hidden] { display: none !important; }

.eyebrow {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent-2);
}

/* ==========================================================================
   首页
   ========================================================================== */

body.home {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(18px, 3vw, 30px);
  padding: clamp(22px, 6vw, 54px) clamp(16px, 4vw, 40px) 34px;
  overflow-x: hidden;
}

.home__bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  background-image: url("../images/bg-home.jpg");
  background-size: cover;
  background-position: center 28%;
  background-repeat: no-repeat;
}

.home__veil {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(120% 80% at 20% 10%, rgba(7, 7, 10, 0.55), transparent 60%),
    linear-gradient(180deg, rgba(7, 7, 10, 0.72) 0%, rgba(7, 7, 10, 0.35) 38%, rgba(7, 7, 10, 0.82) 78%, rgba(7, 7, 10, 0.97) 100%);
}

.home__head {
  width: 100%;
  max-width: 980px;
  text-align: center;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.7);
}

.home__title {
  margin: 10px 0 6px;
  font-family: var(--font-serif);
  font-size: clamp(30px, 8vw, 46px);
  font-weight: 600;
  letter-spacing: 0.16em;
}

.home__sub {
  margin: 0;
  font-size: clamp(12px, 3.4vw, 14px);
  letter-spacing: 0.16em;
  color: var(--muted);
}

.grid {
  width: 100%;
  max-width: 980px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(10px, 2.6vw, 18px);
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 148px;
  aspect-ratio: 3 / 4;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background-color: #111;
  background-size: cover;
  background-position: center;
  text-decoration: none;
  overflow: hidden;
  isolation: isolate;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45);
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.tile::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, rgba(5, 5, 9, 0.05) 35%, rgba(5, 5, 9, 0.55) 68%, rgba(5, 5, 9, 0.92) 100%);
}

.tile__num {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(200, 214, 255, 0.85);
}

.tile__name {
  margin-top: 4px;
  font-family: var(--font-serif);
  font-size: clamp(19px, 5.4vw, 24px);
  font-weight: 600;
  letter-spacing: 0.14em;
  color: #fff;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.8);
}

.tile:active { transform: scale(0.975); }

@media (hover: hover) {
  .tile:hover {
    transform: translateY(-4px);
    border-color: rgba(143, 163, 255, 0.6);
    box-shadow: 0 22px 44px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(47, 75, 255, 0.4);
  }
}

@media (min-width: 620px) {
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.home__foot {
  margin-top: auto;
  padding-top: 12px;
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--dim);
}

/* ==========================================================================
   歌单页
   ========================================================================== */

body.playlist {
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
  overflow-x: hidden;
}

.page__bg {
  position: fixed;
  inset: -8%;
  z-index: -2;
  background-size: cover;
  background-position: center;
  /* 大范围模糊很吃 GPU，半径别开太大 */
  filter: blur(30px) saturate(1.1) brightness(0.26);
  transform: translateZ(0) scale(1.08);
  will-change: transform;
}

/* 压暗整页，保证白色文字在浅色海报上也有足够对比度 */
body.playlist::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(120% 65% at 50% 0%, rgba(7, 7, 10, 0.15) 0%, rgba(7, 7, 10, 0.7) 42%, rgba(7, 7, 10, 0.95) 100%),
    linear-gradient(180deg, rgba(7, 7, 10, 0.35), rgba(7, 7, 10, 0.9));
  pointer-events: none;
}

.page {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 18px;
}

.pl-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 0 8px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.18s ease, transform 0.12s ease, border-color 0.18s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.icon-btn svg { width: 22px; height: 22px; }

.icon-btn:hover { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.24); }
.icon-btn:active { transform: scale(0.94); }

.icon-btn[disabled] { opacity: 0.35; cursor: not-allowed; }

.back { flex: 0 0 auto; }

.pl-cover {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.pl-meta { min-width: 0; }

.pl-title {
  margin: 2px 0 2px;
  font-family: var(--font-serif);
  font-size: clamp(22px, 6vw, 30px);
  font-weight: 600;
  letter-spacing: 0.12em;
  line-height: 1.2;
}

.pl-count {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.now {
  display: grid;
  justify-items: center;
  text-align: center;
  padding: clamp(14px, 3vw, 26px) 0 6px;
}

.now__cover {
  position: relative;
  width: min(66vw, 300px);
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.18),
    0 0 0 9px rgba(255, 255, 255, 0.035),
    0 0 0 10px rgba(255, 255, 255, 0.09),
    0 26px 60px rgba(0, 0, 0, 0.65);
  isolation: isolate;
}

/* 碟片纹路 + 左上高光，让平面图看起来像一张 CD */
.now__cover::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    repeating-radial-gradient(
      circle at 50% 50%,
      rgba(255, 255, 255, 0.055) 0 1px,
      rgba(0, 0, 0, 0.07) 1px 3px,
      rgba(255, 255, 255, 0) 3px 5px
    ),
    radial-gradient(circle at 30% 24%, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0) 46%);
  pointer-events: none;
}

/* 中心孔 */
.now__cover::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 16%;
  height: 16%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, #1b1b22, #050507 72%);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.22),
    0 0 0 8px rgba(0, 0, 0, 0.35),
    inset 0 0 12px rgba(0, 0, 0, 0.95);
  pointer-events: none;
}

/* 播放时缓慢转动，像唱片 */
.now__cover.is-spinning {
  animation: disc-spin 26s linear infinite;
  will-change: transform;
  backface-visibility: hidden;
}

/* 页面切到后台时停转，省电也减少卡顿 */
body.is-hidden .now__cover.is-spinning {
  animation-play-state: paused;
}

@keyframes disc-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .now__cover.is-spinning { animation: none !important; }
}

.now__title {
  margin: 22px 0 6px;
  font-family: var(--font-serif);
  font-size: clamp(20px, 5.6vw, 26px);
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1.3;
  max-width: 100%;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.now__artist {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.progress {
  width: 100%;
  margin-top: 26px;
}

.range {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 28px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

.range::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    var(--accent) 0%,
    var(--accent) var(--p, 0%),
    rgba(255, 255, 255, 0.16) var(--p, 0%),
    rgba(255, 255, 255, 0.16) 100%
  );
}

.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -5px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(47, 75, 255, 0.28), 0 2px 8px rgba(0, 0, 0, 0.6);
}

.range::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
}

.range::-moz-range-progress {
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
}

.range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(47, 75, 255, 0.28);
}

.range:disabled { cursor: default; opacity: 0.5; }

.times {
  display: flex;
  justify-content: space-between;
  margin-top: 2px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
  color: var(--dim);
}

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(18px, 4vw, 30px);
  margin-top: 22px;
}

.icon-btn--main {
  width: 68px;
  height: 68px;
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 12px 34px rgba(47, 75, 255, 0.45);
}

.icon-btn--main:hover {
  background: #3d58ff;
  border-color: transparent;
  box-shadow: 0 16px 40px rgba(47, 75, 255, 0.55);
}

.icon-btn--main svg { width: 26px; height: 26px; }
.i-play { margin-left: 3px; }

/* 播放/暂停图标切换：用按钮上的 is-playing 类控制，不依赖 SVG 的 hidden 属性 */
.icon-btn--main .i-pause { display: none; }
.icon-btn--main.is-playing .i-play { display: none; }
.icon-btn--main.is-playing .i-pause { display: block; }

/* 缓冲中：图标隐去，中间转圈 */
.icon-btn--main { position: relative; }
.icon-btn--main.is-buffering svg { opacity: 0; }
.icon-btn--main.is-buffering::after {
  content: "";
  position: absolute;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  animation: spin 0.85s linear infinite;
}

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

.sub-controls {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.chip:hover { color: var(--ink); border-color: rgba(255, 255, 255, 0.24); }

.chip.is-on { color: var(--accent-2); border-color: rgba(47, 75, 255, 0.55); background: rgba(47, 75, 255, 0.12); }

/* ==========================================================================
   播放列表弹层
   ========================================================================== */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(3, 3, 6, 0.62);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  animation: fade 0.18s ease;
}

.sheet[hidden] { display: none; }

.sheet__panel {
  width: min(720px, 100%);
  max-height: 74dvh;
  overflow-y: auto;
  padding: 18px 20px calc(22px + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--line);
  border-radius: 24px 24px 0 0;
  animation: rise 0.22s ease;
  -webkit-overflow-scrolling: touch;
}

.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
}

.sheet__head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--muted);
}

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

.sheet__item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 10px 6px;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: none;
  text-align: left;
  cursor: pointer;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

.sheet__item:hover { background: rgba(255, 255, 255, 0.03); }

.sheet__num {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--dim);
  text-align: center;
}

.sheet__text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sheet__title {
  font-size: 14px;
  letter-spacing: 0.04em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet__artist {
  font-size: 11px;
  color: var(--dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet__state {
  font-size: 11px;
  color: var(--accent-2);
  letter-spacing: 0.08em;
  opacity: 0;
}

.sheet__item.is-active .sheet__title { color: var(--accent-2); }
.sheet__item.is-active .sheet__state { opacity: 1; }

.sheet__empty {
  padding: 26px 8px;
  text-align: center;
  font-size: 13px;
  color: var(--dim);
  line-height: 1.8;
}

/* ==========================================================================
   提示
   ========================================================================== */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(26px + env(safe-area-inset-bottom));
  z-index: 60;
  max-width: min(88vw, 420px);
  padding: 11px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(18, 18, 24, 0.96);
  color: var(--ink);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-align: center;
  transform: translate(-50%, 12px);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.toast[hidden] { display: none; }
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }

/* ==========================================================================
   动画
   ========================================================================== */

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes rise {
  from { transform: translateY(26px); opacity: 0.4; }
  to { transform: translateY(0); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ==========================================================================
   窄屏微调（320px 也能排下）
   ========================================================================== */

@media (max-width: 359px) {
  .tile { padding: 10px; min-height: 132px; }
  .tile__name { font-size: 17px; letter-spacing: 0.1em; }
  .icon-btn { width: 42px; height: 42px; }
  .icon-btn--main { width: 60px; height: 60px; }
  .now__cover { width: 74vw; }
}
