/* ================= GLOBAL STYLES ================= */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    width: 100%; height: 100vh;
    overflow: hidden;
    font-family: 'Patrick Hand', cursive;
    
    /* PC BACKGROUND */
    background-image: url('assets/bg.png'); 
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.hidden { display: none !important; opacity: 0; pointer-events: none; }

/* ================= PAGE 1 ================= */
#page-1 {
    width: 100%; height: 100vh;
    display: flex; flex-direction: column; 
    justify-content: center; align-items: center;
    text-align: center; transition: opacity 0.5s ease;
}

.top-text {
    font-family: 'Shadows Into Light', cursive;
    font-size: 3.5rem; color: #111; margin-bottom: -15px; letter-spacing: 2px;
}
.title-wrapper { position: relative; display: inline-block; padding: 0 15px; }
.yellow-highlight {
    position: absolute; top: 60%; left: -5%; width: 110%; height: 35%;
    background: #ffeb3b; transform: rotate(-4deg); z-index: -1; opacity: 0.8;
}
.main-title {
    font-family: 'Shadows Into Light', cursive;
    font-size: 5.5rem; color: #111; font-weight: bold;
    line-height: 1.2; transform: rotate(-4deg);
}
.subtitle {
    font-size: 1.3rem; color: #333; margin-top: 30px; 
    margin-bottom: 40px; letter-spacing: 1px; font-weight: bold;
}

.sketch-btn {
    background: rgba(255, 255, 255, 0.7); color: #111; font-family: 'Patrick Hand', cursive;
    font-size: 1.5rem; padding: 12px 50px; font-weight: bold;
    cursor: pointer; border: 3px solid #111;
    border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
    transition: all 0.2s ease; backdrop-filter: blur(2px);
    -webkit-tap-highlight-color: transparent;
}
.sketch-btn:hover { background: rgba(255, 255, 255, 0.9); transform: scale(1.05) rotate(-3deg); }

/* ================= PAGE 2 ================= */
#page-2 {
    width: 100%; height: 100vh;
    overflow-y: auto; -webkit-overflow-scrolling: touch;
    padding: 40px 20px; display: block; transition: opacity 0.5s ease;
}

/* FIREWORKS (Shuffle Logic) */
.firework {
    position: fixed; /* Floats over everything */
    width: 60px; height: 60px;
    cursor: pointer; 
    z-index: 100; /* Sit ON TOP of the letter */
    user-select: none;
    transition: transform 0.2s;
    animation: float 3s infinite ease-in-out;
}
.firework img { width: 100%; height: 100%; object-fit: contain; opacity: 0.9; }
.firework:hover { transform: scale(1.2) rotate(-10deg); z-index: 101; }

.exploded { animation: boom 0.6s forwards; pointer-events: none; }
@keyframes boom {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.5) rotate(10deg); opacity: 0.8; }
    100% { transform: scale(2); opacity: 0; }
}
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

/* LETTER CONTAINER */
.letter-container {
    background: white; width: 100%; max-width: 550px;
    padding: 40px; margin: 0 auto; 
    border: 3px dashed #333; border-radius: 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    position: relative; text-align: left;
    z-index: 10;
}
.header-img { width: 80%; max-width: 300px; height: auto; display: block; margin: 0 auto 10px auto; }
.header-line { width: 50%; height: 3px; background: #333; margin: 10px auto 0; border-radius: 2px; }
.letter-body { font-size: 1.2rem; line-height: 1.6; color: #333; }
.greeting { font-weight: bold; font-size: 1.5rem; margin-bottom: 20px; }
.letter-body p { margin-bottom: 20px; }
.highlight { background-color: #ffeb3b; padding: 2px 8px; box-decoration-break: clone; display: inline; }
.sign { text-align: right; margin-top: 40px; font-weight: bold; font-size: 1.3rem; }

/* GALLERY */
.gallery-section { margin-top: 40px; text-align: center; }
.gallery-divider { display: flex; align-items: center; justify-content: center; margin-bottom: 30px; font-size: 1.2rem; color: #555; }
.gallery-divider::before, .gallery-divider::after { content: ""; flex: 1; border-bottom: 2px solid #ccc; margin: 0 15px; }

.polaroid-stack { position: relative; width: 240px; height: 280px; margin: 0 auto 40px; }
.paperclip { position: absolute; top: -20px; left: 50%; transform: translateX(-50%) rotate(-5deg); width: 60px; z-index: 10; }
.polaroid {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: white; padding: 12px 12px 50px 12px;
    box-shadow: 2px 2px 15px rgba(0,0,0,0.15); border: 1px solid #eee;
    transition: transform 0.3s;
}
.polaroid img { width: 100%; height: 100%; object-fit: cover; border: 1px solid #ddd; }
.p2 { transform: rotate(-6deg); z-index: 1; }
.p1 { transform: rotate(4deg); z-index: 2; }

.btn-container { width: 100%; display: flex; justify-content: center; margin-top: 20px; }

/* ================= PAGE 3 (FIXED ALIGNMENT) ================= */
#page-3 { 
    width: 100%; height: 100vh; 
    display: flex; justify-content: center; align-items: center;
    /* Forces centering even if text wraps */
    text-align: center; 
    padding: 20px; 
}
.final-msg { 
    font-family: 'Shadows Into Light', cursive; 
    font-size: 5rem; font-weight: bold; color: #111; 
}

/* ================= MOBILE OPTIMIZATION ================= */
@media (max-width: 768px) {
    
    /* 1. MOBILE BACKGROUND (Using m-bg.png) */
    body {
        background-image: url('assets/m-bg.png'); 
        background-size: cover;
        background-attachment: fixed;
    }

    /* 2. Text Sizes */
    .top-text { font-size: 2.5rem; }
    .main-title { font-size: 3.5rem; }
    .yellow-highlight { height: 30%; top: 65%; }
    .subtitle { font-size: 1.1rem; }
    .sketch-btn { font-size: 1.2rem; padding: 10px 40px; }

    /* 3. Letter Container */
    .letter-container {
        width: 100%; padding: 25px 20px; 
        border-width: 2px; z-index: 10; margin-top: 10px;
    }
    .letter-body { font-size: 1.1rem; }
    .header-img { width: 90%; }
    
    /* 4. FIREWORKS (Smaller on Mobile) */
    .firework { width: 45px; height: 45px; }

    /* 5. Gallery & Final */
    .gallery-divider { font-size: 1rem; }
    .polaroid-stack { width: 200px; height: 240px; }
    
    /* Page 3 Text Fix for Mobile */
    .final-msg { font-size: 3rem; }
}