/* 底部播放列 — 浮動 pill bar（風格參考 docs/explore01.png 的 Steam app HUD：
   懸浮、圓角、半透明深色background + blur，不是貼齊邊緣的全寬 bar）。
   顏色/字型沿用 docs/web-design-reference.md 第四節（App 本體 HUD 預設值）。 */

.player-bar {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(92vw, 760px);
  display: flex;
  flex-direction: column;
  background: rgba(14, 13, 15, 0.68);
  border: 1px solid var(--border);
  border-radius: 16px;
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  /* 明確高過 credits 面板等其他 fixed 角落元件，避免疊在一起時播放器被蓋住 */
  z-index: 5;
}

.player-bar-main {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 24px 12px;
}

/* 桌面版兩行：name+region 一行，meta+divider+title 另一行，靠 now-playing-break-desktop
   強制斷行；mobile 版改成 name+region+meta 同一行、title 自己一行，
   靠 now-playing-break-mobile 斷行（兩個 break 互斥開關見 css/mobile.css） */
.now-playing {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 3px 10px;
}

.now-playing-break {
  flex-basis: 100%;
  width: 0;
  height: 0;
}

.now-playing-break-mobile {
  display: none;
}

.now-playing-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

#now-city-name {
  font-family: var(--serif);
  font-size: 16px;
  font-style: italic;
  font-weight: 300;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* 區域名跟著城市名同一行，樣式沿用原本 #now-city-meta 那種小字 accent 標籤感 */
#now-city-region {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--accent);
  opacity: 0.6;
  flex-shrink: 0;
  white-space: nowrap;
}

#now-city-meta {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--accent);
  opacity: 0.6;
  flex-shrink: 0;
  white-space: nowrap;
}

.now-playing-divider {
  flex-shrink: 0;
  width: 1px;
  height: 12px;
  background: var(--border2);
}

/* 曲目名稱再長都完整顯示，不截斷、不換行：直接超出容器邊界，不裁切 */
#track-title {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text2);
  overflow: visible;
  white-space: nowrap;
}

/* 進度條：純顯示，不可拖曳、不能快轉。貼著 player-bar 最下緣，撐滿全寬 */
.progress-track {
  height: 3px;
  background: rgba(46, 43, 56, 0.5);
  position: relative;
  flex-shrink: 0;
  opacity: 0.15;
  transition: opacity 0.4s;
}

/* 真的在播放時進度條才完全不透明，未播放（含暫停）一律降為 15% */
body.is-playing .progress-track {
  opacity: 1;
}

.progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0%;
  background: rgba(200, 169, 126, 0.5);
}

/* 右側欄：星星列在上、時間/音量列在下，兩排靠左對齊（左邊緣對齊，不是右邊緣——
   參考 docs/star_ui.jpg，VOL 滑桿會往右延伸得比星星那排更遠，右邊不齊）；
   player-bar-main 的 align-items: center 會讓這整欄相對於 play-visual 垂直置中，
   星星自然落在置中線上方、時間/音量落在下方 */
.player-bar-side {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  flex-shrink: 0;
}

.player-bar-bottom-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.progress-time {
  flex-shrink: 0;
  display: flex;
  gap: 4px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text3);
  letter-spacing: 0.06em;
}

.play-visual {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  margin-left: -6px;
  margin-right: 6px;
}

/* 視波圖：是時域波形，會上下對稱震盪（不是只往上長），所以走預設的
   align-items: center，讓 svg 自己的垂直中心對齊 play-btn 垂直中心即可，
   不用像之前方塊版那樣特別用 align-self: flex-start 去對齊底部。
   預設保留版面空間但完全隱形，避免按下播放時左右排版跳動 */
.viz {
  display: block;
  width: 56px;
  height: 26px;
  overflow: visible;
  opacity: 0;
  transition: opacity 0.3s;
}

body.is-playing-settled .viz {
  opacity: 1;
}

/* points 由 js/main.js 的 bindVisualizer() 依即時時域資料逐 frame 更新，
   點跟點之間故意用直線連（折線），不是平滑貝茲曲線，看起來更接近真實示波器的鋸齒感 */
.viz-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.3;
}

