<?php get_header(); ?>
<?php $opts = get_option('akademic_master_options', array()); ?>

<div class="site-container" style="grid-template-columns: 1fr; lg:grid-template-columns: 8fr 4fr; gap:36px; padding: 24px 0;">
  
  <article class="article-body" style="min-width:0;">
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
      
      <!-- Breadcrumbs -->
      <nav class="breadcrumb" style="font-size:0.875rem; color:var(--text-secondary); margin-bottom:12px;">
        <a href="<?php echo esc_url(home_url('/')); ?>" style="color:var(--accent); text-decoration:none;">Home</a> &raquo;
        <span><?php the_category(', '); ?></span> &raquo;
        <span><?php the_title(); ?></span>
      </nav>

      <h1 class="entry-title" style="font-size:2.25rem; line-height:1.25; font-family:Georgia, serif; margin-bottom:12px; color:var(--text-primary);">
        <?php the_title(); ?>
      </h1>

      <!-- Authority Meta -->
      <div class="entry-meta" style="font-size:0.875rem; color:var(--text-secondary); border-bottom:1px solid var(--border-color); padding-margin-bottom:24px; display:flex; flex-wrap:wrap;align-items:center;">: <strong>Academic Editorial Board</strong></span> |
          <span>📅 Updated: <?php echo get_the_modified_date(); ?></span> | 
          <span>⏱️ Reading Time: ± <?php echo max(1, round(str_word_count(strip_tags(get_the_content())) / 200)); ?> min</span>
        </div>
        <div class="lang-links" style="font-size:0.8rem; display:flex; gap:6px;">
          <span style="color:var(--text-secondary);"><strong style="color:var(--accent);">Global (EN)</strong>
        </div>
      </div>

      <!-- Header Ad Slot (Anti-CLS) -->
      <?php if (!empty($opts['ad_header_slot'])) : ?>
        <div class="adsense-slot adsense-header" style="min-height:90px; margin-bottom:24px; text-align:center;">
          <?php echo $opts['ad_header_slot']; ?>
        </div>
      <?php endif; ?>

      <!-- Table of Contents -->
      <div class="table-of-contents" style="background:var(--bg-secondary); border:1px solid var(--border-color); border-radius:8px; padding:16px; margin-bottom:24px;">
        <h4 style="margin:0 0 10px 0; font-display:flex; align-items:center; gap:8px;"> of Contents
        </h4>
        <div style="font-size:0.875rem; color:var(--accent); display:flex; flex-direction:column; gap:6px;">
          <a href="#section-1" style="color:var(--accent); text-decoration:none;">1. Overview & Core Significance</a>
          <a href="#section-2" style="color:var(--accent); text-decoration:none;">2. Background & Historical Context</a>
          <a href="#section-3" style="color:var(--accent); text-decoration:none;">3. Analysis & Key Characteristics</a>
          <a href="#section-4" style="color:var(--accent); text-decoration:none;">4. Impact, Influence & Legacy</a>
          <a href="#section-5" style="color:var(--accent); text-decoration:none;">5. References & Academic Citations</a>
        </div>
      </div>

      <!-- Article Content -->
      <div class="entry-content" style="line-height:1.8; font-size:1.05rem; font-family:var(--font-body, serif);">
        <?php the_content(); ?>
      </div>

    <?php endwhile; endif; ?>
  </article>

  <!-- Sidebar -->
  <aside class="sidebar" style="position:sticky; top:20px; align-self:start;">
    <div style="background:var(--bg-secondary); border:1px solid var(--border-color); border-radius:8px; padding:20px; margin-bottom:24px;">
      <h3 style="margin-top:0; font-size:1.125rem; border-bottom:2px solid var(--accent); padding-bottom:8px;">
        🏛️ Encyclopedia Navigation
      </h3>
      <p style="font-size:0.875rem; color:var(--text-secondary);">
        Explore peer-reviewed academic archives and verified knowledge entries.
      </p>
      <?php get_search_form(); ?>
    </div>

    <!-- Sticky Sidebar Ad Slot -->
    <?php if (!empty($opts['ad_sidebar_slot'])) : ?>
      <div class="adsense-slot adsense-sidebar" style="min-height:300px; margin-bottom:24px; text-align:center;">
        <?php echo $opts['ad_sidebar_slot']; ?>
      </div>
    <?php endif; ?>
  </aside>

</div>

<?php get_footer(); ?>