<?php
/**
 * Page template — inner pages.
 *
 * Renders the standard WP page in the new dark theme:
 *   ┌─────────────────────────────────┐
 *   │  Header (top strip + nav)        │
 *   ├─────────────────────────────────┤
 *   │  .mp-page-hero (title + crumb)   │
 *   ├─────────────────────────────────┤
 *   │  .mp-page-body (scraped content) │
 *   ├─────────────────────────────────┤
 *   │  .mp-cta-strip (quote CTA)       │
 *   ├─────────────────────────────────┤
 *   │  Footer                          │
 *   └─────────────────────────────────┘
 */
get_header();
?>

<?php while ( have_posts() ) : the_post(); ?>

  <header class="mp-page-hero">
    <div class="mp-page-hero-inner">
      <div class="mp-page-eyebrow">
        <?php
        $parent_id = wp_get_post_parent_id( get_the_ID() );
        if ( $parent_id ) {
          echo esc_html( get_the_title( $parent_id ) );
        } else {
          echo esc_html__( 'Merchant Pro', 'merchantpro' );
        }
        ?>
      </div>
      <h1 class="page-title"><?php the_title(); ?></h1>

      <?php
      $excerpt = has_excerpt() ? get_the_excerpt() : '';
      $meta_desc = get_post_meta( get_the_ID(), '_mp_meta_description', true );
      if ( $meta_desc ) {
        printf( '<p class="page-sub">%s</p>', esc_html( $meta_desc ) );
      } elseif ( $excerpt ) {
        printf( '<p class="page-sub">%s</p>', esc_html( wp_strip_all_tags( $excerpt ) ) );
      }
      ?>

      <nav class="mp-breadcrumb" aria-label="Breadcrumb">
        <a href="<?php echo esc_url( home_url( '/' ) ); ?>">Home</a>
        <?php
        if ( $parent_id ) {
          echo '<span>›</span>';
          echo '<a href="' . esc_url( get_permalink( $parent_id ) ) . '">' . esc_html( get_the_title( $parent_id ) ) . '</a>';
        }
        ?>
        <span>›</span>
        <span><?php the_title(); ?></span>
      </nav>
    </div>
  </header>

  <main class="mp-page-body">
    <div class="mp-page-body-inner">
      <?php the_content(); ?>

      <?php
      wp_link_pages( array(
        'before' => '<div class="mp-pagelinks">' . esc_html__( 'Pages:', 'merchantpro' ),
        'after'  => '</div>',
      ) );
      ?>
    </div>
  </main>

  <?php if ( ! is_page( array( 'contact-us', 'contact', 'quote' ) ) ) : ?>
  <section class="mp-cta-strip">
    <h2>Ready to <span class="gold">Eliminate Your Swipe Fees?</span></h2>
    <p>Talk to a 33-year Visa Certified processor. No pressure, no surprises — just a real conversation about your statement.</p>
    <div class="mp-cta-btns">
      <a href="<?php echo esc_url( home_url( '/contact-us/' ) ); ?>" class="btn-solid">Get My Free Savings Analysis →</a>
      <a href="tel:4105731133" class="btn-ghost">📞 410-573-1133</a>
    </div>
  </section>
  <?php endif; ?>

  <?php if ( comments_open() || get_comments_number() ) : ?>
    <div class="mp-page-body" style="border-top:0;padding-top:0">
      <div class="mp-page-body-inner mp-comments">
        <?php comments_template(); ?>
      </div>
    </div>
  <?php endif; ?>

<?php endwhile; ?>

<?php get_footer(); ?>
