/**
 * Floating YouTube queue player.
 *
 * Desktop: a 360px card fixed to the bottom-right corner, 18px from the
 * edges. Mobile (max-width 560px): full width at the bottom, only the top
 * corners rounded.
 *
 * Colors, fonts, radii, and transitions come from the theme variables in
 * style.css. On the site's z-index scale the panel sits at 90: above the
 * now-playing bar (60) and the report button (80), below the mobile menu
 * (999) and the report modal (10000).
 */

.fsbl-dock {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 90;
  width: min(360px, calc(100vw - 36px));
  background: var(--primary-medium);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  font-family: var(--font-primary);
}

/* ---- Header bar (~46px). Tapping it outside a button toggles the video. ---- */
.fsbl-dock-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px 7px 10px;
  min-height: 46px;
  cursor: pointer;
}

.fsbl-dock-title {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Round play / pause button. Only shows while a queue is active: in closed
   mode the video is hidden, so this is the one playback control. */
.fsbl-dock-play {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: filter var(--transition-fast);
}
.fsbl-dock-play:hover { filter: brightness(1.1); }
.fsbl-dock-play[hidden] { display: none; }

/* Previous / counter / next, grouped in one pill on the brand gradient.
   Hidden while a single song plays. */
.fsbl-dock-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: var(--radius-full);
  background: var(--brand-gradient-90);
}
.fsbl-dock-pill[hidden] { display: none; }

.fsbl-dock-nav {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background var(--transition-fast);
}
.fsbl-dock-nav:hover { background: rgba(255, 255, 255, 0.22); }

.fsbl-dock-count {
  min-width: 34px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Expand / collapse and close */
.fsbl-dock-ico {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: var(--radius-lg);
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background var(--transition-fast);
}
.fsbl-dock-ico:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }

/* ---- Video area ---- */
/* Closed mode: height 0 with overflow hidden. The iframe keeps its 16:9
   render size (width comes from the panel, height from aspect-ratio) and
   stays mounted, so audio continues. display:none is avoided on purpose. */
.fsbl-dock-video {
  position: relative;
  height: 0;
  overflow: hidden;
  background: #000;
}
.fsbl-dock.is-expanded .fsbl-dock-video {
  height: auto;
  aspect-ratio: 16 / 9;
}
.fsbl-dock-video iframe,
.fsbl-dock-video #fsblDockFrame {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  border: 0;
}

/* ---- Accessibility ---- */
.fsbl-dock button:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

/* Visually hidden live region announcing track changes */
.fsbl-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .fsbl-dock, .fsbl-dock * { transition: none !important; }
}

/* ---- Mobile ---- */
@media (max-width: 560px) {
  .fsbl-dock {
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    border-radius: 14px 14px 0 0;
  }
  /* The bar must not cover the page's last content or the report button. */
  body.fsbl-dock-active { padding-bottom: 64px; }
  body.fsbl-dock-active .report-fab {
    bottom: calc(72px + env(safe-area-inset-bottom)) !important;
  }
  /* Play all shrinks to its icon on phones */
  .tr-playall .tr-pa-label { display: none; }
  .tr-playall { padding: 10px 12px; }
}

/* ---- Trending row: YouTube button that opens the docked player ---- */
.tr-yt {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s, background 0.15s;
}
.tr-yt:hover { background: rgba(255, 0, 0, 0.12); transform: scale(1.06); }
.tr-yt svg { width: 24px; height: 24px; }
