/* ============================================================
   ReadIt Stories — Audio Player CSS
   Sticky player, seek bar, waveform, mini player
   ============================================================ */

.rs-player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--rs-z-player);
  background: rgba(16, 16, 29, 0.96);
  backdrop-filter: blur(32px);
  -webkit-backdrop-filter: blur(32px);
  border-top: 1px solid rgba(255,255,255,0.08);
  height: var(--rs-player-height);
  transition: height 0.3s cubic-bezier(0.4,0,0.2,1);
  box-shadow: 0 -8px 40px rgba(0,0,0,0.6);
}

.rs-player[data-state="idle"] { display: none !important; }
.rs-player[data-state="active"] { display: block !important; }

.rs-player-inner {
  display: grid;
  grid-template-columns: 280px 1fr 1fr 280px;
  align-items: center;
  height: var(--rs-player-height);
  padding: 0 var(--rs-space-6);
  gap: var(--rs-space-5);
  max-width: 1800px;
  margin: 0 auto;
}

/* ── TRACK INFO ── */

.rs-player-track {
  display: flex;
  align-items: center;
  gap: var(--rs-space-3);
  min-width: 0;
}

.rs-player-thumb {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: var(--rs-radius-sm);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--rs-card);
}

.rs-player-artwork {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--rs-radius-sm);
  display: block;
}

.rs-player-thumb-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  background: var(--rs-gradient-subtle);
}

.rs-player-waveform {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: rgba(0,0,0,0.6);
}

.rs-player[data-playing="true"] .rs-player-waveform { display: flex; }

.rs-player-waveform span {
  width: 3px;
  height: 8px;
  background: var(--rs-primary);
  border-radius: 2px;
  animation: rs-waveform 0.9s ease-in-out infinite;
}
.rs-player-waveform span:nth-child(1) { animation-delay: 0s; }
.rs-player-waveform span:nth-child(2) { animation-delay: 0.15s; }
.rs-player-waveform span:nth-child(3) { animation-delay: 0.3s; height: 14px; }
.rs-player-waveform span:nth-child(4) { animation-delay: 0.45s; }
.rs-player-waveform span:nth-child(5) { animation-delay: 0.6s; height: 10px; }

.rs-player-meta { min-width: 0; flex: 1; }

.rs-player-title {
  display: block;
  font-size: var(--rs-text-sm);
  font-weight: var(--rs-weight-semibold);
  color: var(--rs-text);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: var(--rs-ease-fast);
  line-height: 1.3;
}
.rs-player-title:hover { color: var(--rs-primary); }

.rs-player-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.rs-player-author {
  font-size: var(--rs-text-xs);
  color: var(--rs-text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.rs-player-sep { color: var(--rs-text-faint); opacity: 0.4; font-size: var(--rs-text-xs); }

.rs-player-category {
  font-size: var(--rs-text-xs);
  color: var(--rs-primary);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100px;
}
.rs-player-category:hover { text-decoration: underline; }

/* ── CONTROLS ── */

.rs-player-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--rs-space-3);
}

.rs-player-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--rs-radius-full);
  border: none;
  background: none;
  color: var(--rs-text-muted);
  cursor: pointer;
  transition: var(--rs-ease-fast);
  position: relative;
  flex-shrink: 0;
}
.rs-player-btn:hover { color: var(--rs-text); background: rgba(255,255,255,0.07); }
.rs-player-btn:active { transform: scale(0.92); }

/* Skip buttons with label */
.rs-player-skip-back,
.rs-player-skip-fwd {
  position: relative;
  font-size: 0;
}

.rs-player-skip-label {
  position: absolute;
  font-size: 8px;
  font-weight: var(--rs-weight-bold);
  line-height: 1;
  bottom: 7px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--rs-text-muted);
}

.rs-player-play-pause {
  width: 48px;
  height: 48px;
  background: var(--rs-gradient);
  color: white;
  box-shadow: 0 4px 16px var(--rs-primary-glow);
  transition: var(--rs-ease-spring) !important;
}
.rs-player-play-pause:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px var(--rs-primary-glow);
  background: var(--rs-gradient);
  color: white;
}

/* ── SEEK BAR ── */

.rs-player-seek-wrap {
  display: flex;
  align-items: center;
  gap: var(--rs-space-3);
  padding: 0 var(--rs-space-2);
}

.rs-player-time {
  font-size: var(--rs-text-xs);
  font-weight: var(--rs-weight-medium);
  color: var(--rs-text-faint);
  white-space: nowrap;
  min-width: 36px;
  font-variant-numeric: tabular-nums;
}

.rs-player-seek {
  flex: 1;
  position: relative;
  height: 20px;
  display: flex;
  align-items: center;
  cursor: pointer;
}

.rs-player-seek-track {
  position: relative;
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: var(--rs-radius-full);
  overflow: visible;
  transition: height 0.15s ease;
}

.rs-player-seek:hover .rs-player-seek-track { height: 5px; }

.rs-player-seek-buffer {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: rgba(255,255,255,0.15);
  border-radius: var(--rs-radius-full);
  transition: width 0.3s ease;
  pointer-events: none;
}

.rs-player-seek-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: var(--rs-gradient);
  border-radius: var(--rs-radius-full);
  pointer-events: none;
  transition: width 0.1s linear;
}

.rs-player-seek-thumb {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%) scale(0);
  width: 14px;
  height: 14px;
  background: white;
  border-radius: var(--rs-radius-full);
  pointer-events: none;
  box-shadow: 0 0 8px rgba(255,77,77,0.5);
  transition: transform 0.15s ease;
}

