/**
 * Video Showcase Block Styles
 * These styles are loaded conditionally when the Video Showcase block is used
 */

/* Video Showcase Section */

/* Remove section padding at 1280px+ to match container system */
@media (width >=1280px) {
    .video-showcase {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
}

.video-showcase-container {
    max-width: var(--container-lg);
    margin: 0 auto;
}

/* Default Layout: Video Below Content */
.video-placement-vidbelow .video-showcase-content {
    text-align: center;

    /* flex-col utility class provides: display: flex; flex-direction: column */
    align-items: center;
    gap: var(--space-lg);
}

/* Reduce section-header margin to account for row gap (gap: var(--space-lg)) */
.video-placement-vidbelow .section-header {
    margin-bottom: var(--space-md);
}

/* Side-by-Side Layouts: Video Left or Right of Content */

/* Grid system (.row class) provides layout - no custom grid needed */

/* REMOVED: display: grid */

/* REMOVED: grid-template-columns: 1fr 1fr */

.video-placement-vidleft .video-showcase-content,
.video-placement-vidright .video-showcase-content {
    align-items: center;
    gap: var(--space-3xl);
    text-align: left;
}

/* Video Column - Contains video wrapper and transcript link */
.video-column {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

section:not(.has-text-color) .video-showcase-subtitle,
section:not(.has-text-color) .video-description,
section:not(.has-text-color) .video-note {
    color: var(--color-text-secondary);
}

/* Video Left: Text on Right */
.video-placement-vidleft .video-text-content {
    order: 2;
}

.video-placement-vidleft .video-column {
    order: 1;
}

/* Video Right: Text on Left (default order) */
.video-placement-vidright .video-text-content {
    order: 1;
}

.video-placement-vidright .video-column {
    order: 2;
}

/* Centered subtitle for default layout */
.video-placement-vidbelow .video-text-content {
    max-width: var(--max-width-content-xl);
    margin-inline: auto;
}

.video-placement-vidbelow .video-showcase-subtitle,
.video-placement-vidbelow .video-description {
    max-width: var(--max-width-content-md);
    margin-inline: auto;
}

.video-placement-vidleft .video-showcase-subtitle,
.video-placement-vidright .video-showcase-subtitle,
.video-placement-vidleft .video-description,
.video-placement-vidright .video-description {
    max-width: 88%;
    margin-left: 0;
}

.video-description {
    margin-top: var(--space-md);
}

/* Ensure bullets are always left-aligned */
.video-description ul,
.video-description ol {
    text-align: left;
}

/* Video Wrapper - with position relative for play button overlay */
.video-wrapper {
    width: 100%;
    max-width: 100%;
    position: relative;
    display: block;
    line-height: 0;
    box-sizing: border-box;
}

/* Constrain video width for centered layout */
.video-placement-vidbelow .video-wrapper {
    max-width: var(--container-sm);
    margin: 0 auto;
}

/* Video Player Styles */
.video-player {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-lg);
    background-color: var(--color-black);
    aspect-ratio: 16 / 9;
    box-sizing: border-box;

    /* Maintain consistent aspect ratio */
}

/* Max height for video player when video is below content */
.video-placement-vidbelow .video-player {
    max-height: 600px;
    object-fit: contain;
}

/* Video Preview Image (for YouTube/Vimeo with poster) */
.video-preview-image {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-lg);
    object-fit: cover;
    cursor: pointer;
    aspect-ratio: 16 / 9;
    box-sizing: border-box;

    /* Match video player aspect ratio */
}

/* Max height for preview image when video is below content */
.video-placement-vidbelow .video-preview-image {
    max-height: 600px;
    object-fit: cover;
}

/* Keyboard focus indicator for video wrapper when it's interactive */
.video-wrapper[role="button"]:focus {
    outline: 3px solid var(--color-accent);
    outline-offset: 4px;
    border-radius: var(--radius-card);
}

/* Remove default focus outline on click, keep for keyboard */
.video-wrapper[role="button"]:focus:not(:focus-visible) {
    outline: none;
}

/* Play Button Overlay */
.video-wrapper::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90px;
    height: 90px;
    background-image: url('play-button.svg');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    pointer-events: none;
    z-index: 2;
    opacity: 1;
    transition: opacity var(--transition-base), transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Play Button Hover Effect - Slight Zoom */
.video-wrapper:hover::before {
    transform: translate(-50%, -50%) scale(1.15);
}

