<?php

use Core\Database\DB;

$stmt = DB::conn()->prepare("
    SELECT setting_value 
    FROM settings 
    WHERE setting_key = ?
    LIMIT 1
");

$stmt->execute(['site_font']);

$siteFont = $stmt->fetchColumn() ?: 'Inter';
?>
<?php
$allowedFonts = [
    'Inter',
    'Poppins',
    'Manrope',
    'Nunito Sans',
    'Roboto'
];

if (!in_array($siteFont, $allowedFonts, true)) {
    $siteFont = 'Inter';
}

$googleFontName = str_replace(' ', '+', $siteFont);
?>
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>Driftly</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://fonts.googleapis.com/css2?family=<?= $googleFontName ?>:wght@300;400;500;600;700&display=swap"
        rel="stylesheet">
    <link href="/driftly/public/assets/css/style.css" rel="stylesheet">
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://unpkg.com/lucide@latest"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css" />
</head>

<body class="bg-gray-100 min-h-screen" style="font-family: '<?= htmlspecialchars($siteFont) ?>', sans-serif;">

    <?php require VIEW_PATH . '/layout/partials/header.php'; ?>
    <main id="app" class="mx-auto">
        <?= $content ?>
    </main>
    <?php require VIEW_PATH . '/layout/partials/footer.php'; ?>
    <script src="/driftly/public/assets/js/app.js"></script>

</body>

</html>