<?php get_header('employment'); ?>
<main>
    <section class="p-fv">
        <?php
        if(have_rows('fv')) :
        while (have_rows('fv')) : the_row();
        ?>
            <h1 class="p-fv__title"><?php the_sub_field('fv-title'); ?></h1>
            <div class="p-fv__swiper swiper js-swiper">
                <div class="swiper-wrapper">
                    <?php if (get_sub_field('fv-slide')) : ?>
                        <?php
                        $group = get_sub_field('fv-slide');
                        if ($group) :
                            foreach ($group as $field) {
                                $acf_row_image_pc = $field['fv-img-pc'];
                                $url_pc = $acf_row_image_pc['url'];
                                $alt = $acf_row_image_pc['alt'];
                                $acf_row_image_sp = $field['fv-img-sp'];
                                $url_sp = $acf_row_image_sp['url'];
                                if ($url_pc) :
                                ?>
                                    <div class="swiper-slide">
                                        <div class="p-fv__img c-img">
                                            <picture>
                                                <source srcset="<?php echo $url_pc; ?>" media="(min-width: 768px)">
                                                <img src="<?php echo $url_sp; ?>" alt="<?php echo $alt; ?>">
                                            </picture>
                                        </div>
                                    </div>
                                <?php
                                endif;
                            }
                        endif;
                        ?>
                    <?php endif; ?>
                </div>
                <div class="swiper-pagination fv-swiper-pagination"></div>
            </div>
        <?php
        endwhile;
        endif;
        ?>
    </section>
    <section class="p-topInterview l-topInterview">
        <div class="p-topInterview__inner l-inner">
            <p class="p-topInterview__entitle c-entitle">interview</p>
            <h2 class="p-topInterview__title c-title">架け橋の向こう側。</h2>
            <?php
            $the_query = new WP_Query();
            $param = array(
                'post_type'      => 'interview',
                'posts_per_page' => '4',
                'post_status'    => 'publish',
                'post__not_in'=> array(215),
            );
            $the_query->query($param);
            if ($the_query->have_posts()) :
            ?>
                <div class="p-topInterview__swiper swiper js-interviewSwiper u-fadein">
                    <div class="swiper-wrapper">
                        <?php while( $the_query->have_posts() ) : $the_query->the_post(); ?>
                            <div class="swiper-slide">
                                <a href="<?php the_permalink(); ?>" class="p-topInterview__item p-interviewItem">
                                    <?php
                                    if(have_rows('introduction')) :
                                    while (have_rows('introduction')) : the_row();
                                    ?>
                                        <div class="p-interviewItem__img c-img">
                                            <?php
                                            if (has_post_thumbnail()) :
                                                the_post_thumbnail('post-thumbnail', array('alt' => the_title_attribute('echo=0')));
                                            else :
                                                echo '<img src="'.get_template_directory_uri().'/images/common/noimage.jpg" alt="'.esc_html(get_the_title()).'">';
                                            endif; ?>
                                            <div class="p-interviewItem__filter">
                                                <p class="p-interviewItem__words"><?php the_title(); ?></p>
                                                <p class="p-interviewItem__position"><?php the_sub_field('introduction-position'); ?></p>
                                                <p class="p-interviewItem__name"><?php the_sub_field('introduction-name'); ?><span><?php if(get_sub_field('introduction-year')) {echo the_sub_field('introduction-year').'入社'; } ?></span></p>
                                            </div>
                                        </div>
                                    <?php
                                    endwhile;
                                    endif;
                                    ?>
                                </a>
                            </div>
                        <?php endwhile; ?>
                    </div>
                    <div class="swiper-pagination interview-swiper-pagination"></div>
                </div>
            <?php
            endif;
            wp_reset_postdata();
            ?>
            <?php if(get_field('interview-text')) : ?>
                <p class="p-topInterview__theme c-theme"><?php echo the_field('interview-text'); ?></p>
            <?php endif;?>
            <div class="p-topInterview__link">
                <a href="<?php echo esc_url(home_url('/employment/interview/')); ?>" class="c-button">インタビュー一覧を見る</a>
            </div>
        </div>
    </section>
    <section class="p-topPerson l-topPerson">
        <div class="p-topPerson__inner l-inner">
            <p class="p-topPerson__entitle c-entitle">person</p>
            <h2 class="p-topPerson__title c-title">現地力とは。</h2>
            <div class="p-topPerson__contents u-fadein">
                <?php
                if(have_rows('person')) :
                while (have_rows('person')) : the_row();
                ?>
                    <div class="p-topPerson__items">
                        <?php if (get_sub_field('person-circle')) : ?>
                            <?php
                            $group = get_sub_field('person-circle');
                            if ($group) :
                                foreach($group as $field) :
                                ?>
                                    <div class="p-topPerson__item p-personItem"><p><?php echo $field['person-circle-text']; ?></p></div>

                                <?php
                                endforeach;
                            endif;
                            ?>
                        <?php endif; ?>
                    </div>
                    <p class="p-topPerson__theme c-theme"><?php the_sub_field('person-text'); ?></p>
                    <div class="p-topPerson__wrap">
                        <p class="p-topPerson__text c-text"><?php the_sub_field('person-description'); ?></p>
                        <div class="p-topPerson__video">
                            <?php the_sub_field('person-youtube'); ?>
                        </div>
                    </div>
                <?php
                endwhile;
                endif;
                ?>
                <div class="p-topPerson__link">
                    <a href="<?php echo esc_url(home_url('/employment/person/')); ?>" class="c-button">詳細を見る</a>
                </div>
            </div>
        </div>
    </section>
    <section class="p-topTalk l-topTalk">
        <div class="p-topTalk__inner l-inner">
            <p class="p-topTalk__entitle c-entitle">cross talk</p>
            <h2 class="p-topTalk__title c-title">入社3年目の景色。</h2>
            <div class="p-topTalk__contents u-fadein">
                <?php
                if(have_rows('talk')) :
                while (have_rows('talk')) : the_row();
                ?>
                    <div class="p-topTalk__container">
                        <?php
                        $acf_row_image = get_sub_field('talk-img');
                        $url = $acf_row_image['url'];
                        $alt = $acf_row_image['alt'];
                        if ($url) :
                        ?>
                            <div class="p-topTalk__img c-img">
                                <img src="<?php echo $url; ?>" alt="<?php echo $alt; ?>">
                            </div>
                        <?php endif; ?>
                        <?php if (get_sub_field('talk-bubble')) : ?>
                            <div class="p-topTalk__speechBubbles">
                                <?php
                                $group = get_sub_field('talk-bubble');
                                if ($group) :
                                ?>
                                    <?php foreach($group as $field) : ?>
                                        <div class="p-topTalk__word"><p><?php echo $field['talk-bubble-text']; ?></p></div>
                                    <?php endforeach; ?>
                                <?php endif;?>
                            </div>
                        <?php endif; ?>
                    </div>
                    <div class="p-topTalk__wrap">
                        <p class="p-topTalk__theme c-theme"><?php the_sub_field('talk-text'); ?></p>
                        <p class="p-topTalk__text c-text"><?php the_sub_field('talk-description'); ?></p>
                    </div>
                <?php
                endwhile;
                endif;
                ?>
                <div class="p-topTalk__link">
                    <a href="<?php echo esc_url(home_url('/employment/interview/round-table-discussion/')); ?>" class="c-button">詳細を見る</a>
                </div>
            </div>
        </div>
    </section>
    <section class="p-topResearch l-topResearch">
        <div class="p-topResearch__inner l-inner">
            <p class="p-topResearch__entitle c-entitle">research</p>
            <h2 class="p-topResearch__title c-title">社員39人のホンネ。</h2>
            <div class="p-topResearch__container">
                <?php
                if(have_rows('research')) :
                while (have_rows('research')) : the_row();
                ?>
                    <?php if (get_sub_field('research-block')) : ?>
                        <div class="p-topResearch__items">
                            <?php
                            $num = 0;
                            $group = get_sub_field('research-block');
                            foreach($group as $field) :
                            ?>
                                <div class="p-topResearch__item js-modalOpen">
                                    <p class="p-topResearch__itemText"><?php echo $field['research-block-text']; ?></p>
                                </div>
                                <div class="p-topResearch__modal p-modal js-modal">
                                    <div class="p-modal__inner l-inner">
                                        <div class="p-modal__container">
                                            <div class="p-modal__contents">
                                                <div class="p-modal__close js-close"></div>
                                                <h3 class="p-modal__title"><?php echo $field['research-block-modaltitle']; ?></h3>
                                                <?php if(!($num == 1 || $num == 4)) : ?>
                                                    <div class="p-modal__body">
                                                        <?php
                                                        $acf_row_image = $field['research-block-modalimg'];
                                                        $url = $acf_row_image['url'];
                                                        $alt = $acf_row_image['alt'];
                                                        if ($url) :
                                                        ?>
                                                            <div class="p-modal__img c-img">
                                                                <img src="<?php echo $url; ?>" alt="<?php echo $alt; ?>">
                                                            </div>
                                                        <?php endif; ?>
                                                        <div class="p-modal__num">
                                                            <?php if($field['research-block-num1']) : ?>
                                                                <p><?php echo $field['research-block-num1']; ?></p>
                                                            <?php endif; ?>
                                                            <?php if($field['research-block-num2']) : ?>
                                                                <p><?php echo $field['research-block-num2']; ?></p>
                                                            <?php endif; ?>
                                                            <?php if($field['research-block-num3']) : ?>
                                                                <p><?php echo $field['research-block-num3']; ?></p>
                                                            <?php endif; ?>
                                                            <?php if($field['research-block-num4']) : ?>
                                                                <p><?php echo $field['research-block-num4']; ?></p>
                                                            <?php endif; ?>
                                                        </div>
                                                    </div>
                                                <?php else : ?>
                                                    <div class="p-modal__body p-modal__body--second">
                                                        <?php
                                                        $acf_row_image = $field['research-block-modalimg'];
                                                        $url = $acf_row_image['url'];
                                                        $alt = $acf_row_image['alt'];
                                                        if ($url) :
                                                        ?>
                                                            <div class="p-modal__secondImg">
                                                                <img src="<?php echo $url; ?>" alt="<?php echo $alt; ?>">
                                                            </div>
                                                        <?php endif; ?>
                                                        <p class="p-modal__secondText">※複数回答</p>
                                                    </div>
                                                <?php endif; ?>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            <?php
                            $num++;
                            endforeach;
                            ?>
                        </div>
                    <?php endif; ?>
                    <p class="p-topResearch__theme c-theme"><?php the_sub_field('research-text'); ?></p>
                    <p class="p-topResearch__text c-text"><?php the_sub_field('research-description'); ?></p>
                <?php
                endwhile;
                endif;
                ?>
                <div class="p-topResearch__link">
                    <a href="<?php echo esc_url(home_url('/employment/career/')); ?>" class="c-button">詳細を見る</a>
                </div>
            </div>
        </div>
    </section>
    <section class="p-topBlog l-topBlog">
        <div class="p-topBlog__inner l-inner">
            <p class="p-topBlog__entitle c-entitle">news&blog</p>
            <h2 class="p-topBlog__title c-title">採用ブログ</h2>
            <div class="p-topBlog__container u-fadein">
                <?php
                $the_query = new WP_Query();
                $param = array(
                    'paged'          => $paged,
                    'post_type'      => 'blog',
                    'posts_per_page' => '6',
                    'post_status'    => 'publish',
                );
                $the_query->query($param);
                if ($the_query->have_posts()) :
                ?>
                    <div class="p-topBlog__items">
                        <?php while( $the_query->have_posts() ) : $the_query->the_post(); ?>
                            <div class="p-topBlog__item p-item">
                                <a href="<?php the_permalink(); ?>" class="p-item__img c-img">
                                    <?php
                                    if (has_post_thumbnail()) :
                                        the_post_thumbnail('post-thumbnail', array('alt' => the_title_attribute('echo=0')));
                                    else :
                                        echo '<img src="'.get_template_directory_uri().'/images/common/noimage.jpg" alt="'.esc_html(get_the_title()).'">';
                                    endif; ?>
                                </a>
                                <div class="p-item__body">
                                    <div class="p-item__info">
                                        <time class="p-item__time" datetime="<?php the_time('c'); ?>"><?php the_time( 'Y年m月d日' ); ?></time>
                                        <?php
                                        $terms = get_the_terms($post->ID, 'blog-cat');
                                        if ( $terms ) {
                                            echo '<div class="p-item__categories">';
                                            foreach ( $terms as $term ) {
                                                echo '<a href="'.esc_url(get_term_link($term)).'" class="p-item__category">'.$term->name.'</a>';
                                            }
                                            echo '</div>';
                                        }
                                        ?>
                                    </div>
                                    <h3 class="p-item__title"><?php the_title(); ?></h3>
                                    <p class="p-item__text"><?php remove_filter('the_excerpt', 'wpautop'); the_excerpt();?></p>
                                </div>
                            </div>
                        <?php endwhile; ?>
                    </div>
                <?php
                endif;
                wp_reset_postdata();
                ?>
                <div class="p-topBlog__link">
                    <a href="<?php echo esc_url(home_url('/employment/blog/')); ?>" class="c-button">ブログ一覧を見る</a>
                </div>
            </div>
        </div>
    </section>
</main>
<?php get_footer('employment');