/* ==========================================================================
   Player Bar Component
   Background furniture, not a control panel. Essential info + play/pause only.
   ========================================================================== */

.player-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  gap: var(--space-1) var(--space-2);
  z-index: var(--z-player);

  /* Safe area inset for notched devices */
  padding-bottom: calc(var(--space-2) + env(safe-area-inset-bottom, 0));
}

/* ==========================================================================
   Now Playing Row
   Mobile: full-width info-only row (track name)
   Desktop: transparent wrapper (display: contents)
   ========================================================================== */

.player-bar__now-playing {
  width: 100%;
  min-width: 0; /* Allow text truncation */
}

/* Hidden state - must override display: flex */
.player-bar[hidden] {
  display: none;
}

/* ==========================================================================
   Mood Indicator
   Small pill showing current mood - tap to return to selector
   ========================================================================== */

.player-bar__mood {
  padding: var(--space-1) var(--space-3);
  background: var(--color-accent);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  white-space: nowrap;
  transition: transform var(--duration-fast) var(--ease-out),
              opacity var(--duration-fast) var(--ease-out);
  /* Touch target enforcement */
  min-height: var(--touch-target);
  display: flex;
  align-items: center;
}

.player-bar__mood:hover,
.player-bar__mood:focus-visible {
  transform: scale(1.05);
  opacity: 0.9;
}

.player-bar__mood:active {
  transform: scale(0.95);
}

/* ==========================================================================
   Track Info
   ========================================================================== */

.player-bar__track {
  display: block;
  font-size: var(--text-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--color-text);
}

/* ==========================================================================
   Play/Pause Button
   Primary control - prominent but not dominating
   ========================================================================== */

.player-bar__play {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--color-accent);
  color: var(--color-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform var(--duration-fast) var(--ease-out),
              background var(--duration-fast) var(--ease-out);
}

.player-bar__play:hover,
.player-bar__play:focus-visible {
  transform: scale(1.08);
  background: var(--color-accent);
  filter: brightness(1.1);
}

.player-bar__play:active {
  transform: scale(0.95);
}

.player-bar__play .icon {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* Slight offset for play icon visual balance */
.player-bar__play .icon:first-child:not(.hidden) {
  margin-left: 2px;
}

/* ==========================================================================
   Skip Button
   Secondary control - smaller and less prominent than play
   ========================================================================== */

.player-bar__skip {
  width: var(--touch-target);
  height: var(--touch-target);
  border-radius: 50%;
  border: none;
  background: var(--color-surface-elevated);
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out),
              background var(--duration-fast) var(--ease-out);
}

/* Skip nudge animation (soft friction visual feedback) */
.player-bar__skip--nudge {
  animation: skip-nudge 600ms var(--ease-out);
}

@keyframes skip-nudge {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  25% {
    transform: scale(0.9);
    opacity: 0.6;
  }
  50% {
    transform: scale(1.1);
    opacity: 1;
  }
}

.player-bar__skip:hover,
.player-bar__skip:focus-visible {
  transform: scale(1.08);
  color: var(--color-text);
  background: var(--color-border);
}

.player-bar__skip:active {
  transform: scale(0.95);
}

.player-bar__skip .icon {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* ==========================================================================
   Progress Rail
   Tappable seek bar
   ========================================================================== */

.player-bar__progress {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.progress-rail {
  flex: 1;
  height: 4px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  cursor: pointer;
  overflow: hidden;
  position: relative;
  /* Increase tap target */
  padding: 10px 0;
  margin: -10px 0;
  background-clip: content-box;
}

.progress-rail:hover .progress-rail__fill,
.progress-rail:focus-visible .progress-rail__fill {
  background: var(--color-accent);
  filter: brightness(1.2);
}

.progress-rail__fill {
  height: 4px;
  background: var(--color-accent);
  border-radius: var(--radius-full);
  width: 0%;
  transition: width var(--duration-instant) linear;
  position: relative;
  top: 10px; /* Align with padded rail */
}

.player-bar__time {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  min-width: 3.5em;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Settings Button
   ========================================================================== */

.player-bar__settings {
  width: var(--touch-target);
  height: var(--touch-target);
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  transition: color var(--duration-fast) var(--ease-out),
              background var(--duration-fast) var(--ease-out);
  flex-shrink: 0;
}

.player-bar__settings .icon {
  width: 20px;
  height: 20px;
}

.player-bar__settings:hover,
.player-bar__settings:focus-visible {
  color: var(--color-text);
  background: var(--color-surface-elevated);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

/* Tablet+: single row layout */
@media (min-width: 641px) {
  :root {
    --player-height: 72px;
  }

  .player-bar {
    flex-wrap: nowrap;
    padding: 0 var(--space-4);
    gap: var(--space-3);
    height: var(--player-height);
  }

  /* Info row becomes inline, takes available space */
  .player-bar__now-playing {
    width: auto;
    flex: 1;
    min-width: 0;
  }
}

/* Tablet: more breathing room */
@media (min-width: 768px) {
  .player-bar {
    padding: 0 var(--space-6);
    gap: var(--space-4);
  }
}

/* Desktop: generous padding */
@media (min-width: 1024px) {
  .player-bar {
    padding: 0 var(--space-8);
  }
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .player-bar__mood,
  .player-bar__play,
  .player-bar__skip,
  .player-bar__settings {
    transition: none;
  }
}
