/* Let provider markup determine the embed block's height. */
.embed__html {
  display: flow-root;
}

.embed--html .embed__html {
  text-align: center;
}

.article-body .embed__html iframe,
.embed__html video {
  display: block;
  max-width: 100%;
  margin-inline: auto;
  border: none;
  border-radius: var(--radius, 8px);
}

/* Scale the fixed viewport and reserve only its visible height. */
.embed__fixed-frame {
  width: calc(var(--embed-width) * 1px);
  max-width: 100%;
  margin-inline: auto;
}

.embed__fixed-frame--scaled {
  position: relative;
  aspect-ratio: var(--embed-width) / var(--embed-height);
  overflow: hidden;
}

.article-body .embed__fixed-frame--scaled > iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: calc(var(--embed-width) * 1px);
  height: calc(var(--embed-height) * 1px);
  max-width: none;
  margin: 0;
  transform: scale(var(--embed-scale));
  transform-origin: top left;
}

/* Supply a ratio only when the video iframe has no declared height.
   Inline provider sizing still takes precedence. */
.article-body iframe:not([height]):is(
  [src*="youtube.com/embed/"],
  [src*="youtube-nocookie.com/embed/"],
  [src*="player.vimeo.com/video/"],
  [src*="dailymotion.com/embed/video/"]
) {
  aspect-ratio: 16 / 9;
}

.article-body iframe:not([width], [height]):is(
  [src*="youtube.com/embed/"],
  [src*="youtube-nocookie.com/embed/"],
  [src*="player.vimeo.com/video/"],
  [src*="dailymotion.com/embed/video/"]
) {
  width: 100%;
}
