<!DOCTYPE html>
<html lang="<?= $isHomepage ? ($seo['lang'] ?? 'en') : ($seo['lang-page'] ?? 'en-US') ?>">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <base href="/">
    <title><?= $content['title'] ?></title>
    <link rel="stylesheet" href="css/styles.css">
    <meta name='robots' content='index, follow' />
    <?php if (!empty($content['favicon'])): ?>
        <link rel="icon" href="<?= htmlspecialchars($content['favicon']) ?>" type="image/x-icon">
    <?php endif; ?>
    <meta property="og:type" content="<?= $seo['og-type'] ?? '' ?>">
    <meta property="og:title" content="<?= $seo['og-title'] ?? '' ?>">
    <meta property="og:description" content="<?= $seo['og-description'] ?? '' ?>">
    <meta property="og:locale" content="<?= $seo['og-locale'] ?? '' ?>">
    <meta property="og:image" content="<?= htmlspecialchars($seo['og-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" => $content['title'],
            "description" => $content['description'],
            "inLanguage" => $content['lang'],
            "url" => $currentUrl,
            "dateModified" => $content['modified-date'] ?? '' , // ISO формат
            "author" => [
                "@type" => "Person",
                "name" => $content['author-name'] ?? '',
                "image" => $currentDomain . '/' . htmlspecialchars($content['author-img'] ?? '')
            ]
        ],
        [
            "@type" => "Organization",
            "name" => $domainName,
            "url" => $currentDomain,
            "logo" => $currentDomain . '/' . htmlspecialchars($content['uploaded_image'] ?? '')
        ],
        [
            "@type" => "BreadcrumbList",
            "itemListElement" => [
                [
                    "@type" => "ListItem",
                    "position" => 1,
                    "name" => $content['title-h1'],
                    "item" => $currentUrl
                ]
            ]
        ],
        !empty($casinoItems) ? [
            "@type" => "ItemList",
            "name" => htmlspecialchars($content['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>


    <style>
        th{
            color: <?= $styles['pass_btn_color'] ?? '' ?>;
            background-color: <?= $styles['accent_color'] ?? '' ?>;
        }
        .burger:before,
        .burger:after,
        .burger {
            background-color: <?= $styles['burger-color'] ?? '' ?>;
        }

        .main-font {
            font-family: <?= $styles['main-fz'] ?? '' ?>;
        }

        .main-color {
            background: <?= $styles['main_color'] ?? '' ?>;
        }

        .header-color {
            background: <?= $styles['header_color'] ?? '' ?>;
        }

        .login-btn-bg {
            background: <?= $styles['login_btn_bg'] ?? '' ?>;
        }

        .accent-color {
            background: <?= $styles['accent_color'] ?? '' ?>;
        }

        button.accent-color {
            transition: filter 0.3s ease;
        }

        button.accent-color:hover {
            filter: brightness(0.85);
        }

        .faq-title-font-color {
            color: <?= $styles['faq-title-font-color'] ?? '' ?>;
        }

        .faq-title-hover-font-color:hover {
            color: <?= $styles['faq-title-hover-font-color'] ?? '' ?>;
        }

        .font-color {
            color: <?= $styles['font_color'] ?? '' ?>;
        }

        a {
            color: <?= $styles['link_color'] ?? '' ?>;
            text-decoration: none;
            transition: 300ms;
        }

        a:hover {
            color: <?= $styles['accent_color'] ?? '' ?>;
        }

        .secondary-color {
            background-color: <?= $styles['secondary_color'] ?? '' ?>;
        }

        .main-fz {
            color: <?= $styles['main_fz'] ?? '' ?>;
        }

        .footer-color {
            background: <?= $styles['footer_color'] ?? '' ?>;
        }

        .accordion-header.active {
            background: <?= $styles['accent_color'] ?? '' ?>;
        }

        .accordion-header:hover {
            background: <?= $styles['accent_color'] ?? '' ?>;
        }

        .header__menu-list {
            background: <?= $styles['header_color'] ?? '' ?>;
        }

        .login-btn-color {
            color: <?= $styles['login_btn_color'] ?? '' ?>;
        }

        .pass-btn-color {
            color: <?= $styles['pass_btn_color'] ?? '' ?>;
        }

        table {
            background: <?= $styles['table'] ?? '' ?>;
        }

        caption {
            background: <?= $styles['caption'] ?? '' ?>;
        }

        .casinos__bonus {
            color: <?= $styles['accent_color'] ?? '' ?>;
        }

        h2 {
            color: inherit;
        }

        h2::after {
            background: <?= $styles['accent_color'] ?? '' ?>;
        }

        @keyframes pulse {
            0% {
                transform: scale(0.95);
                box-shadow: 0 0 0 0;
            }

            70% {
                transform: scale(1);
                box-shadow: 0 4px 24px 0 <?= $styles['accent_color'] ?? '' ?>;
            }

            100% {
                transform: scale(0.95);
                box-shadow: 0 0 0 0 transparent;
            }
        }

        ul {
            list-style: none;
        }

        .main__text ul li {
            position: relative;
            margin: 5px 0;
        }

        .main__text ul li::before {
            content: '✓';
            width: 22px;
            height: 22px;
            border-radius: 50%;
            background: <?= $styles['accent_color'] ?? '' ?>;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            margin-right: 10px;
            font-size: 15px;
        }

        .secondary__text ul li {
            position: relative;
            margin: 5px 0;
        }

        .secondary__text ul li::before {
            content: '✓';
            width: 23px;
            height: 23px;
            border-radius: 50%;
            background: <?= $styles['accent_color'] ?? '' ?>;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            margin-right: 10px;
            font-size: 15px;
        }

        .bottom-btn {
            margin: auto;
            width: 200px;
            background: #c30054;
        }

        ol {
            list-style: none;
            counter-reset: list-counter;
            padding-left: 0;
        }

        ol li {
            counter-increment: list-counter;
            position: relative;
            padding-left: 40px;
            /* Отступ для цифры */
            margin: 15px 0;
        }

        ol li::before {
            content: counter(list-counter);
            position: absolute;
            left: 0;
            width: 25px;
            height: 25px;
            border: 1px solid <?= $styles['accent_color'] ?? '' ?>;
            border-radius: 50%;
            text-align: center;
            line-height: 25px;
            font-weight: bold;
            top: -1px;
            font-size: 14px;
        }

        .main__btn {
            position: relative;
            margin: auto;

        }

        .main__btn a {
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100%;
            width: 100%;
            color: <?= $styles['pass_btn_color'] ?? '' ?>;
        }

        .main__btn a:hover {
            color: <?= $styles['pass_btn_color'] ?? '' ?>;
        }
    </style>
</head>

<body class="main-color font-color main-font">
    <?php include __DIR__ . '/partials/header.php'; ?>
    <main class="main">
        <section>
            <div class="container">
                <h1 class="main__title"><?= $content['title'] ?></h1>
                <div class="main__banner">
                    <?php if (!empty($bannerLogo['src'])): ?>
                        <img class="redirect-js" 
                             width="<?= $bannerLogo['width'] ?? '' ?>" 
                             height="<?= $bannerLogo['height'] ?? '' ?>" 
                             src="<?= htmlspecialchars($bannerLogo['src']) ?>" 
                             alt="<?= $bannerLogo['alt'] ?? '' ?>" 
                             title="<?= $bannerLogo['title'] ?? '' ?>">
                    <?php endif; ?>
                </div>
                <div class="container">
                    <?php if (!empty($content['author-img'])): ?>
                        <div class="author">
                            <div class="author__img">
                                <img width="" height="" src="<?= htmlspecialchars($content['author-img']) ?>" alt="<?= htmlspecialchars($content['author-name'] ?? '') ?>" title="<?= htmlspecialchars($content['author-name'] ?? '') ?>">
                            </div>
                            <div class="author__info">
                                <div class="author__name"><?= htmlspecialchars($content['author-name'] ?? '') ?></div>
                                <div class="author__date"> <?= $content['modified-date'] ?? '' ?></div>
                            </div>
                        </div>
                    <?php endif; ?>
                    <div class="main__text">
                        <?= $content['top_text'] ?>
                    </div>
                    <?php if (empty($content['hide-btns'])): ?>
                        <div class="pulse__btn main__btn accent-color pass-btn-color redirect-js"><?= $content['content_btn'] ?></div>
                     <?php endif; ?>
                </div>
        </section>
        <section class="casinos">

            <div class="container casinos__wrap">
                <?php if (!empty($casinoItems)): ?>
                    <h2 class="casinos__listing"><?= htmlspecialchars($content['listing']) ?></h2>
                <?php endif; ?>

                <?php if (!empty($casinoItems) && is_array($casinoItems)): ?>
                    <?php foreach ($casinoItems as $index => $item):
                        $isTopThree = ($index < 3);
                    ?>
                        <div class="casinos__item <?= $isTopThree ? 'top-casino' : '' ?>" id="<?= getSlug(htmlspecialchars($item['heading'] ?? '')) ?>">
                            <div class="casinos__info">
                                <div class="casinos__number pass-btn-color accent-color"><?= $index + 1 ?></div>
                                <div class="casinos__image">
                                    <div class="redirect-js" data-idp="<?= $index + 1 ?>" data-url="<?= htmlspecialchars($item['keitaro'] ?? '') ?>" data-label="repeater-button-<?= $index + 1 ?>">
                                        <?php if (!empty($item['image'])): ?>
                                            <img
                                                width="140" height="92"
                                                class="lazy"
                                                data-src="<?= htmlspecialchars($item['image']) ?>"
                                                alt="<?= isset($item['alt']) ? htmlspecialchars($item['alt']) : '' ?>"
                                                title="<?= isset($item['title']) ? htmlspecialchars($item['title']) : '' ?>">
                                        <?php endif; ?>
                                    </div>
                                </div>
                                <div class="casinos__title">
                                    <?php if (!empty($item['heading'])): ?>
                                        <div><?= htmlspecialchars($item['heading']) ?></div>
                                    <?php endif; ?>
                                    <div class="casinos__rait">
                                        <img data-src="images/Star.svg" class="lazy" alt="star" title="star" width="24" height="24">
                                        <div class="casinos__rating-box">
                                            <span class="casinos__rating-value"><?= $item['rating'] ?? calculateRating($index) ?> &nbsp;</span> / 10
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="casinos__bonus">
                                <?= isset($item['text']) ? htmlspecialchars($item['text']) : '' ?>
                            </div>

                            <div class="casinos__button">
                                <?php if (!empty($item['keitaro']) && !empty($item['button'])): ?>
                                    <div class="redirect-js" data-idp="<?= $index + 1 ?>" data-url="<?= htmlspecialchars($item['keitaro']) ?>" data-label="repeater-button-<?= $index + 1 ?>">
                                        <button class="accent-color pass-btn-color">
                                            <?= htmlspecialchars($item['button']) ?>
                                        </button>
                                    </div>
                                <?php endif; ?>
                            </div>
                        </div>
                    <?php endforeach; ?>
                <?php endif; ?>
            </div>

        </section>
        <section>
            <div class="container">
                <div class="secondary__text">
                    <?= htmlspecialchars_decode($content['bottom_text']); ?>
                </div>
            </div>
        </section>
        <section>
            <div class="container">
                <h2><?= $content['faq-title'] ?? '' ?></h2>
                <div class="accordion-container">
                    <?php foreach ($faqItems as $item): ?>
                        <div class="accordion-item">
                            <h3 class="accordion-header faq-title-hover-font-color secondary-color faq-title-font-color">
                                <?= htmlspecialchars($item['question']) ?>
                                <span class="icon  faq-title-hover-font-color faq-title-font-color">+</span>
                            </h3>
                            <div class="accordion-content secondary-color faq-title-font-color">
                                <p>
                                    <?= htmlspecialchars($item['answer']) ?>
                                </p>
                            </div>
                        </div>
                    <?php endforeach; ?>
                </div>
            </div>
        </section>

        </div>
    </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>