<?php
/**
 * Index template — fallback / blog listing.
 */
get_header();
?>
<header class="mp-page-hero">
  <div class="mp-page-hero-inner">
    <div class="mp-page-eyebrow">
      <?php echo is_home() ? esc_html__( 'Latest from Merchant Pro', 'merchantpro' ) : esc_html__( 'Archive', 'merchantpro' ); ?>
    </div>
    <h1 class="page-title">
      <?php
      if ( is_home() ) {
        single_post_title();
      } elseif ( is_archive() ) {
        the_archive_title();
      } else {
        esc_html_e( 'Blog', 'merchantpro' );
      }
      ?>
    </h1>
  </div>
</header>

<section class="mp-archive">
  <div class="mp-archive-inner">
    <?php if ( have_posts() ) : ?>
      <?php while ( have_posts() ) : the_post(); ?>
        <article class="mp-post-card">
          <div class="mp-post-meta">
            <?php echo esc_html( get_the_date() ); ?>
            <?php if ( has_category() ) : ?>
              · <?php the_category( ', ' ); ?>
            <?php endif; ?>
          </div>
          <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
          <?php the_excerpt(); ?>
        </article>
      <?php endwhile; ?>

      <div class="mp-pagination">
        <?php
        the_posts_pagination( array(
          'mid_size'  => 1,
          'prev_text' => '← ' . esc_html__( 'Newer', 'merchantpro' ),
          'next_text' => esc_html__( 'Older', 'merchantpro' ) . ' →',
        ) );
        ?>
      </div>
    <?php else : ?>
      <article class="mp-post-card">
        <h2><?php esc_html_e( 'No posts found.', 'merchantpro' ); ?></h2>
        <p><?php esc_html_e( 'Try a different search.', 'merchantpro' ); ?></p>
      </article>
    <?php endif; ?>
  </div>
</section>

<?php get_footer(); ?>
