/* 
  Aysu - Romantic Animated Website Styling
  Designed with deep gothic-romantic HSL gradients, glassmorphism, 
  smooth 3D transforms, and custom typographic layouts.
*/

:root {
    --bg-primary: hsl(265, 80%, 4%);
    --bg-secondary: hsl(275, 70%, 8%);
    --accent-rose: hsl(340, 85%, 65%);
    --accent-rose-glow: hsla(340, 85%, 65%, 0.4);
    --accent-gold: hsl(42, 100%, 62%);
    --accent-gold-glow: hsla(42, 100%, 62%, 0.3);
    --accent-violet: hsl(282, 85%, 60%);
    
    --text-primary: hsl(0, 0%, 94%);
    --text-muted: hsl(270, 20%, 75%);
    
    --glass-bg: rgba(15, 6, 25, 0.55);
    --glass-border: rgba(255, 105, 180, 0.15);
    --glass-shadow: 0 15px 35px rgba(0, 0, 0, 0.6), 
                    0 0 20px rgba(138, 43, 226, 0.15);
    
    --font-serif: 'Playfair Display', serif;
    --font-sans: 'Montserrat', sans-serif;
    --font-cursive: 'Great Vibes', cursive;
}

/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
}

body {
    background: radial-gradient(circle at center, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Custom Custom Cursor Glow */
.cursor-glow {
    position: fixed;
    top: 0;
    left: 0;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(236, 72, 153, 0.08) 0%, rgba(139, 92, 246, 0.03) 50%, transparent 70%);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 1;
    transition: width 0.3s, height 0.3s;
}

/* Multilingual Floating background text */
.love-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.floating-text {
    position: absolute;
    font-family: var(--font-serif);
    font-weight: 600;
    font-style: italic;
    color: rgba(255, 255, 255, 0.03);
    text-shadow: 0 0 15px rgba(255, 105, 180, 0.02);
    white-space: nowrap;
    transform: scale(var(--scale));
    top: var(--top);
    left: var(--left);
    animation: float-love 22s infinite ease-in-out;
    animation-delay: var(--delay);
}

/* Distinct language highlights */
.floating-text.tr { color: rgba(255, 182, 193, 0.04); }
.floating-text.az { color: rgba(255, 223, 186, 0.04); }
.floating-text.ru { color: rgba(221, 160, 221, 0.04); }
.floating-text.fr { color: rgba(173, 216, 230, 0.03); }
.floating-text.en { color: rgba(240, 230, 140, 0.03); }

@keyframes float-love {
    0% {
        transform: translate(0, 0) rotate(0deg) scale(var(--scale));
        opacity: 0;
    }
    10% {
        opacity: 0.6;
    }
    50% {
        transform: translate(30px, -40px) rotate(3deg) scale(calc(var(--scale) * 1.05));
        opacity: 0.9;
        text-shadow: 0 0 25px rgba(255, 105, 180, 0.1);
    }
    90% {
        opacity: 0.6;
    }
    100% {
        transform: translate(0, -80px) rotate(-3deg) scale(var(--scale));
        opacity: 0;
    }
}

/* Fullscreen Canvas */
#animation-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

/* Content Wrapper */
.content-wrapper {
    position: relative;
    z-index: 3;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    padding: 20px;
}

/* 3D Envelope Component */
.envelope-container {
    perspective: 1200px;
    width: 450px;
    height: 300px;
    position: relative;
    cursor: pointer;
    transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.envelope-container:hover {
    transform: translateY(-8px) scale(1.02);
}

.envelope {
    width: 100%;
    height: 100%;
    background-color: hsl(270, 45%, 12%);
    border-radius: 12px;
    position: relative;
    transform-style: preserve-3d;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.7),
                inset 0 0 25px rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Envelope Front Diagonal Wings */
.envelope::before {
    content: '';
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    z-index: 3;
    border-radius: 12px;
    background: 
        linear-gradient(28deg, hsl(270, 50%, 9%) 49.5%, transparent 50%),
        linear-gradient(-28deg, hsl(270, 50%, 9%) 49.5%, transparent 50%);
    background-size: 100% 100%;
}

.envelope-front {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: 4;
    border-radius: 12px;
    background: 
        linear-gradient(150deg, transparent 60%, hsla(270, 50%, 6%, 0.4) 60%),
        linear-gradient(30deg, hsl(270, 45%, 10%) 50%, transparent 50%),
        linear-gradient(-30deg, hsl(270, 45%, 10%) 50%, transparent 50%);
    border-bottom: 2px solid rgba(255, 105, 180, 0.2);
}

/* Envelope Top Flap */
.envelope-top {
    position: absolute;
    top: -2px;
    left: 0;
    width: 100%;
    height: 52%;
    z-index: 7;
    background: hsl(270, 40%, 14%);
    clip-path: polygon(0 0, 50% 100%, 100% 0);
    transform-origin: top;
    transition: transform 0.6s ease-in-out, z-index 0.3s ease-in-out;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.4);
}

.envelope.open .envelope-top {
    transform: rotateX(180deg);
    z-index: 1;
}

/* Body container holding the triggers */
.envelope-body {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 15;
}

/* Pulsing Heart Button */
.heart-btn {
    position: relative;
    width: 75px;
    height: 75px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--accent-rose) 0%, hsl(330, 90%, 50%) 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 8;
    box-shadow: 0 0 25px var(--accent-rose),
                0 0 50px rgba(236, 72, 153, 0.3);
    cursor: pointer;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), 
                box-shadow 0.3s, 
                opacity 0.4s ease-out;
}

