<?php
/**
 * The template for displaying all single posts
 *
 * @package Rosea
 *
 * This file is part of the Rosea WordPress theme.
 *
 * Rosea WordPress Theme, Copyright 2026 nopStation
 * Rosea is distributed under the terms of the GNU General Public License v2 or later.
 *
 * @license GPL-2.0-or-later
 * @license URI: https://www.gnu.org/licenses/gpl-2.0.html
 */

get_header();
?>

<main id="main" role="main">
<!--blog main content-->
<div class="blog-page-container">
	<!-- Breadcrumb -->
	<div class="breadcrumb-section">
		<div class="container">
			<nav aria-label="breadcrumb">
				<ol class="breadcrumb">
					<li class="breadcrumb-item"><a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php esc_html_e( 'Home', 'rosea' ); ?></a></li>
					<?php
					$categories = get_the_category();
					if ( ! empty( $categories ) ) {
						?>
						<li class="breadcrumb-item"><a href="<?php echo esc_url( get_category_link( $categories[0]->term_id ) ); ?>"><?php echo esc_html( $categories[0]->name ); ?></a></li>
						<?php
					}
					?>
					<li class="breadcrumb-item active" aria-current="page"><?php echo esc_html( get_the_title() ); ?></li>
				</ol>
			</nav>
		</div>
	</div>
	
	<div class="blog-content-wrapper">
		<!-- Blog Posts -->
		<div class="blog-posts">
			<?php
			while ( have_posts() ) :
				the_post();
				?>
				<!-- Single Post -->
				<article class="blog-post">
					<h2 class="single-post-title"><?php the_title(); ?></h2>
					<div class="post-meta">
						<P class="post-date">
							<i class="far fa-calendar"></i> <?php echo esc_html( get_the_date() ); ?>
						</P>
						<P class="post-author">
							<i class="far fa-user"></i> <a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>"><?php echo esc_html( get_the_author() ); ?></a>
						</P>
						<?php
						$categories = get_the_category();
						if ( ! empty( $categories ) ) {
							?>
							<p class="post-category">
								<i class="far fa-folder"></i> <a href="<?php echo esc_url( get_category_link( $categories[0]->term_id ) ); ?>"><?php echo esc_html( $categories[0]->name ); ?></a>
							</p>
							<?php
						}
						?>
					</div>
					
					<?php
					if ( has_post_thumbnail() ) {
						?>
						<div class="post-featured-image">
							<?php the_post_thumbnail( 'large' ); ?>
						</div>
						<?php
					}
					?>
					
					<div class="post-content">
						<?php
						the_content();

						wp_link_pages( array(
							'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'rosea' ),
							'after'  => '</div>',
						) );
						?>
					</div>
					
					<?php
					$tags = get_the_tags();
					if ( $tags ) {
						?>
						<div class="post-tags">
							<span><i class="fas fa-tags"></i> Tags:</span>
							<?php
							foreach ( $tags as $tag ) {
								echo '<a href="' . esc_url( get_tag_link( $tag->term_id ) ) . '">' . esc_html( $tag->name ) . '</a>';
							}
							?>
						</div>
						<?php
					}
					?>
				</article>
				
				<!-- Post Navigation -->
				<div class="post-navigation">
					<?php
					$prev_post = get_previous_post();
					if ( $prev_post ) {
						?>
						<div class="nav-previous">
							<a href="<?php echo esc_url( get_permalink( $prev_post->ID ) ); ?>">
								<i class="fas fa-arrow-left"></i>
								<div class="nav-content">
									<div class="nav-label"><?php esc_html_e( 'Previous Post', 'rosea' ); ?></div>
									<div class="nav-title"><?php echo esc_html( get_the_title( $prev_post->ID ) ); ?></div>
								</div>
							</a>
						</div>
						<?php
					}

					$next_post = get_next_post();
					if ( $next_post ) {
						?>
						<div class="nav-next">
							<a href="<?php echo esc_url( get_permalink( $next_post->ID ) ); ?>">
								<div class="nav-content">
									<div class="nav-label"><?php esc_html_e( 'Next Post', 'rosea' ); ?></div>
									<div class="nav-title"><?php echo esc_html( get_the_title( $next_post->ID ) ); ?></div>
								</div>
								<i class="fas fa-arrow-right"></i>
							</a>
						</div>
						<?php
					}
					?>
				</div>
				
				<!-- Comments Section -->
				<?php
				if ( comments_open() || get_comments_number() ) {
					comments_template();
				}
				?>
				<?php
			endwhile;
			?>
		</div>
		
		<?php get_sidebar(); ?>
	</div>
</div>
<!--blog main content-->
</main>

<?php
get_footer();