.play-btn {
  position: relative;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(200, 169, 126, 0.35);
  background: rgba(200, 169, 126, 0.1);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.play-btn:disabled {
  cursor: not-allowed;
}

/* 觸控點擊不要留下瀏覽器預設的藍色焦點框，鍵盤操作仍保留可見的焦點樣式 */
.play-btn:focus {
  outline: none;
}

.play-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* 暫停（未播放）時中央圖示降 30% 透明度，跟按鈕外框/背景脫鉤 */
.play-btn svg {
  opacity: 0.7;
  transition: opacity 0.3s;
}

body.is-playing-settled .play-btn svg {
  opacity: 1;
}

/* 播放中的動態提示：細圓環緩慢旋轉，取代原本的暫停圖示；
   跟 is-playing-settled 掛鉤，沿用「淡入跑完才切換」的延後設計 */
.play-btn::after {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 1px solid transparent;
  pointer-events: none;
  opacity: 0;
}

body.is-playing-settled .play-btn::after {
  opacity: 1;
  border-color: rgba(200, 169, 126, 0.25);
  border-top-color: var(--accent);
  animation: play-ring-spin 2.4s linear infinite;
}

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

/* 淡入播放的 3 秒期間輕微閃動，提示「正在淡入」；keyframes 結尾固定回到 100% 不透明 */
@keyframes play-btn-flicker {
  0%,
  100% {
    opacity: 1;
  }
  20% {
    opacity: 0.55;
  }
  40% {
    opacity: 1;
  }
  60% {
    opacity: 0.55;
  }
  80% {
    opacity: 1;
  }
}

/* 閃動速度加快一倍：單次 keyframes 縮成 1.5s，跑兩次剛好補滿 3 秒淡入鎖定的時間，
   每次迴圈結尾都落在 100% 不透明，不會卡在閃爍中間 */
.play-btn-flicker {
  animation: play-btn-flicker 1.5s ease-in-out 2;
}

/* :hover 限定在真的有滑鼠的裝置才套用，避免觸控裝置點擊後 hover 樣式卡住不放 */
@media (hover: hover) and (pointer: fine) {
  .play-btn:hover {
    background: rgba(200, 169, 126, 0.2);
    border-color: rgba(200, 169, 126, 0.65);
  }
}

.play-btn svg {
  width: 16px;
  height: 16px;
}

/* 圖示 + 常駐文字標籤橫排成一組，文字放在面板上而不是只靠 hover tooltip，
   行動裝置（沒有 hover）也看得到目前狀態是「可以按」還是「已喜愛」 */
.star-group {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.star-label {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text3);
  letter-spacing: 0.06em;
  white-space: nowrap;
}

/* 無底版、無外框——只看到星星圖示本身，跟 .play-btn 的圓形 HUD 風格刻意不同 */
.star-btn {
  position: relative;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.star-btn:disabled {
  cursor: not-allowed;
}

.star-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  /* 預設稍微收斂，hover／已喜愛時才提升到全亮，呼應 .play-btn svg 的 0.7→1 語言 */
  opacity: 0.75;
  transition: fill 0.3s, opacity 0.2s, transform 0.2s;
}

/* 已喜愛：實心點亮；dim 動畫由 JS 中控透過 .star-btn-firing class 觸發，不在這裡宣告 */
.star-btn.star-btn-liked svg {
  fill: var(--accent);
  opacity: 1;
}

@keyframes star-fire-dim {
  0%   { opacity: 1; }
  8%   { opacity: 0.5; }
  38%  { opacity: 1; }
  100% { opacity: 1; }
}

.star-btn-firing svg {
  animation: star-fire-dim 5.5s ease-in-out forwards;
}

/* :hover 限定在真的有滑鼠的裝置才套用，避免觸控裝置點擊後 hover 樣式卡住不放；
   已喜愛（disabled）時不再需要 hover 提示 */
@media (hover: hover) and (pointer: fine) {
  .star-btn:not(:disabled):hover svg {
    opacity: 1;
    transform: scale(1.15);
  }
}

/* 按下瞬間的呼吸動畫，呼應 .play-btn-flicker 的做法，跑完固定停在「已喜愛」實心狀態 */
@keyframes star-btn-breathe {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.55;
    transform: scale(1.15);
  }
}

.star-btn-flicker {
  animation: star-btn-breathe 0.6s ease-in-out 2;
}

@keyframes star-particle-rise {
  0% {
    transform: translate(-50%, -50%) translateY(0) rotate(0deg);
    opacity: 0;
  }
  5% {
    transform: translate(-50%, -50%) translateY(-6px) rotate(20deg);
    opacity: 0.5;
  }
  20% {
    transform: translate(-50%, -50%) translateY(-64px) rotate(148deg);
    opacity: 0.45;
  }
  45%, 100% {
    transform: translate(-50%, -50%) translateY(-160px) rotate(360deg);
    opacity: 0;
  }
}

.star-particle {
  position: fixed;
  width: 16px;
  height: 16px;
  color: var(--accent);
  pointer-events: none;
  z-index: 9999;
  animation: star-particle-rise 5s linear forwards;
}

.star-particle svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.volume {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text3);
  letter-spacing: 0.06em;
}

.volume-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.volume input[type='range'] {
  -webkit-tap-highlight-color: transparent;
  width: 60px;
  height: 2px;
  appearance: none;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 1px;
  accent-color: var(--accent);
}

.volume input[type='range']::-webkit-slider-thumb {
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #544735;
  cursor: pointer;
  transition: background 0.2s;
}

.volume input[type='range']::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: none;
  border-radius: 50%;
  background: #544735;
  cursor: pointer;
  transition: background 0.2s;
}

/* :hover 限定在真的有滑鼠的裝置才套用，避免觸控裝置點擊後 hover 樣式卡住不放 */
@media (hover: hover) and (pointer: fine) {
  .volume input[type='range']:hover::-webkit-slider-thumb {
    background: var(--accent);
  }

  .volume input[type='range']:hover::-moz-range-thumb {
    background: var(--accent);
  }
}
