/* Feed videos take their own shape (portrait capped at 4:5) instead of
   Plyr's fixed 16:9 / 9:16 box with black bars. --feed-video-ratio is set by
   feed-video.js once the video's size is known. */
.post .plyr--video:not(.plyr--fullscreen-active) {
  aspect-ratio: var(--feed-video-ratio, 4 / 5);
  width: 100%;
  background: #000;
}

/* Absolute positioning: WebKit (iOS) doesn't resolve % heights against an
   aspect-ratio box, which left the video small inside it. */
.post .plyr--video:not(.plyr--fullscreen-active) {
  position: relative;
}

.post .plyr--video:not(.plyr--fullscreen-active) .plyr__video-wrapper {
  position: absolute !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  aspect-ratio: auto !important;
  transform: none !important;
}

.post .plyr--video:not(.plyr--fullscreen-active) video {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-height: none !important;
  object-fit: cover;
  background: #000;
}

/* Wide videos are shown whole; only tall ones are cropped to 4:5. */
.post .plyr--video.feed-video-wide:not(.plyr--fullscreen-active) video {
  object-fit: contain;
}

.post .plyr--fullscreen-active video {
  object-fit: contain;
}

@media (max-width: 767px) {
  /* Edge to edge inside the card on phones, like other apps. */
  .post .post-body .plyr--video {
    border-radius: 0;
  }
}

@media (min-width: 768px) {
  /* On wide screens keep tall videos to 75% of the window height. */
  .post .plyr--video:not(.plyr--fullscreen-active) {
    max-width: min(100%, calc(75vh * var(--feed-video-ratio, 0.8)));
    margin: 0 auto;
  }
}

/* Plyr's thumbnail is letterboxed by default; fill like the video does. */
.post .plyr--video:not(.plyr--fullscreen-active) .plyr__poster {
  background-size: cover;
}

.post .plyr--video.feed-video-wide .plyr__poster {
  background-size: contain;
}
