/**
 * Video Embed Component Styles
 * 
 * Component for displaying YouTube or Vimeo videos with featured image overlay,
 * gradient, play button, and cinematic viewing experience.
 */

/* ===== BASE COMPONENT STRUCTURE ===== */

.video-embed {
    /* Changed from relative to static to allow fixed overlay to escape */
    position: static;
    width: 100%;
    /* Removed padding - let individual use cases add padding if needed */
}

/* ===== CONTAINER ===== */

.video-embed__container {
    max-width: 1200px; /* container-medium */
    margin: 0 auto;
    padding: 0 1rem;
    position: relative; /* Add position here instead */
}

/* Container size variations */
.video-embed.container-small .video-embed__container {
    max-width: 800px;
}

.video-embed.container-large .video-embed__container {
    max-width: 1400px;
}

.video-embed.container-full .video-embed__container {
    max-width: none;
    padding: 0;
}

/* ===== TITLE ===== */

.video-embed__title {
    margin-bottom: 2rem;
    text-align: center;
}

/* ===== VIDEO WRAPPER ===== */

.video-embed__video-wrapper {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    overflow: hidden;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.25);
}

/* ===== FEATURED IMAGE OVERLAY ===== */

.video-embed__overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    cursor: pointer;
    transition: none;
}

/* ===== GRADIENT OVERLAY ===== */

.video-embed__gradient {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50%;
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.8) 0%,
        rgba(0, 0, 0, 0.4) 25%,
        transparent 50%
    );
    pointer-events: none;
}

/* ===== PLAY BUTTON ===== */

.video-embed__play-btn {
    position: absolute;
    bottom: 2rem;
    right: 2rem;
    background: none;
    border: none;
    cursor: pointer;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    padding: 0;
    z-index: 2;
}

.video-embed__play-btn:hover {
    transform: scale(1.1);
    opacity: 0.8;
}

.video-embed__play-btn:focus {
    outline: 2px solid white;
    outline-offset: 4px;
}

.video-embed__play-btn i {
    font-size: 5.5rem; /* 120pt equivalent */
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
}

.video-embed__play-btn:hover i {
    text-shadow: 0 6px 12px rgba(0, 0, 0, 0.7);
}

/* ===== IFRAME CONTAINER ===== */

.video-embed__iframe-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
    z-index: 1;
}

.video-embed__iframe-container.active {
    opacity: 1;
    pointer-events: auto;
}

.video-embed__iframe-container iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Hide overlay when video is playing */
.video-embed__video-wrapper.playing .video-embed__overlay {
    opacity: 0;
    pointer-events: none;
}

/* ===== CINEMATIC OVERLAY ===== */

.video-embed__cinematic-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9998 !important;
    opacity: 0;
    visibility: hidden;
    transition: all 0.8s ease;
    pointer-events: none;
}

.video-embed__cinematic-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Hover effect using pseudo-element behind video */
.video-embed__video-wrapper::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.2);
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.video-embed__video-wrapper:hover::before {
    opacity: 1;
}

/* Only show hover effect when video is not playing */
.video-embed__video-wrapper.playing::before {
    opacity: 0 !important;
}

/* ===== BACKGROUND VARIATIONS ===== */

/* Light background */
.video-embed.bg-light {
    background-color: var(--color-gray-50, #f9fafb);
    padding: var(--spacing-section-sm, 2rem) 0;
}

/* Dark background */
.video-embed.bg-dark {
    background-color: var(--color-gray-900, #111827);
    padding: var(--spacing-section-sm, 2rem) 0;
}

.video-embed.bg-dark .video-embed__title {
    color: var(--color-gray-100, #f9fafb);
}

@media (min-width: 768px) {
    .video-embed.bg-light,
    .video-embed.bg-dark {
        padding: var(--spacing-section-md, 3rem) 0;
    }
}

@media (min-width: 1024px) {
    .video-embed.bg-light,
    .video-embed.bg-dark {
        padding: var(--spacing-section-lg, 4rem) 0;
    }
}

/* When cinematic mode is active, elevate the video */
.video-embed.cinematic-mode {
    /* Removed position relative to prevent constraining the overlay */
    z-index: 10001; /* Higher than hover overlay */
}

.video-embed.cinematic-mode .video-embed__video-wrapper {
    position: relative;
    z-index: 10000;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

/* Fix any parent containers that might have transforms or overflow hidden */
.video-embed-section,
.video-embeds-grid,
.page-builder-content {
    transform: none !important;
    overflow: visible !important;
}

/* ===== RESPONSIVE DESIGN ===== */

@media (max-width: 768px) {
    .video-embed__play-btn {
        bottom: 1.5rem;
        right: 1.5rem;
        width: 50%;
    }
    
    .video-embed__play-btn i {
        font-size: 4rem;
    }
    
    .video-embed__title {
        margin-bottom: 1.5rem;
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .video-embed__play-btn {
        bottom: 1rem;
        right: 1rem;
        width: 60%;
    }
    
    .video-embed__play-btn i {
        font-size: 4rem;
    }
}

/* ===== ACCESSIBILITY ===== */

@media (prefers-reduced-motion: reduce) {
    .video-embed__overlay,
    .video-embed__play-btn,
    .video-embed__play-btn i,
    .video-embed__iframe-container,
    .video-embed__cinematic-overlay {
        transition: none;
    }
    
    .video-embed__overlay:hover {
        transform: none;
    }
    
    .video-embed__play-btn:hover {
        transform: none;
    }
}

/* High contrast support */
@media (prefers-contrast: high) {
    .video-embed__gradient {
        background: linear-gradient(
            to top,
            rgba(0, 0, 0, 0.95) 0%,
            rgba(0, 0, 0, 0.6) 25%,
            transparent 50%
        );
    }
    
    .video-embed__play-btn {
        outline: 2px solid white;
    }
}

/* Focus styles for keyboard navigation */
.video-embed__video-wrapper:focus-within {
    outline: 2px solid var(--primary-700, #2563eb);
    outline-offset: 4px;
}

/* ===== ERROR STATE ===== */

.video-embed-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
    margin: 2rem auto;
    max-width: 600px;
}

/* ===== LOADING STATE ===== */

.video-embed__video-wrapper.loading {
    position: relative;
}

.video-embed__video-wrapper.loading::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: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 10;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}