/* ==========================================================================
   Music player: a small card in the corner, built from the site's own tokens
   ========================================================================== */

.pip-player {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1004;
  width: 330px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  box-shadow: 4px 4px 0 var(--shadow);
  overflow: hidden;
}
.pip-player.is-closed { display: none; }
.pip-player.is-dragging { opacity: .9; }

.pip-main {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px 10px 12px;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.pip-player.is-dragging .pip-main { cursor: grabbing; }

.pip-play {
  flex: none;
  width: 34px;
  height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
}
.pip-play svg { width: 12px; height: 12px; }

.pip-meta { flex: 1; min-width: 0; }
.pip-title {
  font-family: var(--sans);
  font-size: .8125rem;
  line-height: 1.3;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pip-artist {
  font-family: var(--mono);
  font-size: .6875rem;
  line-height: 1.4;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pip-actions { display: flex; flex: none; }
.pip-ico {
  width: 24px;
  height: 28px;
  display: grid;
  place-items: center;
  color: var(--ink-3);
  transition: color .15s;
}
.pip-ico:hover { color: var(--ink); }
.pip-ico.is-active { color: var(--acc); }
.pip-ico svg { width: 10px; height: 10px; }

/* thin progress line along the bottom edge */
.pip-progress { height: 2px; background: var(--line-soft); }
.pip-progress-bar { height: 100%; width: 0; background: var(--acc); }

/* --- playlist --- */
.pip-drawer { display: none; border-top: 1px solid var(--line-soft); }
.pip-drawer.is-open { display: block; }

.pip-list {
  max-height: 200px;
  overflow-y: auto;
  padding: 4px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-4) transparent;
}
.pip-item { display: flex; align-items: center; }
.pip-item:hover { background: var(--hover-row); }
.pip-item-name {
  flex: 1;
  min-width: 0;
  padding: 6px 12px;
  text-align: left;
  font-family: var(--mono);
  font-size: .6875rem;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color .15s;
}
.pip-item-name:hover { color: var(--ink); }
.pip-item.is-current .pip-item-name { color: var(--acc); }
.pip-item.is-current .pip-item-name::before { content: "> "; }
.pip-item-del {
  width: 24px;
  height: 24px;
  display: none;
  place-items: center;
  margin-right: 6px;
  color: var(--ink-4);
}
.pip-item:hover .pip-item-del { display: grid; }
.pip-item-del:hover { color: var(--soul); }
.pip-item-del svg { width: 8px; height: 8px; }

.pip-add {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--line-soft);
}
.pip-add-input {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 0;
  color: var(--ink);
  font-family: var(--mono);
  font-size: .6875rem;
  padding: 5px 8px;
}
.pip-add-input::placeholder { color: var(--ink-4); }
.pip-add-input:focus { outline: 0; border-color: var(--ink-3); }
.pip-add-btn {
  font-family: var(--mono);
  font-size: .6875rem;
  color: var(--ink-3);
  transition: color .15s;
}
.pip-add-btn:hover { color: var(--acc); }

/* --- reopens the player once it was closed --- */
.pip-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1004;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  box-shadow: 3px 3px 0 var(--shadow);
  font-family: var(--mono);
  font-size: .75rem;
  color: var(--ink-2);
  transition: color .15s, border-color .15s;
}
.pip-launcher.is-visible { display: inline-flex; }
.pip-launcher:hover { color: var(--ink); border-color: var(--ink-4); }
.pip-launcher.is-playing svg { color: var(--acc); }

/* the YouTube iframe: it has to exist to play, nobody has to see it */
.pip-audio-holder {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 200px;
  height: 200px;
  overflow: hidden;
  pointer-events: none;
}

@media (max-width: 640px) {
  .pip-player, .pip-launcher { right: 12px; bottom: 12px; }
  .pip-player { width: calc(100vw - 24px); max-width: 330px; }
}
