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

.video {
  max-width: 860px;
  margin: 0 auto var(--space-52);
  aspect-ratio: 16 / 9;
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-navy);
  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-navy);
}

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

/* 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;
  background-color: var(--color-navy);
  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;
}

.video__poster::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--color-video-scrim);
  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 {
  position: relative;
  z-index: var(--z-raised);
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--color-primary);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-play);
  transition: transform var(--duration-base) var(--ease-spring), opacity var(--duration-base) ease;
  animation: fs-pulse 2.4s infinite;
}

.video__play::before {
  content: "";
  width: 0;
  height: 0;
  margin-left: var(--space-6);
  border-style: solid;
  border-width: 14px 0 14px 24px;
  border-color: transparent transparent transparent var(--color-text);
  transition: opacity var(--duration-fast) ease;
}

/* Pause bars — only visible while the video is playing. */
.video__play::after {
  content: "";
  position: absolute;
  width: 24px;
  height: 26px;
  border-left: 8px solid var(--color-text);
  border-right: 8px solid var(--color-text);
  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 (prefers-reduced-motion: reduce) {
  .video__play {
    animation: none;
  }
}

@keyframes fs-pulse {
  0%   { box-shadow: 0 0 0 0 var(--color-pulse); }
  70%  { box-shadow: 0 0 0 26px var(--color-pulse-out); }
  100% { box-shadow: 0 0 0 0 var(--color-pulse-out); }
}
