/*
 * Click-to-play placeholder for YouTube embeds.
 *
 * A YouTube iframe pulls roughly a megabyte of player JavaScript on every page
 * view whether or not the visitor ever presses play. This renders a thumbnail
 * instead and swaps the real iframe in on click, so the player is only paid for
 * when it is wanted. See /js/yt-facade.js.
 *
 * The facade inherits whatever class the original iframe carried, so the sizing
 * rules of the surrounding page (Tailwind's aspect-video, songs.css, or
 * song-page.css) still apply. Everything below is scoped to .yt-facade and must
 * not assume a particular parent.
 */

.yt-facade {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #000;
  border: 0;
}

/* Pages that give the embed an explicit height still win. */
.yt-facade[style*="height"] {
  aspect-ratio: auto;
}

.yt-facade__btn {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  color: inherit;
  font: inherit;
}

.yt-facade__thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  /* hqdefault is 4:3 with pillarboxing baked in; cover crops it back to 16:9. */
  object-fit: cover;
  display: block;
}

.yt-facade__play {
  position: relative;
  width: 68px;
  height: 48px;
  border-radius: 12px;
  background: rgba(18, 18, 18, 0.78);
  transition: background-color 0.15s ease;
}

.yt-facade__play::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-42%, -50%);
  border-style: solid;
  border-width: 10px 0 10px 17px;
  border-color: transparent transparent transparent #fff;
}

.yt-facade__btn:hover .yt-facade__play,
.yt-facade__btn:focus-visible .yt-facade__play {
  background: #f00;
}

.yt-facade__btn:focus-visible {
  outline: 3px solid #fff;
  outline-offset: -3px;
}

.yt-facade iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .yt-facade__play {
    transition: none;
  }
}
