/* Phase 12 — Background tab (items 45+46).
 * Queue list + sticky bottom player. Mounted on /student/background.
 *
 * Cap: under 500 lines. Pure CSS, no preprocessor.
 *
 * Conventions:
 *  - v2 tokens (--v2-*) from 00-v2-tokens.css supply colors/spacing/types.
 *  - Layout: scrolling list above the fold; sticky bar pinned to bottom
 *    inside the .v2-scroll viewport.
 *  - Two item variants: --auto (from Focused) and --manual.
 */

/* ------------------------------------------------------------ */
/* The scroll container leaves room for the sticky player bar.  */
/* ------------------------------------------------------------ */
.v2-bg-scroll {
  padding-top: var(--v2-s-3);
  /* Reserve space for the sticky player + safe area. */
  padding-bottom: calc(108px + env(safe-area-inset-bottom, 0px));
}

.v2-bg-section {
  margin-top: var(--v2-s-4);
}

/* ------------------------------------------------------------ */
/* Queue groups + items.                                         */
/* ------------------------------------------------------------ */
.v2-bg-group {
  display: flex;
  flex-direction: column;
  gap: var(--v2-s-2);
  margin-bottom: var(--v2-s-2);
}

.v2-bg-item {
  display: flex;
  align-items: center;
  gap: var(--v2-s-3);
  padding: var(--v2-s-3) var(--v2-s-4);
  background: var(--v2-surface);
  border: 1px solid var(--v2-hairline);
  border-radius: var(--v2-r-md);
  transition: border-color 120ms ease, background 120ms ease;
}

.v2-bg-item:hover,
.v2-bg-item:focus-within {
  border-color: var(--v2-hairline-strong, #d0d0d0);
}

.v2-bg-item--auto {
  background: linear-gradient(0deg, var(--v2-surface) 0%, var(--v2-surface) 100%);
  border-left: 3px solid var(--v2-accent, #ff4700);
  padding-left: calc(var(--v2-s-4) - 3px);
}

.v2-bg-item--manual {
  /* nothing extra — default look */
}

.v2-bg-item--active {
  background: var(--v2-surface-active, #f6f3ee);
  border-color: var(--v2-accent, #ff4700);
}

/* Per-item ▶ button on the left edge. */
.v2-bg-item-play {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: 1px solid var(--v2-hairline-strong, #d0d0d0);
  border-radius: 999px;
  background: transparent;
  color: var(--v2-ink, #1a1a1a);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.v2-bg-item-play:hover { background: var(--v2-surface-active, #f6f3ee); }
.v2-bg-item-play:focus-visible {
  outline: 2px solid var(--v2-accent, #ff4700);
  outline-offset: 2px;
}

.v2-bg-item-meta {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.v2-bg-item-title {
  font-size: var(--v2-t-md, 15px);
  font-weight: 500;
  color: var(--v2-ink, #1a1a1a);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.v2-bg-item-sub {
  font-size: var(--v2-t-xs, 12px);
  color: var(--v2-ink-3, #8a8a8a);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.v2-bg-item-badge {
  flex: 0 0 auto;
  font-family: var(--v2-mono, "JetBrains Mono", monospace);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--v2-accent, #ff4700);
  color: #fff;
  padding: 3px 7px;
  border-radius: 4px;
  align-self: center;
}

.v2-bg-item-x {
  flex: 0 0 auto;
  background: transparent;
  border: none;
  color: var(--v2-ink-3, #8a8a8a);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 4px;
}

.v2-bg-item-x:hover {
  background: var(--v2-surface-active, #f6f3ee);
  color: var(--v2-ink, #1a1a1a);
}

.v2-bg-item-x:focus-visible {
  outline: 2px solid var(--v2-accent, #ff4700);
  outline-offset: 2px;
}

.v2-bg-add-cta {
  margin-top: var(--v2-s-5);
  border: 1px dashed var(--v2-hairline-strong, #d0d0d0);
}

/* ------------------------------------------------------------ */
/* Sticky bottom player.                                          */
/* ------------------------------------------------------------ */
.v2-bg-player {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0;
  background: var(--v2-surface, #fff);
  border-top: 1px solid var(--v2-hairline, #e6e6e6);
  box-shadow: 0 -8px 20px rgba(0, 0, 0, 0.04);
  z-index: 90;
  /* Honor safe-area on iPhones. */
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.v2-bg-player[hidden] { display: none; }

.v2-bg-player-progress {
  height: 3px;
  background: var(--v2-hairline, #e6e6e6);
  position: relative;
}

.v2-bg-player-bar {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 0%;
  background: var(--v2-accent, #ff4700);
  transition: width 250ms linear;
}

.v2-bg-player-row {
  display: flex;
  align-items: center;
  gap: var(--v2-s-3);
  padding: var(--v2-s-3) var(--v2-s-4);
}

.v2-bg-player-titles {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.v2-bg-player-title {
  font-size: var(--v2-t-md, 15px);
  font-weight: 600;
  color: var(--v2-ink, #1a1a1a);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.v2-bg-player-sub {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.v2-bg-player-controls {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: var(--v2-s-2);
}

.v2-bg-pbtn {
  width: 40px;
  height: 40px;
  background: transparent;
  border: 1px solid var(--v2-hairline-strong, #d0d0d0);
  border-radius: 999px;
  color: var(--v2-ink, #1a1a1a);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.v2-bg-pbtn:hover { background: var(--v2-surface-active, #f6f3ee); }
.v2-bg-pbtn:focus-visible {
  outline: 2px solid var(--v2-accent, #ff4700);
  outline-offset: 2px;
}

.v2-bg-pbtn--big {
  width: 56px;
  height: 56px;
  font-size: 22px;
  background: var(--v2-accent, #ff4700);
  border-color: var(--v2-accent, #ff4700);
  color: #fff;
}

.v2-bg-pbtn--big:hover {
  background: var(--v2-accent-hover, #ff5e1a);
}

/* Compact mode on small screens — drop borders, shrink controls. */
@media (max-width: 480px) {
  .v2-bg-player-row {
    padding: var(--v2-s-2) var(--v2-s-3);
  }
  .v2-bg-pbtn {
    width: 36px;
    height: 36px;
  }
  .v2-bg-pbtn--big {
    width: 48px;
    height: 48px;
    font-size: 18px;
  }
  .v2-bg-item {
    padding: var(--v2-s-2) var(--v2-s-3);
    gap: var(--v2-s-2);
  }
  .v2-bg-item-play {
    width: 36px;
    height: 36px;
  }
}

/* Library "+ Додати" button on item cards (Phase 12 cross-cut). */
.v2-bg-add-btn {
  background: transparent;
  border: 1px solid var(--v2-hairline-strong, #d0d0d0);
  color: var(--v2-ink, #1a1a1a);
  font-size: var(--v2-t-xs, 12px);
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.2;
  white-space: nowrap;
}

.v2-bg-add-btn:hover {
  background: var(--v2-surface-active, #f6f3ee);
}

.v2-bg-add-btn--added {
  background: var(--v2-accent, #ff4700);
  color: #fff;
  border-color: var(--v2-accent, #ff4700);
}

/* Toast (used by the library "+ Background" cross-cut). */
.v2-bg-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(26, 26, 26, 0.92);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--v2-r-md, 8px);
  font-size: var(--v2-t-sm, 14px);
  z-index: 200;
  pointer-events: none;
  opacity: 0;
  transition: opacity 180ms ease, transform 180ms ease;
}

.v2-bg-toast--on {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}
