<?php

if(get_theme_mod('video_area_disable') != 'on' ){ ?>
	<div class="video-area" id="video" >
		<?php

		// Heading Style
		$heading_case = get_theme_mod('vdio_maintitle_case', 'capitalize');

		if ($heading_case === 'uppercase') {
				$text_case = 'uppercase';
			} elseif ($heading_case === 'lowercase') {
			    $text_case = 'lowercase';
			} elseif ($heading_case === 'capitalize') {
			    $text_case = 'capitalize';
			} else {
			    $text_case = 'capitalize'; // Default to 'left' if the setting is invalid
			}
			 
		// Alignment
		$heading_alignment = get_theme_mod('vdio_maintitle_align', 'right');

		if ($heading_alignment === 'left') {
			  $text_alignment = 'left';
			} elseif ($heading_alignment === 'center') {
			    $text_alignment = 'center';
			} elseif ($heading_alignment === 'right') {
			    $text_alignment = 'right';
			} else {
			    $text_alignment = 'right'; // Default to 'left' if the setting is invalid
			}

	  	?>

	  	<?php

			$video_subtitle = get_theme_mod('videosubtitle', 'projects World-wide');
			$video_title = get_theme_mod('videotitle', '$430 millions');						
			$video_text = get_theme_mod('videotext', 'We Invested.');
		?>
    	 <div class="imgbx">	
			<div class="v-bx-img">
				<div class="video-content-bg" > 	
					<div class="hover_bkgr_fricc " >
					    <div class="popupCloseButton">X</div>
							<?php
								// Retrieve the video URL from the WordPress customizer
								$videoUrl = get_theme_mod('luzuk_premium_faci_video_iframe', '');

								// Check if a valid URL is provided
								if (!empty($videoUrl)) {
								    // Handle YouTube videos
								    if (strpos($videoUrl, 'youtube.com') !== false) {
								        // Extract video ID from a standard YouTube watch URL
								        parse_str(parse_url($videoUrl, PHP_URL_QUERY), $queryParams);
								        if (isset($queryParams['v'])) {
								            $videoId = $queryParams['v'];
								            $videoUrl = "https://www.youtube.com/embed/{$videoId}?autoplay=1&mute=1";
								        }
								    }
								    // Handle Vimeo videos
								    elseif (strpos($videoUrl, 'vimeo.com') !== false) {
								        // For Vimeo, ensure autoplay parameter is added
								        if (strpos($videoUrl, '?') === false) {
								            $videoUrl .= '?autoplay=1';
								        } else {
								            $videoUrl .= '&autoplay=1';
								        }
								    }

								    // Output the iframe HTML with the dynamic URL
								    echo '<iframe id="video-popup-iframe" src="' . esc_url($videoUrl) . '" width="100%" height="100%" frameborder="0" allow="autoplay; fullscreen"></iframe>';
								} else {
								    // Optional: Handle the case where no URL has been set
								    echo '<p>No video available.</p>';
								}
							?>
							<div class="video-contbx">
								<div class="sub_title" style="text-align: <?php echo esc_attr($text_alignment); ?>; text-transform: <?php echo esc_attr($heading_case); ?>;">
									<?php echo ($video_subtitle); ?>
								</div>
				                <h4 style="text-align: <?php echo esc_attr($text_alignment); ?>; text-transform: <?php echo esc_attr($heading_case); ?>;">
				                	<?php echo ($video_title); ?>
				                		
				                </h4>
				                <p  style="text-align: <?php echo esc_attr($text_alignment); ?>; "> <?php echo ($video_text); ?></p>
					            
							</div>	

					</div>
					<div class="clearfix"></div>	
								
				</div>
				
							
					
			</div>	
		</div>
	</div> 

	
<?php } 