/* The docked player bar.
 *
 * Single-palette dark, matching the unified shell rather than the app's
 * themes, for the same reason stated at the top of player-shell.css: the
 * redesign spec gives this surface's colours as dark literals only, and a bar
 * that is the shell in miniature should not change palette when the shell
 * above it doesn't.
 *
 * The element also wears `.hp-mini` so the host's existing layout rules keep
 * working (see the file comment in player-bar.js). Everything here is scoped
 * to `.pk-bar` so none of it leaks onto the engines' own bars, which are still
 * built — just never shown.
 */

.pk-bar {
  --pk-bar-h: 55px;
  /* Follows the kit's docking convention (see the --pk-dock-position block in
   * player.css) rather than hardcoding `relative`. A flat `relative` here beat
   * `.hp-mini`'s `position: var(--pk-dock-position)` on load order while
   * `.hp-mini`'s companion `bottom: calc(--pk-dock-bottom + safe-area)` still
   * applied — and on a relatively-positioned element that `bottom` is a visual
   * nudge off its flow position rather than a dock, so the bar floated ~25px
   * clear of the tab bar it is supposed to sit flush against. Either property
   * alone is fine; the two disagreeing is the bug. The fallback keeps a
   * standalone consumer of player-bar.css (no player.css, so no
   * --pk-dock-position) on the old behaviour, and `fixed` establishes the
   * containing block .pk-bar-prog needs just as well as `relative` did. */
  position: var(--pk-dock-position, relative);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  min-height: var(--pk-bar-h);
  padding: 0 12px;
  background: #0a0c11;
  border-top: 1px solid #16181f;
  color: #edeff4;
  font-family: var(--font-body, inherit);
}
.pk-bar[hidden] {
  display: none;
}

/* While the full player is up, the bar is the same item in miniature under its
 * own backdrop — the surface duplicating itself. Same rule the shell already
 * applies to the engines' bars. */
body.ps-open .pk-bar {
  display: none;
}

/* ── Progress ────────────────────────────────────────────────────────────── */

.pk-bar-prog {
  position: absolute;
  top: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: #ffffff14;
}
.pk-bar-prog-fill {
  height: 100%;
  width: 0;
  background: #f2a113;
  transition: width 0.4s linear;
}

/* ── Item ────────────────────────────────────────────────────────────────── */

/* One large target: tapping anywhere that isn't a control opens the player. */
.pk-bar-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.pk-bar-art {
  position: relative;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 4px;
  overflow: hidden;
  background: #ffffff0f;
  display: grid;
  place-items: center;
  color: #7a8193;
}
.pk-bar-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.pk-bar-art img[hidden],
.pk-bar-art-glyph[hidden] {
  display: none;
}
/* Both live in the same grid cell, so whichever is showing is centred and the
 * art fills the square. */
.pk-bar-art img,
.pk-bar-art-glyph {
  grid-area: 1 / 1;
}

.pk-bar-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.pk-bar-title,
.pk-bar-sub {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pk-bar-title {
  font-size: 12.5px;
  font-weight: 500;
}
.pk-bar-sub {
  font-size: 11px;
  color: #8a91a0;
}
.pk-bar-sub:empty {
  display: none;
}

/* ── Controls ────────────────────────────────────────────────────────────── */

.pk-bar-controls {
  flex: none;
  display: flex;
  align-items: center;
  gap: 2px;
}

.pk-bar-btn {
  position: relative;
  width: 30px;
  height: 32px;
  display: grid;
  place-items: center;
  gap: 0;
  border: 0;
  background: none;
  color: #c8cdd8;
  cursor: pointer;
  padding: 0;
}
.pk-bar-btn .pk-bar-num {
  font-size: 9.5px;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.pk-bar-queue {
  color: #8a91a0;
}
.pk-bar-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

/* The one filled control on the bar, as in the shell's transport — and square,
 * because things you press to play are square. */
.pk-bar-play {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: #f2a113;
  color: #08090d;
  cursor: pointer;
  padding: 0;
}
.pk-bar-play:disabled {
  opacity: 0.4;
  cursor: default;
}

/* How many are still to come. */
.pk-bar-count {
  position: absolute;
  top: 1px;
  right: 0;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  border-radius: 999px;
  background: #f2a113;
  color: #08090d;
  font-size: 9.5px;
  font-weight: 600;
  line-height: 14px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.pk-bar-count[hidden] {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .pk-bar-prog-fill {
    transition: none;
  }
}