.heart-btn:hover {
    transform: scale(1.15) rotate(5deg);
    box-shadow: 0 0 35px var(--accent-rose),
                0 0 70px rgba(236, 72, 153, 0.6);
}

/* Hide heart button beautifully when envelope is open */
.envelope.open .heart-btn {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.4) rotate(-10deg);
}

.heart-svg {
    display: block;
    width: 32px;
    height: 32px;
    fill: #fff;
    filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.3));
    animation: heart-beat 1.4s infinite ease-in-out;
}

.pulse-ring {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: 50%;
    border: 2px solid var(--accent-rose);
    animation: pulse-out 1.8s infinite ease-out;
    pointer-events: none;
}

.click-prompt {
    position: absolute;
    bottom: -32px;
    font-family: var(--font-sans);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--accent-gold);
    white-space: nowrap;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.6);
    animation: text-pulse 2s infinite ease-in-out;
}

@keyframes heart-beat {
    0%, 100% { transform: scale(1); }
    30% { transform: scale(1.18); }
    45% { transform: scale(1.05); }
    60% { transform: scale(1.2); }
}

@keyframes pulse-out {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.8); opacity: 0; }
}

@keyframes text-pulse {
    0%, 100% { opacity: 0.6; transform: translateY(0); }
    50% { opacity: 1; transform: translateY(-3px); }
}

/* The Romantic Letter Card */
.letter {
    position: absolute;
    left: 4%;
    top: 5%;
    width: 92%;
    height: 90%;
    background: var(--glass-bg);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    box-shadow: var(--glass-shadow);
    padding: 30px;
    z-index: 2;
    transition: transform 0.8s cubic-bezier(0.19, 1, 0.22, 1), 
                z-index 0.1s ease-out;
    overflow: hidden;
    transform: translateY(0) scale(0.95);
    opacity: 0.5;
}

/* When letter slides out */
.envelope.open .letter {
    transform: translateY(-240px) scale(1.08);
    opacity: 1;
    z-index: 10;
    height: 480px;
    cursor: default;
}

.letter-content {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    opacity: 0;
    transition: opacity 0.4s ease-out;
    transition-delay: 0.4s;
}

.envelope.open .letter-content {
    opacity: 1;
}

.letter-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border-bottom: 1px solid rgba(255, 105, 180, 0.15);
    padding-bottom: 10px;
}

