<?php
declare(strict_types=1);
require_once __DIR__ . '/config.php';
require_once __DIR__ . '/includes/functions.php';
$slug = (string)($_GET['slug'] ?? '');
$s = $slug !== '' ? service_by_slug($slug) : null;
if (!$s) {
    http_response_code(404);
    $pageTitle = 'Not found';
} else {
    $pageTitle = $s['title'] . ' — ' . setting('company_name', SITE_NAME);
}
$current = 'services';
$breadcrumbTitle = $s ? (string)$s['title'] : 'Service';
require __DIR__ . '/includes/head.php';
require __DIR__ . '/includes/preloader.php';
require __DIR__ . '/includes/offcanvas.php';
require __DIR__ . '/includes/header.php';
require __DIR__ . '/includes/breadcrumb.php';
?>
  <main>
    <?php if (!$s): ?>
      <section class="ot-space"><div class="container"><p>Service not found. <a href="services.php">Back to services</a></p></div></section>
    <?php else: ?>
      <section class="ot-space">
        <div class="container">
          <div class="row">
            <div class="col-lg-6 mb-4">
              <img src="<?= h(img_url($s['image_path'] ?? null)) ?>" class="img-fluid rounded w-100" alt="">
            </div>
            <div class="col-lg-6">
              <span class="ot-sec-subtitle">Service</span>
              <h1 class="ot-sec-title"><?= h((string)$s['title']) ?></h1>
              <p class="ot-sec-text"><?= nl2br(h((string)$s['short_description'])) ?></p>
              <div class="mt-4"><?= nl2br(h((string)$s['full_description'])) ?></div>
              <a href="contact.php" class="ot-btn-primary mt-4">Request quote</a>
            </div>
          </div>
        </div>
      </section>
    <?php endif; ?>
  </main>
<?php require __DIR__ . '/includes/footer.php'; ?>
