/**
 * @file
 * MediaHub persistent bottom player styles (dark bar, RTL-friendly).
 *
 * The bar itself is intentionally dark (it must stand out on light pages);
 * every color inside it is either a player-scoped custom property or a
 * literal dark-theme value, so host themes cannot bleach it.
 */

.mh-player {
  /* Player-scoped dark theme: every rule below reads these, so the whole
     bar (menus, queue panel, controls) follows the dark surface without
     depending on the site theme's variables. */
  --mh-text: #eef2f9;
  --mh-muted: #9aa6bb;
  --mh-border: rgba(255, 255, 255, 0.14);
  --mh-surface: #182236;
  --mh-hover: rgba(255, 255, 255, 0.09);
  position: fixed !important;
  left: 0;
  right: 0;
  bottom: 0;
  inset-inline: 0;
  inset-block-end: 0;
  width: auto;
  margin: 0;
  z-index: 1000;
  background: rgba(13, 18, 30, 0.98);
  backdrop-filter: blur(12px);
  border-block-start: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: 0 -10px 34px rgba(0, 0, 0, 0.45);
  transform: translateY(110%);
  visibility: hidden;
  transition: transform 0.32s ease, visibility 0.32s ease;
  color: var(--mh-text);
}

.mh-player.mh-is-active {
  transform: none;
  visibility: visible;
}

body.mh-has-player {
  padding-block-end: 78px;
}

/* Mini video stage inside the bar makes it taller; give the page more
   room (but not while the cinema overlay keeps the stage out of flow). */
body.mh-has-player.mh-video-open:not(.mh-cinema-open) {
  padding-block-end: 258px;
}

body.mh-has-player.mh-cinema-open {
  padding-block-end: 78px;
}

body.mh-cinema-open {
  overflow: hidden;
}

.mh-player__bar {
  position: relative;
  /* Above the cinema backdrop so the transport controls stay reachable
     while the big player is open. */
  z-index: 1090;
  max-width: 1200px;
  margin-inline: auto;
  padding-block: 6px 7px;
  padding-inline: 16px;
}

/* ---------------------------------------------------------------- *
 * Cinema backdrop (big same-page video player)
 * ---------------------------------------------------------------- */

.mh-player__backdrop {
  position: fixed;
  inset: 0;
  z-index: 1085;
  background: rgba(5, 8, 14, 0.74);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.mh-player.mh-cinema .mh-player__backdrop {
  opacity: 1;
  pointer-events: auto;
}

/* ---------------------------------------------------------------- *
 * Video stage (mini view + cinema mode)
 * ---------------------------------------------------------------- */

.mh-player__stage {
  position: relative;
  display: flex;
  justify-content: center;
  margin-block: 0 5px;
}

.mh-player__stage video {
  width: auto;
  max-width: 100%;
  max-height: 170px;
  border-radius: 10px;
  background: #000;
  display: block;
  cursor: pointer;
}

/* Cinema: the stage itself becomes the big in-page player. Clicking a
   video opens it; the header's "send to bottom bar" button closes it
   and playback continues in the mini stage without restarting. */
.mh-cinema__head {
  display: none;
}

.mh-player.mh-cinema {
  /* backdrop-filter would become the containing block for the fixed
     stage and pin the overlay to the bar instead of the viewport. */
  backdrop-filter: none;
}

.mh-player.mh-cinema .mh-player__stage {
  position: fixed;
  z-index: 1100;
  inset-block-start: 5vh;
  inset-inline: 0;
  margin-inline: auto;
  width: min(920px, 94vw);
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  background: #0d1320;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 16px;
  padding: 10px 12px 12px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}

.mh-player.mh-cinema .mh-cinema__head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 4px 10px;
  color: #e7ecf5;
}

.mh-cinema__title {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mh-cinema__btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #e7ecf5;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: none;
  padding: 0;
}

