{{> header}}

<style>
  .archive-page {
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    min-height: 100vh;
    padding: 100px 20px 80px;
    position: relative;
    z-index: 1;
  }
  .archive-container {
    max-width: 900px;
    margin: 0 auto;
  }
  .archive-header {
    text-align: center;
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }
  .archive-header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 0.75rem;
  }
  .archive-header p {
    color: #94a3b8;
    font-size: 1.1rem;
  }
  .posts-grid {
    display: grid;
    gap: 1.5rem;
  }
  .post-card {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 1.75rem;
    transition: all 0.3s ease;
  }
  .post-card:hover {
    border-color: rgba(99, 102, 241, 0.4);
    transform: translateY(-2px);
  }
  .post-card h2 {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
  }
  .post-card h2 a {
    color: #fff;
    text-decoration: none;
    transition: color 0.2s;
  }
  .post-card h2 a:hover {
    color: #818cf8;
  }
  .post-card-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #64748b;
    font-size: 0.85rem;
    margin-bottom: 1rem;
  }
  .post-card-meta span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
  }
  .post-card p {
    color: #94a3b8;
    line-height: 1.7;
    margin-bottom: 1rem;
  }
  .post-card .read-more {
    color: #818cf8;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: color 0.2s;
  }
  .post-card .read-more:hover {
    color: #a5b4fc;
  }
  .pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 3rem;
  }
  .pagination a, .pagination span {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    text-decoration: none;
    transition: all 0.2s;
  }
  .pagination a {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
  }
  .pagination a:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: rgba(99, 102, 241, 0.4);
    color: #fff;
  }
  .pagination .active {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #fff;
    border: none;
  }
  .no-posts {
    text-align: center;
    padding: 4rem 2rem;
    color: #64748b;
  }
  @media (max-width: 768px) {
    .archive-page { padding-top: 80px; }
    .archive-header h1 { font-size: 2rem; }
    .post-card { padding: 1.25rem; }
  }
</style>

<div class="archive-page">
  <div class="archive-container">
    <header class="archive-header">
      <h1>{{archiveTitle}}</h1>
      {{#if archiveDescription}}
        <p>{{archiveDescription}}</p>
      {{/if}}
    </header>

    <!-- Personalized Recommendations for logged-in users -->
    {{> personalized-recommendations contentType="post" recTitle="✨ Recommended for You"}}

    {{#if posts}}
      <div class="posts-grid">
        {{#each posts}}
          <article class="post-card">
            <h2><a href="/post/{{this.slug}}">{{this.title}}</a></h2>
            <div class="post-card-meta">
              {{#if this.author.name}}<span>By {{this.author.name}}</span>{{/if}}
              <span>•</span>
              <span>{{formatDate this.createdAt}}</span>
            </div>
            <p>{{excerpt this.content 150}}</p>
            <a href="/post/{{this.slug}}" class="read-more">Read More →</a>
          </article>
        {{/each}}
      </div>

      {{#if pagination}}
        <nav class="pagination">
          {{#if pagination.prev}}
            <a href="{{pagination.prev}}">← Previous</a>
          {{/if}}

          {{#each pagination.pages}}
            {{#if this.active}}
              <span class="active">{{this.number}}</span>
            {{else}}
              <a href="{{this.url}}">{{this.number}}</a>
            {{/if}}
          {{/each}}

          {{#if pagination.next}}
            <a href="{{pagination.next}}">Next →</a>
          {{/if}}
        </nav>
      {{/if}}
    {{else}}
      <div class="no-posts">
        <p>No posts found.</p>
      </div>
    {{/if}}
  </div>
</div>

{{> footer}}

