<?php
/**
 * Single Posts
 *
 * @package CWC
 * @since 1.0.0
 */

namespace CWC;

get_header();

// Determine classes based on sidebar presence
if ( hasSidebar() ) {
	$classes  = 'container grid grid-cols-1 lg:grid-cols-4 gap-8 xl:gap-16 my-section mx-auto';
	$clsEntry = 'lg:col-span-3';
} else {
	$classes = 'container my-section lg:my-0 mx-auto';
}
?>

<article class="<?php echo esc_attr( $classes ); ?>">
	<div class="entry-content <?php echo esc_attr( $clsEntry ); ?>">
		<?php
		if ( have_posts() ) {
			while ( have_posts() ) {
				the_post();
				?>

                <div class="post-img">
                    <?php if ( has_post_thumbnail() ) : ?>
                        <img src="<?php the_post_thumbnail_url( 'full' ); ?>" alt="<?php the_title(); ?>" class="w-full h-auto mb-6">
                    <?php endif; ?>
                </div>

				<div class="post-title mb-0">
					<h1 class=""><?php the_title(); ?></h1>

                    <div class="post-subtitle text-28px font-quincy font-bold m-0 mb-6 p-0 leading-none text-cwc-blue-02">
                        <?php the_field( 'subtitle' ); ?>
                    </div>
				</div>

				<div class="post-meta text-14px text-cwc-orange-01 uppercase font-bold mb-6">
					<div class="">
						<span class="post-date">Posted: <?php the_date(); ?></span> | <span class="post-author">Posted by: <?php echo esc_html( ucfirst( get_the_author() ) ); ?></span>
					</div>
				</div>

                <div class="post-content font-light">
                    <?php the_content(); ?>
                </div>
                <?php
			}
		}
		?>
	</div>

	<?php if ( hasSidebar() ) : ?>
		<?php get_sidebar(); ?>
	<?php endif; ?>
</article>

<?php get_footer(); ?>
