/* Сброс стандартных отступов и настройка box-sizing */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}



/* Основные стили для body */
body {
    font-family: 'Inter', sans-serif;
    background-color: #f6f3e4;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Контейнер для всей страницы */
.container {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    padding: 20px;
}

/* Стили для заголовка */
.header {
    text-align: center;
    margin-bottom: 40px;
}

/* Аватар или иконка профиля */
.avatar-container {
    margin-bottom: 20px;
}

.avatar-placeholder {
    width: 100px;
    height: 100px;
    background-color: #a22929;
    border-radius: 50%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 40px;
    box-shadow: 0 4px 12px rgba(162, 41, 41, 0.2);
}

/* Заголовок и подзаголовок */
.title {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 10px;
    color: #333;
}

.subtitle {
    font-size: 16px;
    color: #666;
    font-weight: 400;
    max-width: 300px;
    margin: 0 auto;
}

/* Контейнер для ссылок */
.links-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 40px;
}

/* Общие стили для кнопок-ссылок */
.link-button {
    display: flex;
    align-items: center;
    background-color: #a22929;
    color: white;
    text-decoration: none;
    padding: 18px 20px;
    border-radius: 12px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

/* Эффект при наведении на кнопки */
.link-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.link-button:active {
    transform: translateY(0);
}

/* Иконка внутри кнопки */
.button-icon {
    width: 44px;
    height: 44px;
    background-color: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 16px;
    font-size: 22px;
    flex-shrink: 0;
}

/* Текст на кнопке */
.button-text {
    font-size: 16px;
    font-weight: 500;
    flex-grow: 1;
}

/* Иконка внешней ссылки */
.button-external {
    font-size: 14px;
    opacity: 0.7;
    flex-shrink: 0;
}

/* Индивидуальные оттенки для кнопок (легкие вариации основного цвета) */
.link-button.vk {
    background-color: #a22929;
}

.link-button.whatsapp {
    background-color: #a22929;
}

.link-button.max {
    background-color: #a22929;
}

.link-button.telegram {
    background-color: #a22929;
}

.link-button.website {
    background-color: #a22929;
}

/* Легкие вариации цвета при наведении */
.link-button.vk:hover {
    background-color: #b83535;
}

.link-button.whatsapp:hover {
    background-color: #b83535;
}

.link-button.max:hover {
    background-color: #b83535;
}

.link-button.telegram:hover {
    background-color: #b83535;
}

.link-button.website:hover {
    background-color: #b83535;
}

/* Подвал */
.footer {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.footer-text {
    font-size: 14px;
    color: #666;
    margin-bottom: 8px;
}

.footer-note {
    font-size: 13px;
    color: #888;
}

/* Адаптивность для мобильных устройств */
@media (max-width: 600px) {
    .container {
        padding: 15px;
    }
    
    .title {
        font-size: 24px;
    }
    
    .subtitle {
        font-size: 15px;
    }
    
    .link-button {
        padding: 16px 18px;
    }
    
    .button-icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
        margin-right: 14px;
    }
    
    .button-text {
        font-size: 15px;
    }
}

/* Для очень маленьких экранов */
@media (max-width: 380px) {
    .container {
        padding: 10px;
    }
    
    .link-button {
        padding: 14px 16px;
    }
    
    .button-icon {
        width: 36px;
        height: 36px;
        font-size: 18px;
        margin-right: 12px;
    }
    
    .button-text {
        font-size: 14px;
    }
    
    .title {
        font-size: 22px;
    }
    
    .avatar-placeholder {
        width: 80px;
        height: 80px;
        font-size: 32px;
    }
}

/* Стили для сердечка */
.heart-icon {
    animation: heartbeat 1.5s ease-in-out infinite;
}

@keyframes heartbeat {
    0% {
        transform: scale(1);
    }
    5% {
        transform: scale(1.1);
    }
    10% {
        transform: scale(1);
    }
    15% {
        transform: scale(1.1);
    }
    20% {
        transform: scale(1);
    }
    100% {
        transform: scale(1);
    }
}

// Отслеживаем движение мыши для определения намерения уйти
let mouseY = 0;
let popupShown = false;
let timerInterval;

document.addEventListener('mousemove', function(e) {
    // Если мышь уходит вверх (к крестику закрыть вкладку)
    if (e.clientY < 50 && !popupShown) {
        showPopup();
    }
});

// Также отслеживаем, когда курсор покидает окно
document.addEventListener('mouseout', function(e) {
    if (!e.toElement && !e.relatedTarget && !popupShown) {
        showPopup();
    }
});

// Показываем попап
function showPopup() {
    if (popupShown) return;
    
    const popup = document.getElementById('exitPopup');
    popup.classList.add('active');
    popupShown = true;
    
    // Запускаем таймер
    startTimer(5); // 5 минут
    
    // Сохраняем в localStorage, чтобы не показывать слишком часто
    localStorage.setItem('popupLastShown', Date.now());
    
    // Блокируем прокрутку фона
    document.body.style.overflow = 'hidden';
}

// Закрываем попап
document.getElementById('closePopup').addEventListener('click', function() {
    const popup = document.getElementById('exitPopup');
    popup.classList.remove('active');
    document.body.style.overflow = '';
    
    // Очищаем таймер
    if (timerInterval) {
        clearInterval(timerInterval);
    }
});

// Закрытие при клике на фон
document.getElementById('exitPopup').addEventListener('click', function(e) {
    if (e.target.id === 'exitPopup') {
        const popup = document.getElementById('exitPopup');
        popup.classList.remove('active');
        document.body.style.overflow = '';
        
        if (timerInterval) {
            clearInterval(timerInterval);
        }
    }
});

// Таймер обратного отсчета
function startTimer(minutes) {
    let time = minutes * 60;
    const minutesElement = document.getElementById('minutes');
    const secondsElement = document.getElementById('seconds');
    
    function updateTimer() {
        const minutesLeft = Math.floor(time / 60);
        const secondsLeft = time % 60;
        
        minutesElement.textContent = minutesLeft.toString().padStart(2, '0');
        secondsElement.textContent = secondsLeft.toString().padStart(2, '0');
        
        if (time <= 0) {
            clearInterval(timerInterval);
            // Можно добавить действие по истечении времени
        }
        
        time--;
    }
    
    updateTimer();
    timerInterval = setInterval(updateTimer, 1000);
}

// Не показываем попап, если он уже показывался менее часа назад
window.addEventListener('load', function() {
    const lastShown = localStorage.getItem('popupLastShown');
    const hourInMs = 60 * 60 * 1000;
    
    if (lastShown && (Date.now() - lastShown) < hourInMs) {
        // Не показываем попап
    }
});