<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/** PORTFOLIO LISTING — Expects: $projects, $categories, $counts, $active_cat. */
?>
<section class="page-hero">
	<div class="container">
		<div class="page-hero-inner" data-reveal>
			<div class="breadcrumb"><a href="<?= base_url() ?>">Home</a> / <span>Portfolio</span></div>
			<span class="eyebrow">Selected Work</span>
			<h1>Campaigns that made brands <span class="serif-italic text-iris">bloom</span></h1>
			<p>A showcase of editorial shoots, brand collaborations, activations and motion work.</p>
		</div>
	</div>
</section>

<section class="section">
	<div class="container">
		<!-- FILTER BAR -->
		<div class="filter-bar" data-filter-bar="#portfolio-grid" data-reveal>
			<button class="filter-chip <?= $active_cat === 'all' ? 'active' : '' ?>" data-filter="all">
				All Work
			</button>
			<?php foreach ($categories as $slug => $label): ?>
				<button class="filter-chip <?= $active_cat === $slug ? 'active' : '' ?>" data-filter="<?= $slug ?>">
					<?= html_escape($label) ?>
					<?php if ( ! empty($counts[$slug])): ?>
						<span style="opacity:.6;">(<?= $counts[$slug] ?>)</span>
					<?php endif; ?>
				</button>
			<?php endforeach; ?>
		</div>

		<!-- GRID -->
		<?php if ($projects): ?>
			<div class="card-grid cols-3" id="portfolio-grid">
				<?php foreach ($projects as $i => $proj): ?>
					<a href="<?= base_url('portfolio/view/'.$proj['slug']) ?>" class="work-card" data-category="<?= $proj['category'] ?>" data-reveal data-delay="<?= ($i % 3) + 1 ?>">
						<div class="work-media">
							<span class="work-tag"><?= html_escape($categories[$proj['category']] ?? $proj['category']) ?></span>
							<?php if ($proj['video_type'] !== 'none'): ?>
								<span class="work-play"><span><?= bloom_icon('play', 24) ?></span></span>
							<?php endif; ?>
							<img src="<?= upload_url($proj['cover_image'], 'img/work-fallback.jpg') ?>" alt="<?= html_escape($proj['title']) ?>" loading="lazy">
						</div>
						<div class="work-body">
							<span class="meta"><?= html_escape($proj['brand']) ?> · <?= html_escape($proj['year']) ?></span>
							<h3><?= html_escape($proj['title']) ?></h3>
							<p class="brand"><?= html_escape(excerpt($proj['excerpt'], 12)) ?></p>
						</div>
					</a>
				<?php endforeach; ?>
			</div>
		<?php else: ?>
			<?= empty_state('No projects in this category yet.') ?>
		<?php endif; ?>
	</div>
</section>