/* Hide play button when video is playing (inline mode only) */
.video-playback-inline .video-wrapper.is-playing::before {
    opacity: 0;
}

/* Disable hover effect when video is playing (inline mode) */
.video-playback-inline .video-wrapper.is-playing:hover::before {
    transform: translate(-50%, -50%) scale(1);
}

/* Keep play button visible for modal playback mode */
.video-playback-modal .video-wrapper::before {
    opacity: 1;
    pointer-events: auto;

    /* Play button should be clickable */
}

/* Poster image should cover entire space */
.video-player[poster] {
    object-fit: cover;
}

/* Hide controls until user interacts with video */
.video-player:not(.has-played) {
    cursor: pointer;
}

/* Hide native controls on all browsers before first play */
.video-player:not(.has-played)::-webkit-media-controls {
    display: none !important;
    opacity: 0;
}

.video-player:not(.has-played)::-webkit-media-controls-enclosure {
    display: none !important;
}

.video-player:not(.has-played)::-webkit-media-controls-panel {
    display: none !important;
}

.video-player:not(.has-played)::-webkit-media-controls-play-button {
    display: none !important;
}

.video-player:not(.has-played)::-webkit-media-controls-start-playback-button {
    display: none !important;
}

/* Show controls after first play */
.video-player.has-played::-webkit-media-controls {
    display: flex !important;
    opacity: 1;
}

.video-player.has-played::-webkit-media-controls-play-button {
    display: inline-block !important;
}

.video-player.has-played::-webkit-media-controls-start-playback-button {
    display: inline-block !important;
}

/* Modal Playback Method - Enhanced pointer cursor */
.video-playback-modal .video-wrapper {
    cursor: pointer;
}

.video-playback-modal .video-player {
    pointer-events: none;

    /* Allow clicks to pass through to wrapper */
}

/* Video Embed Container - Block-Specific Modifier */

/* Base .video-embed-container styles are in theme utilities.css */
.video-placement-vidbelow .video-embed-container {
    max-height: 600px;
}

/* Video Placeholder */
.video-placeholder {
    background: var(--gradient-primary);
    border-radius: var(--radius-card);
    padding: var(--space-3xl);
    min-height: var(--dimension-hero-height);

    /* flex-center utility class provides: display: flex; align-items: center; justify-content: center */
    position: relative;
    box-shadow: var(--shadow-lg);
}

/* Preview/fallback state */
.video-placeholder:not([style*="background"]) {
    background: var(--color-neutral-100);
    min-height: 300px;
}

/* Video Note Row - Displays below the main content row */
.video-note-row {
    margin-top: var(--space-lg);
}

.video-note {
    font-size: var(--font-size-small);
    font-style: italic;
    text-align: center;
    color: var(--color-text-secondary);
    margin: 0;
}

/* Center video note for vidbelow layout */
.video-placement-vidbelow .video-note {
    text-align: center;
    max-width: var(--container-md);
    margin-inline: auto;
}

/* Center video note under video for side-by-side layouts */
.video-placement-vidleft .video-note,
.video-placement-vidright .video-note {
    text-align: center;
}

/* Video Transcript Link - WCAG AAA Compliance */
.video-transcript-link {
    margin-top: var(--space-md);
    text-align: center;
    width: 100%;
}

.video-placement-vidbelow .video-transcript-link {
    max-width: var(--container-md);
    margin-inline: auto;
}

.transcript-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    color: var(--color-primary);
    text-decoration: none;
    font-size: var(--font-size-small);
    font-weight: 500;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    transition: all var(--transition-base);
}

.transcript-link:hover,
.transcript-link:focus {
    color: var(--color-link-hover);
    background-color: var(--color-bg-secondary);
    text-decoration: underline;
}

