/**
 * Floating-Webradio-Player - Optik angelehnt an den ffh.de-Webplayer
 * (schwebende, abgerundete "Glas"-Leiste mit Blur statt kantig am Rand).
 * Nur auf #webPlayer* skopierte Regeln, damit nichts mit den bestehenden
 * Bootstrap-Package-Styles kollidiert.
 */

body:has(#webPlayer) {
  padding-bottom: 121px; /* Platz für den fixierten, freischwebenden Player */
}

#webPlayer {
  position: fixed;
  left: 7.5px;
  right: 7.5px;
  bottom: 7.5px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-sizing: border-box;
  height: 96px; /* 80px Logo/Cover-Box + Luft oben/unten */
  padding: 0 15px;
  border-radius: 8px;
  background: rgba(20, 20, 20, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  transition: transform 0.3s ease-out;
}

/* Ladeanimation: schimmernder Verlauf über die Leiste, solange der Stream puffert */
#webPlayer:has(#webPlayerPlay.loading) {
  background: linear-gradient(
    to right,
    rgba(20, 20, 20, 0.6) 20%,
    rgba(150, 150, 150, 0.6) 45%,
    rgba(150, 150, 150, 0.6) 55%,
    rgba(20, 20, 20, 0.6) 80%
  );
  background-size: 200% 100%;
  animation: webPlayerLoading 2.5s linear infinite;
}

@keyframes webPlayerLoading {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

#webPlayerLogo {
  /* Feste 80x80px-Box fuer Logo UND Cover (statt variabler Breite): verhindert,
     dass der danebenliegende Text (#webPlayerMeta) beim Wechsel zwischen
     Sender-Logo (oft Wortmarke/anderes Seitenverhaeltnis) und quadratischem
     Song-Cover seitlich "springt". */
  width: 80px;
  height: 80px;
  padding: 8px;
  background: #fff;
  border-radius: 8px;
  box-sizing: border-box;
  flex-shrink: 0;
  object-fit: contain; /* zeigt Logo/Cover vollstaendig statt es zuzuschneiden */
  transition: opacity 0.2s ease;
}

/* Song-Cover: randlos, volle 80x80px nutzen (keine Logo-typische weisse
   Matte/Padding - das Cover ist bereits quadratisch) */
#webPlayerLogo.isCover {
  padding: 0;
  background: none;
  object-fit: cover;
}

/* Kurzes Aus-/Einblenden beim Wechsel zwischen Sender-Logo und Song-Cover
   (Player-Anzeige und aktiver Listeneintrag der Senderliste) */
#webPlayerLogo.isFading {
  opacity: 0;
}

#webPlayerMeta {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

#webPlayerMeta p {
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#webPlayerStation {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
}

#webPlayerTitle {
  font-size: 0.8rem;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.7);
  padding-top: 2px;
}

#webPlayerControls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

#webPlayerPlay,
#webPlayerVolumeBtn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.05rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.1s ease;
}

#webPlayerPlay:hover,
#webPlayerVolumeBtn:hover {
  background: rgba(255, 255, 255, 0.22);
}

#webPlayerPlay:active,
#webPlayerVolumeBtn:active {
  transform: scale(0.9);
}

#webPlayerPlay.loading {
  opacity: 0.7;
  cursor: wait;
}

#webPlayerPlay svg,
#webPlayerVolumeBtn svg {
  width: 18px;
  height: 18px;
}

/* Play/Pause- bzw. Lautsprecher/Stumm-Icon je nach Zustand umschalten */
#webPlayerPlay .icon-pause,
#webPlayerVolumeBtn .icon-mute {
  display: none;
}

#webPlayerPlay.isPlaying .icon-play {
  display: none;
}

#webPlayerPlay.isPlaying .icon-pause {
  display: block;
}

#webPlayerVolumeBtn.isMuted .icon-volume {
  display: none;
}

