/* Only opted-in HTML5 players; no background-video or native-fallback styles. */
.km-player-shell {
  --plyr-color-main: #007e92;
  --plyr-font-family: inherit;
  --plyr-font-size-base: 13px;
  --plyr-video-background: #10191b;
  --plyr-video-control-background-hover: #007e92;
  --plyr-range-fill-background: #0099b7;
  --plyr-control-icon-size: 18px;
  --plyr-control-radius: 4px;
  --plyr-control-spacing: 6px;
  width: 100%;
  min-width: 0;
  background: #10191b;
  color: #fff;
  font-family: inherit;
}

.km-player-shell .plyr {
  font-family: inherit;
  border-radius: 0;
  container-name: km-player;
  container-type: inline-size;
}

/* An actively used menu must remain above the fixed admissions invitation. */
.km-player-shell:has([data-plyr="settings"][aria-expanded="true"]) {
  position: relative;
  z-index: 11;
}

.km-player-shell .plyr--video {
  display: flex;
  flex-direction: column;
}

.km-player-shell .plyr__video-wrapper {
  position: relative;
  order: 0;
  width: 100%;
  flex: 0 0 auto;
}

.km-player-shell .plyr__video-wrapper > .plyr__control--overlaid {
  top: 50%;
  left: 50%;
}

.km-player-shell .plyr video {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

.km-player-shell .plyr__poster {
  background-size: contain;
  background-color: #10191b;
}

/* Keep controls below the real image, not across an embedded school logo. */
.km-player-shell .plyr--video .plyr__controls {
  position: relative;
  inset: auto;
  order: 1;
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 2px;
  padding: 8px;
  background: linear-gradient(180deg, #18292bf5, #10191b);
  opacity: 1;
  transform: none;
}

.km-player-shell .plyr__progress__container {
  flex: 1 0 100%;
  order: -1;
  margin: 0;
}

.km-player-shell .plyr__control {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.km-player-shell .plyr__control[hidden] {
  display: none;
}

.km-player-shell .plyr input[type="range"] {
  min-height: 44px;
}

.km-player-shell .plyr__volume {
  flex: 0 0 44px;
  min-width: 44px;
  max-width: 44px;
}

/* Compact fallback also works without container-query support. Keep mute,
 * settings and fullscreen visible; only secondary controls need more width. */
.km-player-shell .plyr__volume input[type="range"],
.km-player-shell .plyr__time--duration,
.km-player-shell .plyr__control[data-plyr="pip"] {
  display: none;
}

@container km-player (min-width: 361px) {
  .km-player-shell .plyr__time--duration:not([hidden]) {
    display: inline-block;
  }
}

/* Two-column tablet layouts can make the actual player narrower than mobile. */
@container km-player (width < 260px) {
  .km-player-shell .plyr__time--current {
    display: none;
  }
}

@container km-player (min-width: 421px) {
  .km-player-shell .plyr__control[data-plyr="pip"]:not([hidden]) {
    display: inline-flex;
  }
}

@container km-player (min-width: 521px) {
  .km-player-shell .plyr__volume {
    flex: 0 1 96px;
    max-width: 96px;
  }

  .km-player-shell .plyr__volume input[type="range"]:not([hidden]) {
    display: block;
  }
}

.km-player-shell .plyr__time {
  font-size: 11px;
}

.km-player-shell .plyr__control:focus-visible,
.km-player-shell .plyr input:focus-visible {
  outline: 3px solid #f7c378;
  outline-offset: 2px;
}

.km-player-shell .plyr__menu__container {
  max-width: min(240px, 80vw);
}

/* Menu choices must be block-level: the vendor menu inherits nowrap.
 * Inline-flex would place all speed choices in one clipped horizontal row. */
.km-player-shell .plyr__menu__container .plyr__control {
  display: flex;
  justify-content: flex-start;
}

.km-player-shell .plyr__menu__container [role="menu"] {
  max-height: min(288px, calc(100vh - 180px));
  max-height: min(288px, calc(100dvh - 180px));
  overflow-y: auto;
  overscroll-behavior: contain;
}

.km-player-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 8px 12px;
  border-top: 1px solid #ffffff26;
  color: #e4f3f4;
  font: 500 11px/1.4 var(--sans, Arial, sans-serif);
  letter-spacing: 0.035em;
}

.km-player-brand img {
  display: block;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  background: #fff;
  object-fit: contain;
}

.km-player-shell .plyr--fullscreen-active {
  width: 100%;
  height: 100%;
}

.km-player-shell .plyr--fullscreen-active .plyr__video-wrapper {
  flex: 1 1 0;
  min-height: 0;
  height: auto !important;
  padding: 0 !important;
  aspect-ratio: auto !important;
}

.km-player-shell .plyr--fullscreen-active video {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  object-fit: contain;
}

/* Native fullscreen does not necessarily add Plyr's fallback state class.
 * Separate WebKit rules so an unknown prefixed selector cannot invalidate others. */
.km-player-shell .plyr:fullscreen {
  width: 100%;
  height: 100%;
}

.km-player-shell .plyr:fullscreen .plyr__video-wrapper {
  flex: 1 1 0;
  min-height: 0;
  height: auto !important;
  padding: 0 !important;
  aspect-ratio: auto !important;
}

.km-player-shell .plyr:fullscreen video {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  object-fit: contain;
}

.km-player-shell .plyr:-webkit-full-screen {
  width: 100%;
  height: 100%;
}

.km-player-shell .plyr:-webkit-full-screen .plyr__video-wrapper {
  flex: 1 1 0;
  min-height: 0;
  height: auto !important;
  padding: 0 !important;
  aspect-ratio: auto !important;
}

.km-player-shell .plyr:-webkit-full-screen video {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  object-fit: contain;
}

@media (prefers-reduced-motion: reduce) {
  .km-player-shell .plyr *,
  .km-player-shell .plyr *::before,
  .km-player-shell .plyr *::after {
    transition: none !important;
    animation: none !important;
  }
}

@media (forced-colors: active) {
  .km-player-shell .plyr__control,
  .km-player-brand {
    border: 1px solid ButtonText;
  }
}
