<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
 * HOMEPAGE
 * Expects: $hero_slides, $partners, $services, $featured, $talent,
 *          $events, $testimonials.
 */
$tcats = $this->config->item('talent_categories');
$pcats = $this->config->item('portfolio_categories');
?>

<!-- ================= HERO CAROUSEL ================= -->
<?php $this->load->view('partials/hero_carousel', array('hero_slides' => $hero_slides)); ?>

<!-- ================= CLIENT MOVING SLIDER ================= -->
<?php $this->load->view('partials/clients_slider', array('partners' => $partners)); ?>

<!-- ================= INTRO / POSITIONING ================= -->
<section class="section">
	<div class="container">
		<div class="card-grid cols-2" style="align-items:center;gap:60px;">
			<div data-reveal>
				<span class="eyebrow">Welcome to Bloom Iris</span>
				<h2 style="margin:18px 0;">A creative agency built for brands &amp; talent who refuse to <span class="serif-italic text-iris">blend in.</span></h2>
				<p style="color:var(--ink-soft);font-size:1.08rem;">
					Bloom Iris Agency is where creative vision becomes unforgettable work. We discover and represent
					exceptional talent, craft campaigns that move brands forward, and produce experiences people
					remember long after the lights go down.
				</p>
				<div style="display:flex;gap:14px;margin-top:28px;flex-wrap:wrap;">
					<a href="<?= base_url('about') ?>" class="btn btn-primary">Our Story <?= bloom_icon('arrow', 18) ?></a>
					<a href="<?= base_url('services') ?>" class="btn btn-ghost">What We Do</a>
				</div>
			</div>
			<div data-reveal data-delay="2">
				<div class="card-grid cols-2" style="gap:18px;">
					<div style="border-radius:var(--radius);overflow:hidden;aspect-ratio:3/4;background:var(--cream-deep);">
						<img src="<?= base_url('assets/img/intro-1.jpg') ?>" alt="Creative work" style="width:100%;height:100%;object-fit:cover;" onerror="this.style.display='none'">
					</div>
					<div style="display:flex;flex-direction:column;gap:18px;padding-top:36px;">
						<div style="border-radius:var(--radius);overflow:hidden;aspect-ratio:1;background:var(--grad-brand);"></div>
						<div style="border-radius:var(--radius);overflow:hidden;aspect-ratio:3/4;background:var(--cream-deep);">
							<img src="<?= base_url('assets/img/intro-2.jpg') ?>" alt="Talent" style="width:100%;height:100%;object-fit:cover;" onerror="this.style.display='none'">
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</section>

<!-- ================= SERVICES ================= -->
<section class="section section--cream">
	<div class="container">
		<div class="section-head center" data-reveal>
			<span class="eyebrow" style="justify-content:center;">What We Do</span>
			<h2>Creative services, end to end</h2>
			<p>From talent representation to full campaign production — everything your brand needs under one creative roof.</p>
		</div>
		<div class="card-grid cols-3">
			<?php foreach (array_slice($services, 0, 6) as $i => $svc): ?>
				<a href="<?= base_url('services/view/'.$svc['slug']) ?>" class="service-card" data-reveal data-delay="<?= ($i % 3) + 1 ?>">
					<div class="service-ico"><?= bloom_icon($svc['icon'] ?: 'sparkle', 28) ?></div>
					<h3><?= html_escape($svc['title']) ?></h3>
					<p><?= html_escape(excerpt($svc['summary'], 18)) ?></p>
					<span class="link-arrow">Explore service <?= bloom_icon('arrow', 18) ?></span>
				</a>
			<?php endforeach; ?>
		</div>
	</div>
</section>

