/* wecap Live-Player
 *
 * Layout: Das Video nimmt immer die volle Breite in 16:9 ein (nie schwarze
 * Ränder an den Seiten), darunter folgen die Bedienelemente. Die passende
 * iframe-Höhe misst der Konfigurator; ist das iframe niedriger, lässt sich
 * darin scrollen, ist es höher, bleibt unten Seitenhintergrund frei.
 */

:root {
  --accent: #ffffff;
  --bg: #000000;
  --page-bg: transparent;
  --text: #ffffff;
  --button-bg: #f1f2f3;
  --button-text: #000000;
  --button-active-bg: #000000;
  --button-active-text: #ffffff;
  --button-radius: 0px;
  --label-text: #1c1f24;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: var(--page-bg);
  font-family: var(--font);
}

.player {
  display: flex;
  flex-direction: column;
  width: 100%;
}

/* Bühne für Player und Tafel: immer volle Breite in 16:9 */
.stage {
  position: relative;
  flex: 0 0 auto;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--bg);
  overflow: hidden;
}

.controller-host,
.slate {
  position: absolute;
  inset: 0;
}

.controller {
  width: 100%;
  height: 100%;
  --media-primary-color: var(--accent);
  --media-range-thumb-background: var(--accent);
  --media-range-bar-color: var(--accent);
  --media-font-family: var(--font);
}

.controller hls-video,
.controller video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--bg);
}

.spacer {
  flex-grow: 1;
  background: var(--media-control-background, rgba(20, 20, 30, 0.7));
}

/* Safari (iPhone/iPad) blendet die Leiste beim Ausblenden sonst nur teilweise
   aus oder nicht wieder ein: Leiste als eine Ebene ein- und ausblenden. */
media-control-bar {
  transform: translateZ(0);
  will-change: opacity;
}

/* Lautstärke lässt sich auf iPhone/iPad nur mit den Tasten des Geräts ändern */
media-volume-range[mediavolumeunavailable] {
  display: none;
}

/* Schmale Player (Handy hochkant): Leiste auf das Nötigste kürzen, damit
   Wiedergabe-Knopf und Vollbild nicht aus der Leiste fallen. AirPlay und
   Bild-in-Bild bleiben im Vollbild über die Systemsteuerung erreichbar. */
.stage {
  container-type: inline-size;
}

@container (max-width: 480px) {
  media-volume-range,
  media-airplay-button,
  media-rendition-menu-button {
    display: none;
  }

  media-control-bar > * {
    --media-control-padding: 6px;
  }
}

@container (max-width: 360px) {
  media-pip-button,
  media-time-display {
    display: none;
  }
}

/* Sprachcode statt Symbol in der Ton-Schaltfläche (ui.audioIcon = "code") */
.lang-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 20px;
  padding: 0 4px;
  border: 2px solid currentColor;
  border-radius: 4px;
  font: 700 12px/1 var(--font);
  letter-spacing: 0.04em;
}

/* Zeitleiste nur bei MP4/VOD, Live läuft ohne DVR */
.stage[data-stream="live"] .vod-only,
.stage[data-stream="vod"] .live-only {
  display: none;
}

/* Schaltflächen ohne passende Spuren oder Funktion ausblenden */
media-captions-menu-button:not([mediasubtitleslist]),
media-audio-track-menu-button[mediaaudiotrackunavailable],
media-rendition-menu-button[mediarenditionunavailable],
media-airplay-button[mediaairplayunavailable],
media-pip-button[mediapipunavailable],
media-fullscreen-button[mediafullscreenunavailable] {
  display: none;
}

/* Umschalten zwischen Tafel und Player */
.stage[data-mode="slate"] .controller-host {
  visibility: hidden;
}

.stage[data-mode="player"] .slate {
  display: none;
}

.slate {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.slate img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.slate-text {
  margin: 0;
  padding: 1rem;
  color: var(--text);
  font-size: clamp(1rem, 3vw, 1.75rem);
  text-align: center;
}

.slate-text small {
  font-size: 0.6em;
  opacity: 0.7;
}

.slate img:not([hidden]) + .slate-text:empty {
  display: none;
}

/* Hinweis bei stummem Autoplay: gut sichtbar auf jedem Bildinhalt */
.unmute {
  position: absolute;
  top: clamp(10px, 3%, 20px);
  left: clamp(10px, 2%, 20px);
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px 10px 14px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: #111;
  font: inherit;
  font-size: clamp(14px, 1.6vw, 17px);
  font-weight: 600;
  line-height: 1.2;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  animation: unmute-in 0.35s ease-out;
}

.unmute svg {
  flex: 0 0 auto;
  width: 1.4em;
  height: 1.4em;
}

.unmute[hidden] {
  display: none;
}

.unmute:hover {
  background: #fff;
}

.unmute:focus-visible {
  outline: 3px solid #1a73e8;
  outline-offset: 2px;
}

@keyframes unmute-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .unmute {
    animation: none;
  }
}

/* Bedienelemente unter dem Player
 * Gemeinsames Raster: links die Beschriftungen, rechts die Knöpfe. Umgebrochen
 * wird nur innerhalb der Knopfspalte, alle Reihen beginnen an derselben Linie. */
.controls {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  column-gap: 14px;
  row-gap: 10px;
  padding-top: 8px;
}

.controls[hidden] {
  display: none;
}

.ctl-group {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: subgrid;
  align-items: start;
}

/* Ältere Browser ohne subgrid: feste Beschriftungsspalte */
@supports not (grid-template-columns: subgrid) {
  .ctl-group {
    grid-template-columns: 8em minmax(0, 1fr);
    column-gap: 14px;
  }
}

.ctl-label {
  grid-column: 1;
  display: flex;
  align-items: center;
  min-height: 40px;
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--label-text);
}

.ctl-buttons,
.ctl-select {
  grid-column: 2;
}

/* Raumwahl ohne Beschriftung über die volle Breite */
.ctl-rooms .ctl-label {
  display: none;
}

.ctl-rooms .ctl-buttons,
.ctl-rooms .ctl-select {
  grid-column: 1 / -1;
}

.ctl-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ctl-button,
.ctl-select {
  min-height: 40px;
  padding: 6px 14px;
  border: 0;
  border-radius: var(--button-radius);
  background: var(--button-bg);
  color: var(--button-text);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}

.ctl-rooms .ctl-button {
  flex: 1 1 160px;
  min-height: 44px;
  font-size: 16px;
}

.ctl-button:hover {
  filter: brightness(0.92);
}

.ctl-button[aria-pressed="true"] {
  background: var(--button-active-bg);
  color: var(--button-active-text);
}

.ctl-select {
  justify-self: start;
  width: min(100%, var(--dropdown-width, 420px));
  padding-right: 32px;
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

.ctl-rooms .ctl-select {
  width: min(100%, var(--rooms-dropdown-width, 100%));
}

.ctl-button:focus-visible,
.ctl-select:focus-visible {
  outline: 2px solid #1a73e8;
  outline-offset: 2px;
}

/* Schmale Player: alle Beschriftungen einheitlich über den Knöpfen */
@media (max-width: 600px) {
  .controls,
  .ctl-group {
    grid-template-columns: minmax(0, 1fr);
  }

  .ctl-label,
  .ctl-buttons,
  .ctl-select {
    grid-column: 1;
  }

  .ctl-label {
    min-height: 0;
    margin-top: 2px;
  }

  .ctl-rooms .ctl-button {
    flex: 1 1 calc(50% - 4px);
  }
}
