<?php get_header(); ?>

<!-- About Section -->
<?php
$ha_desc        = get_field('ha_desc', 'option');
$ha_button      = get_field('ha_button', 'option');

if ($ha_desc) :
?>

    <div class="about fade-in">
        <div class="wrapper">
            <?php
            if ($ha_desc) :
                echo '<div class="desc">' . $ha_desc . '</div>';
            endif;

            if ($ha_button['link'] && $ha_button['text']) :
                echo '<a href="' . $ha_button['link'] . '" target="' . $ha_button['target'] . '" class="common-btn">';
                echo $ha_button['text'];
                echo '<svg> <use xlink:href="#btn_arr"></use> </svg>';
                echo '</a>';
            endif;
            ?>
        </div>
    </div>

<?php
endif;
?>

<!-- Collection Section -->
<?php
$hb_heading_level   = get_field('hb_heading_level', 'option');
$hb_heading         = get_field('hb_heading', 'option');
$hb_heading_link    = get_field('hb_heading_link', 'option');
$hb_desc            = get_field('hb_desc', 'option');
$hb_items           = get_field('hb_items', 'option');

if ($hb_items) :
?>

    <div class="collection fade-in">
        <div class="wrapper">
            <div class="col-1">
                <?php
                if ($hb_heading && $hb_heading_level) :
                    // Linked only when the optional Heading Link field is filled in.
                    $hb_heading_html = $hb_heading;
                    if ($hb_heading_link) :
                        $hb_heading_html = '<a href="' . esc_url($hb_heading_link) . '">' . $hb_heading . '</a>';
                    endif;

                    echo '<' . $hb_heading_level . ' class="common-heading">' . $hb_heading_html . '</' . $hb_heading_level . '>';
                endif;

                if ($hb_desc) :
                    echo '<div class="desc">' . $hb_desc . '</div>';
                endif;
                ?>
            </div>
            <div class="col-2">
                <div class="collection-slider owl-carousel">
                    <?php
                    foreach ($hb_items as $hb) :
                        $hb_image       = $hb['hb_image'];
                        $hb_image_url   = validateImage(800, 800, $hb_image);
                        $hb_image_alt   = validateImageAlt($hb_image);
                        $hb_title       = $hb['hb_title'];
                        $hb_link        = $hb['hb_link'];
                    ?>
                        <a href="<?php echo $hb_link; ?>" class="item">
                            <div class="image">
                                <img src="<?php echo $hb_image_url; ?>" alt="<?php echo $hb_image_alt; ?>">
                            </div>
                            <div class="title">
                                <?php echo $hb_title; ?>
                            </div>
                        </a>
                    <?php
                    endforeach;
                    ?>
                </div>
            </div>
        </div>
    </div>

<?php
endif;
?>

<!-- Community Section -->
<?php
$hc_heading_level   = get_field('hc_heading_level', 'option');
$hc_heading         = get_field('hc_heading', 'option');
$hc_quote           = get_field('hc_quote', 'option');
$hc_item            = get_field('hc_item', 'option');

if ($hc_item) :
?>

    <div class="community fade-in">
        <div class="wrapper">
            <div class="col-1">
                <?php
                if ($hc_heading && $hc_heading_level) :
                    echo '<' . $hc_heading_level . ' class="common-heading">' . $hc_heading . '</' . $hc_heading_level . '>';
                endif;
                ?>
            </div>
            <div class="col-2">
                <div class="community-slider owl-carousel">
                    <?php
                    foreach ($hc_item as $hc) :
                        $hc_image           = $hc['hc_image'];
                        $hc_image_url       = validateImage(800, 800, $hc_image);
                        $hc_image_alt       = validateImageAlt($hc_image);
                        $hc_title           = $hc['hc_title'];
                        $hc_instagram_link  = $hc['hc_instagram_link'];
                    ?>
                        <?php if ($hc_instagram_link) : ?>
                            <a href="<?php echo $hc_instagram_link; ?>" class="item" target="_blank">
                                <div class="image">
                                    <img src="<?php echo $hc_image_url; ?>" alt="<?php echo $hc_image_alt; ?>">
                                </div>
                                <div class="title">
                                    <?php echo $hc_title; ?>
                                </div>
                            </a>
                        <?php else : ?>
                            <div class="item">
                                <div class="image">
                                    <img src="<?php echo $hc_image_url; ?>" alt="<?php echo $hc_image_alt; ?>">
                                </div>
                                <div class="title">
                                    <?php echo $hc_title; ?>
                                </div>
                            </div>
                        <?php endif; ?>
                    <?php
                    endforeach;
                    ?>
                </div>
                <div class="quote">
                    <?php echo $hc_quote; ?>
                </div>
            </div>
        </div>
    </div>

<?php
endif;
?>

<?php get_footer(); ?>