<?php
defined('BASEPATH') OR exit('No direct script access allowed');

/**
 * Services — listing + individual service detail with process flow.
 */
#[\AllowDynamicProperties]
class Services extends Public_Controller {

	public function __construct()
	{
		parent::__construct();
	}

	/** All services. */
	public function index()
	{
		$this->meta(array(
			'title'       => 'Services — Bloom Iris Agency',
			'description' => 'Creative services from talent management to full campaign production.',
		));
		$this->render('services/index', array(
			'services' => $this->service_model->active(),
		));
	}

	/** Single service detail. */
	public function detail($slug)
	{
		$service = $this->service_model->by_slug($slug);
		if ( ! $service) show_404();

		$this->meta(array(
			'title'       => ($service['meta_title'] ?: $service['title'].' — Bloom Iris Agency'),
			'description' => ($service['meta_desc'] ?: $service['summary']),
		));

		// Other services for the cross-sell strip.
		$others = array_filter($this->service_model->active(), function ($s) use ($service) {
			return $s['id'] != $service['id'];
		});

		$this->render('services/detail', array(
			'service' => $service,
			'steps'   => decode_json($service['process_steps']),
			'others'  => array_slice($others, 0, 3),
		));
	}
}
