<?php
$title      = isset($args['title']) ? $args['title'] : '';
$content    = isset($args['content']) ? $args['content'] : '';
$category    = isset($args['category']) ? $args['category'] : '';
$class      = isset($args['class']) ? $args['class'] : '';

$args = array(
    'post_type'           => 'services',
    'post_status'         => 'publish',
    'ignore_sticky_posts' => 1,
    'posts_per_page'      =>-1,
    'orderby'             => 'ASC',
    'order'               => 'ASC',
    'tax_query'           => array(array(
        'taxonomy'      => 'services_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 our-services <?php echo $class;?>">
    <div class="container">
        <div class="text-cont slide-up">
            <h2 class="section-title"><?php echo $title?></h2>
            <p class="section-content">
                <?php echo $content?>
            </p>
        </div>

        <div class="row">
        <?php
                if ($the_query->found_posts!=0)
                {
                   
                    while ( $the_query->have_posts() ) : $the_query->the_post();
                        $post_id=get_the_ID();
                        $card_title  = get_the_title();
                        $card_content = get_the_content(); 
                        $card_icon_url = get_the_post_thumbnail_url($post_id, 'full');
                        $cards_animation = get_field('cards_animation');
                    ?>
                        <div class="col-lg-4 col-md-6 p-0">
                            <div class="card <?php echo $cards_animation ? $cards_animation : 'slide-up'; ?>">
                                <div class="img-cont">
                                    <img src="<?php echo $card_icon_url; ?>" alt="icon" class="img-fluid" loading="lazy">
                                </div>
                                <div class="text-cont">
                                    <h3><?php echo $card_title;?></h3>
                                    <p><?php echo $card_content?></p>
                                    <a href="<?php echo get_field('services_link');?>" aria-label="<?php echo $card_title; ?>">
                                        <svg width="81" height="23" viewBox="0 0 81 23" fill="none"
                                            xmlns="http://www.w3.org/2000/svg">
                                            <path d="M79.6505 12.295C80.2363 11.7092 80.2363 10.7595 79.6505 10.1737L70.1045 0.627773C69.5187 0.0419865 68.569 0.0419865 67.9832 0.627773C67.3974 1.21356 67.3974 2.16331 67.9832 2.74909L76.4685 11.2344L67.9832 19.7197C67.3974 20.3054 67.3974 21.2552 67.9832 21.841C68.569 22.4268 69.5187 22.4268 70.1045 21.841L79.6505 12.295ZM0.549805 12.7344H78.5898V9.73438H0.549805V12.7344Z"
                                                fill="#BCBCBC"/>
                                        </svg>
                                    </a>
                                </div>
                            </div>
                        </div>
                <?php
                        
                    endwhile;
                    wp_reset_postdata();
                    wp_reset_query();
                }
                ?>
        </div>
    </div>
</section>