{{> header}}

<style>
  /* Single Post Article - One Cohesive Container */
  .single-post-page {
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    min-height: 100vh;
    padding: 100px 20px 80px; /* Top padding for fixed header */
  }

  .post-article {
    max-width: 800px;
    margin: 0 auto;
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.4);
    position: relative;
    z-index: 1;
  }

  /* Featured Image - Inside Article */
  .post-featured-image {
    width: 100%;
    aspect-ratio: 16/9;
    overflow: hidden;
    background: rgba(15, 23, 42, 0.5);
    display: block;
    position: relative;
    z-index: 1;
  }
  .post-featured-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: rgba(15, 23, 42, 0.8);
    display: block;
  }

  /* Article Header - Inside Container */
  .post-header {
    padding: 40px 50px 30px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    position: relative;
    z-index: 1;
  }
  .post-category {
    display: inline-block;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    padding: 0.4rem 1rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 1rem;
  }
  .post-title {
    font-size: 2.5rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 1.25rem;
    line-height: 1.25;
    position: relative;
    z-index: 1;
  }
  .post-excerpt {
    font-size: 1.15rem;
    color: #94a3b8;
    line-height: 1.7;
    margin-bottom: 1.5rem;
  }
  .post-meta {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
  }
  .post-meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #64748b;
    font-size: 0.9rem;
  }
  .post-meta-item svg {
    width: 16px;
    height: 16px;
    opacity: 0.7;
  }
  .author-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #6366f1 0%, #10b981 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: white;
  }
  .author-info {
    text-align: left;
  }
  .author-name {
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
  }
  .author-role {
    color: #64748b;
    font-size: 0.8rem;
  }

  /* Post Content - Inside Container */
  .post-content {
    padding: 40px 50px 50px;
    color: #e2e8f0;
    font-size: 1.1rem;
    line-height: 1.9;
    position: relative;
    z-index: 1;
  }

  /* Content images - ensure visibility */
  .post-content img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin: 2rem auto;
    position: relative;
    z-index: 1;
  }

  .post-content h2 {
    color: #fff;
    font-size: 1.75rem;
    margin: 2.5rem 0 1rem;
    font-weight: 700;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid rgba(99, 102, 241, 0.3);
    clear: both;
  }
  .post-content h2:first-child {
    margin-top: 0;
  }
  .post-content h3 {
    color: #a5b4fc;
    font-size: 1.35rem;
    margin: 2rem 0 0.75rem;
    font-weight: 600;
    clear: both;
  }
  .post-content p {
    margin-bottom: 1.25rem;
    color: #cbd5e1;
  }
  .post-content ul, .post-content ol {
    margin: 1rem 0 1.5rem 1.5rem;
    color: #cbd5e1;
    list-style-position: outside;
  }
  .post-content ul {
    list-style-type: disc;
  }
  .post-content ol {
    list-style-type: decimal;
  }
  .post-content li {
    margin-bottom: 0.5rem;
    padding-left: 0.5rem;
  }
  .post-content strong {
    color: #fff;
  }
  .post-content em {
    color: #94a3b8;
  }
  .post-content blockquote {
    background: rgba(99, 102, 241, 0.1);
    border-left: 4px solid #6366f1;
    padding: 1.25rem 1.5rem;
    margin: 1.5rem 0;
    border-radius: 0 12px 12px 0;
    color: #e2e8f0;
    font-style: italic;
    clear: both;
  }
  .post-content blockquote p {
    margin-bottom: 0;
  }
  .post-content a {
    color: #818cf8;
    text-decoration: underline;
  }
  .post-content a:hover {
    color: #a5b4fc;
  }
  .post-content pre, .post-content code {
    background: rgba(15, 23, 42, 0.6);
    border-radius: 8px;
  }
  .post-content pre {
    padding: 1rem 1.25rem;
    overflow-x: auto;
    margin: 1.5rem 0;
  }
  .post-content code {
    padding: 0.2rem 0.5rem;
    font-size: 0.9em;
  }

  /* Ensure figure/figcaption render properly */
  .post-content figure {
    margin: 2rem 0;
    text-align: center;
  }
  .post-content figcaption {
    color: #64748b;
    font-size: 0.9rem;
    margin-top: 0.5rem;
  }

  /* Video/iframe embeds */
  .post-content iframe,
  .post-content video {
    max-width: 100%;
    display: block;
    margin: 2rem auto;
    border-radius: 12px;
  }

  /* Post Footer - Inside Container */
  .post-footer {
    padding: 30px 50px 40px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }
  .post-tags a {
    display: inline-block;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(99, 102, 241, 0.15);
    border-radius: 20px;
    text-decoration: none;
    color: #a5b4fc;
    font-size: 0.85rem;
    transition: all 0.2s;
  }
  .post-tags a:hover {
    background: rgba(99, 102, 241, 0.3);
  }

  @media (max-width: 768px) {
    .single-post-page { padding-top: 80px; }
    .post-header { padding: 30px 25px 25px; }
    .post-title { font-size: 1.75rem; }
    .post-content { padding: 30px 25px 40px; }
    .post-footer { padding: 25px; }
    .post-meta { gap: 1rem; }
  }
</style>

<!-- Single Post Page - One Cohesive Article -->
<div class="single-post-page">
  <article class="post-article">

    <!-- Featured Image (if present) -->
    {{#if post.featuredImage}}
    <div class="post-featured-image">
      <img src="{{post.featuredImage}}" alt="{{post.title}}">
    </div>
    {{/if}}

    <!-- Article Header -->
    <header class="post-header">
      <span class="post-category">📝 Blog</span>
      <h1 class="post-title">{{post.title}}</h1>
      {{#if post.excerpt}}
      <p class="post-excerpt">{{post.excerpt}}</p>
      {{/if}}
      <div class="post-meta">
        <div class="post-meta-item" style="display: flex; align-items: center; gap: 0.6rem;">
          <div class="author-avatar">
            {{#if post.author.name}}{{substring post.author.name 0 1}}{{else}}A{{/if}}
          </div>
          <div class="author-info">
            <div class="author-name">{{#if post.author.name}}{{post.author.name}}{{else}}Author{{/if}}</div>
            <div class="author-role">Author</div>
          </div>
        </div>
        <div class="post-meta-item">
          <svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"></path></svg>
          <span>{{#if post.date}}{{post.date}}{{else}}{{formatDate post.publishedAt}}{{/if}}</span>
        </div>
        <div class="post-meta-item">
          <svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
          <span>5 min read</span>
        </div>
      </div>
    </header>

    <!-- Article Content -->
    <div class="post-content">
      {{{post.content}}}
    </div>

    <!-- Article Footer / Tags -->
    {{#if post.tags}}
    <footer class="post-footer">
      <div class="post-tags">
        {{#each post.tags}}
          <a href="/tag/{{this}}">{{this}}</a>
        {{/each}}
      </div>
    </footer>
    {{/if}}

  </article>

</div>

<!-- Dynamic Recommendations Section -->
{{> recommendations sourceType="post" sourceId=post.id contentType="post" recTitle="📚 Related Posts"}}

{{> footer}}

