/* ===== Right Player Wrapper =====
   Zero-width flex child inside .layout, player overflows into right margin.
   Uses position:sticky for perfectly synchronous scrolling. */

/* Wrapper: zero-width flex item, stretches to full layout height for sticky */
#right-player-wrapper {
  order: 3;
  width: 0 !important;
  min-width: 0 !important;
  flex: 0 0 0px;
  position: relative;
  /* Must NOT have align-self: flex-start, needs to stretch for sticky */
}

/* Player: sticky positioning, same technique as aside .sticky_layout */
#right-player {
  position: -webkit-sticky;
  position: sticky;
  top: 20px;
  transition: top 0.3s;
  margin-left: 15px;
}

/* Playlist scrollable */
#right-player .playlist {
  max-height: calc((100vh - 480px) / 2);
  min-height: 150px;
  overflow-y: auto;
}

/* When nav is fixed/visible, match aside's sticky top adjustment */
.page #page-header.nav-visible ~ #content-inner > #right-player-wrapper #right-player,
.page #page-header.fixed ~ #content-inner > #right-player-wrapper #right-player,
#page-header.nav-visible + #content-inner > #right-player-wrapper #right-player,
#page-header.fixed + #content-inner > #right-player-wrapper #right-player,
#page-header.nav-visible + .layout > #right-player-wrapper #right-player,
#page-header.fixed + .layout > #right-player-wrapper #right-player {
  top: 70px;
}

/* Hide on narrow screens */
@media screen and (max-width: 1500px) {
  #right-player-wrapper {
    display: none !important;
  }
}

/* ===== Player Card ===== */
.player-card {
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  padding: 20px;
  transition: box-shadow 0.3s;
}

.player-card:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

/* ===== Header ===== */
.player-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  font-size: 0.85em;
  font-weight: 600;
  color: var(--font-color);
  opacity: 0.7;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.player-header i {
  font-size: 1em;
}

/* ===== CD Cover ===== */
.cd-container {
  position: relative;
  width: 140px;
  height: 140px;
  margin: 0 auto 16px;
}

.cd-disc {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  animation: cd-spin 12s linear infinite;
  animation-play-state: paused;
}

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

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

/* Center hole */
.cd-disc::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--card-bg, #fff);
  box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.15);
}

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

/* ===== Song Info ===== */
.song-info {
  text-align: center;
  margin-bottom: 14px;
}

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

.song-artist {
  font-size: 0.78em;
  color: var(--font-color);
  opacity: 0.55;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Progress Bar ===== */
.progress-container {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.progress-time {
  font-size: 0.68em;
  color: var(--font-color);
  opacity: 0.5;
  min-width: 32px;
  font-variant-numeric: tabular-nums;
}

.progress-time.current {
  text-align: right;
}

/* Outer wrapper expands click area, inner track is visible */
.progress-bar-wrapper {
  flex: 1;
  padding: 10px 0;
  cursor: pointer;
}

.progress-bar {
  height: 6px;
  background: #d9d9d9;
  border-radius: 3px;
  position: relative;
}

.progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: #49b1f5;
  border-radius: 3px;
  transition: width 0.1s linear;
}

[data-theme="dark"] .progress-bar {
  background: rgba(255, 255, 255, 0.2);
}

/* ===== Controls ===== */
.player-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-bottom: 4px;
}

.ctrl-btn {
  background: none;
  border: none;
  color: var(--font-color);
  cursor: pointer;
  padding: 4px;
  opacity: 0.6;
  transition: all 0.2s;
  font-size: 1em;
  line-height: 1;
}

.ctrl-btn:hover {
  opacity: 1;
  transform: scale(1.15);
}

.ctrl-btn.mode-btn {
  font-size: 0.85em;
  opacity: 0.35;
}

.ctrl-btn.mode-btn.active {
  opacity: 1;
  color: #49b1f5;
}

.ctrl-btn.play-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #49b1f5;
  color: #fff;
  opacity: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1em;
  box-shadow: 0 2px 8px rgba(73, 177, 245, 0.35);
}

.ctrl-btn.play-btn:hover {
  background: #3aa0e4;
  transform: scale(1.1);
}

/* ===== Playlist ===== */
.playlist-divider {
  height: 1px;
  background: var(--font-color);
  opacity: 0.08;
  margin: 14px 0;
}

.playlist {
  max-height: 240px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.1) transparent;
}

.playlist::-webkit-scrollbar {
  width: 3px;
}

.playlist::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.12);
  border-radius: 2px;
}

.playlist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.playlist-item:hover {
  background: rgba(0, 0, 0, 0.04);
}

.playlist-item.active {
  background: rgba(73, 177, 245, 0.1);
}

.playlist-item-cover {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}

.playlist-item-info {
  flex: 1;
  min-width: 0;
}

.playlist-item-title {
  font-size: 0.78em;
  color: var(--font-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.playlist-item.active .playlist-item-title {
  color: #49b1f5;
  font-weight: 600;
}

.playlist-item-artist {
  font-size: 0.68em;
  color: var(--font-color);
  opacity: 0.45;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Loading State ===== */
.player-loading {
  text-align: center;
  padding: 30px 0;
  color: var(--font-color);
  opacity: 0.4;
  font-size: 0.85em;
}

/* ===== Dark Mode ===== */
[data-theme="dark"] .player-card {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .player-card:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .playlist-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .playlist-item.active {
  background: rgba(73, 177, 245, 0.15);
}

[data-theme="dark"] .cd-disc::after {
  background: var(--card-bg, #1d1e22);
}
