/* The docked player bar.
 *
 * Dark by default, same chrome tokens as the shell. Day remaps them in
 * app.css so the bar uses the paper palette instead of staying a dark slab
 * over a light screen.
 *
 * 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: 60px;
  --pk-bar-gap: 8px;
  /* 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;
  --pk-bar-bg: #14171e;
  --pk-bar-ink: #edeff4;
  --pk-bar-muted: #8a91a0;
  --pk-bar-dim: #c8cdd8;
  --pk-bar-wash: #ffffff14;
  --pk-bar-line: #1c2028;
  --pk-bar-edge: #22262f;
  background: var(--pk-bar-bg);
  border-top: 1px solid var(--pk-bar-line);
  color: var(--pk-bar-ink);
  font-family: var(--font-body, inherit);
  /* pan-y, not the default `auto`: a sideways drag on the bar is the
   * dismiss gesture (see player-bar.js's _wireDismissSwipe), and under the
   * default value the browser can start its own horizontal pan/navigation
   * gesture before JS ever sees a pointermove, the same race
   * player-shell.js's own drag surfaces avoid with `none`. pan-y rather than
   * `none` because there is nothing vertical for this element to own —
   * leaving that axis to the browser costs nothing and keeps any vertical
   * page behaviour (e.g. a pull gesture starting here) working normally. */
  touch-action: pan-y;
}
.hp-mini.pk-bar {
  /* Fixed, not in-flow. The bar is inserted just before .tabs at the end of
   * <body>; tabs are themselves fixed, so a relative bar sits after the
   *   screens and scrolls away from the nav with the page. */
  position: fixed;
  left: calc(var(--pk-dock-left, 0px) + 8px);
  right: 8px;
  bottom: calc(
    var(--pk-dock-bottom, 0px) + var(--pk-bar-gap, 8px) + env(safe-area-inset-bottom, 0px)
  );
  border-radius: 16px;
  border: 1px solid var(--pk-bar-edge);
  overflow: hidden;
  box-shadow: 0 10px 28px -16px #000c;
  z-index: var(--z-player-bar, 90);
}
.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;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--pk-bar-wash);
}
.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: var(--pk-bar-wash);
  display: grid;
  place-items: center;
  color: var(--pk-bar-muted);
}
.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-sub {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* The wrap is the clipped viewport. The title is an inline-block the
 * marquee (PlayerBar._syncTitleMarquee) slides when the text is wider
 * than the bar. A title that fits never moves. Same split as
 * .hp-mini-title-wrap, which this bar replaced. */
.pk-bar-title-wrap {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  min-width: 0;
}
.pk-bar-title {
  display: inline-block;
  font-size: 0.78125rem;
  font-weight: 500;
  white-space: nowrap;
}
.pk-bar-sub {
  font-size: 0.6875rem;
  color: var(--pk-bar-muted);
}
.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: var(--pk-bar-dim);
  cursor: pointer;
  padding: 0;
}
.pk-bar-btn .pk-bar-num {
  font-size: 0.59375rem;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.pk-bar-queue {
  color: var(--pk-bar-muted);
}
.pk-bar-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
/* The swap control comes and goes rather than sitting disabled (#1287).
 * `.pk-bar-btn { display: grid }` beats the hidden attribute, so spell
 * display:none or an empty 30px hole sits to the left of rewind on
 * every track that has no twin. */
.pk-bar-swap[hidden] {
  display: none;
}

/* 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: var(--ps-on-accent, #12161f);
  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: var(--ps-on-accent, #12161f);
  font-size: 0.59375rem;
  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;
  }
  /* No slide. Clip the title in place, with an ellipsis so the cut is
   * visible rather than a hard edge. */
  .pk-bar-title {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