#webPlayerVolumeBtn.isMuted .icon-mute {
  display: block;
}

#webPlayerVolumeWrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#webPlayerVolume {
  width: 80px;
  accent-color: #fff;
}

@media (max-width: 480px) {
  #webPlayerVolumeWrap {
    display: none;
  }
}

/* Chevron-Button zum Auf-/Zuklappen der Senderliste */
#webPlayerExpandBtn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease, transform 0.15s ease;
}

#webPlayerExpandBtn:hover {
  background: rgba(255, 255, 255, 0.22);
}

#webPlayerExpandBtn svg {
  width: 20px;
  height: 20px;
}

/* Burger-Icon im geschlossenen, X-Icon im geoeffneten Zustand */
#webPlayerExpandBtn .icon-close,
#webPlayerExpandBtn.isExpanded .icon-burger {
  display: none;
}

#webPlayerExpandBtn.isExpanded .icon-close {
  display: block;
}

/* Aufklappbare Senderliste: als Panel oberhalb der Player-Leiste */
#webPlayerChannelList {
  position: fixed;
  left: 7.5px;
  right: 7.5px;
  bottom: calc(96px + 7.5px + 8px);
  z-index: 1000;
  margin: 0;
  padding: 8px;
  list-style: none;
  max-height: 50vh;
  overflow-y: auto;
  border-radius: 8px;
  background: rgba(20, 20, 20, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

#webPlayerChannelList[hidden] {
  display: none;
}

#webPlayerChannelList li + li {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

#webPlayerChannelList button {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: none;
  color: #fff;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  border-radius: 6px;
  font-family: inherit;
}

#webPlayerChannelList button img {
  /* Gleiche feste 80x80px-Box wie #webPlayerLogo, damit alle Logos (auch
     nicht-quadratische) gleich viel Platz belegen und der Text daneben ruhig bleibt. */
  width: 80px;
  height: 80px;
  flex-shrink: 0;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  padding: 6px;
  box-sizing: border-box;
  transition: opacity 0.2s ease;
}

#webPlayerChannelList button:hover {
  background: rgba(255, 255, 255, 0.1);
}

#webPlayerChannelList button.isActive {
  font-weight: 700;
  color: #d20a11; /* Radio-Rot der Seite ($amsRot in _variables.scss) */
}

#webPlayerChannelList .channelInfo {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
}

#webPlayerChannelList .channelTitle,
#webPlayerChannelList .channelSongInfo {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#webPlayerChannelList .channelSongInfo {
  font-size: 0.78rem;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.65);
}

#webPlayerChannelList .channelSongInfo:empty {
  display: none;
}

@media (min-width: 1080px) {
  #webPlayerChannelList {
    left: 50%;
    right: auto;
    bottom: calc(96px + 15px + 8px);
    width: 700px;
    max-width: calc(100% - 30px);
    transform: translateX(-50%);
  }
}

/* Ab Desktop-Breite: zentrierte, schmalere "Pill" statt voller Breite - wie bei ffh.de */
@media (min-width: 1080px) {
  #webPlayer {
    left: 50%;
    right: auto;
    bottom: 15px;
    width: 700px;
    max-width: calc(100% - 30px);
    transform: translateX(-50%);
  }
}

/* Der site-eigene "Nach oben"-Button (.scroll-top) sitzt fix unten rechts und
   liegt unterhalb von 1080px genau dort, wo auch unser Player die (fast) volle
   Breite einnimmt - er würde den Player sonst unbenutzbar überdecken. Wir
   schieben ihn nach oben, sodass beide Elemente erreichbar bleiben. */
body:has(#webPlayer) .scroll-top {
  bottom: calc(96px + 7.5px + 15px);
}

@media (min-width: 1080px) {
  body:has(#webPlayer) .scroll-top {
    bottom: 20px; /* ab hier ist der Player zentriert/schmaler und überlappt nicht mehr */
  }
}