.mh-cinema__btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.mh-cinema__btn:focus-visible {
  outline: 2px solid var(--mh-accent, #16a34a);
  outline-offset: 2px;
}

.mh-cinema__btn svg {
  width: 16px;
  height: 16px;
}

.mh-player.mh-cinema .mh-player__stage video {
  width: 100%;
  height: auto;
  max-height: 74vh;
  border-radius: 10px;
}

/* Native fullscreen (Fullscreen API on the player root): the whole player
   fills the screen — the big stage becomes an overlay and the transport
   bar docks to the bottom edge, so every control stays reachable.
   :-webkit-full-screen covers older Safari builds. */
.mh-player.mh-cinema:fullscreen,
.mh-player.mh-cinema:-webkit-full-screen {
  background: #05080e;
  transform: none !important;
  visibility: visible !important;
}

.mh-player.mh-cinema:fullscreen .mh-player__bar,
.mh-player.mh-cinema:-webkit-full-screen .mh-player__bar {
  position: absolute;
  inset-inline: 0;
  inset-block-end: 0;
  max-width: none;
}

.mh-player.mh-cinema:fullscreen .mh-player__stage,
.mh-player.mh-cinema:-webkit-full-screen .mh-player__stage {
  inset-block-start: 3vh;
  width: min(1500px, 96vw);
}

.mh-player.mh-cinema:fullscreen .mh-player__stage video,
.mh-player.mh-cinema:-webkit-full-screen .mh-player__stage video {
  max-height: calc(100vh - 200px);
}

/* CSS fallback (.mh-cinema--max, see js/mediahub.player.js): used when the
   Fullscreen API is unavailable (iframe without allowfullscreen, denied
   permission, iOS iPhone) so the button still visibly enlarges the video. */
.mh-player.mh-cinema.mh-cinema--max .mh-player__stage {
  inset-block-start: 2vh;
  width: 96vw;
  max-width: none;
}

.mh-player.mh-cinema.mh-cinema--max .mh-player__stage video {
  max-height: calc(100vh - 200px);
}

/* ---------------------------------------------------------------- *
 * Progress row
 * ---------------------------------------------------------------- */

.mh-player__progressrow {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mh-time {
  font-size: 11px;
  color: var(--mh-muted, #6b7280);
  font-variant-numeric: tabular-nums;
  min-width: 38px;
  text-align: center;
}

.mh-seek {
  flex: 1;
  height: 16px;
  accent-color: var(--mh-accent, #16a34a);
  cursor: pointer;
}

/* ---------------------------------------------------------------- *
 * Main row
 * ---------------------------------------------------------------- */

.mh-player__row {
  display: grid;
  /* col3 min=auto: grows with the cluster's real width (max-content) so the
     utility buttons never spill into the transport column; col1 then takes
     the rest. When the viewport cannot fit max-content, the flex cluster
     wraps instead of colliding. */
  grid-template-columns: minmax(150px, 1fr) auto minmax(auto, max-content);
  align-items: center;
  gap: 6px;
  margin-block-start: 2px;
}

.mh-player__left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.mh-player__art {
  width: 44px;
  height: 44px;
  flex: none;
  border: none;
  border-radius: 8px;
  overflow: hidden;
  background: #1c2740;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: #66759a;
}

.mh-player__artimg {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mh-player__ph {
  display: flex;
}

.mh-player__ph svg {
  width: 18px;
  height: 18px;
}

.mh-player__meta {
  min-width: 0;
}

.mh-player__title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mh-player__sub {
  font-size: 11px;
  color: var(--mh-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mh-player__center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.mh-player__right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 2px;
}

/* ---------------------------------------------------------------- *
 * Theme-interference guards
 * ---------------------------------------------------------------- */
/* The persistent bar is rendered inside pages styled by the site
   theme. Generic theme rules break it in two ways: (1) any author
   `display` declaration on an element beats the UA `[hidden]` rule,
   so hidden video buttons, the pause/play icon pair, the stage and
   the popover menus all leak into view; (2) button margin/padding
   rules inflate the control clusters until they collide with the
   transport buttons. The guards below keep the bar deterministic in
   both LTR and RTL. */

/* hidden must always win inside the player. */
#mediahub-player [hidden] {
  display: none !important;
}

/* theme button/input margins must not inflate the control rows. */
#mediahub-player button,
#mediahub-player a.mh-ctl,
#mediahub-player input {
  margin: 0 !important;
  box-sizing: border-box;
}

/* ---------------------------------------------------------------- *
 * Controls
 * ---------------------------------------------------------------- */

.mh-ctl {
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--mh-text);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  flex: none;
  padding: 0;
  box-sizing: border-box;
}

.mh-ctl svg {
  width: 17px;
  height: 17px;
}

.mh-ctl:hover {
  background: var(--mh-hover, #f1f3f7);
}

.mh-ctl:focus-visible {
  outline: 2px solid var(--mh-accent, #16a34a);
  outline-offset: 2px;
}

.mh-ctl[aria-pressed="true"] {
  color: var(--mh-accent, #22c55e);
  background: rgba(34, 197, 94, 0.16);
}

.mh-ctl--main {
  width: 42px;
  height: 42px;
  background: var(--mh-accent, #16a34a);
  color: var(--mh-accent-contrast, #fff);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.mh-ctl--main:hover {
  filter: brightness(1.06);
}

.mh-ctl--main .mh-icon {
  display: flex;
}

.mh-ctl--text {
  width: auto;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid var(--mh-border);
  color: var(--mh-muted);
  font-variant-numeric: tabular-nums;
}

.mh-repeat {
  position: relative;
}

.mh-repeat[data-badge="1"]::after {
  content: "1";
  position: absolute;
  inset-block-start: 3px;
  inset-inline-end: 3px;
  font-size: 9px;
  font-weight: 700;
  color: var(--mh-accent, #16a34a);
}

.mh-sleep-btn {
  position: relative;
}

.mh-sleep-badge {
  position: absolute;
  inset-block-start: 1px;
  inset-inline-end: 1px;
  background: var(--mh-accent, #16a34a);
  color: var(--mh-accent-contrast, #fff);
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

.mh-queue-btn {
  position: relative;
}

.mh-queue-count {
  position: absolute;
  inset-block-start: 1px;
  inset-inline-end: 1px;
  background: var(--mh-accent, #16a34a);
  color: var(--mh-accent-contrast, #fff);
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

.mh-vol {
  display: flex;
  align-items: center;
  gap: 2px;
}

.mh-vol input {
  width: 70px;
  accent-color: var(--mh-accent, #16a34a);
  direction: ltr;
  cursor: pointer;
}

.mh-icon {
  display: flex;
}

/* ---------------------------------------------------------------- *
 * Popover menus (speed / share)
 * ---------------------------------------------------------------- */

.mh-menuwrap {
  position: relative;
  display: flex;
}

.mh-menu {
  position: absolute;
  inset-block-end: calc(100% + 8px);
  inset-inline-end: 0;
  background: var(--mh-surface, #fff);
  border: 1px solid var(--mh-border, #e5e7eb);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(17, 24, 39, 0.16);
  padding: 6px;
  min-width: 150px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 1101;
}

.mh-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: none;
  background: transparent;
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  color: inherit;
  cursor: pointer;
  text-align: start;
}

.mh-menu button:hover {
  background: var(--mh-hover, #f1f3f7);
}

.mh-menu button.is-active {
  color: var(--mh-accent, #16a34a);
  font-weight: 700;
}

.mh-menu button svg {
  width: 16px;
  height: 16px;
  flex: none;
}

/* ---------------------------------------------------------------- *
 * Queue panel
 * ---------------------------------------------------------------- */

.mh-queue {
  border-block-start: 1px solid var(--mh-border, #e5e7eb);
  max-height: 300px;
  overflow: auto;
  margin-block-start: 8px;
  padding: 8px 4px 4px;
}

.mh-queue__tabs {
  display: flex;
  gap: 6px;
  padding: 0 10px 8px;
}

.mh-queue__tab {
  border: 1px solid var(--mh-border, #e5e7eb);
  background: transparent;
  border-radius: 999px;
  padding: 5px 12px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--mh-muted, #6b7280);
  cursor: pointer;
}

.mh-queue__tab:hover {
  color: var(--mh-text, #111827);
}

.mh-queue__tab.is-active {
  background: var(--mh-accent, #16a34a);
  border-color: var(--mh-accent, #16a34a);
  color: var(--mh-accent-contrast, #fff);
}

.mh-queue__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 10px 8px;
  font-size: 12px;
  color: var(--mh-muted, #6b7280);
}

.mh-queue__clear,
.mh-queue__recentclear {
  border: none;
  background: transparent;
  color: #f2b25c;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  margin-inline-start: auto;
}

.mh-queue__clear:hover,
.mh-queue__recentclear:hover {
  text-decoration: underline;
}

.mh-queue__alllink {
  color: var(--mh-accent, #16a34a);
  font-weight: 600;
  text-decoration: none;
}

.mh-queue__alllink:hover {
  text-decoration: underline;
}

.mh-queue__empty {
  margin: 0;
  padding: 10px;
  font-size: 12px;
  color: var(--mh-muted, #6b7280);
  text-align: center;
}

.mh-queue__list,
.mh-queue__recentlist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mh-queue__list.is-loading,
.mh-queue__recentlist.is-loading {
  opacity: 0.5;
}

.mh-queue__item {
  display: flex;
  align-items: center;
  border-radius: 8px;
}

.mh-queue__item:hover {
  background: var(--mh-hover, #f1f3f7);
}

.mh-queue__row {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  background: transparent;
  padding: 8px 10px;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-align: start;
  min-width: 0;
}

.mh-queue__idx {
  flex: none;
  width: 26px;
  font-size: 11px;
  color: var(--mh-muted, #6b7280);
  text-align: center;
}

.mh-queue__meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.mh-queue__itemtitle {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mh-queue__itemsub {
  font-size: 11px;
  color: var(--mh-muted, #6b7280);
}

.mh-queue__dur {
  flex: none;
  font-size: 11px;
  color: var(--mh-muted, #6b7280);
  direction: ltr;
}

.mh-queue__moves {
  display: flex;
  flex: none;
}

.mh-queue__move {
  flex: none;
  border: none;
  background: transparent;
  color: var(--mh-muted, #6b7280);
  font-size: 13px;
  line-height: 1;
  width: 24px;
  height: 30px;
  cursor: pointer;
  opacity: 0;
}

.mh-queue__move:disabled {
  opacity: 0.25 !important;
  cursor: default;
}

.mh-queue__item:hover .mh-queue__move,
.mh-queue__move:focus {
  opacity: 1;
}

.mh-queue__remove {
  flex: none;
  border: none;
  background: transparent;
  color: var(--mh-muted, #6b7280);
  font-size: 16px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  opacity: 0;
}

.mh-queue__item:hover .mh-queue__remove {
  opacity: 1;
}

.mh-queue__item.is-current .mh-queue__itemtitle {
  color: var(--mh-accent, #16a34a);
}

/* ---------------------------------------------------------------- *
 * Collapsed state
 * ---------------------------------------------------------------- */

.mh-player--collapsed .mh-player__stage {
  display: none;
}

.mh-player--collapsed .mh-player__right {
  visibility: hidden;
}

.mh-player--collapsed .mh-player__center {
  position: absolute;
  inset-inline-end: 16px;
}

.mh-player--collapsed .mh-player__row {
  position: relative;
  grid-template-columns: 1fr auto;
}

.mh-player--collapsed .mh-queue {
  display: none;
}

.mh-collapse svg {
  transition: transform 0.2s ease;
}

.mh-player--collapsed .mh-collapse svg {
  transform: rotate(180deg);
}

/* ---------------------------------------------------------------- *
 * Toast
 * ---------------------------------------------------------------- */

.mh-toast {
  position: fixed;
  inset-block-end: 110px;
  /* Physical left + physical translateX: centers the toast over its
     containing block in BOTH directions. (inset-inline-start: 50% plus
     translateX(-50%) mirrored the toast one width off-center in RTL.) */
  left: 50%;
  transform: translateX(-50%);
  background: rgba(17, 24, 39, 0.92);
  color: #fff;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 999px;
  z-index: 1102;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.mh-toast.is-visible {
  opacity: 1;
}

/* ---------------------------------------------------------------- *
 * Responsive
 * ---------------------------------------------------------------- */

@media (max-width: 860px) {
  .mh-vol input,
  .mh-speed {
    display: none;
  }

  .mh-player__sub {
    display: none;
  }
}

@media (max-width: 640px) {
  .mh-player__row {
    grid-template-columns: 1fr auto;
    grid-template-areas: "left center" "right right";
  }

  .mh-player__left {
    grid-area: left;
  }

  .mh-player__center {
    grid-area: center;
  }

  .mh-player__right {
    grid-area: right;
    justify-content: center;
    margin-block-start: 4px;
  }

  .mh-shuffle,
  .mh-repeat {
    display: none;
  }

  .mh-ctl {
    width: 30px;
    height: 30px;
  }

  .mh-ctl--main {
    width: 38px;
    height: 38px;
  }

  body.mh-has-player {
    padding-block-end: 112px;
  }

  body.mh-has-player.mh-video-open:not(.mh-cinema-open) {
    padding-block-end: 296px;
  }

  body.mh-has-player.mh-cinema-open {
    padding-block-end: 112px;
  }

  .mh-player.mh-cinema .mh-player__stage {
    inset-block-start: 3vh;
    width: 96vw;
    padding: 8px 8px 10px;
  }

  .mh-player.mh-cinema .mh-player__stage video {
    max-height: 56vh;
  }

  .mh-player.mh-cinema:fullscreen .mh-player__stage video,
  .mh-player.mh-cinema:-webkit-full-screen .mh-player__stage video,
  .mh-player.mh-cinema.mh-cinema--max .mh-player__stage video {
    max-height: calc(100vh - 230px);
  }
}
