<?php
/**
 * The main template file
 *
 * @package Proto_Previewer
 */

if (!defined('ABSPATH')) exit;

get_header();
?>

<main id="primary" class="site-main">
    <div class="site-container">
        
        <?php if (have_posts()) : ?>
            
            <header class="page-header" style="margin-bottom: 2rem; border-bottom: 2px solid #e2e8f0; padding-bottom: 1rem;">
                <h1 class="page-title"><?php single_post_title(); ?></h1>
            </header>

            <div class="posts-list" style="display: flex; flex-direction: column; gap: 2rem;">
                <?php while (have_posts()) : the_post(); ?>
                    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?> style="background: #fff; border-radius: 1rem; border: 1px solid #e2e8f0; padding: 2rem;">
                        <header class="entry-header">
                            <h2 class="entry-title" style="margin-top: 0;">
                                <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                            </h2>
                            <div class="entry-meta" style="font-size: 0.8rem; color: #64748b; margin-bottom: 1rem;">
                                <?php proto_previewer_posted_on(); ?> <?php proto_previewer_posted_by(); ?>
                            </div>
                        </header>

                        <div class="entry-summary">
                            <?php the_excerpt(); ?>
                        </div>
                    </article>
                <?php endwhile; ?>
            </div>

            <div class="pagination" style="margin-top: 2rem;">
                <?php the_posts_navigation(); ?>
            </div>

        <?php else : ?>
            <div style="background: #fff; padding: 3rem; border-radius: 1rem; border: 1px solid #e2e8f0; text-align: center;">
                <h2>Nothing Found</h2>
                <p>It seems we can't find what you're looking for.</p>
            </div>
        <?php endif; ?>

    </div>
</main>

<?php
get_footer();
