<?php get_header(); ?>
<main class="corporate">
    <?php include('template/bottom-corporate-construction.php'); ?>
    <?php include('template/breadcrumb.php'); ?>
    <section class="p-products">
        <div class="p-products__heading">
            <div class="p-products__inner l-inner">
                <div class="p-products__categories p-products__categories--construction">
                    <a href="<?php echo esc_url(home_url('/construction/')); ?>#bridge" class="p-products__category">橋梁事業</a>
                    <a href="<?php echo esc_url(home_url('/construction/')); ?>#maintenance" class="p-products__category">橋梁保全事業</a>
                    <a href="<?php echo esc_url(home_url('/construction/')); ?>#coastal" class="p-products__category">沿岸事業</a>
                    <a href="<?php echo esc_url(home_url('/construction/')); ?>#other" class="p-products__category">その他事業</a>
                </div>
            </div>
            <div id="bridge" class="p-construction">
                <div class="p-construction__wrap">
                    <div class="p-construction__headingInner p-construction__headingInner--reverse">
                        <div class="p-construction__headingBlock p-construction__headingBlock">
                            <?php if (have_rows('bridge', 526)) : ?>
                                <?php while (have_rows('bridge', 526)) : the_row(); ?>
                                    <?php
                                    $acf_row_image = get_sub_field('bridge-img');
                                    $url = $acf_row_image['url'];
                                    $alt = $acf_row_image['alt'];
                                    if ($url) :
                                    ?>
                                        <div class="p-construction__headingBlockImg c-img">
                                            <img src="<?php echo $url; ?>" alt="<?php echo $alt; ?>">
                                        </div>
                                    <?php endif; ?>
                                    <div class="p-construction__headingBlockWrap">
                                        <p class="p-construction__entitle c-entitle c-entitle--capitalize">bridge business</p>
                                        <h2 class="p-construction__title c-title">橋梁事業</h2>
                                        <h3 class="p-construction__headingTheme"><?php the_sub_field('bridge-title'); ?></h3>
                                        <p class="p-construction__headingText c-text"><?php the_sub_field('bridge-text'); ?></p>
                                        <div class="p-construction__link">
                                            <a href="<?php echo esc_url(home_url('/construction-cat/bridge/')); ?>" class="c-link">実績一覧を見る</a>
                                        </div>
                                    </div>
                                <?php endwhile; ?>
                            <?php endif; ?>
                        </div>
                    </div>
                </div>
                <div class="p-construction__inner l-inner">
                    <?php
                    $taxonomy_slug = 'construction-cat';
                    $parent_slug = 'bridge';
                    $parent_id = get_terms($taxonomy_slug, array('slug' => $parent_slug))[0]->term_id;
                    $childs = get_terms($taxonomy_slug, array('parent' => $parent_id));
                    if(!empty($childs) && !is_wp_error($childs)) {
                        echo '<div class="p-construction__bottom">';
                        foreach($childs as $child) {
                            echo '<div class="p-construction__bottomBlock">';
                                // リンクテキストを表示
                                $child_link = get_term_link($child, $taxonomy_slug);
                                echo '<p class="p-post__theme">'. $child->name .'・施工実績検索</p>';
                                // 孫のタームリストを取得
                                $grand_childs = get_terms($taxonomy_slug, array('parent' => $child->term_id));
                                if(!empty($grand_childs) && !is_wp_error($grand_childs)) {
                                    echo '<div class="p-construction__categories">';
                                    foreach($grand_childs as $grand_child) {
                                        // リンクテキストを表示
                                        $grand_child_link = get_term_link($grand_child, $taxonomy_slug);
                                        echo '<a href="'. esc_url(home_url('/construction-cat/'. $parent_slug .'/')). '#track-'. $grand_child->slug .'" class="p-construction__category">'. $grand_child->name .'</a>';
                                    }
                                    echo '</div>';
                                }
                            echo '</div>';
                        }
                        echo '</div>';
                    }
                    ?>
                </div>
            </div>
        </div>
        <div id="maintenance" class="p-construction__section p-construction__section--bg">
            <div class="p-construction__wrap">
                <div class="p-construction__headingInner">
                    <div class="p-construction__headingBlock">
                        <?php if (have_rows('maintenance', 526)) : ?>
                            <?php while (have_rows('maintenance', 526)) : the_row(); ?>
                                <?php
                                $acf_row_image = get_sub_field('maintenance-img');
                                $url = $acf_row_image['url'];
                                $alt = $acf_row_image['alt'];
                                if ($url) :
                                ?>
                                    <div class="p-construction__headingBlockImg c-img">
                                        <img src="<?php echo $url; ?>" alt="<?php echo $alt; ?>">
                                    </div>
                                <?php endif; ?>

                                <div class="p-construction__headingBlockWrap">
                                    <p class="p-construction__entitle c-entitle c-entitle--capitalize">bridge maintenance project</p>
                                    <h2 class="p-construction__title c-title">橋梁保全事業</h2>
                                    <h3 class="p-construction__headingTheme"><?php the_sub_field('maintenance-title'); ?></h3>
                                    <p class="p-construction__headingText c-text"><?php the_sub_field('maintenance-text'); ?></p>
                                    <div class="p-construction__link">
                                        <a href="<?php echo esc_url(home_url('/construction-cat/maintenance/')); ?>" class="c-link">実績一覧を見る</a>
                                    </div>
                                </div>
                            <?php endwhile; ?>
                        <?php endif; ?>
                    </div>
                </div>
            </div>
            <div class="p-construction__inner l-inner">
                <?php
                $taxonomy_slug = 'construction-cat';
                $parent_slug = 'maintenance';
                $parent_id = get_terms($taxonomy_slug, array('slug' => $parent_slug))[0]->term_id;
                $childs = get_terms($taxonomy_slug, array('parent' => $parent_id));
                if(!empty($childs) && !is_wp_error($childs)) {
                    echo '<div class="p-construction__bottom">';
                    foreach($childs as $child) {
                        echo '<div class="p-construction__bottomBlock">';
                            // リンクテキストを表示
                            $child_link = get_term_link($child, $taxonomy_slug);
                            echo '<p class="p-post__theme">'. $child->name .'・施工実績検索</p>';
                            // 孫のタームリストを取得
                            $grand_childs = get_terms($taxonomy_slug, array('parent' => $child->term_id));
                            if(!empty($grand_childs) && !is_wp_error($grand_childs)) {
                                echo '<div class="p-construction__categories">';
                                foreach($grand_childs as $grand_child) {
                                    // リンクテキストを表示
                                    $grand_child_link = get_term_link($grand_child, $taxonomy_slug);
                                    echo '<a href="'. esc_url(home_url('/construction-cat/'. $parent_slug .'/')). '#track-'. $grand_child->slug .'" class="p-construction__category">'. $grand_child->name .'</a>';
                                }
                                echo '</div>';
                            }
                        echo '</div>';
                    }
                    echo '</div>';
                }
                ?>
            </div>
        </div>
        <div id="coastal" class="p-construction__section">
            <div class="p-construction__wrap">
                <div class="p-construction__headingInner p-construction__headingInner--reverse">
                    <div class="p-construction__headingBlock">
                        <?php if (have_rows('coastal', 526)) : ?>
                            <?php while (have_rows('coastal', 526)) : the_row(); ?>
                                <?php
                                $acf_row_image = get_sub_field('coastal-img');
                                $url = $acf_row_image['url'];
                                $alt = $acf_row_image['alt'];
                                if ($url) :
                                ?>
                                    <div class="p-construction__headingBlockImg c-img">
                                        <img src="<?php echo $url; ?>" alt="<?php echo $alt; ?>">
                                    </div>
                                <?php endif; ?>
                                <div class="p-construction__headingBlockWrap">
                                    <p class="p-construction__entitle c-entitle c-entitle--capitalize">coastal business</p>
                                    <h2 class="p-construction__title c-title">沿岸事業</h2>
                                    <h3 class="p-construction__headingTheme"><?php the_sub_field('coastal-title'); ?></h3>
                                    <p class="p-construction__headingText c-text"><?php the_sub_field('coastal-text'); ?></p>
                                    <div class="p-construction__link">
                                        <a href="<?php echo esc_url(home_url('/construction-cat/coast/')); ?>" class="c-link">実績一覧を見る</a>
                                    </div>
                                </div>
                            <?php endwhile; ?>
                        <?php endif; ?>
                    </div>
                </div>
            </div>
            <div class="p-construction__inner l-inner">
                <?php
                $taxonomy_slug = 'construction-cat';
                $parent_slug = 'coast';
                $parent_id = get_terms($taxonomy_slug, array('slug' => $parent_slug))[0]->term_id;
                $childs = get_terms($taxonomy_slug, array('parent' => $parent_id));
                if(!empty($childs) && !is_wp_error($childs)) {
                    echo '<div class="p-construction__bottom">';
                    foreach($childs as $child) {
                        echo '<div class="p-construction__bottomBlock">';
                            // リンクテキストを表示
                            $child_link = get_term_link($child, $taxonomy_slug);
                            echo '<p class="p-post__theme">'. $child->name .'・施工実績検索</p>';
                            // 孫のタームリストを取得
                            $grand_childs = get_terms($taxonomy_slug, array('parent' => $child->term_id));
                            if(!empty($grand_childs) && !is_wp_error($grand_childs)) {
                                echo '<div class="p-construction__categories">';
                                foreach($grand_childs as $grand_child) {
                                    // リンクテキストを表示
                                    $grand_child_link = get_term_link($grand_child, $taxonomy_slug);
                                    echo '<a href="'. esc_url(home_url('/construction-cat/'. $parent_slug .'/')). '#track-'. $grand_child->slug .'" class="p-construction__category">'. $grand_child->name .'</a>';
                                }
                                echo '</div>';
                            }
                        echo '</div>';
                    }
                    echo '</div>';
                }
                ?>
            </div>
        </div>
        <div id="other" class="p-construction__section p-construction__section--bg">
            <div class="p-construction__wrap">
                <div class="p-construction__headingInner">
                    <div class="p-construction__headingBlock">
                        <?php if (have_rows('others', 526)) : ?>
                            <?php while (have_rows('others', 526)) : the_row(); ?>
                                <?php
                                $acf_row_image = get_sub_field('others-img');
                                $url = $acf_row_image['url'];
                                $alt = $acf_row_image['alt'];
                                if ($url) :
                                ?>
                                    <div class="p-construction__headingBlockImg c-img">
                                        <img src="<?php echo $url; ?>" alt="<?php echo $alt; ?>">
                                    </div>
                                <?php endif; ?>
                                <div class="p-construction__headingBlockWrap">
                                    <p class="p-construction__entitle c-entitle c-entitle--capitalize">other business</p>
                                    <h2 class="p-construction__title c-title">その他事業</h2>
                                    <h3 class="p-construction__headingTheme"><?php the_sub_field('others-title'); ?></h3>
                                    <p class="p-construction__headingText c-text"><?php the_sub_field('others-text'); ?></p>
                                    <div class="p-construction__link">
                                        <a href="<?php echo esc_url(home_url('/construction-cat/others/')); ?>" class="c-link">実績一覧を見る</a>
                                    </div>
                                </div>
                            <?php endwhile; ?>
                        <?php endif; ?>
                    </div>
                </div>
            </div>
            <div class="p-construction__inner l-inner">
                <?php
                $taxonomy_slug = 'construction-cat';
                $parent_slug = 'others';
                $parent_id = get_terms($taxonomy_slug, array('slug' => $parent_slug))[0]->term_id;
                $childs = get_terms($taxonomy_slug, array('parent' => $parent_id));
                if(!empty($childs) && !is_wp_error($childs)) {
                    echo '<div class="p-construction__bottom">';
                    foreach($childs as $child) {
                        echo '<div class="p-construction__bottomBlock">';
                            // リンクテキストを表示
                            $child_link = get_term_link($child, $taxonomy_slug);
                            echo '<p class="p-post__theme">'. $child->name .'・施工実績検索</p>';
                            // 孫のタームリストを取得
                            $grand_childs = get_terms($taxonomy_slug, array('parent' => $child->term_id));
                            if(!empty($grand_childs) && !is_wp_error($grand_childs)) {
                                echo '<div class="p-construction__categories">';
                                foreach($grand_childs as $grand_child) {
                                    // リンクテキストを表示
                                    $grand_child_link = get_term_link($grand_child, $taxonomy_slug);
                                    echo '<a href="'. esc_url(home_url('/construction-cat/'. $parent_slug .'/')). '#track-'. $grand_child->slug .'" class="p-construction__category">'. $grand_child->name .'</a>';
                                }
                                echo '</div>';
                            }
                        echo '</div>';
                    }
                    echo '</div>';
                }
                ?>
            </div>
        </div>
        <div id="coastal" class="p-construction__section">
            <div class="p-construction__wrap">
                <div class="p-construction__headingInner p-construction__headingInner--reverse">
                    <div class="p-construction__headingBlock">
                        <div class="p-construction__headingBlockImg c-img">
                            <img src="<?php echo get_stylesheet_directory_uri(); ?>/images/corporate/youtube.png" alt="YouTube">
                        </div>
                        <div class="p-construction__headingBlockWrap">
                            <p class="p-construction__entitle c-entitle c-entitle--capitalize">movie</p>
                            <h2 class="p-construction__title c-title">施工実績</h2>
                            <p class="p-construction__headingText p-construction__headingText--youtube c-text">施工事例を、実際の映像やCGを駆使した動画でご覧いただけます。</p>
                            <div class="p-construction__link">
                                <a href="https://www.youtube.com/@%E4%B8%89%E4%BA%95%E4%BD%8F%E5%8F%8B%E5%BB%BA%E8%A8%AD%E9%89%84%E6%A7%8B%E3%82%A8%E3%83%B3%E3%82%B8%E3%83%8B/videos" target="_blank" rel="noopener noreferrer" class="c-link">施工事例動画を見る</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <?php include('template/others.php'); ?>
    </section>
</main>
<?php get_footer();