.letter-title {
    font-family: var(--font-serif);
    font-size: 1.6rem;
    color: var(--accent-rose);
    text-shadow: 0 0 10px rgba(255, 105, 180, 0.3);
}

.letter-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}

.letter-body {
    flex-grow: 1;
    padding: 20px 0;
    font-family: var(--font-serif);
    font-size: 1.15rem;
    line-height: 1.7;
    color: var(--text-primary);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-rose-glow) transparent;
}

.letter-body::-webkit-scrollbar {
    width: 4px;
}
.letter-body::-webkit-scrollbar-thumb {
    background: var(--accent-rose-glow);
    border-radius: 4px;
}

.typewriter-text {
    font-style: italic;
    min-height: 100px;
}

.letter-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(255, 105, 180, 0.15);
    padding-top: 10px;
}

.signature {
    font-family: var(--font-cursive);
    font-size: 2rem;
    color: var(--accent-gold);
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.2);
}

.interactive-heart-stamp {
    font-size: 1.4rem;
    color: var(--accent-rose);
    cursor: pointer;
    transition: transform 0.3s;
}

.interactive-heart-stamp:hover {
    transform: scale(1.3) rotate(15deg);
}

/* Floating Controls Panel */
.controls-panel {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 100;
    display: flex;
    gap: 15px;
}

.control-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(0,0,0,0.5);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), 
                border-color 0.3s, 
                box-shadow 0.3s, 
                color 0.3s;
    outline: none;
}

.control-btn:hover {
    transform: scale(1.1) translateY(-3px);
    border-color: var(--accent-rose);
    box-shadow: 0 10px 30px rgba(236, 72, 153, 0.3);
    color: var(--accent-rose);
}

/* Sound waves display on active play */
.sound-wave-container {
    display: none;
    align-items: flex-end;
    justify-content: space-between;
    width: 20px;
    height: 18px;
    pointer-events: none;
}

.wave-bar {
    width: 3px;
    height: 100%;
    background-color: var(--accent-rose);
    border-radius: 3px;
    transform-origin: bottom;
    animation: bounce-wave 1.2s ease-in-out infinite alternate;
}

.wave-bar:nth-child(1) { animation-delay: 0.1s; }
.wave-bar:nth-child(2) { animation-delay: 0.4s; }
.wave-bar:nth-child(3) { animation-delay: 0.2s; }
.wave-bar:nth-child(4) { animation-delay: 0.5s; }

@keyframes bounce-wave {
    0% { transform: scaleY(0.2); }
    100% { transform: scaleY(1); }
}

.music-btn.playing .music-icon {
    display: none;
}

.music-btn.playing .sound-wave-container {
    display: flex;
}

/* Dynamic screen toast hint */
.toast-hint {
    position: fixed;
    top: 30px;
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    z-index: 101;
    letter-spacing: 0.5px;
    animation: fade-pulse-hint 4s ease-in-out infinite;
    pointer-events: none;
}

@keyframes fade-pulse-hint {
    0%, 100% { opacity: 0.4; transform: translateY(0) scale(0.98); }
    50% { opacity: 0.95; transform: translateY(-3px) scale(1); color: var(--accent-rose); }
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .envelope-container {
        width: 340px;
        height: 230px;
    }
    
    .envelope.open .letter {
        transform: translateY(-160px) scale(1.02);
        height: 380px;
        padding: 20px;
    }
    
    .letter-title {
        font-size: 1.3rem;
    }
    
    .letter-body {
        font-size: 1rem;
        padding: 12px 0;
    }
    
    .signature {
        font-size: 1.6rem;
    }
    
    .controls-panel {
        bottom: 20px;
        right: 20px;
        gap: 10px;
    }
    
    .control-btn {
        width: 44px;
        height: 44px;
    }
    
    .floating-text {
        font-size: 0.9rem;
    }
}

@media (max-height: 700px) and (min-width: 600px) {
    .envelope.open .letter {
        transform: translateY(-180px) scale(0.95);
        height: 380px;
    }
}
