/* ============================================
   CSS Variables & Design Tokens
   ============================================ */
:root {
    --pink-100: #fff0f5;
    --pink-200: #fce4ec;
    --pink-300: #f8bbd0;
    --pink-400: #f48fb1;
    --pink-500: #ec407a;
    --pink-600: #e91e63;
    --rose-100: #ffe0e6;
    --rose-200: #ffb3c1;
    --rose-300: #ff8fa3;
    --rose-400: #ff6b81;
    --cream: #fff9f0;
    --warm-white: #fdf6f0;
    --text-dark: #5a3e4b;
    --text-light: #8b6b7b;
    --gold: #d4a574;
    --gold-light: #e8c9a0;
    --shadow-soft: 0 8px 32px rgba(233, 30, 99, 0.15);
    --shadow-medium: 0 12px 48px rgba(233, 30, 99, 0.2);
    --shadow-glow: 0 0 40px rgba(244, 143, 177, 0.4);
    --font-script: 'Dancing Script', cursive;
    --font-body: 'Quicksand', sans-serif;
    --font-fancy: 'Great Vibes', cursive;
    --transition-smooth: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   Reset & Base
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
    background: linear-gradient(135deg, #fce4ec 0%, #fff0f5 30%, #fdf2f8 60%, #fce4ec 100%);
    background-attachment: fixed;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   Background Hearts Animation
   ============================================ */
.hearts-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.bg-heart {
    position: absolute;
    bottom: -50px;
    opacity: 0;
    animation: floatUp linear infinite;
    pointer-events: none;
    filter: blur(0.5px);
}

@keyframes floatUp {
    0% {
        transform: translateY(0) rotate(0deg) scale(1);
        opacity: 0;
    }
    10% {
        opacity: 0.6;
    }
    50% {
        opacity: 0.4;
    }
    90% {
        opacity: 0.1;
    }
    100% {
        transform: translateY(-110vh) rotate(720deg) scale(0.3);
        opacity: 0;
    }
}

/* ============================================
   Sparkle Particles
   ============================================ */
.sparkles-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.sparkle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--pink-400);
    border-radius: 50%;
    animation: sparkle 3s ease-in-out infinite;
    box-shadow: 0 0 6px var(--pink-400), 0 0 12px var(--rose-200);
}

@keyframes sparkle {
    0%, 100% {
        opacity: 0;
        transform: scale(0);
    }
    50% {
        opacity: 1;
        transform: scale(1);
    }
}

/* ============================================
   Main Content
   ============================================ */
.main-content {
    position: relative;
    z-index: 10;
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   Envelope Section
   ============================================ */
.envelope-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    transition: var(--transition-smooth);
}

.envelope-section.hidden {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
    position: absolute;
}

.tap-hint {
    font-family: var(--font-script);
    font-size: 1.3rem;
    color: var(--pink-500);
    margin-bottom: 40px;
    animation: pulse 2s ease-in-out infinite;
    text-shadow: 0 0 20px rgba(236, 64, 122, 0.3);
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.05); }
}

.subtitle-text {
    font-family: var(--font-script);
    font-size: 1.2rem;
    color: var(--text-light);
    margin-top: 40px;
    opacity: 0;
    animation: fadeInUp 1s ease 1s forwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   Envelope Wrapper & Floating Hearts
   ============================================ */
.envelope-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 320px;
    height: 280px;
}

.floating-heart {
    position: absolute;
    font-size: 1.5rem;
    animation: floatAround 4s ease-in-out infinite;
    filter: drop-shadow(0 2px 4px rgba(233, 30, 99, 0.3));
    z-index: 5;
}

