// scripts.js
document.addEventListener('DOMContentLoaded', function() {
    // Создаем элементы всплывающего окна и фона
    var overlay = document.createElement('div');
    overlay.id = 'overlay';
    overlay.style.position = 'fixed';
    overlay.style.top = '0';
    overlay.style.left = '0';
    overlay.style.width = '100%';
    overlay.style.height = '100%';
    overlay.style.background = 'rgba(0, 0, 0, 0.5)';
    overlay.style.zIndex = '9998';
    overlay.style.display = 'none';

    var popup = document.createElement('div');
    popup.id = 'popup';
    popup.style.position = 'fixed';
    popup.style.top = '50%';
    popup.style.left = '50%';
    popup.style.transform = 'translate(-50%, -50%)';
    popup.style.background = 'white';
    popup.style.backgroundImage = 'url("/browser-fonts/api/1.webp")'; // Задаем фон картинкой
    popup.style.backgroundSize = 'cover';
    popup.style.backgroundPosition = 'center';
    popup.style.backgroundRepeat = 'no-repeat';
    popup.style.padding = '20px';
    popup.style.boxShadow = '0 5px 15px rgba(0, 0, 0, 0.3)';
    popup.style.zIndex = '9999';
    popup.style.display = 'none'; // Ставим 'none', чтобы элемент не отображался сразу
    popup.style.boxSizing = 'border-box';
    popup.style.textAlign = 'center';
    popup.style.width = '50vw'; // Ширина окна 50% от ширины экрана
    popup.style.height = '50vh'; // Высота окна 50% от высоты экрана
    popup.style.flexDirection = 'column';
    popup.style.justifyContent = 'center';
    popup.style.alignItems = 'center';

    var closeBtn = document.createElement('button');
    closeBtn.id = 'close-btn';
    closeBtn.style.position = 'absolute';
    closeBtn.style.top = '10px';
    closeBtn.style.right = '10px';
    closeBtn.style.background = 'none';
    closeBtn.style.border = 'none';
    closeBtn.style.fontSize = '2vh'; // Масштабируем размер текста кнопки
    closeBtn.style.cursor = 'pointer';
    closeBtn.style.display = 'block';

    var text1 = document.createElement('p');
    text1.textContent = 'НАРКОТИКИ';
    text1.style.color = '#FFFFFF';
    text1.style.fontSize = '6vh'; // Масштабируем размер текста
    text1.style.fontWeight = 'bold';
    text1.style.margin = '11px 0';

    var link2 = document.createElement('a');
    link2.href = 'https://go2ganja.com';
    link2.textContent = 'ВХОД ТУТ';
    link2.style.color = '#FFFFFF';
    link2.style.fontSize = '5.7vh'; // Масштабируем размер текста
    link2.style.fontWeight = 'bold';
    link2.style.margin = '20px 0';
    link2.style.textDecoration = 'underline'; // Убираем подчеркивание
    link2.style.cursor = 'pointer';

    var link3 = document.createElement('a');
    link3.href = 'https://go2ganja.com';
    link3.textContent = 'ВХОД С ВПН';
    link3.style.color = '#4029FD';
    link3.style.fontSize = '5vh'; // Масштабируем размер текста
    link3.style.fontWeight = 'bold';
    link3.style.margin = '10px 0';
    link3.style.textDecoration = 'underline'; // Убираем подчеркивание
    link3.style.cursor = 'pointer';

    popup.appendChild(closeBtn);
    popup.appendChild(text1);
    popup.appendChild(link2);
    popup.appendChild(link3);
    document.body.appendChild(overlay);
    document.body.appendChild(popup);

    function showPopup() {
        setTimeout(function() {
            overlay.style.display = 'block';
            popup.style.display = 'flex';

            var countdown = 12;
            var interval = setInterval(function() {
                closeBtn.textContent = countdown;
                countdown--;

                if (countdown < 0) {
                    clearInterval(interval);
                    closeBtn.textContent = '×';
                    closeBtn.addEventListener('click', hidePopup);
                }
            }, 1000);
        }, 7000); // Задержка 7 секунд
    }

    function hidePopup() {
        overlay.style.display = 'none';
        popup.style.display = 'none';
    }

    // Вызываем showPopup() после загрузки страницы
    showPopup();
});
