<?php
/**
 * Single blog post template.
 *
 * @package Shabnam_MuchWOW
 */
defined( 'ABSPATH' ) || exit;
get_header();

$single_label    = function_exists( 'shabnam_get_setting' ) ? shabnam_get_setting( 'blog_single_label', 'خواندنی‌ها' ) : 'خواندنی‌ها';
$show_featured   = function_exists( 'shabnam_get_setting' ) ? (bool) shabnam_get_setting( 'blog_show_featured', true ) : true;
$show_sidebar    = function_exists( 'shabnam_get_setting' ) ? (bool) shabnam_get_setting( 'blog_show_sidebar', true ) : true;
$show_tags       = function_exists( 'shabnam_get_setting' ) ? (bool) shabnam_get_setting( 'blog_show_tags', true ) : true;
$show_navigation = function_exists( 'shabnam_get_setting' ) ? (bool) shabnam_get_setting( 'blog_show_navigation', true ) : true;
$show_comments   = function_exists( 'shabnam_get_setting' ) ? (bool) shabnam_get_setting( 'blog_show_comments', true ) : true;
$has_sidebar     = $show_sidebar && is_active_sidebar( 'blog-sidebar' );
?>
<main id="primary" class="shabnam-single-post shabnam-inner-page section panel overflow-hidden">
	<?php if ( function_exists( 'shabnam_get_setting' ) && shabnam_get_setting( 'blog_reading_progress', true ) ) : ?>
		<div class="shabnam-reading-progress" data-shcd-reading-progress aria-hidden="true"><i></i></div>
	<?php endif; ?>
	<div class="section-outer panel py-8 lg:py-10">
		<div class="container sm:max-w-md xl:max-w-lg">
			<?php while ( have_posts() ) : the_post(); ?>
				<article id="post-<?php the_ID(); ?>" <?php post_class( 'panel' ); ?>>
					<header class="sm:max-w-900px mx-auto text-center mb-5 lg:mb-7">
						<div class="category mb-2"><div class="-rotate-2"><span class="fs-5 text-secondary fw-bold"><?php echo esc_html( $single_label ); ?></span></div></div>
						<?php if ( function_exists( 'shabnam_post_meta' ) ) { shabnam_post_meta(); } ?>
						<?php if ( function_exists( 'shabnam_post_secondary_meta' ) ) { shabnam_post_secondary_meta(); } ?>
						<h1 class="h3 sm:h2 xl:display-6 text-white mb-3 mt-2"><?php the_title(); ?></h1>
						<?php if ( has_excerpt() ) : ?><p class="fs-5 xl:fs-4 text-white text-opacity-80"><?php echo esc_html( get_the_excerpt() ); ?></p><?php endif; ?>
					</header>

					<?php if ( $show_featured && has_post_thumbnail() ) : ?>
						<div class="sm:max-w-1100px mx-auto mb-5 lg:mb-7 panel overflow-hidden rounded-3 border border-1 border-gray-100 border-opacity-40"><?php the_post_thumbnail( 'shabnam-hero', array( 'class' => 'w-100 d-block' ) ); ?></div>
					<?php endif; ?>

					<div class="row g-4 lg:g-6 justify-center">
						<div class="<?php echo $has_sidebar ? 'lg:col-8' : 'lg:col-10'; ?>">
							<div class="shabnam-entry-content panel p-3 sm:p-5 lg:p-6 border border-1 border-gray-100 border-opacity-40 rounded-3 bg-white bg-opacity-5 fs-5">
								<?php the_content(); ?>
								<?php wp_link_pages(); ?>
							</div>
							<?php if ( $show_tags && has_tag() ) : ?><div class="shabnam-tags mt-3 fs-6"><?php the_tags( '<span class="text-secondary">#</span> ', ' · ' ); ?></div><?php endif; ?>
							<?php if ( function_exists( 'shabnam_related_posts' ) ) { shabnam_related_posts(); } ?>
							<?php if ( $show_navigation ) : ?><nav class="shabnam-post-navigation mt-5" aria-label="<?php esc_attr_e( 'حرکت میان نوشته‌ها', 'shabnam-muchwow' ); ?>"><?php the_post_navigation( array( 'prev_text' => '→ %title', 'next_text' => '%title ←' ) ); ?></nav><?php endif; ?>
							<?php if ( $show_comments && ( comments_open() || get_comments_number() ) ) : comments_template(); endif; ?>
						</div>
						<?php if ( $has_sidebar ) : ?><aside class="lg:col-4"><div class="vstack gap-3"><?php dynamic_sidebar( 'blog-sidebar' ); ?></div></aside><?php endif; ?>
					</div>
				</article>
			<?php endwhile; ?>
		</div>
	</div>
</main>
<?php get_footer(); ?>