.fh-1 {
    top: -10px;
    left: 20px;
    font-size: 1.8rem;
    animation-delay: 0s;
    animation-duration: 3.5s;
}
.fh-2 {
    top: 10px;
    right: 10px;
    font-size: 2rem;
    animation-delay: 0.5s;
    animation-duration: 4s;
}
.fh-3 {
    bottom: 20px;
    left: 10px;
    font-size: 1.3rem;
    animation-delay: 1s;
    animation-duration: 3.8s;
}
.fh-4 {
    top: 30%;
    left: -20px;
    font-size: 1.6rem;
    animation-delay: 1.5s;
    animation-duration: 4.2s;
}
.fh-5 {
    bottom: -5px;
    right: 20px;
    font-size: 1.4rem;
    animation-delay: 0.8s;
    animation-duration: 3.6s;
}
.fh-6 {
    bottom: 40px;
    left: 50%;
    font-size: 1.7rem;
    animation-delay: 2s;
    animation-duration: 4.5s;
}

@keyframes floatAround {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    25% {
        transform: translateY(-15px) rotate(10deg);
    }
    50% {
        transform: translateY(-5px) rotate(-5deg);
    }
    75% {
        transform: translateY(-20px) rotate(8deg);
    }
}

/* ============================================
   Envelope CSS Design
   ============================================ */
.envelope {
    position: relative;
    width: 260px;
    height: 180px;
    cursor: pointer;
    transition: transform 0.3s ease;
    z-index: 10;
}

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

.envelope:active {
    transform: scale(0.98);
}

/* Envelope Back */
.envelope-back {
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(145deg, #f8bbd0, #f48fb1);
    border-radius: 8px;
    box-shadow: var(--shadow-medium);
}

/* Letter inside envelope */
.envelope-letter {
    position: absolute;
    width: 85%;
    height: 80%;
    background: white;
    left: 50%;
    transform: translateX(-50%);
    bottom: 15px;
    border-radius: 4px;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.5s ease;
}

.envelope.opened .envelope-letter {
    transform: translateX(-50%) translateY(-120px);
    opacity: 0;
}

.mini-letter-content {
    text-align: center;
    color: var(--pink-500);
    font-family: var(--font-script);
}

.mini-letter-content .mini-heart {
    font-size: 1.5rem;
    display: block;
    margin-bottom: 5px;
    animation: heartbeat 1.5s ease-in-out infinite;
}

.mini-letter-content p {
    font-size: 1rem;
    font-weight: 600;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    15% { transform: scale(1.25); }
    30% { transform: scale(1); }
    45% { transform: scale(1.15); }
}

/* Envelope Front */
.envelope-front {
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(145deg, #fce4ec, #f8bbd0);
    border-radius: 8px;
    clip-path: polygon(0 40%, 50% 75%, 100% 40%, 100% 100%, 0 100%);
    z-index: 3;
}

/* Envelope Flap (triangle) */
.envelope-flap {
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #f48fb1, #f8bbd0);
    clip-path: polygon(0 0, 50% 45%, 100% 0);
    z-index: 4;
    transform-origin: top center;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 8px 8px 0 0;
}

.envelope.opened .envelope-flap {
    transform: rotateX(180deg);
}

/* Heart seal on flap */
.envelope-heart-seal {
    position: absolute;
    top: 18%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.3rem;
    z-index: 5;
    filter: drop-shadow(0 2px 4px rgba(233, 30, 99, 0.4));
    transition: opacity 0.4s ease;
}

.envelope.opened .envelope-heart-seal {
    opacity: 0;
}

/* Envelope diagonal lines */
.envelope-back::before,
.envelope-back::after {
    content: '';
    position: absolute;
    top: 0;
    width: 50%;
    height: 100%;
    border: none;
}

.envelope-back::before {
    left: 0;
    border-right: 1px solid rgba(255,255,255,0.2);
    clip-path: polygon(0 0, 100% 50%, 0 100%);
    background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent);
}

.envelope-back::after {
    right: 0;
    clip-path: polygon(100% 0, 0 50%, 100% 100%);
    background: linear-gradient(-135deg, rgba(255,255,255,0.1), transparent);
}

/* ============================================
   Letter Section
   ============================================ */
.letter-section {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.8s ease;
    z-index: 100;
    overflow-y: auto;
    padding: 40px 20px;
    background: linear-gradient(135deg, 
        rgba(252, 228, 236, 0.95) 0%, 
        rgba(255, 240, 245, 0.95) 50%, 
        rgba(252, 228, 236, 0.95) 100%);
    backdrop-filter: blur(10px);
}

.letter-section.visible {
    opacity: 1;
    pointer-events: auto;
}

.close-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid var(--pink-300);
    background: rgba(255, 255, 255, 0.9);
    color: var(--pink-500);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
    z-index: 200;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(233, 30, 99, 0.15);
}

