<?php
/**
 * Main template file
 *
 * This is the most generic template file in a WordPress theme.
 * Used for blog archive and as a fallback for other templates.
 *
 * @package HomeProz
 */

// Prevent direct access
if (!defined('ABSPATH')) {
    exit;
}

get_header();
?>

<main id="primary" class="site-main">
    <div class="container">
        <?php if (is_home() && !is_front_page()) : ?>
            <header class="archive-header">
                <h1 class="archive-title"><?php single_post_title(); ?></h1>
            </header>
        <?php endif; ?>

        <?php if (have_posts()) : ?>
            <div class="posts-grid">
                <?php
                while (have_posts()) :
                    the_post();
                    get_template_part('template-parts/content/content', 'card');
                endwhile;
                ?>
            </div>

            <?php the_posts_pagination(array(
                'prev_text' => '&larr; Previous',
                'next_text' => 'Next &rarr;',
                'mid_size'  => 2,
            )); ?>

        <?php else : ?>
            <p class="no-posts"><?php esc_html_e('No posts found.', 'homeproz'); ?></p>
        <?php endif; ?>
    </div>
</main>

<?php
get_footer();
