@extends('public.layout')
@section('title', 'Blog')
@section('content')

<section class="max-w-6xl mx-auto px-6 py-24">
    <p class="text-xs font-semibold text-gray-400 uppercase tracking-widest mb-4 flex items-center gap-2">
        <span class="w-4 h-px bg-gray-400 inline-block"></span> Blog
    </p>
    <h1 class="text-5xl font-bold mb-4">Artikel</h1>
    <p class="text-gray-500 mb-16 max-w-xl">Pengumuman, berita, dan tulisan dari organisasi Persegi.</p>

    <div class="grid md:grid-cols-2 gap-6">
        @forelse($posts as $post)
        <a href="{{ route('blog.detail', $post) }}" class="group border border-gray-100 rounded-xl overflow-hidden hover:border-gray-300 transition">
            <div class="bg-gray-900 p-6 font-mono text-xs text-green-400 leading-relaxed">
                <div class="flex gap-1 mb-3">
                    <span class="w-2 h-2 rounded-full bg-red-500"></span>
                    <span class="w-2 h-2 rounded-full bg-yellow-500"></span>
                    <span class="w-2 h-2 rounded-full bg-green-500"></span>
                </div>
                <p class="text-gray-500">// {{ $post->published_at->format('d M Y') }}</p>
                <p class="text-white mt-1">{{ $post->title }}</p>
            </div>
            <div class="p-5">
                <div class="flex items-center gap-2 mb-2">
                    <span class="text-xs px-2 py-0.5 rounded-full bg-gray-100 text-gray-600">{{ ucfirst($post->category) }}</span>
                </div>
                <h3 class="font-bold mb-2 group-hover:underline underline-offset-2">{{ $post->title }}</h3>
                <p class="text-sm text-gray-500 line-clamp-2">{{ strip_tags($post->content) }}</p>
                <p class="text-xs text-gray-400 mt-3">see more →</p>
            </div>
        </a>
        @empty
        <p class="text-gray-400 col-span-2">Belum ada artikel.</p>
        @endforelse
    </div>

    <div class="mt-12">{{ $posts->links() }}</div>
</section>

@endsection