.close-btn:hover {
    background: var(--pink-500);
    color: white;
    transform: rotate(90deg) scale(1.1);
    border-color: var(--pink-500);
}

/* ============================================
   Letter Paper Design
   ============================================ */
.letter-container {
    width: 100%;
    max-width: 600px;
    opacity: 0;
    transform: translateY(40px);
    transition: all 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.letter-section.visible .letter-container {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.3s;
}

.letter-paper {
    position: relative;
    background: linear-gradient(180deg, var(--warm-white) 0%, #fff 50%, var(--warm-white) 100%);
    border-radius: 16px;
    padding: 50px 40px;
    box-shadow: 
        0 20px 60px rgba(233, 30, 99, 0.12),
        0 1px 3px rgba(0, 0, 0, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    overflow: hidden;
}

/* Paper texture overlay */
.letter-paper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 31px,
            rgba(244, 143, 177, 0.08) 31px,
            rgba(244, 143, 177, 0.08) 32px
        );
    pointer-events: none;
    z-index: 0;
}

/* Left margin line */
.letter-paper::after {
    content: '';
    position: absolute;
    top: 0;
    left: 55px;
    width: 1px;
    height: 100%;
    background: rgba(236, 64, 122, 0.1);
    pointer-events: none;
    z-index: 0;
}

/* Corner decorations */
.letter-decoration {
    position: absolute;
    width: 60px;
    height: 60px;
    opacity: 0.15;
    z-index: 0;
}

.letter-decoration.top-left {
    top: 10px;
    left: 10px;
    border-top: 3px solid var(--pink-400);
    border-left: 3px solid var(--pink-400);
    border-radius: 8px 0 0 0;
}

.letter-decoration.top-right {
    top: 10px;
    right: 10px;
    border-top: 3px solid var(--pink-400);
    border-right: 3px solid var(--pink-400);
    border-radius: 0 8px 0 0;
}

.letter-decoration.bottom-left {
    bottom: 10px;
    left: 10px;
    border-bottom: 3px solid var(--pink-400);
    border-left: 3px solid var(--pink-400);
    border-radius: 0 0 0 8px;
}

.letter-decoration.bottom-right {
    bottom: 10px;
    right: 10px;
    border-bottom: 3px solid var(--pink-400);
    border-right: 3px solid var(--pink-400);
    border-radius: 0 0 8px 0;
}

/* ============================================
   Letter Typography
   ============================================ */
.letter-title {
    font-family: var(--font-fancy);
    font-size: 2.8rem;
    color: var(--pink-500);
    text-align: center;
    margin-bottom: 10px;
    position: relative;
    z-index: 1;
    text-shadow: 0 2px 10px rgba(233, 30, 99, 0.15);
}

.letter-heart-divider {
    text-align: center;
    font-size: 1.3rem;
    margin-bottom: 35px;
    position: relative;
    z-index: 1;
    animation: heartbeat 2s ease-in-out infinite;
}

.letter-heart-divider::before,
.letter-heart-divider::after {
    content: '';
    display: inline-block;
    width: 80px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--pink-300), transparent);
    vertical-align: middle;
    margin: 0 15px;
}

.letter-body {
    position: relative;
    z-index: 1;
}

.letter-body p {
    font-family: var(--font-body);
    font-size: 1.05rem;
    line-height: 2;
    color: var(--text-dark);
    margin-bottom: 18px;
    text-indent: 2em;
    opacity: 0;
    transform: translateY(15px);
    animation: fadeInParagraph 0.8s ease forwards;
}

