/*
 * MediaPlayer: the media element is the part, so it fills the host's box (and keeps its natural ratio when the host
 * has no height); `object-fit` letterboxes an image or video inside it. An image that failed to load is removed
 * rather than shown broken, and an embed fades in once loaded so the platform's blank frame never flashes.
 */

@layer dx-components {
  .dx-media-player {
    display: block;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    object-fit: cover;
  }
  .dx-media-player[data-fit='contain'] {
    object-fit: contain;
  }
  .dx-media-player[data-fit='fill'] {
    object-fit: fill;
  }
  .dx-media-player[data-fit='none'] {
    object-fit: none;
  }
  .dx-media-player[data-fit='scale-down'] {
    object-fit: scale-down;
  }

  .dx-media-player[data-kind='audio'] {
    height: auto;
  }

  .dx-media-player[data-kind='image'][data-status='error'] {
    display: none;
  }

  .dx-media-player[data-kind='embed'] {
    aspect-ratio: 16 / 9;
    border: none;
    color-scheme: dark;
    background: var(--color-base-surface);
    opacity: 0;
    transition: opacity 150ms;
  }
  .dx-media-player[data-kind='embed'][data-status='loaded'] {
    opacity: 1;
  }

  @media (prefers-reduced-motion: reduce) {
    .dx-media-player[data-kind='embed'] {
      transition: none;
    }
  }
}
