<?php
/**
 * Projects listing — all company work posts
 */
include_once 'header.php';

$projects = get_projects();
?>

<section class="relative bg-gradient-to-r from-slate-950 to-blue-900 text-white py-14 md:py-20">
    <div class="max-w-7xl mx-auto px-4 text-center">
        <nav class="text-xs text-sky-400 font-bold uppercase mb-3">
            <a href="index.php" class="hover:text-white">Home</a> <span class="mx-2">/</span> Projects
        </nav>
        <h1 class="text-3xl md:text-5xl font-black uppercase">Our Projects</h1>
        <p class="text-sky-100/80 mt-3 text-sm md:text-base">Completed work for leading companies across Bangladesh</p>
        <div class="w-16 h-1 bg-secondary mx-auto mt-4"></div>
    </div>
</section>

<section class="py-14 md:py-20 bg-gray-50">
    <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
        <?php if (empty($projects)): ?>
        <div class="text-center py-20 bg-white rounded-3xl border border-gray-100">
            <i class="fa-solid fa-briefcase text-4xl text-gray-200 mb-4 block"></i>
            <p class="text-gray-500">কোনো প্রজেক্ট এখনো যোগ করা হয়নি।</p>
        </div>
        <?php else: ?>
        <div class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4 md:gap-6">
            <?php foreach ($projects as $p):
                $cover = project_cover($p);
            ?>
            <a href="projects-details.php?id=<?php echo intval($p['id']); ?>"
               class="group bg-white rounded-2xl overflow-hidden border border-gray-100 hover:shadow-xl hover:-translate-y-1 transition-all">
                <div class="aspect-[4/3] overflow-hidden bg-gray-200">
                    <img src="<?php echo htmlspecialchars($cover); ?>"
                         class="w-full h-full object-cover group-hover:scale-110 transition-transform duration-500" alt="">
                </div>
                <div class="p-3 md:p-4 space-y-1">
                    <?php if (!empty($p['category_name'])): ?>
                    <span class="text-[10px] font-bold uppercase text-secondary"><?php echo htmlspecialchars($p['category_name']); ?></span>
                    <?php endif; ?>
                    <h3 class="font-black text-primary text-xs md:text-sm uppercase leading-snug group-hover:text-secondary transition-colors line-clamp-2">
                        <?php echo htmlspecialchars($p['company_name']); ?>
                    </h3>
                </div>
            </a>
            <?php endforeach; ?>
        </div>
        <?php endif; ?>
    </div>
</section>

<?php include_once 'footer.php'; ?>