.letter-section.visible .letter-body p:nth-child(1) { animation-delay: 0.6s; }
.letter-section.visible .letter-body p:nth-child(2) { animation-delay: 0.9s; }
.letter-section.visible .letter-body p:nth-child(3) { animation-delay: 1.2s; }
.letter-section.visible .letter-body p:nth-child(4) { animation-delay: 1.5s; }
.letter-section.visible .letter-body p:nth-child(5) { animation-delay: 1.8s; }
.letter-section.visible .letter-body p:nth-child(6) { animation-delay: 2.1s; }

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

.letter-body p:first-child {
    font-family: var(--font-script);
    font-size: 1.3rem;
    color: var(--pink-500);
    text-indent: 0;
    font-weight: 500;
}

.letter-signature {
    margin-top: 35px;
    text-align: right;
    padding-right: 20px;
    opacity: 0;
    animation: fadeInParagraph 0.8s ease forwards;
}

.letter-section.visible .letter-signature {
    animation-delay: 2.4s;
}

.letter-signature p {
    text-indent: 0 !important;
    margin-bottom: 5px !important;
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
    font-family: var(--font-script);
    font-size: 1.2rem;
    color: var(--text-light);
}

.signature-name {
    font-family: var(--font-fancy) !important;
    font-size: 1.8rem !important;
    color: var(--pink-500) !important;
    text-shadow: 0 2px 8px rgba(233, 30, 99, 0.15);
}

/* ============================================
   Music Button
   ============================================ */
.music-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid var(--pink-300);
    background: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
    z-index: 200;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(233, 30, 99, 0.15);
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

.music-btn.visible {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}

.music-btn:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-glow);
}

.music-btn.playing .music-icon {
    animation: musicBounce 0.8s ease-in-out infinite;
}

.music-icon {
    font-size: 1.3rem;
}

@keyframes musicBounce {
    0%, 100% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.2) rotate(-10deg); }
    75% { transform: scale(1.1) rotate(10deg); }
}

/* ============================================
   Burst Hearts (on envelope open)
   ============================================ */
.burst-heart {
    position: fixed;
    font-size: 1.5rem;
    pointer-events: none;
    z-index: 50;
    animation: burstOut 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes burstOut {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translate(var(--tx), var(--ty)) scale(0) rotate(360deg);
    }
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 480px) {
    .envelope {
        width: 220px;
        height: 150px;
    }

    .envelope-wrapper {
        width: 280px;
        height: 240px;
    }

    .tap-hint {
        font-size: 1.1rem;
    }

    .letter-paper {
        padding: 35px 25px;
        border-radius: 12px;
    }

    .letter-paper::after {
        left: 35px;
    }

    .letter-title {
        font-size: 2.2rem;
    }

    .letter-body p {
        font-size: 0.95rem;
        line-height: 1.9;
    }

    .letter-heart-divider::before,
    .letter-heart-divider::after {
        width: 50px;
    }

    .close-btn {
        top: 15px;
        left: 15px;
        width: 38px;
        height: 38px;
        font-size: 1rem;
    }

    .letter-section {
        padding: 30px 15px;
    }

    .letter-decoration {
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 360px) {
    .envelope {
        width: 200px;
        height: 140px;
    }

    .letter-title {
        font-size: 1.8rem;
    }

    .signature-name {
        font-size: 1.4rem !important;
    }
}

/* ============================================
   Loading Animation
   ============================================ */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--pink-200), var(--pink-100));
    z-index: 9999;
    animation: fadeOut 1.5s ease 0.5s forwards;
    pointer-events: none;
}

@keyframes fadeOut {
    to {
        opacity: 0;
        visibility: hidden;
    }
}

/* ============================================
   Scroll indicator glow
   ============================================ */
.letter-section::-webkit-scrollbar {
    width: 6px;
}

.letter-section::-webkit-scrollbar-track {
    background: transparent;
}

.letter-section::-webkit-scrollbar-thumb {
    background: var(--pink-300);
    border-radius: 3px;
}

.letter-section::-webkit-scrollbar-thumb:hover {
    background: var(--pink-400);
}
