---
import CrushBase from '../../layouts/CrushBase.astro';
import posts from '../../data/posts.json';
---

<CrushBase title="dangrubb.net/blog">
  <div class="page">
    <header class="blog-header">
      <div class="header-logo">
        <img src="/src/img/DanGrubbLogoTeal.png" alt="dangrubb" class="logo-img">
      </div>
      <p class="page-title">
        <span class="title-name">dangrubb</span><span class="title-dot">.</span><span class="title-tld">net</span><span class="title-slash">/</span><span class="title-page">blog</span>
      </p>
      <p class="back-link"><a href="/">← home</a></p>
    </header>

    <div class="blogs-container">
      {posts.map(post => (
        <article class="blog-post" id={post.slug}>
          <h2 class="blog-post-title">{post.title}</h2>
          <div class="blog-post-date">
            {new Date(post.date).toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' })}
          </div>
          <div class="blog-post-content" set:html={post.content} />
          <div class="blog-post-image">
            <img src={post.image} alt={post.title} />
          </div>
        </article>
      ))}
    </div>

    <footer class="blog-footer">
      <a href="/">← home</a>
    </footer>
  </div>
</CrushBase>

<style>
  .page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--crush-white);
  }

  .blog-header {
    text-align: center;
    padding: 30px 20px 20px;
    background: linear-gradient(180deg, #e8f5f5 0%, transparent 100%);
    border-bottom: 3px solid var(--crush-teal);
  }

  .header-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 12px;
  }

  .logo-img {
    width: 60px;
    height: 60px;
    object-fit: contain;
  }

  .page-title {
    font-family: 'Alfa Slab One', 'Georgia', serif;
    font-size: clamp(1.8rem, 5vw, 3rem);
    letter-spacing: -1px;
    line-height: 1;
    margin-bottom: 8px;
  }

  .title-name { color: var(--crush-teal); }
  .title-dot { color: var(--crush-teal-light); }
  .title-tld { color: var(--crush-teal-dark); }
  .title-slash { color: var(--crush-teal); }
  .title-page { color: var(--crush-teal-dark); font-size: 0.7em; }

  .back-link {
    font-size: 0.875rem;
    color: var(--crush-teal);
    margin-top: 4px;
  }
  .back-link a {
    color: var(--crush-teal);
    opacity: 0.7;
  }
  .back-link a:hover { opacity: 1; }

  .blogs-container {
    margin: 30px auto;
    max-width: 700px;
    width: 100%;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .blog-post {
    margin-bottom: 40px;
    padding: 24px;
    border: 1px solid rgba(0, 139, 139, 0.12);
    border-radius: 6px;
    background: linear-gradient(135deg, #f0faf9, #f8f9fa);
    max-width: 700px;
    width: 100%;
  }

  .blog-post-title {
    color: var(--crush-teal);
    font-weight: 700;
    font-size: 1.6rem;
    text-align: center;
    margin-bottom: 6px;
  }

  .blog-post-date {
    color: var(--crush-teal-light);
    font-size: 0.85rem;
    text-align: center;
    margin-bottom: 20px;
    opacity: 0.7;
  }

  .blog-post-content {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #333;
    text-align: center;
  }
  .blog-post-content :global(p) {
    margin: 0 0 15px;
  }

  .blog-post-image {
    display: flex;
    justify-content: center;
    margin-top: 20px;
  }
  .blog-post-image img {
    max-width: 100%;
    height: auto;
    max-height: 60vh;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 102, 102, 0.15);
  }

  .blog-footer {
    text-align: center;
    padding: 30px 20px 40px;
    border-top: 3px solid var(--crush-teal);
    background: linear-gradient(0deg, #e8f5f5 0%, transparent 100%);
    margin-top: auto;
  }
  .blog-footer a {
    color: var(--crush-teal);
    font-weight: 600;
  }

  @media (max-width: 768px) {
    .blog-header { padding: 20px 15px 15px; }
    .logo-img { width: 45px; height: 45px; }
    .blogs-container { padding: 0 15px; }
    .blog-post { padding: 16px; margin-bottom: 24px; }
    .blog-post-title { font-size: 1.3rem; }
  }
</style>
