<?php
/**
 * Privacy Policy — Direct-Serve Wrapper
 *
 * Some ad network bots and crawlers can't handle clean URLs
 * (e.g., /privacy-policy routed through index.php).
 * This wrapper serves the page directly at /privacy-policy.php.
 *
 * Nginx: either point the bot to /privacy-policy.php directly,
 * or add: location = /privacy-policy { rewrite ^ /privacy-policy.php last; }
 */

// Force REQUEST_URI so the engine resolves the correct route
$_SERVER['REQUEST_URI'] = '/privacy-policy';

$siteRoot = dirname(__DIR__);

// Load engine config
$engineConfig = [];
$engineConfigFile = $siteRoot . '/config/engine.php';
if (is_file($engineConfigFile)) {
    $engineConfig = require $engineConfigFile;
}

$enginePath = $engineConfig['path'] ?? null;

// Engine mode — full CMS render (theme, nav, footer all work)
if ($enginePath && is_dir($enginePath) && is_file($enginePath . '/core/Bootstrap.php')) {
    require_once $enginePath . '/core/Bootstrap.php';
    Bootstrap::run($siteRoot, $enginePath);
    exit;
}

// Fallback mode — serve page directly (minimal, no theme)
if (!defined('ENGINE_PATH')) define('ENGINE_PATH', '');
if (!defined('SITE_ROOT')) define('SITE_ROOT', $siteRoot);
if (!defined('CONFIG_PATH')) define('CONFIG_PATH', $siteRoot . '/config');
if (!defined('STORAGE_PATH')) define('STORAGE_PATH', $siteRoot . '/storage');
if (!function_exists('site_url')) {
    function site_url(string $path = '/'): string { return $path; }
}
$config = is_file(CONFIG_PATH . '/site.php') ? require CONFIG_PATH . '/site.php' : [];
include $siteRoot . '/pages/privacy-policy.php';
