/**
 * Video Infrastructure Styles
 * 
 * Handles video containers, poster images, play/pause buttons,
 * loading states, and error handling
 */

/* Video Container */
.video-container {
  position: relative;
  width: 100%;
  overflow: hidden;
  background-color: #000;
}

.video-container video {
  display: block;
  width: 100%;
  height: auto;
}

/* Hero video specific */
.video-container--hero {
  aspect-ratio: 16 / 9;
}

@media (max-width: 768px) {
  .video-container--hero {
    aspect-ratio: 4 / 3; /* Mobile crop shows more of the tap */
  }
}

/* Poster/Fallback Image */
.video-container__poster {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.video-container.is-loaded .video-container__poster,
.video-container video:not([poster]) ~ .video-container__poster {
  opacity: 0;
}

/* Play/Pause Toggle Button */
.video-toggle {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  background-color: rgba(0, 0, 0, 0.6);
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
}

.video-toggle:hover {
  background-color: rgba(0, 0, 0, 0.8);
  border-color: #fff;
  transform: scale(1.05);
}

.video-toggle:focus {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.video-toggle:active {
  transform: scale(0.95);
}

/* Toggle Icons */
.video-toggle__icon {
  position: absolute;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.video-toggle__icon--pause {
  opacity: 1;
  transform: scale(1);
}

.video-toggle__icon--play {
  opacity: 0;
  transform: scale(0.8);
}

.video-toggle.is-paused .video-toggle__icon--pause {
  opacity: 0;
  transform: scale(0.8);
}

.video-toggle.is-paused .video-toggle__icon--play {
  opacity: 1;
  transform: scale(1);
}

/* Loading State */
.video-container::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  opacity: 0;
  animation: video-spinner 0.8s linear infinite;
  pointer-events: none;
}

.video-container:not(.is-loaded) video[data-src]::before {
  opacity: 1;
}

@keyframes video-spinner {
  to {
    transform: rotate(360deg);
  }
}

/* Error State */
.video-container.has-error::after {
  content: 'Video unavailable';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 1rem 1.5rem;
  background-color: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 0.875rem;
  border-radius: 4px;
}

.video-container.has-error video {
  opacity: 0.3;
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  .video-container video {
    /* Show poster only */
    display: none;
  }
  
  .video-container__poster {
    opacity: 1 !important;
    position: static;
  }
  
  .video-toggle {
    display: none;
  }
}

/* Touch Devices - Larger Hit Area */
@media (hover: none) and (pointer: coarse) {
  .video-toggle {
    width: 56px;
    height: 56px;
    bottom: 1.5rem;
    right: 1.5rem;
  }
}

/* Small Screens */
@media (max-width: 480px) {
  .video-toggle {
    width: 44px;
    height: 44px;
    bottom: 0.75rem;
    right: 0.75rem;
  }
}

/* Focus Visible (keyboard navigation) */
.video-toggle:focus:not(:focus-visible) {
  outline: none;
}

.video-toggle:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}
