/* ==========================================================================
   DESIGN SYSTEM & VARIABLES
   ========================================================================== */
:root {
    --bg-dark: #0f050c;
    --bg-mid: #1d0918;
    --bg-gradient: linear-gradient(135deg, #0a0308 0%, #1a0614 50%, #29091d 100%);
    --accent-red: #ff3366;
    --accent-pink: #ff5e7e;
    --accent-rose: #ff85a1;
    --accent-gold: #f4d068;
    --text-white: #fff0f5;
    --text-muted: #ffccd5;
    --glass-bg: rgba(26, 8, 20, 0.65);
    --glass-border: rgba(255, 94, 126, 0.15);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    --font-serif: 'Playfair Display', Georgia, serif;
    --font-sans: 'Montserrat', sans-serif;
    --font-cursive: 'Dancing Script', cursive;
}

/* ==========================================================================
   RESET & BASE STYLES
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-dark);
    background: var(--bg-gradient);
    font-family: var(--font-sans);
    color: var(--text-white);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Canvas background for heart particles */
#heart-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

/* Main App Wrapper */
#app {
    position: relative;
    width: 100%;
    height: 100%;
    z-index: 2;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Screen Management */
.screen {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.95);
    transition: opacity 1.2s cubic-bezier(0.4, 0, 0.2, 1), 
                transform 1.2s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 20px;
}

.screen.active {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}

/* ==========================================================================
   SCREEN 1: INTRO / ENVELOPE
   ========================================================================== */
.intro-content {
    text-align: center;
    max-width: 450px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
}

.intro-title {
    font-family: var(--font-serif);
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1.4;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    animation: fadeInDown 1.5s ease;
}

/* Envelope Container */
.envelope-wrapper {
    position: relative;
    width: 180px;
    height: 130px;
    perspective: 800px;
    cursor: pointer;
    animation: floatEnvelope 4s ease-in-out infinite;
}

.envelope {
    position: absolute;
    width: 100%;
    height: 100%;
    background: #e63956;
    border-radius: 6px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    transition: transform 0.5s ease;
}

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

/* Flap at top of envelope */
.envelope-flap {
    position: absolute;
    top: 0;
    left: 0;
    border-left: 90px solid transparent;
    border-right: 90px solid transparent;
    border-top: 70px solid #d92b47;
    transform-origin: top;
    transition: transform 0.4s ease 0.1s;
    z-index: 3;
}

/* Letter inside the envelope */
.envelope-paper {
    position: absolute;
    bottom: 5px;
    left: 15px;
    width: 150px;
    height: 90px;
    background: #fff0f5;
    border-radius: 4px;
    z-index: 2;
    transition: transform 0.4s ease;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Heart Wax Seal / Button */
.envelope-heart {
    position: absolute;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 2.2rem;
    color: #ff3366;
    z-index: 4;
    text-shadow: 0 2px 5px rgba(0,0,0,0.2);
    animation: heartbeat 1.4s infinite alternate;
    user-select: none;
    transition: transform 0.3s ease;
}

.envelope-wrapper:hover .envelope-heart {
    animation-play-state: paused;
    transform: translateX(-50%) scale(1.2);
}

/* Interactive envelope animation states (JS triggered class if needed, or hover preview) */
.envelope-wrapper:hover .envelope-flap {
    transform: rotateX(180deg);
    z-index: 1;
}

.envelope-wrapper:hover .envelope-paper {
    transform: translateY(-25px);
}

.intro-hint {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-style: italic;
    letter-spacing: 0.5px;
    animation: pulseText 2s infinite;
}

/* ==========================================================================
   SCREEN 2: GREETING / CELEBRATION
   ========================================================================== */
.greeting-content {
    text-align: center;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
}

.birthday-banner {
    padding: 20px;
}

.sparkle-text {
    font-family: var(--font-serif);
    font-size: 3.5rem;
    font-weight: 700;
    line-height: 1.2;
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 94, 126, 0.8),
                 0 0 20px rgba(255, 94, 126, 0.4),
                 0 0 30px rgba(255, 94, 126, 0.2);
    animation: textShimmer 3s ease infinite alternate;
}

/* Glow Button Style */
.btn-glow {
    position: relative;
    padding: 16px 36px;
    font-family: var(--font-sans);
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 1px;
    color: #fff;
    background: linear-gradient(45deg, var(--accent-red), var(--accent-pink));
    border: none;
    border-radius: 50px;
    cursor: pointer;
    outline: none;
    box-shadow: 0 0 20px rgba(255, 51, 102, 0.4);
    transition: all 0.3s ease;
    overflow: hidden;
    z-index: 1;
}

.btn-glow::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, var(--accent-rose), var(--accent-red));
    opacity: 0;
    z-index: -1;
    transition: opacity 0.3s ease;
}

.btn-glow:hover {
    transform: translateY(-3px);
    box-shadow: 0 0 30px rgba(255, 51, 102, 0.7);
}

.btn-glow:hover::before {
    opacity: 1;
}

.btn-glow:active {
    transform: translateY(-1px);
}

/* ==========================================================================
   SCREEN 3: THE LOVE LETTER
   ========================================================================== */
.letter-container {
    width: 100%;
    max-width: 580px;
    height: 90%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 20px;
}

/* Card with glassmorphism */
.letter-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: var(--glass-shadow);
    padding: 40px 30px;
    overflow-y: auto;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: relative;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 94, 126, 0.3) rgba(0, 0, 0, 0.1);
}

