<?php
declare(strict_types=1);
$db_path = __DIR__ . '/../data/pages.sqlite';
$db = new SQLite3($db_path, SQLITE3_OPEN_READONLY);
$db->busyTimeout(3000);
$nav_result = $db->query("SELECT slug, nav_label FROM pages WHERE in_nav=1 ORDER BY nav_order");
$nav_items = [];
while ($row = $nav_result->fetchArray(SQLITE3_ASSOC)) {
    $nav_items[] = $row;
}
$db->close();
$canonical = $canonical ?? '';
$schema_json = $schema_json ?? '';
$page_title = htmlspecialchars($page_title ?? 'Floor It Hardwood Floors', ENT_QUOTES);
$page_meta  = htmlspecialchars($page_meta  ?? '', ENT_QUOTES);
?><!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title><?= $page_title ?></title>
  <meta name="description" content="<?= $page_meta ?>">
  <link rel="icon" type="image/jpeg" href="/assets/images/favicon.jpg">
  <?php if ($canonical): ?><link rel="canonical" href="<?= htmlspecialchars($canonical, ENT_QUOTES) ?>">
  <?php endif; ?>
  <?php if (!empty($schema_json)): ?><script type="application/ld+json"><?= $schema_json ?></script>
  <?php endif; ?>
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet">
  <link rel="stylesheet" href="/assets/css/tokens.css">
  <link rel="stylesheet" href="/assets/css/main.css">
  <link rel="stylesheet" href="/assets/css/components.css">
</head>
<body>
<div id="promo-topbar" role="complementary" aria-label="Summer promotion">
  <span id="promo-topbar-text">Summer Refinishing Savings: Save up to 15% through June 30, 2026</span>
  <button id="promo-topbar-btn" type="button">Get Offer</button>
</div>
<header id="site-header" class="site-header">
  <div class="container">
    <div class="header-inner">
      <a href="/" class="header-logo" aria-label="Floor It Hardwood Floors">
        <img src="/assets/images/logo-header.png" alt="Floor It Hardwood Floors" style="height:42px;width:auto;object-fit:contain;">
      </a>
      <nav class="header-nav" aria-label="Main navigation">
        <?php foreach ($nav_items as $item):
          $href = $item['slug'] === 'home' ? '/' : '/' . $item['slug'] . '/';
        ?><a href="<?= htmlspecialchars($href, ENT_QUOTES) ?>"><?= htmlspecialchars($item['nav_label'], ENT_QUOTES) ?></a>
        <?php endforeach; ?>
      </nav>
      <div class="header-cta">
        <a href="tel:+17166021429" class="header-phone" aria-label="Call (716) 602-1429">(716) 602-1429</a>
        <a href="/contact/" class="btn btn--primary btn--sm">Get Estimate</a>
        <button class="header-menu-btn" aria-label="Open menu" aria-expanded="false">
          <span></span><span></span><span></span>
        </button>
      </div>
    </div>
  </div>
  <div class="mobile-nav" id="mobileNav" aria-hidden="true">
    <div class="mobile-nav-overlay" id="mobileNavOverlay"></div>
    <div class="mobile-nav-panel">
      <button class="mobile-nav-close" aria-label="Close menu" id="mobileNavClose">&#x2715;</button>
      <nav class="mobile-nav-links">
        <?php foreach ($nav_items as $item):
          $href = $item['slug'] === 'home' ? '/' : '/' . $item['slug'] . '/';
        ?><a href="<?= htmlspecialchars($href, ENT_QUOTES) ?>"><?= htmlspecialchars($item['nav_label'], ENT_QUOTES) ?></a>
        <?php endforeach; ?>
      </nav>
      <div class="mobile-nav-cta">
        <a href="tel:+17166021429" class="mobile-nav-phone">(716) 602-1429</a>
        <a href="/contact/" class="btn btn--primary btn--full">Request Free Estimate</a>
      </div>
    </div>
  </div>
</header>
<main>
