<?php
$heading     = $args['heading'];
$description = $args['description'];
$category    = $args['category'];
$show_cta    = isset($args['show-cta']) ? $args['show-cta'] : false;

$args = array(
    'post_type'           => 'industry',
    'post_status'         => 'publish',
    'ignore_sticky_posts' => 1,
    'posts_per_page'      =>-1,
    'orderby'             => 'ASC',
    'order'               => 'ASC',
    'tax_query'           => array(array(
        'taxonomy'      => 'industry_categories',
        'field'         => 'slug', //This is optional, as it defaults to 'term_id'
        'terms'         => $category ? $category : '',
        'operator'      => 'IN' // Possible values are 'IN', 'NOT IN', 'AND'.
    ))
);

$the_query = new WP_Query( $args );
?>
<section class="section more-industries-new">
    <div class="container-fluid px-lg-0">
        <div class="more-industries-slider-wrapper">
            <div class="row gy-4 gy-lg-0 justify-content-lg-between align-items-center">
                <div class="col-lg-6 col-xl-5 col-xxl-5 pe-lg-0">
                    <div class="text-cont slide-right">
                        <h2 class="why-choose-title mb-0 mt-2 mt-lg-4"><?php echo $heading; ?></h2>
                        <p class="why-choose-text mt-md-1 mt-3 mt-lg-4"><?php echo $description; ?></p>

                        <div class="buttons-wrapper">
                            <a href="<?php echo get_field('industries_button_link'); ?>" class="purple-outline-btn animated-btn" aria-label="Know More about industries" title="<?php echo get_field('industries_button_text'); ?>"></a>
                        </div>
                        <div class="slide-owl-nav d-none d-lg-flex">
                            <button class="slide-prev-button" aria-label="Previous Slide Button">
                                <img src='<?php echo get_template_directory_uri();?>/assets/img/left-arrow.webp' alt="Previous Slide arrow">
                            </button>
                            <button class="slide-next-button" aria-label="Next Slide Button">
                                <img src='<?php echo get_template_directory_uri();?>/assets/img/right-arrow.webp' alt="Next Slide arrow">
                            </button>
                        </div>

                    </div>
                </div>
                <div class="col-lg-6 col-xl-7 col-xxl-6 pr-md-0">
                    <div class="owl-carousel owl-theme more-industries-slider">
					<?php
            if ($the_query->found_posts!=0)
                {
                
                while ( $the_query->have_posts() ) : $the_query->the_post();
                $post_id=get_the_ID();
                    $titles  = get_the_title();
                    $content = get_the_content(); 
					$svgicon = get_field('svgicon'); 
                    $featured_image_url = get_the_post_thumbnail_url($post_id, 'full'); 
                        ?>
                        <div class="item">
                            <div class="card">
                                <div class="card-header p-0">
                                    <div class="img-content">
                                        <img src="<?php echo $featured_image_url; ?>" alt="<?php echo $titles; ?>" loading="lazy" class="img-fluid">
                                        <div class="svg-wrapper">
                                            <?php echo $svgicon; ?>                                                                                                                                             
                                        </div>
                                    </div>
                                </div>
                                <div class="card-body pt-0">
                                    <h2><?php echo $titles; ?></h2>
                                    <p class="mb-0"><?php echo $content; ?></p>
                                    <?php if ($show_cta) : ?>
                                        <a href="<?php echo get_field('industry_link'); ?>" aria-label="Know More about <?php echo $titles;?>" class="read-more rounded-0 d-inline-block mt-3"> 
                                            <svg class="me-2" width="15" height="13" viewBox="0 0 15 13" fill="none" xmlns="http://www.w3.org/2000/svg">
                                                <path d="M14.2148 7.66406L9.21484 12.6641C9.02734 12.8516 8.77734 12.9453 8.52734 12.9453C8.24609 12.9453 7.99609 12.8516 7.80859 12.6641C7.40234 12.2891 7.40234 11.6328 7.80859 11.2578L11.0898 7.94531H1.52734C0.964844 7.94531 0.527344 7.50781 0.527344 6.94531C0.527344 6.41406 0.964844 5.94531 1.52734 5.94531H11.0898L7.80859 2.66406C7.40234 2.28906 7.40234 1.63281 7.80859 1.25781C8.18359 0.851562 8.83984 0.851562 9.21484 1.25781L14.2148 6.25781C14.6211 6.63281 14.6211 7.28906 14.2148 7.66406Z" fill="#5956E9"/>
                                            </svg>                                                                                 
                                        </a>
                                    <?php endif; ?>
                                </div>
                            </div>
                        </div>
						<?php
                      
                    endwhile;
                    wp_reset_postdata();
                    wp_reset_query();
                }
                ?>
                    </div>
                    <div class="slide-owl-nav d-lg-none">
                        <button class="slide-prev-button" aria-label="Previous Slide Button">
                            <img src='<?php echo get_template_directory_uri();?>/assets/img/left-arrow.webp' alt="Previous Slide arrow">
                         </button>
                         <button class="slide-next-button" aria-label="Next Slide Button">
                            <img src='<?php echo get_template_directory_uri();?>/assets/img/right-arrow.webp' alt="Next Slide arrow">
                         </button>
                     </div>
                </div>
            </div>
        </div>
    </div>
</section>