<!-- About Section -->

<div class="container">
    <p class="title-span-head">Our Team</p>
    <p>At Nzamba Kitonga Advocates LLP, we pride ourselves on having a team of highly skilled professionals with a deep understanding of the legal landscape. Founded in 1980 by Mr. Nzamba Kitonga S.C., the firm has grown from a specialized conveyancing practice into a full-service law firm. Our team includes experienced associates, consultants, and dedicated support staff who provide comprehensive legal services to a diverse range of clients, including public and private corporations, state institutions, and individuals.
    </p>
</div>

<div class="container bttm">

<div class="cards">
<?php
// Custom query for the 'team' post type
$args = array(
    'post_type' => 'team', // Custom post type name
    'posts_per_page' => 10, // Display up to 10 posts
    // 'order' => 'DSC', // Optional: Order by ascending
    'orderby' => 'menu_order' // Optional: Order by menu order if applicable
);

$team_members = new WP_Query($args);

if ($team_members->have_posts()) :
    $counter = 3; // Initialize counter
    while ($team_members->have_posts()) : $team_members->the_post();
        // Check if the repeater field has rows of data
        if (have_rows('our_team')) :
            while (have_rows('our_team')) : the_row();
                // Get sub-field values
                $image = get_sub_field('team_member_image'); // ACF field for image
                $name = get_sub_field('team_member_name'); // ACF field for name
                $position = get_sub_field('team_member_position'); // ACF field for position
                $link = get_sub_field('team_member_link'); // ACF field for link
                
                // Start a new .cards container if needed
                if ($counter % 3 == 0) {
                    if ($counter > 0) echo '</div>'; // Close previous .cards if it's not the first container
                    echo '<div class="cards">'; // Start a new .cards container
                }
                ?>

                <div class="card m-3">
                   
                         <?php if ($image) : ?>
                        <img src="<?php echo esc_url($image['url']); ?>" alt="<?php echo esc_attr($name ? $name : 'No Name'); ?>">
                    <?php endif; ?>
                         
                         <a href="<?php echo esc_url($link ? $link : '#'); ?>" class="card-link">
                    <div class="card-content">
                        
                            <h3><?php echo esc_html($name ? $name : 'No Name'); ?></h3>
                            <?php if ($position): ?>
                                <p class="text-warning"><?php echo esc_html($position); ?></p>
                            <?php endif; ?>
                    
                    </div>
                    </a>
                </div>
                <?php
                $counter++;
            endwhile; endif;
    endwhile;
    // Close the last .cards container if needed
    if ($counter % 3 != 0) echo '</div>';
    wp_reset_postdata();
else : ?>
    <p><?php _e('No team members found.', 'text-domain'); ?></p>
<?php endif; ?>

</div>



</div>