<?php
/**
 * The template for displaying comments
 *
 * @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
 */

if ( post_password_required() ) {
	return;
}
?>

<div class="comments-section">
	<?php if ( have_comments() ) : ?>
		<h3 class="comments-title">
			<?php
			$comments_number = get_comments_number();
			if ( '1' === $comments_number ) {
				printf( esc_html_x( 'Comments (%1$s)', 'comments title', 'rosea' ), number_format_i18n( $comments_number ) );
			} else {
				printf( esc_html_x( 'Comments (%1$s)', 'comments title', 'rosea' ), number_format_i18n( $comments_number ) );
			}
			?>
		</h3>

		<?php the_comments_navigation(); ?>

		<ol class="comment-list">
			<?php
			wp_list_comments( array(
				'style'       => 'ol',
				'short_ping'  => true,
				'callback'    => 'rosea_comment',
			) );
			?>
		</ol>

		<?php
		the_comments_navigation();

		if ( ! comments_open() ) {
			?>
			<p class="no-comments"><?php esc_html_e( 'Comments are closed.', 'rosea' ); ?></p>
			<?php
		}
	endif;

	comment_form();
	?>
</div>
