<?php
// Page: Home
// ID: 7

get_header();

$blog_args = array(
    'post_type'      => 'post',
    'posts_per_page' => 5,
	'orderby'        => 'date',
	'order'          => 'DESC',
);

$blog_posts = new WP_Query( $blog_args );

$box_1 = get_field('box_1');
$box_2 = get_field('box_2');
$box_3 = get_field('box_3');
$box_4 = get_field('box_4');
$box_5 = get_field('box_5');
?>
<main id="primary" class="site-main">
    <section class="box-1" id="interaktywny-model">
        <div class="box-bg">
            <img src="/wp-content/uploads/2025/10/img-2.svg" alt="">
        </div>
        <div class="container">
            <div class="row">
                <div class="col-1">
                    <div class="box-mini-title">
                        <p><?php echo $box_1['mini_title']; ?></p>
                    </div>
                    <div class="box-title">
                        <h2><?php echo $box_1['title']; ?></h2>
                    </div>
                    <div class="box-text">
                        <p><?php echo $box_1['text']; ?></p>
                    </div>
                </div>
                <div class="col-2">
                    <div class="advanced-posts-box">
                        <div class="advanced-posts-bg">
                            <img src="/wp-content/uploads/2025/10/Frame-365.svg" alt="">
                        </div>

                        <div class="advanced-posts-list">
                            <ol>
                                <li class="lvl-1" style="--size: 120px; --bg: #583967;">
                                    <?php if ($box_1['posts_list']['lvl_1']['post_1']['url']): ?>
                                    <a href="<?php echo $box_1['posts_list']['lvl_1']['post_1']['url']; ?>">
                                        <span><?php echo $box_1['posts_list']['lvl_1']['post_1']['title']; ?></span>
                                    </a>
                                    <?php endif; ?>
                                </li>
                                <li class="lvl-1" style="--size: 120px; --bg: #583967;">
                                    <?php if ($box_1['posts_list']['lvl_1']['post_2']['url']): ?>
                                    <a href="<?php echo $box_1['posts_list']['lvl_1']['post_2']['url']; ?>">
                                        <span><?php echo $box_1['posts_list']['lvl_1']['post_2']['title']; ?></span>
                                    </a>
                                    <?php endif; ?>
                                </li>
                                <li class="lvl-1" style="--size: 120px; --bg: #583967;">
                                    <?php if ($box_1['posts_list']['lvl_1']['post_3']['url']): ?>
                                    <a href="<?php echo $box_1['posts_list']['lvl_1']['post_3']['url']; ?>">
                                        <span><?php echo $box_1['posts_list']['lvl_1']['post_3']['title']; ?></span>
                                    </a>
                                    <?php endif; ?>
                                </li>
                                
                                <li class="lvl-2" style="--size: 88px; --bg: #9c7ea4;">
                                    <?php if ($box_1['posts_list']['lvl_2']['post_1']['url']): ?>
                                    <a href="<?php echo $box_1['posts_list']['lvl_2']['post_1']['url']; ?>">
                                        <span><?php echo $box_1['posts_list']['lvl_2']['post_1']['title']; ?></span>
                                    </a>
                                    <?php endif; ?>
                                </li>
                                <li class="lvl-2" style="--size: 88px; --bg: #9c7ea4;">
                                    <?php if ($box_1['posts_list']['lvl_2']['post_2']['url']): ?>
                                    <a href="<?php echo $box_1['posts_list']['lvl_2']['post_2']['url']; ?>">
                                        <span><?php echo $box_1['posts_list']['lvl_2']['post_2']['title']; ?></span>
                                    </a>
                                    <?php endif; ?>
                                </li>
                                <li class="lvl-2" style="--size: 88px; --bg: #9c7ea4;">
                                    <?php if ($box_1['posts_list']['lvl_2']['post_3']['url']): ?>
                                    <a href="<?php echo $box_1['posts_list']['lvl_2']['post_3']['url']; ?>">
                                        <span><?php echo $box_1['posts_list']['lvl_2']['post_3']['title']; ?></span>
                                    </a>
                                    <?php endif; ?>
                                </li>
                                
                                <li class="lvl-3" style="--size: 44px; --bg: #d5c9df;">
                                    <?php if ($box_1['posts_list']['lvl_3']['post_1']['url']): ?>
                                    <a href="<?php echo $box_1['posts_list']['lvl_3']['post_1']['url']; ?>">
                                        <span><?php echo $box_1['posts_list']['lvl_3']['post_1']['title']; ?></span>
                                    </a>
                                    <?php endif; ?>
                                </li>
                                <li class="lvl-3" style="--size: 44px; --bg: #d5c9df;">
                                    <?php if ($box_1['posts_list']['lvl_3']['post_2']['url']): ?>
                                    <a href="<?php echo $box_1['posts_list']['lvl_3']['post_2']['url']; ?>">
                                        <span><?php echo $box_1['posts_list']['lvl_3']['post_2']['title']; ?></span>
                                    </a>
                                    <?php endif; ?>
                                </li>
                            </ol>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <section class="box-2">
        <div class="box-bg">
            <img src="/wp-content/uploads/2025/10/img-3.svg" alt="">
        </div>
        <div class="container">
            <div class="row">
                <div class="col-1">
                    <div class="box-title">
                        <h2><?php echo $box_2['title']; ?></h2>
                    </div>
                    <div class="box-text">
                        <?php echo $box_2['text']; ?>
                    </div>
                    <ul class="box-nav">
                        <li>
                            <?php if ($box_2['btn']['title']): ?>
                            <a class="btn-1" href="<?php echo $box_2['btn']['url']; ?>"><?php echo $box_2['btn']['title']; ?></a>
                            <?php endif; ?>
                        </li>
                    </ul>
                </div>
                <div class="col-2">
                    <div class="box-img">
                        <img src="<?php echo $box_2['img']; ?>" alt="">
                    </div>
                </div>
            </div>
        </div>
    </section>

    <section class="box-3" id="5-kluczowych-tekstow">
        <div class="box-bg">
            <img src="/wp-content/uploads/2025/10/img-5.svg" alt="">
        </div>
        <div class="container">
            <div class="row row-1">
                <div class="box-title">
                    <h2><?php echo $box_3['title']; ?></h2>
                </div>
            </div>
            <div class="row row-2">
                <div class="box-list">
                    <?php foreach ($box_3['posts'] as $item) : ?>
                        <?php
                            get_template_part('inc/template-article-card', null, [
                                'post_id'  => $item['post']->ID,
                                'image' => get_the_post_thumbnail_url($item['post']->ID),
                                'title' => $item['post']->post_title,
                                'link'  => get_the_permalink($item['post']->ID),
								// 'category' => get_the_category($item->ID)
                            ]);
                        ?>
                    <?php endforeach; ?>
                    <?php
                        get_template_part('inc/template-article-more-card', null, [
                            'image' => $box_3['img'],
                            'title' => $box_3['text'],
                            'link_text' => 'Zobacz wszystkie artykuły',
                            'link'  => get_permalink(94),
                        ]);
                    ?>
                </div>
            </div>
        </div>
    </section>

    <section class="box-4">
        <div class="box-bg">
            <img src="/wp-content/uploads/2025/10/img-6.svg" alt="">
        </div>
        <div class="container">
            <div class="row">
                <div class="col col-1">
                    <div class="box-img">
                        <img src="<?php echo $box_4['img']; ?>" alt="">
                    </div>
                </div>
                <div class="col col-2">
                    <div class="box-title">
                        <h2><?php echo $box_4['title']; ?></h2>
                    </div>
                    <div class="box-text">
                        <?php echo $box_4['text']; ?>
                    </div>
                    <ul class="box-nav">
                        <li>
                            <?php if ($box_4['btn']['title']): ?>
                            <a class="btn-2" href="<?php echo $box_4['btn']['url']; ?>"><?php echo $box_4['btn']['title']; ?></a>
                            <?php endif; ?>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </section>

    <section class="box-5">
        <div class="box-bg">
            <img src="/wp-content/uploads/2025/10/img-7.svg" alt="">
        </div>
        <div class="container">
            <div class="row">
                <div class="col col-1">
                    <div class="box-title">
                        <h2><?php echo $box_5['title']; ?></h2>
                    </div>
                    <div class="box-text">
                        <?php echo $box_5['text']; ?>
                    </div>
                    <ul class="box-nav">
                        <li>
                            <?php if ($box_5['btn']['title']): ?>
                            <a class="btn-3" href="<?php echo $box_5['btn']['url']; ?>"><?php echo $box_5['btn']['title']; ?></a>
                            <?php endif; ?>
                        </li>
                    </ul>
                </div>
                <div class="col col-2">
                    <div class="box-img">
                        <img src="<?php echo $box_5['img']; ?>" alt="">
                    </div>
                </div>
            </div>
        </div>
    </section>
</main>
<?php get_footer(); ?>