.rs-player-seek:hover .rs-player-seek-thumb,
.rs-player-seek.rs-seeking .rs-player-seek-thumb { transform: translate(-50%, -50%) scale(1); }

.rs-player-seek-input {
  position: absolute;
  inset: -8px 0;
  width: 100%;
  height: calc(100% + 16px);
  opacity: 0;
  cursor: pointer;
  -webkit-appearance: none;
  z-index: 2;
}

/* ── EXTRAS ── */

.rs-player-extras {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--rs-space-1);
}

/* Volume */
.rs-player-volume {
  display: flex;
  align-items: center;
  gap: var(--rs-space-2);
}

.rs-player-vol-slider { width: 80px; position: relative; }

.rs-player-vol-input {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  background: rgba(255,255,255,0.15);
  border-radius: var(--rs-radius-full);
  outline: none;
  cursor: pointer;
}

.rs-player-vol-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: white;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  transition: transform 0.15s ease;
}
.rs-player-vol-input::-webkit-slider-thumb:hover { transform: scale(1.2); }

.rs-player-vol-input::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: white;
  border: none;
  cursor: pointer;
}

/* Speed Selector */
.rs-player-speed,
.rs-player-sleep { position: relative; }

.rs-player-speed-btn,
.rs-player-sleep-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--rs-text-xs);
  font-weight: var(--rs-weight-bold);
  color: var(--rs-text-muted);
  width: auto;
  padding: 0 var(--rs-space-2);
  min-width: 52px;
  border-radius: var(--rs-radius-sm);
}

.rs-player-speed-label,
.rs-player-sleep-label { font-size: var(--rs-text-xs); font-weight: var(--rs-weight-bold); }

.rs-player-speed-menu,
.rs-player-sleep-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  background: var(--rs-card);
  border: 1px solid var(--rs-border);
  border-radius: var(--rs-radius-md);
  overflow: hidden;
  min-width: 100px;
  box-shadow: var(--rs-shadow-md);
  animation: rs-dropdown-in 0.15s ease;
  z-index: 10;
}

.rs-speed-option,
.rs-sleep-option {
  display: block;
  width: 100%;
  padding: var(--rs-space-2) var(--rs-space-4);
  font-size: var(--rs-text-sm);
  font-weight: var(--rs-weight-medium);
  color: var(--rs-text-muted);
  text-align: center;
  cursor: pointer;
  transition: var(--rs-ease-fast);
  background: none;
  border: none;
}
.rs-speed-option:hover,
.rs-sleep-option:hover { background: rgba(255,255,255,0.07); color: var(--rs-text); }
.rs-speed-option.rs-speed-active,
.rs-sleep-option.rs-sleep-active { color: var(--rs-primary); font-weight: var(--rs-weight-bold); background: rgba(255,77,77,0.08); }

/* Collapse/Goto */
.rs-player-collapse { color: var(--rs-text-faint); }
.rs-player-collapse svg { transform: rotate(90deg); transition: transform 0.3s ease; }
.rs-player[data-collapsed="true"] .rs-player-collapse svg { transform: rotate(-90deg); }

.rs-player-goto { text-decoration: none; }

/* ── MINI PLAYER ── */

.rs-player-mini {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--rs-player-height);
  display: flex;
  flex-direction: column;
}

.rs-mini-seek {
  height: 3px;
  background: rgba(255,255,255,0.1);
  flex-shrink: 0;
}

.rs-mini-seek-fill {
  height: 100%;
  background: var(--rs-gradient);
  border-radius: 0;
  transition: width 0.1s linear;
}

.rs-mini-inner {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--rs-space-3);
  padding: 0 var(--rs-space-5);
}

.rs-mini-artwork {
  width: 44px;
  height: 44px;
  border-radius: var(--rs-radius-sm);
  object-fit: cover;
  flex-shrink: 0;
}

.rs-mini-info { flex: 1; min-width: 0; }
.rs-mini-title {
  font-size: var(--rs-text-sm);
  font-weight: var(--rs-weight-semibold);
  color: var(--rs-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.rs-mini-play { width: 40px; height: 40px; }

/* ── RESPONSIVE ── */

@media (max-width: 1024px) {
  .rs-player-inner {
    grid-template-columns: 1fr auto 1fr;
    grid-template-rows: auto auto;
    height: auto;
    padding: var(--rs-space-3) var(--rs-space-4);
    gap: var(--rs-space-3);
  }

  .rs-player-track { grid-column: 1; grid-row: 1; }
  .rs-player-controls { grid-column: 2; grid-row: 1; }
  .rs-player-extras { grid-column: 3; grid-row: 1; justify-content: flex-end; }
  .rs-player-seek-wrap { grid-column: 1 / -1; grid-row: 2; }

  .rs-player { height: auto; }

  .rs-player-vol-slider { width: 60px; }
}

@media (max-width: 768px) {
  .rs-player-inner {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: var(--rs-space-2);
    padding: var(--rs-space-2) var(--rs-space-3);
  }

  .rs-player-track { grid-column: 1; grid-row: 1; }
  .rs-player-controls { grid-column: 2; grid-row: 1; gap: var(--rs-space-2); }
  .rs-player-seek-wrap { grid-column: 1 / -1; grid-row: 2; padding: 0; }
  .rs-player-extras { display: none; }
  .rs-player-prev, .rs-player-next { display: none; }
  .rs-player-skip-back, .rs-player-skip-fwd { display: none; }
}
