@import url('https://fonts.googleapis.com/css2?family=Pacifico&family=Nunito:wght@400;700&display=swap');

body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
    background: radial-gradient(circle at center, #fff0f5, #ffe4e1);
    font-family: 'Nunito', sans-serif;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: none;
    /* Скрываем стандартный курсор для эффекта */
}

/* Canvas для искорок */

/* Контейнер конверта */
.envelope-container {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

/* Конверт */
.envelope {
    position: relative;
    width: 400px;
    height: 280px;
    cursor: pointer;
    transition: transform 0.3s ease;
    background: #ff8fa3; /* Внутренний фон конверта */
    border-radius: 5px;
}

.envelope:hover {
    transform: scale(1.05);
}

/* Карман конверта (передняя часть) */
.envelope-pocket {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 0;
    border-left: 200px solid #ff6b81;
    border-right: 200px solid #ff6b81;
    border-bottom: 140px solid #ff8fa3;
    border-top: 140px solid transparent;
    z-index: 3;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
    pointer-events: none;
}

/* Клапан конверта (верхняя часть) */
.envelope-flap {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-left: 200px solid transparent;
    border-right: 200px solid transparent;
    border-top: 150px solid #ff8fa3;
    z-index: 4;
    transform-origin: top;
    transition: transform 0.5s ease, z-index 0.5s ease;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

/* Письмо внутри конверта */
.letter {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    width: 360px;
    height: 240px;
    background: linear-gradient(135deg, #fff5f7 0%, #ffffff 100%);
    border-radius: 10px;
    z-index: 2;
    transition: transform 0.8s ease, z-index 0.8s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    overflow: hidden;
    cursor: default;
}

.letter::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 30px;
    background: linear-gradient(to bottom, rgba(255,107,129,0.1), transparent);
    pointer-events: none;
}

.letter-content {
    padding: 25px;
    text-align: center;
    height: 100%;
    overflow-y: auto;
}

.letter-content h1 {
    font-family: 'Pacifico', cursive;
    color: #ff6b81;
    font-size: 2rem;
    margin: 0 0 15px 0;
}

.letter-content p {
    color: #555;
    font-size: 1.1rem;
    line-height: 1.6;
    margin: 0;
}

/* Состояние открытого клапана */
.envelope.flap-open .envelope-flap {
    transform: rotateX(180deg);
    z-index: 1;
}

/* Письмо немного видно после открытия клапана - верхняя часть выглядывает */
.envelope.flap-open .letter {
    transform: translateX(-50%) translateY(-30px);
    z-index: 2;
}

/* Письмо выдвинуто из конверта */
.envelope.letter-pulled .envelope-flap {
    transform: rotateX(180deg);
    z-index: 1;
}

.envelope.letter-pulled .letter {
    transform: translateX(-50%) translateY(-150px);
    z-index: 5;
    cursor: pointer;
}

/* Добавляем подсказку для письма */
.letter-hint {
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    color: #ff6b81;
    font-size: 0.9rem;
    opacity: 0;
    transition: opacity 0.3s ease;
    white-space: nowrap;
}

.envelope.flap-open .letter-hint {
    opacity: 0.8;
    animation: pulse 2s infinite;
}

/* Подсказка */
.hint {
    color: #ff6b81;
    font-size: 1rem;
    opacity: 0.8;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 0.4; }
}

/* Скрываем подсказку после открытия клапана */
.envelope.flap-open ~ .hint {
    display: none;
}

/* Адаптивность для мобильных */
@media (max-width: 450px) {
    .envelope {
        width: 320px;
        height: 220px;
    }
    
    .envelope-pocket {
        border-left-width: 160px;
        border-right-width: 160px;
        border-bottom-width: 110px;
        border-top-width: 110px;
    }
    
    .envelope-flap {
        border-left-width: 160px;
        border-right-width: 160px;
        border-top-width: 120px;
    }
    
    .letter {
        width: 290px;
        height: 190px;
    }
    
    .envelope.letter-pulled .letter {
        transform: translateX(-50%) translateY(-120px);
    }
    
    .letter-hint {
        font-size: 0.8rem;
        bottom: -25px;
    }
    
    .letter-content h1 {
        font-size: 1.5rem;
    }
    
    .letter-content p {
        font-size: 0.95rem;
    }
}

/* Анимация появления */
.fade-in {
    animation: fadeIn 1.5s ease-out forwards;
    opacity: 0;
    transform: translateY(20px);
}

@keyframes fadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Кастомный курсор (сердечко) */
.cursor-ring {
    position: fixed;
    width: 40px;
    height: 40px;
    pointer-events: none;
    z-index: 9999;
    left: -100px;
    top: -100px;
    transform: translate(-50%, -50%);
    transition: transform 0.2s;
    mix-blend-mode: multiply;
}

/* Основной контур сердечка - используем SVG через background для устранения шва */
.cursor-ring {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ff6b81' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z'%3E%3C/path%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

/* Заливка сердечка при нажатии */
.cursor-ring .heart-fill {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ff6b81'%3E%3Cpath d='M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z'%3E%3C/path%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.cursor-ring.active .heart-fill {
    opacity: 1;
}

.cursor-dot {
    position: fixed;
    width: 8px;
    height: 8px;
    background: #ff6b81;
    border-radius: 50%;
    pointer-events: none;
    z-index: 10000;
    left: -100px;
    top: -100px;
    transform: translate(-50%, -50%);
}

/* Кнопка управления музыкой */
.music-control {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff6b81, #ff8fa3);
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 15px rgba(255, 107, 129, 0.4);
    transition: all 0.3s ease;
    z-index: 9999;
    padding: 0;
}

.music-control:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(255, 107, 129, 0.6);
}

.music-control:active {
    transform: scale(0.95);
}

.music-control svg {
    width: 24px;
    height: 24px;
    color: white;
    fill: white;
}