lite-youtube {
  background-color: #000;
  background-position: center center;
  background-size: cover;
  contain: content;
  cursor: pointer;
  display: block;
  inline-size: calc(100vw - 50px);
  max-block-size: 360px;
  max-inline-size: 640px;
  position: relative;
}

@media (min-width: 768px) {
  .nested lite-youtube {
    max-inline-size: 400px;
  }
}

/* gradient */
lite-youtube::before {
  /* Pixel-perfect port of YT's gradient PNG, using https://github.com/bluesmoon/pngtocss plus optimizations */
  background-image: linear-gradient(
    180deg,
    rgb(0 0 0 / 67%) 0%,
    rgb(0 0 0 / 54%) 14%,
    rgb(0 0 0 / 15%) 54%,
    rgb(0 0 0 / 5%) 72%,
    rgb(0 0 0 / 0%) 94%
  );
  block-size: 99px;
  box-sizing: border-box;
  color: hsl(0deg 0% 93.33%);
  content: attr(data-title);
  display: block;
  font-family: 'YouTube Noto', Roboto, Arial, Helvetica, sans-serif;
  font-size: 18px;
  inline-size: 100%;
  inset-block-start: 0;
  overflow: hidden;
  padding-block: 25px;
  padding-inline: 20px;
  position: absolute;
  text-overflow: ellipsis;
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
}

lite-youtube:hover::before {
  color: #fff;
}

/* responsive iframe with a 16:9 aspect ratio
    thanks https://css-tricks.com/responsive-iframes/
*/
lite-youtube::after {
  content: '';
  display: block;
  padding-block-end: calc(100% / (16 / 9));
}

lite-youtube > iframe {
  block-size: 100%;
  border: 0;
  inline-size: 100%;
  inset-block-start: 0;
  inset-inline-start: 0;
  position: absolute;
}

/* play button */
lite-youtube > .lyt-playbtn {
  /* …but visually it's still the same size */
  background: no-repeat center/68px 48px;
  /* YT's actual play button svg */
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 68 48"><path d="M66.52 7.74c-.78-2.93-2.49-5.41-5.42-6.19C55.79.13 34 0 34 0S12.21.13 6.9 1.55c-2.93.78-4.63 3.26-5.42 6.19C.06 13.05 0 24 0 24s.06 10.95 1.48 16.26c.78 2.93 2.49 5.41 5.42 6.19C12.21 47.87 34 48 34 48s21.79-.13 27.1-1.55c2.93-.78 4.64-3.26 5.42-6.19C67.94 34.95 68 24 68 24s-.06-10.95-1.48-16.26z" fill="red"/><path d="M45 24 27 14v20" fill="white"/></svg>');
  block-size: 100%;
  border: 0;
  cursor: pointer;
  display: block;
  filter: grayscale(100%);
  /* Make the button element cover the whole area for a large hover/click target… */
  inline-size: 100%;
  position: absolute;
  transition: filter 0.1s cubic-bezier(0, 0, 0.2, 1);
  z-index: 1;
}

lite-youtube:hover > .lyt-playbtn,
lite-youtube .lyt-playbtn:focus {
  filter: none;
}

/* Post-click styles */
lite-youtube.lyt-activated {
  cursor: unset;
}

lite-youtube.lyt-activated::before,
lite-youtube.lyt-activated > .lyt-playbtn {
  opacity: 0;
  pointer-events: none;
}

.lyt-visually-hidden {
  block-size: 1px;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  inline-size: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
}
