/**
 * VideoEmbed Component Styles
 * Responsive video embedding for YouTube and Vimeo
 */

.video-embed {
  width: 100%;
  margin: 0 auto;
  --aspect-ratio: 16/9;
}

/* Wrapper for aspect ratio */
.video-embed__wrapper {
  position: relative;
  width: 100%;
  padding-bottom: calc(100% / (var(--aspect-ratio)));
  overflow: hidden;
  border-radius: 0.5rem;
  background-color: var(--color-bg-tertiary);
}

/* Iframe */
.video-embed__iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 0.5rem;
}

/* Caption/Title */
.video-embed__caption {
  font-family: 'Lato', sans-serif;
  font-size: var(--text-sm);
  color: var(--color-primary-light);
  text-align: center;
  margin-top: var(--space-3);
  margin-bottom: 0;
  line-height: var(--leading-normal);
}

/* Thumbnail Variant (Click-to-Play) */
.video-embed__thumbnail {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  background-color: var(--color-bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.3s;
}

.video-embed__thumbnail::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.1) 0%,
    rgba(0, 0, 0, 0.3) 100%
  );
  transition: background 0.3s;
}

.video-embed__thumbnail:hover::before {
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.2) 0%,
    rgba(0, 0, 0, 0.4) 100%
  );
}

/* Play Button */
.video-embed__play-button {
  position: relative;
  z-index: 1;
  width: 80px;
  height: 80px;
  border: none;
  background-color: rgba(255, 255, 255, 0.95);
  color: var(--color-accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.video-embed__play-button:hover {
  background-color: var(--color-accent);
  color: white;
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.video-embed__play-button:active {
  transform: scale(1.05);
}

.video-embed__play-button svg {
  margin-left: 4px; /* Optical alignment */
}

/* Error State */
.video-embed__error {
  padding: var(--space-8);
  background-color: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  text-align: center;
  color: var(--color-error);
  font-family: 'Lato', sans-serif;
  font-size: var(--text-sm);
}

/* Platform-specific Styling (if needed) */
.video-embed[data-platform="youtube"] {
  /* YouTube-specific styles */
}

.video-embed[data-platform="vimeo"] {
  /* Vimeo-specific styles */
}

/* Responsive Adjustments */
@media (max-width: 640px) {
  .video-embed__play-button {
    width: 64px;
    height: 64px;
  }

  .video-embed__play-button svg {
    width: 32px;
    height: 32px;
  }
}

/* Container for multiple videos */
.video-gallery {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-8);
}

@media (min-width: 768px) {
  .video-gallery {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Featured Video (Larger) */
.video-embed--featured {
  max-width: 900px;
  margin: 0 auto;
}

.video-embed--featured .video-embed__wrapper {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* Compact Variant */
.video-embed--compact .video-embed__wrapper {
  border-radius: 0.25rem;
}

.video-embed--compact .video-embed__caption {
  font-size: var(--text-xs);
  margin-top: var(--space-2);
}

/* Hero Section Video */
.hero-video {
  max-width: 1000px;
  margin: var(--space-8) auto;
}

.hero-video .video-embed__wrapper {
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
}

/* Accessibility: Focus States */
.video-embed__play-button:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 4px;
}

.video-embed__iframe:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Loading State (for lazy loading) */
.video-embed__iframe[data-src]:not([src]) {
  background: var(--color-bg-tertiary);
}

.video-embed__iframe[data-src]:not([src])::after {
  content: 'Loading...';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--color-primary-lighter);
  font-family: 'Lato', sans-serif;
  font-size: var(--text-sm);
}
