Add class to first post queried

<?php
    $_terms = get_terms( array('claim-accordion-type') );
    $i = 0;
    foreach ($_terms as $term) :
    $term_slug = $term->slug;
    $_posts = new WP_Query( array(                        'post_type'         => 'claims_accordion',                        'posts_per_page'    => -1,                        'tax_query' => array(                            array(                                'taxonomy' => 'claim-accordion-type',                                'field'    => 'slug',                                'terms'    => $term_slug,                            ),                        ),                    ));

    if( $_posts->have_posts() ) :
    $i++;

    if ( $i == 1 ) {
        $class="is-active";
    } else {
        $class = null;
    }

    echo'<li class="accordion-item ' . $class . '" data-accordion-item>';
    echo'<a href="#" class="accordion-title">';
    echo ''. $term->name .'';
    echo'</a>';
    while ( $_posts->have_posts() ) :
    $_posts->the_post();
    ?>
        <div class="accordion-content" data-tab-content>
          <a data-open="exampleModal1">
            <h4><?php  the_title(); ?></h4></a>
        </div>
        <div class="reveal" id="exampleModal1" data-reveal>
          <?php  the_content(); ?>
            <button class="close-button" data-close aria-label="Close modal" type="button">
              <span aria-hidden="true">&times;</span>
            </button>
        </div>
        <?php
    endwhile;
    echo '</li>';
    endif;
    wp_reset_postdata();
    endforeach;
    ?>
</ul>
?>