.transcript-link:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.transcript-icon {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

/* Accessibility: Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .video-wrapper::before {
        transition: none;
    }

    .video-wrapper:hover::before {
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Tablet Responsive (1024px and below) */
@media (width <=1024px) {
    .video-placement-vidleft .video-showcase-content,
    .video-placement-vidright .video-showcase-content {
        gap: var(--space-lg);
    }
}

/* Tablet & Mobile Responsive (1024px and below) */
@media (width <=1024px) {
    /* Stack side-by-side layouts vertically on mobile */

    /* REMOVED: grid-template-columns: 1fr - grid system (.col-md-12) handles mobile stacking */

    .video-placement-vidleft .video-showcase-content,
    .video-placement-vidright .video-showcase-content {
        text-align: center;
    }

    /* Keep bullets left-aligned even when parent is centered */
    .video-placement-vidleft .video-showcase-content ul,
    .video-placement-vidright .video-showcase-content ul,
    .video-placement-vidbelow .video-showcase-content ul {
        text-align: left;
    }

    .video-placement-vidleft .video-showcase-subtitle,
    .video-placement-vidright .video-showcase-subtitle,
    .video-placement-vidleft .video-description,
    .video-placement-vidright .video-description {
        max-width: 100%;
    }

    /* Reset order for mobile - always show text first */
    .video-placement-vidleft .video-text-content,
    .video-placement-vidright .video-text-content {
        order: 1;
    }

    .video-placement-vidleft .video-column,
    .video-placement-vidright .video-column {
        order: 2;
    }

    .video-showcase-subtitle,
    .video-description {
        font-size: var(--font-size-body);
        margin-bottom: var(--space-xl);
    }

    .video-placeholder {
        padding: var(--space-2xl) var(--space-lg);
        min-height: 300px;
    }

    .video-play-button {
        width: 80px;
        height: 80px;
        margin-bottom: var(--space-lg);
    }

    .video-play-icon {
        font-size: var(--font-size-h4);
    }
}

/* Preview Mode Styles */
.video-preview-subtitle-placeholder {
    color: var(--color-text-muted);
    font-style: italic;
}

.video-preview-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.video-placeholder-content {
    text-align: center;
}

.video-play-hint {
    margin-top: var(--space-sm);
}

/* ============================================
 * Sticky Video Feature (User-Controlled)
 * ============================================ */

/**
 * Sticky Video Column - Desktop Only (>1024px)
 * When enabled via ACF toggle, video sticks while text content scrolls
 * Only applies to side-by-side layouts (vidleft/vidright)
 * Automatically disabled on tablet/mobile for optimal UX
 */

/* Desktop: Enable sticky behavior when toggle is ON */
@media (width > 1024px) {
    /* Critical: Override main element overflow-x which prevents sticky */
    main:has(.video-showcase.video-sticky-enabled) {
        overflow-x: visible !important;
    }

    /* Critical: Override parent theme's overflow settings for sticky to work */
    .video-showcase.video-sticky-enabled {
        overflow: visible !important;
        contain: none !important;
    }

    /* Force overflow visible on all parent containers */
    .video-showcase.video-sticky-enabled .container,
    .video-showcase.video-sticky-enabled .video-showcase-content {
        overflow: visible !important;
        contain: none !important;
    }

    /* Convert grid to flexbox for proper sticky behavior */
    .video-showcase.video-sticky-enabled .video-showcase-content {
        display: flex !important;
        flex-wrap: nowrap;
    }

    /* Make columns take 50% width in flex layout minus half of gap (96px / 2 = 48px) */
    .video-showcase:not(.video-placement-vidbelow).video-sticky-enabled .video-text-content {
        flex: 0 0 calc(50% - 48px);
        max-width: calc(50% - 48px);
    }

    .video-showcase.video-sticky-enabled .video-column {
        flex: 0 0 calc(50% - 48px);
        width: calc(50% - 48px);
        max-width: calc(50% - 48px);
        max-height: calc(100vh - var(--sticky-element-top-offset) - 40px);
        overflow-y: auto;
    }

    /* Only apply to side-by-side layouts with sticky enabled */
    .video-showcase.video-sticky-enabled.video-placement-vidleft .video-column,
    .video-showcase.video-sticky-enabled.video-placement-vidright .video-column {
        position: sticky;
        align-self: flex-start;
        top: calc(var(--header-height) + var(--announcement-bar-height) + var(--sticky-element-top-offset));
        z-index: 10;
        will-change: transform;
    }

    /* Account for WordPress admin bar in logged-in state */
    .admin-bar .video-showcase.video-sticky-enabled.video-placement-vidleft .video-column,
    .admin-bar .video-showcase.video-sticky-enabled.video-placement-vidright .video-column {
        top: calc(var(--header-height) + var(--announcement-bar-height) + 32px + var(--sticky-element-top-offset));
    }
}

/* Tablet/Mobile: Disable sticky behavior regardless of toggle state */
@media (width <=1024px) {
    .video-showcase.video-sticky-enabled .video-column {
        position: static;
        align-self: auto;
        max-height: none;
    }
}