<section class="blog-section relative overflow-hidden bg-gradient-to-b from-white via-[#FFF9F5] to-white py-24 lg:py-32">
    <div class="absolute top-20 right-10 w-[500px] h-[500px] bg-gradient-to-bl from-[#FF007A]/5 to-transparent rounded-full blur-3xl"></div>
    <div class="absolute bottom-20 left-10 w-[400px] h-[400px] bg-gradient-to-tr from-[#D87AA8]/5 to-transparent rounded-full blur-3xl"></div>

    <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 relative z-10">
        <div class="text-center max-w-3xl mx-auto mb-20">
            <span class="inline-flex items-center gap-2 px-5 py-2.5 rounded-full bg-gradient-to-r from-[#FF007A] to-[#D87AA8] text-white text-xs font-bold uppercase tracking-[0.25em] mb-8 shadow-xl shadow-[#FF007A]/20">
                Our Blog
            </span>
            <h1 class="text-4xl sm:text-5xl lg:text-6xl font-extrabold text-slate-900 tracking-tight leading-[1.08] mb-6">
                Insights for <span class="text-transparent bg-clip-text bg-gradient-to-r from-[#FF007A] to-[#D87AA8]">modern interiors</span>
            </h1>
            <p class="text-base sm:text-lg text-slate-500 leading-relaxed max-w-2xl mx-auto">Expert guides on finishes, design trends, and project planning to help you create stunning spaces.</p>
        </div>

        <div class="grid gap-8 grid-cols-1 md:grid-cols-2 lg:grid-cols-3">
            <?php if (empty($posts)): ?>
                <div class="md:col-span-3 text-center text-slate-500 py-12">No blog posts published yet. Check back soon.</div>
            <?php else: ?>
                <?php foreach ($posts as $post): ?>
                <article class="blog-card group relative bg-white rounded-[2rem] overflow-hidden shadow-lg border border-slate-100 hover:shadow-2xl hover:shadow-[#FF007A]/10 hover:-translate-y-1 transition-all duration-500">
                    <div class="relative h-56 overflow-hidden">
                        <img src="<?= htmlspecialchars($baseUrl) ?>/images/<?= htmlspecialchars($post['image_path'] ?? 'living1.png') ?>" alt="<?= htmlspecialchars($post['title']) ?>" class="w-full h-full object-cover transition-transform duration-700 group-hover:scale-110">
                        <div class="absolute inset-0 bg-gradient-to-t from-black/20 to-transparent"></div>
                        <div class="absolute top-4 left-4">
                            <span class="inline-flex items-center px-3 py-1 rounded-full bg-white/90 backdrop-blur-sm text-xs font-semibold text-slate-900">Blog</span>
                        </div>
                    </div>
                    <div class="p-7">
                        <div class="flex items-center gap-3 text-xs text-slate-500 mb-4">
                            <span><?= $post['published_at'] ? date('M j, Y', strtotime($post['published_at'])) : '' ?></span>
                        </div>
                        <h2 class="text-xl font-bold text-slate-900 mb-3 group-hover:text-[#FF007A] transition-colors"><?= htmlspecialchars($post['title']) ?></h2>
                        <p class="text-sm text-slate-600 leading-relaxed mb-5"><?= htmlspecialchars($post['excerpt'] ?? '') ?></p>
                        <a href="#" class="inline-flex items-center gap-2 text-sm font-semibold text-[#FF007A] group-hover:gap-3 transition-all">
                            Read More
                            <span class="material-symbols-outlined text-base group-hover:translate-x-1 transition-transform">arrow_forward</span>
                        </a>
                    </div>
                </article>
                <?php endforeach; ?>
            <?php endif; ?>
        </div>

        <div class="mt-16 text-center">
            <a href="<?= htmlspecialchars($baseUrl) ?>/estimate" class="inline-flex items-center gap-3 px-10 py-4 rounded-full bg-gradient-to-r from-[#FF007A] to-[#D87AA8] text-white font-semibold text-base shadow-xl shadow-[#FF007A]/25 hover:shadow-2xl hover:shadow-[#FF007A]/40 hover:-translate-y-1 transition-all duration-300">
                <span class="material-symbols-outlined text-xl">request_quote</span>
                Start Your Project
            </a>
        </div>
    </div>
</section>
