<?php
$settingsContent = settings('content')->getAll();
?>
<!DOCTYPE html>
<html lang="<?= $seo['extra_fields']['locale'] ?? 'en' ?>">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <base href="/">
    <title><?= $seo['title'] ?></title>
    <link rel="stylesheet" href="css/styles.css">
    <meta name='robots' content='index, follow' />
    <?php if (!empty($settingsContent['favicon'])): ?>
        <link rel="icon" href="<?= htmlspecialchars($settingsContent['favicon']) ?>" type="image/x-icon">
    <?php endif; ?>
    <meta property="og:title" content="<?= $seo['title'] ?? '' ?>">
    <meta property="og:description" content="<?= $seo['description'] ?? '' ?>">
    <meta property="og:locale" content="<?= $seo['extra_fields']['locale'] ?? '' ?>">
    <meta property="og:image" content="<?= htmlspecialchars($seo['image'] ?? '') ?>">
    <meta name="description" content="<?= $seo['description'] ?? '' ?>">

    <link rel="canonical" href="<?= $seo['canonical'] ?? '' ?>">

    <script type="application/ld+json">
<?= json_encode([
    "@context" => "https://schema.org",
    "@graph" => [
        [
            "@type" => "WebPage",
            "name" => $settingsContent['title'],
            "description" => $settingsContent['description'],
            "inLanguage" => $settingsContent['lang'],
            "url" => $currentUrl,
            "dateModified" => $settingsContent['modified-date'] ?? '' , // ISO формат
            "author" => [
                "@type" => "Person",
                "name" => $settingsContent['author-name'] ?? '',
                "image" => $currentDomain . '/' . htmlspecialchars($settingsContent['author-img'] ?? '')
            ]
        ],
        [
            "@type" => "Organization",
            "name" => $domainName,
            "url" => $currentDomain,
            "logo" => $currentDomain . '/' . htmlspecialchars($settingsContent['uploaded_image'] ?? '')
        ],
        [
            "@type" => "BreadcrumbList",
            "itemListElement" => [
                [
                    "@type" => "ListItem",
                    "position" => 1,
                    "name" => $settingsContent['title-h1'],
                    "item" => $currentUrl
                ]
            ]
        ],
        !empty($casinoItems) ? [
            "@type" => "ItemList",
            "name" => htmlspecialchars($settingsContent['listing']),
            "itemListElement" => array_map(function ($item, $index) use ($currentDomain, $currentReviewCount) {
                $data = json_decode($item['value'], true);
                return [
                    "@type" => "ListItem",
                    "position" => $index + 1,
                    "item" => [
                        "@type" => "Offer",
                        "name" => htmlspecialchars($data['heading']),
                        "description" => htmlspecialchars($data['text']),
                        "url" => $currentDomain . '/#' . getSlug($data['heading']),
                        "offeredBy" => [
                            "@type" => "Organization",
                            "name" => htmlspecialchars($data['heading']),
                            "logo" => $currentDomain . '/' . htmlspecialchars($data['image']),
                            "aggregateRating" => [
                                "@type" => "AggregateRating",
                                "ratingValue" => "5",
                                "reviewCount" => $currentReviewCount + ($index + 1),
                                "bestRating" => "5",
                                "worstRating" => "1"
                            ]
                        ]
                    ]
                ];
            }, $casinoItems, array_keys($casinoItems))
        ] : null,
        [
            "@type" => "FAQPage",
            "mainEntity" => array_map(function ($item) {
                return [
                    "@type" => "Question",
                    "name" => htmlspecialchars($item['question']),
                    "acceptedAnswer" => [
                        "@type" => "Answer",
                        "text" => htmlspecialchars($item['answer'])
                    ]
                ];
            }, $faqItems)
        ]
    ]
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT); ?>
    </script>
    <?php include __DIR__ . '/partials/styles.php'; ?>
</head>

<body class="main-color font-color main-font">
    <?php include __DIR__ . '/partials/header.php'; ?>
    <main class="main">
        <?= $pageContent ?>
    </main>
    <?php include __DIR__ . '/partials/footer.php'; ?>
    <script src="js/script.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/blazy/1.8.2/blazy.min.js"></script>
</body>
</html>