{% if posts %}
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
    {% for post in posts %}
    <article class="card hover:shadow-lg transition-shadow">
        <div class="text-sm text-gray-500 mb-2">{{ post.created_at.strftime('%B %d, %Y') }}</div>
        <h2 class="text-xl font-semibold text-gray-900 mb-2">
            <a href="{{ url_for('blog_post', slug=post.slug) }}" class="hover:text-primary-600 transition-colors">
                {{ post.title }}
            </a>
        </h2>
        <p class="text-gray-600 mb-4 line-clamp-3">
            {{ post.excerpt or post.content[:150] }}{% if post.content|length > 150 %}...{% endif %}
        </p>
        <div class="flex items-center justify-between">
            <div class="flex items-center text-sm text-gray-500">
                <div class="w-6 h-6 bg-primary-100 rounded-full flex items-center justify-center text-primary-600 text-xs font-semibold mr-2">
                    {{ post.author.username[0].upper() }}
                </div>
                {{ post.author.username }}
            </div>
            <a href="{{ url_for('blog_post', slug=post.slug) }}" class="text-primary-600 hover:text-primary-700 font-medium text-sm">
                Read more &rarr;
            </a>
        </div>
    </article>
    {% endfor %}
</div>
{% else %}
<div class="text-center py-16">
    <div class="w-16 h-16 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-4">
        <svg class="w-8 h-8 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 20H5a2 2 0 01-2-2V6a2 2 0 012-2h10a2 2 0 012 2v1m2 13a2 2 0 01-2-2V7m2 13a2 2 0 002-2V9a2 2 0 00-2-2h-2m-4-3H9M7 16h6M7 8h6v4H7V8z" />
        </svg>
    </div>
    <h3 class="text-xl font-semibold text-gray-900 mb-2">No posts yet</h3>
    <p class="text-gray-600">Check back soon for new content!</p>
</div>
{% endif %}
