---
import Base from '../layouts/Base.astro';
import GlitchBard from '../components/GlitchBard.astro';
import posts from '../data/posts.json';

const latest = posts[0];
const formattedDate = new Date(latest.date).toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' });
---

<Base title="dangrubb.net">
  <div class="page">
    <GlitchBard />

    <p class="site-title">dangrubb.net</p>

    <p class="announcement">
      <a href="/music">EXCLUSIVE: Leaked mixtape from Darnea's vault</a>
    </p>

    <div class="blog-preview-container">
      <div class="blog-preview">
        <a href={`/blog/#${latest.slug}`} class="blog-preview-title">{latest.title}</a>
        <div class="blog-preview-date">{formattedDate}</div>
        <img src={latest.image} alt={latest.title} />
        <p class="blog-preview-excerpt">{latest.excerpt}</p>
        <a href={`/blog/#${latest.slug}`} class="blog-preview-link">Read more →</a>
      </div>
    </div>

    <nav class="bottom-nav">
      <a target="_parent" href="https://ai.dangrubb.net">ai</a>
      <a target="_parent" href="/blog">blog</a>
      <a target="_parent" href="https://pi.dangrubb.net/jellyfin">media</a>
      <a target="_parent" href="https://pi.dangrubb.net/nextcloud">storage</a>
      <a target="_parent" href="/cv">cv</a>
      <a target="_parent" href="https://pi.dangrubb.net/dangit">git</a>
    </nav>
  </div>
</Base>

<style>
  @import '../styles/bard.css';

  .page {
    padding: 20px 20px 100px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
  }

  .site-title {
    margin: 10px auto 0;
    max-width: 400px;
    text-align: center;
    line-height: 1.3;
    font-size: 0.875rem;
  }

  .announcement {
    margin: 20px auto 0;
    display: inline-block;
    border: 1px solid #ffff00;
    padding: 10px 15px;
    border-radius: 3px;
    font-size: 0.875rem;
    text-align: center;
  }
  .announcement a {
    color: #ffff00;
    font-weight: bold;
  }
  .announcement a:hover { text-decoration: underline; }

  .blog-preview-container {
    margin: 30px auto 0;
    width: 100%;
    display: flex;
    justify-content: center;
  }

  .blog-preview {
    border: 1px solid rgba(155, 169, 180, 0.3);
    border-radius: 4px;
    padding: 15px;
    background: linear-gradient(135deg, rgba(13, 10, 20, 0.6), rgba(50, 30, 80, 0.3));
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    max-width: 350px;
    width: 100%;
  }
  .blog-preview img {
    width: 100%;
    height: auto;
    max-height: 150px;
    object-fit: cover;
    border-radius: 3px;
    margin: 10px 0;
  }
  .blog-preview-title {
    color: #ffff00;
    font-weight: bold;
    font-size: 0.95rem;
    margin: 10px 0 5px;
    display: block;
  }
  .blog-preview-title:hover { text-decoration: underline; }
  .blog-preview-date {
    color: #aa95bd;
    font-size: 0.8rem;
    margin-bottom: 8px;
  }
  .blog-preview-excerpt {
    color: #9d9aa4;
    font-size: 0.85rem;
    line-height: 1.4;
    margin: 8px 0 10px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .blog-preview-link {
    display: inline-block;
    color: #6be1e9;
    font-size: 0.8rem;
  }
  .blog-preview-link:hover { text-decoration: underline; }

  .bottom-nav {
    margin-top: auto;
    width: 100%;
    text-align: center;
    padding: 20px 10px;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px 20px;
  }
  .bottom-nav a {
    color: #6be1e9;
    font-size: 0.875rem;
  }

  @media (max-width: 768px) {
    .page { padding: 20px 10px 80px; }
    .site-title { font-size: 0.8rem; max-width: 320px; }
    .blog-preview { max-width: 300px; }
  }
  @media (max-width: 400px) {
    .site-title { font-size: 0.75rem; }
    .blog-preview-container { margin-top: 20px; }
  }
</style>