<!-- ================= FEATURED WORK ================= -->
<section class="section">
	<div class="container">
		<div class="section-head" data-reveal style="display:flex;justify-content:space-between;align-items:flex-end;max-width:100%;gap:24px;flex-wrap:wrap;">
			<div style="max-width:560px;">
				<span class="eyebrow">Selected Work</span>
				<h2 style="margin-top:16px;">Campaigns that made brands bloom</h2>
			</div>
			<a href="<?= base_url('portfolio') ?>" class="link-arrow">View full portfolio <?= bloom_icon('arrow', 18) ?></a>
		</div>

		<?php if ($featured): ?>
			<div class="card-grid cols-3">
				<?php foreach ($featured as $i => $proj): ?>
					<a href="<?= base_url('portfolio/view/'.$proj['slug']) ?>" class="work-card" data-reveal data-delay="<?= ($i % 3) + 1 ?>">
						<div class="work-media">
							<span class="work-tag"><?= html_escape($pcats[$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('Portfolio projects will appear here soon.') ?>
		<?php endif; ?>
	</div>
</section>

<!-- ================= STATS STRIP ================= -->
<section class="section section--plum section--tight">
	<div class="container">
		<div class="stats-grid">
			<?php
			// Use stats passed from controller
			$stats_items = array(
				'stat_campaigns' => 'Campaigns Delivered',
				'stat_talent'    => 'Talent Represented',
				'stat_events'    => 'Events Produced',
				'stat_brands'    => 'Brand Partners',
			);
			$delay = 1;
			foreach ($stats_items as $key => $label):
				$value = isset($stats[$key]) ? $stats[$key] : 0;
			?>
				<div class="stat" data-reveal data-delay="<?= $delay ?>">
					<div class="stat-num" data-count="<?= $value ?>">0<span class="plus">+</span></div>
					<div class="stat-label"><?= $label ?></div>
				</div>
			<?php 
			$delay++;
			endforeach; 
			?>
		</div>
	</div>
</section>

<!-- ================= TALENT ================= -->
<section class="section">
	<div class="container">
		<div class="section-head" data-reveal style="display:flex;justify-content:space-between;align-items:flex-end;max-width:100%;gap:24px;flex-wrap:wrap;">
			<div style="max-width:560px;">
				<span class="eyebrow">The Faces</span>
				<h2 style="margin-top:16px;">Meet the Bloom Iris talent</h2>
			</div>
			<a href="<?= base_url('talent') ?>" class="link-arrow">See full roster <?= bloom_icon('arrow', 18) ?></a>
		</div>

		<?php if ($talent): ?>
			<div class="card-grid cols-4">
				<?php foreach (array_slice($talent, 0, 8) as $i => $t): ?>
					<a href="<?= base_url('talent/view/'.$t['slug']) ?>" class="talent-card" data-reveal data-delay="<?= ($i % 4) + 1 ?>">
						<div class="talent-media">
							<img src="<?= upload_url($t['photo'], 'img/talent-fallback.jpg') ?>" alt="<?= html_escape($t['name']) ?>" loading="lazy">
						</div>
						<div class="talent-overlay">
							<span class="talent-cat"><?= html_escape($tcats[$t['category']] ?? $t['category']) ?></span>
							<h3><?= html_escape($t['name']) ?></h3>
							<p><?= html_escape($t['tagline']) ?></p>
						</div>
					</a>
				<?php endforeach; ?>
			</div>
		<?php else: ?>
			<?= empty_state('Talent profiles will appear here soon.') ?>
		<?php endif; ?>
	</div>
</section>

<!-- ================= EVENTS ================= -->
<?php if ($events): ?>
<section class="section section--cream">
	<div class="container">
		<div class="section-head center" data-reveal>
			<span class="eyebrow" style="justify-content:center;">What's Coming Up</span>
			<h2>Upcoming events &amp; activations</h2>
		</div>
		<div class="card-grid cols-3">
			<?php foreach ($events as $i => $ev): ?>
				<a href="<?= base_url('events/view/'.$ev['slug']) ?>" class="event-card" data-reveal data-delay="<?= ($i % 3) + 1 ?>">
					<div class="event-date">
						<span class="d"><?= nice_date($ev['event_date'], 'd') ?: '--' ?></span>
						<span class="m"><?= nice_date($ev['event_date'], 'M') ?: 'TBA' ?></span>
					</div>
					<div class="event-info">
						<h3><?= html_escape($ev['title']) ?></h3>
						<span class="where"><?= bloom_icon('pin', 15) ?> <?= html_escape($ev['location']) ?></span>
						<?php if ($ev['is_paid']): ?>
							<span class="event-pill">Ticketed · <?= money($ev['ticket_price']) ?></span>
						<?php else: ?>
							<span class="event-pill">Free Entry</span>
						<?php endif; ?>
					</div>
				</a>
			<?php endforeach; ?>
		</div>
	</div>
</section>
<?php endif; ?>

<!-- ================= TESTIMONIALS ================= -->
<?php if ($testimonials): ?>
<section class="section">
	<div class="container">
		<div class="section-head center" data-reveal>
			<span class="eyebrow" style="justify-content:center;">Kind Words</span>
			<h2>What brands &amp; talent say about us</h2>
		</div>
		<div class="card-grid cols-3">
			<?php foreach (array_slice($testimonials, 0, 3) as $i => $tm): ?>
				<div class="quote-card" data-reveal data-delay="<?= $i + 1 ?>">
					<span class="q-mark"><?= bloom_icon('quote', 38) ?></span>
					<blockquote><?= html_escape($tm['quote']) ?></blockquote>
					<div class="quote-author">
						<?php if ( ! empty($tm['photo']) && is_file(FCPATH.'assets/uploads/'.$tm['photo'])): ?>
							<img class="avatar" src="<?= upload_url($tm['photo']) ?>" alt="<?= html_escape($tm['author_name']) ?>">
						<?php else: ?>
							<span class="avatar"><?= strtoupper(substr($tm['author_name'], 0, 1)) ?></span>
						<?php endif; ?>
						<div>
							<div class="name"><?= html_escape($tm['author_name']) ?></div>
							<div class="role"><?= html_escape($tm['author_role']) ?></div>
						</div>
					</div>
				</div>
			<?php endforeach; ?>
		</div>
	</div>
</section>
<?php endif; ?>
