<?php get_header(); ?>

<?php while(have_posts()): the_post();  ?>
    <?php
	$post_id = get_the_ID();
	$post_thumbnail = get_the_post_thumbnail_url();
	$post_format = get_post_format();

	$post_style = 'standard';
	$single_class = '';
    $enable_sidebar = true;
    $sidebar_name = 'breek_lite_sidebar_default';

    if( !is_active_sidebar( $sidebar_name ) ){
        $enable_sidebar = false;
        $single_class .= ' no-sidebar';
    }
	?>
	<!-- start: #single -->
	<main id="single" class="main grid-container <?php echo esc_attr($post_style.$single_class); ?>">

		<!-- start: .center -->
	    <div class="center content">

            <!-- start: .epcl-page-wrapper -->
            <div class="epcl-page-wrapper">

                <!-- start: .content -->
                <div class="left-content grid-70 np-mobile">

                    <article <?php post_class('main-article'); ?>>

                        <?php edit_post_link( esc_html__('Edit this post', 'breek-lite'), '', '', '', 'edit-post-button epcl-button dark'); ?>
                    
                        <?php if( $post_style == 'standard'): ?>
                            <?php get_template_part('partials/single/standard'); ?>
                        <?php endif; ?>

                        <section class="post-content">

                            <div class="text">
                                <?php if( breek_lite_get_option('enable_single_toc', 1) ): ?>
                                    <div class="epcl-single-toc <?php if( breek_lite_get_option('single_toc_state', 'closed') == 'open') echo 'active open'; ?>" data-heading-selector="<?php echo esc_attr( breek_lite_get_option('toc_heading_selector', "h1, h2, h3, h4, h5") ); ?>">
                                        <div class="toggle-title"><?php echo esc_html__("Table of Contents", 'breek-lite'); ?><svg class="epcl-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M11.9997 13.1714L16.9495 8.22168L18.3637 9.63589L11.9997 15.9999L5.63574 9.63589L7.04996 8.22168L11.9997 13.1714Z"></path></svg></div>
                                        <div class="toggle-content epcl-toc border-effect" <?php if( breek_lite_get_option('single_toc_state', 'closed') == 'open') echo 'style="display:block;"'; ?>></div>
                                    </div>
                                <?php endif; ?>
                                <?php the_content(); ?>
                                <?php
                                    if ( is_singular( 'attachment' ) ) {
                                        echo '<h2 class="title usmall">'.esc_html__('Published in:', 'breek-lite').'</h2>';
                                        // Parent post navigation.
                                        the_post_navigation();
                                    }
                                ?>
                            </div>
                            <div class="clear"></div>

                            <?php if( function_exists('breek_lite_render_copy_permalink') && breek_lite_get_option('enable_share_buttons', true)  ): ?>
                                <div class="share-buttons section">
                                    <?php breek_lite_render_copy_permalink(); ?>
                                </div>
                            <?php endif; ?> 

                        </section>

                        <?php if( get_the_tags() ): ?>
                            <div class="bottom-tags">
                                <i class="remixicon remixicon-price-tag-3-line"></i>
                                <?php the_tags(''); ?>
                            </div>
                        <?php endif; ?>

                        <?php
                            $link_pages_args = array(
                                'before'           => '<div class="epcl-pagination link-pages section"><div class="nav"><span class="page-number">'.esc_html__( 'Pages', 'breek-lite' ).'</span>',
                                'after'            => '</div></div>',
                                'link_before'      => '',
                                'link_after'       => '',
                                'next_or_number'   => 'number',
                                'separator'        => '',
                                'nextpagelink'     => esc_html__( 'Next', 'breek-lite'),
                                'previouspagelink' => esc_html__( 'Previous', 'breek-lite' ),
                                'pagelink'         => '<span class="page-number">%</span>',
                                'echo'             => 1
                            );
                            wp_link_pages( $link_pages_args );
                        ?>

                    </article>
                    <div class="clear"></div>

                    <?php if( breek_lite_get_option('enable_single_author', 1) ): ?>
                        <?php get_template_part('partials/author-box'); ?>
                    <?php endif; ?>

                    <?php if( breek_lite_get_option('siblings_posts', 1) ): ?>

                        <section class="related section">
                            <?php                       
                            $prev_post = get_previous_post();
                            $prev_thumb = $prev_url = '';
                            if( !empty($prev_post) ){
                                $prev_url = get_the_permalink($prev_post->ID);
                                $prev_thumb = get_the_post_thumbnail_url($prev_post->ID, 'medium_large');
                            }
                            ?>
                            <?php if( !empty($prev_post) ): ?>
                                <article class="prev grid-50 tablet-grid-50 grid-parent">
                                    <?php if($prev_thumb): ?>
                                        <div class="thumb cover" style="background: url('<?php echo esc_url($prev_thumb); ?>');"></div>    
                                    <?php endif; ?>
                                    <a href="<?php echo esc_url($prev_url); ?>" class="full-link"></a>                              
                                    <div class="info">
                                        <?php if( breek_lite_get_option('enable_global_date') !== '0' ): ?>
                                            <time datetime="<?php echo get_the_time('Y-m-d', $prev_post); ?>">
                                                <?php echo get_the_time( get_option('date_format'), $prev_post ); ?>
                                            </time>
                                        <?php endif; ?>
                                        <h4 class="title white no-margin"><?php echo get_the_title($prev_post->ID); ?></h4>
                                    </div>                                
                                    <span class="epcl-button red"><img src="<?php echo BREEK_LITE_THEMEPATH; ?>/assets/images/left-arrow.svg" width="15" alt="<?php esc_attr_e('Left Arrow', 'breek-lite'); ?>"></span>
                                    <div class="overlay"></div>
                                </article>
                            <?php endif; ?>

                            <?php
                            $next_post = get_next_post();
                            $next_thumb = $next_url = '';
                            if( !empty($next_post) ){
                                $next_url = get_the_permalink($next_post->ID);
                                $next_thumb = get_the_post_thumbnail_url($next_post->ID, 'breek_lite_single_content');
                            }
                            ?>
                            <?php if( !empty($next_post) ): ?>
                                <article class="next grid-50 tablet-grid-50 grid-parent">
                                    <?php if($next_thumb): ?>  
                                        <div class="thumb cover" style="background: url('<?php echo esc_url($next_thumb); ?>');"></div>                      
                                    <?php endif; ?>
                                    <a href="<?php echo esc_url($next_url); ?>" class="full-link"></a>                            
                                    <div class="info">
                                        <?php if( breek_lite_get_option('enable_global_date') !== '0' ): ?>
                                            <time datetime="<?php echo get_the_time('Y-m-d', $next_post); ?>">
                                                <?php echo get_the_time( get_option('date_format'), $next_post ); ?>
                                            </time>
                                        <?php endif; ?>
                                        <h4 class="title white no-margin"><?php echo get_the_title($next_post->ID); ?></h4>                                
                                    </div>
                                    <span class="epcl-button red"><img src="<?php echo BREEK_LITE_THEMEPATH; ?>/assets/images/right-arrow.svg" width="15" alt="<?php esc_attr_e('Right Arrow', 'breek-lite'); ?>"></span>
                                    <div class="overlay"></div>
                                </article>
                            <?php endif; ?>
                            <div class="clear"></div>
                        </section>

                    <?php endif; ?>

                    <div class="clear"></div>

                    <?php comments_template(); ?>            

                    <div class="clear"></div>
                </div>
                <!-- end: .content -->

                <?php get_sidebar(); ?>

            </div>
            <!-- end: .epcl-page-wrapper -->            
        
        </div>
        <!-- end: .center -->

	</main>
	<!-- end: #single -->

<?php endwhile; ?>

<?php get_footer(); ?>
