/* =========================================
   1. GLOBAL RESETS & BODY
   ========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    
    /* Kills the blue tap-highlight box on mobile/tablets */
    -webkit-tap-highlight-color: transparent;
    
    /* Prevents accidental text selection while tapping or swiping */
    -webkit-user-select: none; /* Safari/iOS */
    user-select: none; /* Standard */
}
body {
    font-family: 'Varela Round', sans-serif;
    
    /* Premium Moonlit Ivory Animated Background */
    background: linear-gradient(-45deg, #fdfbfb, #f3ede6, #ebedee, #faecee);
    background-size: 400% 400%;
    animation: ambientGlow 15s ease infinite;
    
    overflow-x: hidden;
    overflow-y: hidden; 
    width: 100%;
    color: #5e4648;
}

@keyframes ambientGlow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* =========================================
   2. TYPOGRAPHY
   ========================================= */
h1, h2, h3 {
    font-family: 'Fredoka One', cursive;
    color: #5e4648; /* Soft Cocoa color */
    margin-bottom: 10px;
}

p {
    color: #7a6163;
    font-size: 1.1rem;
    line-height: 1.5;
}

/* =========================================
   3. SECTION 1: THE HUG SCENE
   ========================================= */
#main-screen {
    height: 100vh; /* Takes up full screen height */
    width: 100%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.screen {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex; /* Flexbox centers everything */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    transition: opacity 0.5s ease;
}

/* CRITICAL: This class hides elements! */
.hidden {
    display: none !important;
    opacity: 0;
}

/* WAITING SCREEN ANIMATION */
#waiting-img {
    width: 150px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}

/* BUTTON STYLING */
#start-btn {
    margin-top: 20px;
    padding: 15px 35px;
    font-family: 'Fredoka One', cursive;
    font-size: 1.2rem;
    color: #5e4648; /* Soft Cocoa */
    
    /* Morph-blur Button Styling */
    background: rgba(255, 255, 255, 0.45);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 50px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.05), inset 0 0 10px rgba(255,255,255,0.5);
    
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    animation: floatingPulse 2.5s infinite ease-in-out;
}

#start-btn:active {
    transform: translateY(2px) scale(0.98);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

@keyframes floatingPulse {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-5px) scale(1.02); box-shadow: 0 15px 35px rgba(0, 0, 0, 0.08); }
}
/* =========================================
   4. THE ANIMATION STAGE (BEARS & DUST)
   ========================================= */
.characters-container {
    position: relative;
    width: 100%;
    height: 300px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; /* Keeps running bears inside the box */
}

.character {
    position: absolute;
    width: 150px;
    /* This makes them run slowly (3 seconds) */
    transition: left 3s linear, right 3s linear, transform 3s linear !important;
    z-index: 50;
}

/* Initial Positions (Off-screen) */
#char-left { left: -300px; }
#char-right { right: -300px; }

/* Running States */
.rush-in-left { 
    left: 50% !important; 
    transform: translateX(-50%) !important; 
}

.rush-in-right { 
    right: 50% !important; 
    transform: translateX(50%) !important; 
}

/* HUG GIF (Updated Size) */
#hug-gif {
    width: 200px; /* 20% Smaller */
    z-index: 10;
}