/* Custom scrollbar for modern browsers */
.letter-card::-webkit-scrollbar {
    width: 6px;
}
.letter-card::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 10px;
}
.letter-card::-webkit-scrollbar-thumb {
    background: rgba(255, 94, 126, 0.4);
    border-radius: 10px;
}
.letter-card::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 94, 126, 0.6);
}

/* Letter elements styling */
.letter-header {
    display: flex;
    justify-content: center;
    margin-bottom: 5px;
}

.wax-seal {
    font-size: 2.2rem;
    color: var(--accent-red);
    background: rgba(255, 51, 102, 0.1);
    width: 65px;
    height: 65px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px dashed rgba(255, 51, 102, 0.3);
    box-shadow: inset 0 0 10px rgba(255, 51, 102, 0.2);
    animation: rotateSeal 20s linear infinite;
}

.letter-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.letter-greeting {
    font-family: var(--font-serif);
    font-size: 1.8rem;
    color: var(--accent-rose);
    padding-bottom: 5px;
}

.letter-subheader {
    font-family: var(--font-sans);
    font-size: 1.05rem;
    color: var(--accent-gold);
    font-style: italic;
    opacity: 0.9;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 12px;
    margin-top: -5px;
    margin-bottom: 5px;
    font-weight: 300;
}

.letter-text {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text-white);
    display: flex;
    flex-direction: column;
    gap: 18px;
    font-weight: 300;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.letter-text p {
    text-align: justify;
}

.letter-signature {
    margin-top: 25px;
    text-align: right;
    display: flex;
    flex-direction: column;
    gap: 5px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 15px;
}

.letter-signature p:first-child {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-style: italic;
}

.signature-name {
    font-family: var(--font-cursive);
    font-size: 2.5rem;
    color: var(--accent-pink);
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Actions panel below letter */
.letter-actions {
    display: flex;
    justify-content: space-between;
    gap: 15px;
}

/* Secondary Button designs */
.btn-love, .btn-music {
    flex: 1;
    padding: 14px 20px;
    border-radius: 30px;
    border: 1px solid var(--glass-border);
    cursor: pointer;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #fff;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.btn-love {
    background: rgba(255, 51, 102, 0.15);
    box-shadow: 0 4px 15px rgba(255, 51, 102, 0.1);
}

.btn-love:hover {
    background: rgba(255, 51, 102, 0.35);
    box-shadow: 0 4px 20px rgba(255, 51, 102, 0.25);
    transform: translateY(-2px);
}

.btn-music {
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.btn-music:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.btn-love:active, .btn-music:active {
    transform: translateY(0);
}

#love-count {
    background: var(--accent-red);
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.8rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* ==========================================================================
   ANIMATIONS & KEYFRAMES
   ========================================================================== */
@keyframes heartbeat {
    0% { transform: translateX(-50%) scale(0.95); }
    100% { transform: translateX(-50%) scale(1.1); }
}

@keyframes floatEnvelope {
    0% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-10px) rotate(1deg); }
    100% { transform: translateY(0px) rotate(0deg); }
}

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

@keyframes pulseText {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

@keyframes textShimmer {
    from {
        text-shadow: 0 0 10px rgba(255, 94, 126, 0.8), 
                     0 0 20px rgba(255, 94, 126, 0.4);
    }
    to {
        text-shadow: 0 0 15px rgba(255, 94, 126, 1), 
                     0 0 35px rgba(255, 94, 126, 0.7),
                     0 0 50px rgba(255, 212, 104, 0.4);
    }
}

@keyframes rotateSeal {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */
@media (max-width: 600px) {
    .sparkle-text {
        font-size: 2.3rem;
    }
    .intro-title {
        font-size: 1.4rem;
        padding: 0 10px;
    }
    .letter-card {
        padding: 25px 20px;
    }
    .letter-greeting {
        font-size: 1.5rem;
    }
    .letter-text {
        font-size: 0.95rem;
        line-height: 1.6;
    }
    .signature-name {
        font-size: 1.5rem;
    }
    .letter-actions {
        flex-direction: column;
        gap: 10px;
    }
}

/* Secret Section & Glowing Message */
.secret-section {
    margin-top: 35px;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: 80px;
}

.secret-section .btn-love {
    max-width: 250px;
    width: 100%;
    animation: pulseButton 2s infinite alternate;
}

.secret-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    opacity: 0;
    transform: scale(0.7);
    transition: all 1.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    user-select: none;
    width: 100%;
}

.secret-message.show {
    opacity: 1;
    transform: scale(1);
}

.secret-text {
    font-family: var(--font-cursive);
    font-size: 3.2rem;
    color: var(--accent-rose);
    text-align: center;
    text-shadow: 0 0 15px rgba(255, 94, 126, 0.8),
                 0 0 30px rgba(255, 94, 126, 0.4);
    line-height: 1.2;
    margin: 0;
}

.photo-frame {
    width: 240px;
    height: 310px;
    background: rgba(255, 255, 255, 0.06);
    border: 3px solid rgba(255, 94, 126, 0.5);
    border-radius: 16px;
    padding: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    margin-top: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    overflow: hidden;
}

.secret-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
}

.hidden {
    display: none !important;
}

@keyframes pulseButton {
    0% {
        box-shadow: 0 0 15px rgba(255, 51, 102, 0.3);
        transform: scale(1);
    }
    100% {
        box-shadow: 0 0 25px rgba(255, 51, 102, 0.65);
        transform: scale(1.03);
    }
}

@media (max-width: 600px) {
    .secret-text {
        font-size: 2.4rem;
    }
    .photo-frame {
        width: 180px;
        height: 240px;
        padding: 6px;
    }
}
