/* Purpose: 16:9 video frame with poster, vignette and pulsing play affordance. */

.video {
  max-width: 900px;
  margin: 0 auto var(--space-56);
  aspect-ratio: 16 / 9;
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--color-bg-3);
  box-shadow: var(--shadow-video);
  transition: transform var(--duration-slow) var(--ease-smooth), box-shadow var(--duration-slow) ease;
}

.video:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-video-h);
}

.video__frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.video__media {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--color-bg-3);
}

.video__poster {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background-color: var(--color-select-bg);
}

/* The poster doubles as the play/pause control when a video file is set. */
button.video__poster {
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  cursor: pointer;
  transition: background-color var(--duration-base) ease;
}

.video__poster-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity var(--duration-base) ease;
}

/* Soft vignette so the photo sits into the dark frame. */
.video__poster::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: var(--z-raised);
  pointer-events: none;
  box-shadow: var(--shadow-video-in);
  transition: opacity var(--duration-base) ease;
}

/* Once playback starts the poster stays out of the way until the video ends. */
.video.is-started button.video__poster {
  background-color: transparent;
}

.video.is-started .video__poster-img,
.video.is-started .video__poster::after {
  opacity: 0;
}

/* Playing: the control fades back only on hover and focus. */
.video.is-playing .video__play {
  opacity: 0;
  animation: none;
}

.video.is-playing:hover .video__play,
.video.is-playing .video__poster:focus-visible .video__play {
  opacity: 1;
}

.video__play {
  /* Scales with the frame: at 84px the button covered half a phone-width video. */
  --play-size: 56px;
  --play-tri-h: 10px;
  --play-tri-w: 17px;
  --play-bar-w: 6px;
  --play-bar-h: 18px;

  position: relative;
  z-index: var(--z-content);
  width: var(--play-size);
  height: var(--play-size);
  border-radius: 50%;
  background: var(--foil);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-play);
  transition: transform var(--duration-med) var(--ease-spring), opacity var(--duration-base) ease;
  animation: fs-pulse var(--duration-pulse) infinite;
}

.video__play::before {
  content: "";
  width: 0;
  height: 0;
  margin-left: calc(var(--play-tri-w) * 0.28);
  border-style: solid;
  border-width: var(--play-tri-h) 0 var(--play-tri-h) var(--play-tri-w);
  border-color: transparent transparent transparent var(--color-dark-ink);
  transition: opacity var(--duration-fast) ease;
}

/* Pause bars — only visible while the video is playing. */
.video__play::after {
  content: "";
  position: absolute;
  width: calc(var(--play-bar-w) * 3);
  height: var(--play-bar-h);
  border-left: var(--play-bar-w) solid var(--color-dark-ink);
  border-right: var(--play-bar-w) solid var(--color-dark-ink);
  opacity: 0;
  transition: opacity var(--duration-fast) ease;
}

.video.is-playing .video__play::before {
  opacity: 0;
}

.video.is-playing .video__play::after {
  opacity: 1;
}

.video:hover .video__play {
  transform: scale(1.1);
}

@media (min-width: 561px) {
  .video__play {
    --play-size: 68px;
    --play-tri-h: 12px;
    --play-tri-w: 20px;
    --play-bar-w: 7px;
    --play-bar-h: 22px;
  }
}

@media (min-width: 821px) {
  .video__play {
    --play-size: 84px;
    --play-tri-h: 15px;
    --play-tri-w: 25px;
    --play-bar-w: 8px;
    --play-bar-h: 26px;
  }
}

@keyframes fs-pulse {
  0%   { box-shadow: 0 0 0 0 var(--color-gold-glow-2); }
  70%  { box-shadow: 0 0 0 28px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
