@layer components {
  /* Embedded video player (YoutubeVideo attachable). A fluid 16:9 frame so the iframe
     scales with the content column instead of a fixed pixel size. */
  .video-embed {
    position: relative;
    aspect-ratio: 16 / 9;
    margin-block: var(--block-space-double);
    border-radius: var(--radius);
    overflow: hidden;
  }

  .video-embed iframe {
    display: block;
    inline-size: 100%;
    block-size: 100%;
    border: 0;
  }

  /* Poster only stands in where the iframe is missing — the Lexxy editor strips iframes, so
     the embed would otherwise be an empty box. On the page the iframe is present, so hide it. */
  .video-embed img {
    display: block;
    inline-size: 100%;
    block-size: 100%;
    object-fit: cover;
  }
  .video-embed:has(iframe) img {
    display: none;
  }

  /* Editor-only YouTube play badge, so the poster reads as a video (the page shows the real
     iframe instead): a red button (::before) with a white triangle (::after) over it. */
  .video-embed:not(:has(iframe))::before,
  .video-embed:not(:has(iframe))::after {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
  }
  .video-embed:not(:has(iframe))::before {
    inline-size: 4rem;
    block-size: 2.8rem;
    border-radius: 0.7rem;
    background: #f00;
  }
  .video-embed:not(:has(iframe))::after {
    inline-size: 0;
    block-size: 0;
    border-block: 0.6rem solid transparent;
    border-inline-start: 1rem solid #fff;
    border-inline-end: 0;
    translate: 0.15rem 0;
  }

  /* An imported [audio]/[video] player lands inline inside a text paragraph (the
     reset blocks <video> but not <audio>, which is inline by default) — put each on
     its own line with room to breathe rather than mid-sentence. */
  audio, video {
    display: block;
    margin-block: var(--block-space);
  }
  audio {
    inline-size: 100%;
    max-inline-size: 32rem;
  }
}
