<?php
/*
Template Name: Casino Page
*/
get_header();
?>
<main class="main casino">
    <aside class="sidebar">
        <?php get_template_part('template-part/sidebar'); ?>
        <div class="sidebar__table-content">
            <div class="sidebar__title">
                <p><?php pll_e('Navigation'); ?></p>
                <?php
                $sidebar = get_field('sidebar', 'option');
                $icon = $sidebar['icon'];
                ?>
                <img class="sidebar__arrow" src="<?php echo esc_url($icon['url']); ?>" alt="<?php echo esc_attr($icon['alt']); ?>" title="<?php echo esc_attr($icon['title']); ?>" width="16" />
            </div>
            <ul class="list sidebar__list">
                <?php $block_4 = get_field('block_4');
                $i = 0;
                foreach ($block_4 as $row) :
                    $i++;
                    $title = $row['title'];
                ?>
                    <li>
                        <a href="#content-<?php echo $i; ?>"><?php echo esc_html($title); ?></a>
                    </li>
                <?php endforeach; ?>

                <?php $faq_section = get_field('faq_section');
                $title = $faq_section['title']; ?>
                <li><a href="#10"><?php echo esc_html($title); ?></a></li>
            </ul>
            </nav>

    </aside>
    <div class="main__content">
        <?php
        $block_1 = get_field('block_1');
        $bg_image = $block_1['bg_image'];
        $title = $block_1['title'];
        $text = $block_1['text'];
        ?>
        <section class="section hero">
            <div class="hero__info">
                <?php if (function_exists('kama_breadcrumbs')) kama_breadcrumbs(' '); ?>
                <h1 class="title general"><?php echo $title; ?></h1>
                <p class="hero__desc"><?php echo $text; ?></p>
                <a class="button hero__button" href="<?php echo esc_url($ref_link); ?>"><?php pll_e('Register now'); ?></a>
            </div>
            <div class="background hero__background">
                <img
                    src="<?php echo esc_url($bg_image['url']); ?>"
                    alt="<?php echo esc_attr($bg_image['alt']); ?>"
                    title="<?php echo esc_attr($bg_image['title']); ?>" />
            </div>
        </section>
        <section class="page-nav">
            <div class="sidebar__table-content">
                <div class="sidebar__title">
                    <p><?php pll_e('Navigation'); ?></p>
                    <?php
                    $sidebar = get_field('sidebar', 'option');
                    $icon = $sidebar['icon'];
                    ?>
                    <img class="sidebar__arrow" src="<?php echo esc_url($icon['url']); ?>" alt="<?php echo esc_attr($icon['alt']); ?>" title="<?php echo esc_attr($icon['title']); ?>" width="16" />
                </div>
                <ul class="list sidebar__list">
                    <?php $block_4 = get_field('block_4');
                    $i = 0;
                    foreach ($block_4 as $row) :
                        $i++;
                        $title = $row['title'];
                    ?>
                        <li>
                            <a href="#content-<?php echo $i; ?>"><?php echo esc_html($title); ?></a>
                        </li>
                    <?php endforeach; ?>

                    <?php $faq_section = get_field('faq_section');
                    $title = $faq_section['title']; ?>
                    <li><a href="#10"><?php echo esc_html($title); ?></a></li>
                </ul>
            </div>
        </section>

        <?php $block_2 = get_field('block_2');
        $content = $block_2['content']; ?>
        <section class="section">
            <?php echo $content; ?>
        </section>

        <?php
        $block_3 = get_field('block_3');
        $game_title = $block_3['title'];
        $games_main = $block_3['games_main'];
        $games = $block_3['games'];
        ?>
        <section class="section top">
            <h2 class="title high"><?php echo $game_title; ?></h2>
            <div class="top__info">
                <a class="top__game-main" href="<?php echo esc_url($ref_link); ?>">
                    <img
                        src="<?php echo esc_url($games_main['url']); ?>"
                        alt="<?php echo esc_attr($games_main['alt']); ?>"
                        title="<?php echo esc_attr($games_main['title']); ?>" />
                </a>
                <ul class="list top__list">
                    <?php foreach ($games as $row) :
                        $image = $row['image'];
                    ?>
                        <li>
                            <a href="<?php echo esc_url($ref_link); ?>">
                                <img
                                    src="<?php echo esc_url($image['url']); ?>"
                                    alt="<?php echo esc_attr($image['alt']); ?>"
                                    title="<?php echo esc_attr($image['title']); ?>" />
                            </a>
                        </li>
                    <?php endforeach; ?>
                </ul>
            </div>
        </section>

        <?php
        $block_4 = get_field('block_4');
        $total = count($block_4);
        $i = 0;
        foreach ($block_4 as $row) :
            $i++;
            $title = $row['title'];
            $content = $row['content'];
        ?>
            <section class="section info" id="content-<?php echo esc_attr($i); ?>">
                <h2 class="title high"><?php echo esc_html($title); ?></h2>
                <?php echo $content; ?>
                <?php if ($i % 2 === 0):
                ?>
                    <a href="<?php echo esc_url($ref_link); ?>" class="button info__button">
                        <?php pll_e('Get bonus'); ?>
                    </a>
                <?php endif; ?>
            </section>
        <?php endforeach; ?>

        <?php
        $faq_section = get_field('faq_section');
        $title = $faq_section['title'];
        $faq = $faq_section['faq'];
        if ($faq_section) :
        ?>
            <section class="section faq" id="10">
                <h2 class="title high"><?php echo esc_html($title); ?></h2>
                <ul class="list faq__list">

                    <?php
                    $i = 0;
                    foreach ($faq as $row) :
                        $i++;
                        $title = $row['title'];
                        $text = $row['text'];
                    ?>
                        <li class="faq__item">
                            <div class="faq__question">
                                <h3 class="title low"><?php echo ($i . '. ' . $title); ?></h3>
                            </div>
                            <div class="faq__answer">
                                <p><?php echo esc_html($text); ?></p>
                            </div>
                        </li>
                    <?php endforeach; ?>
                </ul>
            </section>
        <?php endif; ?>
    </div>
    <div class="scroll-up">
        <?php $up_icon = get_field('up_icon', "option"); ?>
        <img
            src="<?php echo esc_url($up_icon['url']); ?>"
            alt="<?php echo esc_attr($up_icon['alt']); ?>"
            title="<?php echo esc_attr($up_icon['title']); ?>" />
    </div>
</main>
<?php
get_footer();