/* DUST CLOUD EFFECT (Updated Size & Layer) */
.dust-effect {
    position: absolute;
    width: 150px;  /* Bigger dust */
    height: 150px; /* Bigger dust */
    background: radial-gradient(circle, #f0f0f0 20%, transparent 70%); /* Soft puff look */
    
    bottom: 50px; 
    left: 50%;
    transform: translateX(-50%) scale(0);
    z-index: 999; /* On top of everything */
    opacity: 0;
    pointer-events: none;
}

.dust-active {
    animation: poof 0.8s ease-out forwards;
}

@keyframes poof {
    0% { transform: translateX(-50%) scale(0.5); opacity: 1; }
    100% { transform: translateX(-50%) scale(2.5); opacity: 0; }
}

/* =========================================
   5. MESSAGE CARD
   ========================================= */
.card {
    /* Deep Morph-Blur UI */
    background: rgba(255, 255, 255, 0.35);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-top: 1px solid rgba(255, 255, 255, 0.8);
    border-left: 1px solid rgba(255, 255, 255, 0.8);
    border-right: 1px solid rgba(255, 255, 255, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    
    padding: 30px 20px;
    border-radius: 24px;
    width: 85%;
    max-width: 400px;
    margin-top: 20px;
    
    /* Elegant soft shadow */
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.06);
    transform: translateY(50px);
    opacity: 0;
    transition: all 0.8s cubic-bezier(0.25, 0.8, 0.25, 1);
    z-index: 20;
}
.card.show-card {
    transform: translateY(0);
    opacity: 1;
}

.signature {
    margin-top: 15px;
    font-weight: bold;
    color: #ff4d6d;
}

/* SCROLL HINT TEXT */
.hidden-hint {
    opacity: 0;
    margin-top: 15px;
    font-size: 0.9rem;
    color: #ff4d6d;
    animation: bounce 2s infinite;
    transition: opacity 1s;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {transform: translateY(0);}
    40% {transform: translateY(-5px);}
    60% {transform: translateY(-3px);}
}

/* =========================================
   6. SECTION 2: BONUS CONTENT (ENVELOPE/CARDS)
   ========================================= */
#bonus-section {
    width: 100%;
    min-height: 100vh;
    background: linear-gradient(180deg, #ee9ca7 0%, #ffdde1 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 50px;
    opacity: 0; /* Hidden initially */
    transition: opacity 2s ease;
}

.section-title {
    font-family: 'Dancing Script', cursive;
    font-size: 2.5rem;
    color: #fff;
    text-shadow: 2px 2px 0px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

/* ENVELOPE STYLES */
.envelope-wrapper {
    cursor: pointer;
    margin-bottom: 80px;
    transform: scale(0.8);
}

/* Premium Stationery Envelope */
.envelope {
    position: relative;
    width: 300px;
    height: 200px;
    background: #e8d0d3; /* Soft Rose Gold Base */
    border-radius: 0 0 10px 10px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.08);
}

.flap {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-left: 150px solid transparent;
    border-right: 150px solid transparent;
    border-top: 100px solid #f2e1e3; /* Champagne Top Flap */
    transform-origin: top;
    transition: transform 0.6s cubic-bezier(0.25, 0.8, 0.25, 1), z-index 0.6s;
    z-index: 3;
    /* Adds a subtle paper edge shadow */
    filter: drop-shadow(0px 3px 3px rgba(0,0,0,0.03)); 
}

.pocket {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 0;
    border-left: 150px solid transparent;
    border-right: 150px solid transparent;
    border-bottom: 100px solid #dfc2c5; /* Muted Blush Bottom */
    z-index: 2;
    border-radius: 0 0 10px 10px;
}
.letter {
    position: absolute;
    top: 10px;
    left: 25px;
    width: 250px;
    height: 180px;
    background: #fff;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: transform 0.6s ease-in-out;
    z-index: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Pushes content to the top so it doesn't clip */
    text-align: center;
    overflow-y: auto; /* Enables vertical scrolling */
    -webkit-overflow-scrolling: touch; /* Smooth touch scrolling for mobile */
}
.letter h3 { font-family: 'Dancing Script', cursive; color: #ff4d6d; }
.letter p { 
    font-family: 'Varela Round', sans-serif; 
    font-size: 0.9rem; 
    color: #555; 
    white-space: pre-wrap; /* Keeps your \n formatting intact */
    margin-top: 10px; /* Gives some breathing room below the title */
}
/* Open Animation */
.envelope.open .flap {
    transform: rotateX(180deg);
    z-index: 0;
}
.envelope.open .letter {
    transform: translateY(-100px);
    z-index: 2;
}

/* --- PREMIUM GLASS CARDS --- */
.card-deck {
    position: relative;
    width: 300px;
    height: 400px;
    margin-top: 20px;
    /* Center the cards */
    display: flex;
    justify-content: center;
}

.glass-card {
    position: absolute;
    top: 0;
    width: 100%;
    height: 100%;
    
    /* 1. THE GLASS BASE */
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.3) 0%,   /* Top left is brighter (Light source) */
        rgba(255, 255, 255, 0.05) 100% /* Bottom right is transparent */
    );
    
    /* 2. THE BLUR (Frost Effect) */
    backdrop-filter: blur(20px); 
    -webkit-backdrop-filter: blur(20px);
    
    /* 3. THE REFLECTIVE BORDERS (Light Catching) */
    border-top: 1px solid rgba(255, 255, 255, 0.8);  /* Bright top edge */
    border-left: 1px solid rgba(255, 255, 255, 0.8); /* Bright left edge */
    border-right: 1px solid rgba(255, 255, 255, 0.2); /* Dim right edge */
    border-bottom: 1px solid rgba(255, 255, 255, 0.2); /* Dim bottom edge */
    
    /* 4. DEPTH & SHADOW */
    border-radius: 20px;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15); /* Soft deep shadow */
    
    /* Layout */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    cursor: pointer;
    
    /* Smooth Transition for hover */
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Hover Effect: Lifts up slightly */
.glass-card:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 15px 40px 0 rgba(31, 38, 135, 0.25);
}

/* TEXT & IMAGE STYLING */
.glass-card img {
    width: 100%;
    max-height: 200px;
    object-fit: contain;
    /* Add a small shadow to the image inside so it floats */
    filter: drop-shadow(0 10px 10px rgba(0,0,0,0.1));
    margin-bottom: 15px;
}

.glass-card p {
    font-family: 'Varela Round', sans-serif;
    font-weight: bold;
    color: #fff; /* White text */
    text-shadow: 0 2px 5px rgba(0,0,0,0.2); /* Shadow for readability */
    font-size: 1.1rem;
    margin: 0;
}

/* --- SWIPE ANIMATIONS --- */
/* The card flies out to the right and fades away */
@keyframes flyOutRight {
    0% { transform: translateX(0) rotate(0); opacity: 1; }
    100% { transform: translateX(300px) rotate(20deg); opacity: 0; }
}

/* The card flies out to the left and fades away */
@keyframes flyOutLeft {
    0% { transform: translateX(0) rotate(0); opacity: 1; }
    100% { transform: translateX(-300px) rotate(-20deg); opacity: 0; }
}

/* The card gently fades in at the back */
@keyframes fadeInBack {
    0% { transform: scale(0.9); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.animate-right { animation: flyOutRight 0.6s ease-out forwards; }
.animate-left { animation: flyOutLeft 0.6s ease-out forwards; }
.animate-back { animation: fadeInBack 0.6s ease-in forwards; }

/* CONFETTI */
@keyframes fall {
    0% { transform: translateY(-10px) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(360deg); opacity: 0; }
}


/* --- CUSTOM SCROLLBAR FOR THE LETTER --- */
.letter::-webkit-scrollbar {
    width: 4px; /* Super thin and minimal */
}
.letter::-webkit-scrollbar-track {
    background: transparent; 
    border-radius: 10px;
    margin: 5px 0; /* Keeps it away from the absolute edges */
}
.letter::-webkit-scrollbar-thumb {
    background: #ff85a2; /* Matches your envelope flap */
    border-radius: 10px;
}

/* --- MINIMALIST SCROLL INDICATOR --- */
.letter-indicator {
    position: sticky;
    bottom: 0px;
    width: 100%;
    text-align: center;
    color: #ff85a2; /* Matches the Kawaii aesthetic */
    font-size: 1.2rem;
    padding-top: 20px;
    padding-bottom: 5px;
    background: linear-gradient(to bottom, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 60%);
    pointer-events: none; /* Ensures the user can still touch/scroll the text beneath it */
    animation: small-bounce 1.5s infinite;
    transition: opacity 0.3s ease;
    opacity: 0.9;
}

@keyframes small-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}