/* --- 1. Global Settings --- */
:root {
    --primary-color: #ff4d6d;
    --dark-bg: #1a1a1a;
    --dark-overlay: rgba(30, 0, 10, 0.6); 
    --pink-tint: rgba(255, 77, 109, 0.4); 
    --glass-bg: rgba(255, 255, 255, 0.1);
}

body, html {
    margin: 0; padding: 0;
    font-family: 'Prompt', sans-serif;
    background-color: var(--dark-bg);
    color: white;
    scroll-behavior: smooth;
    overflow-x: hidden;
}

/* --- 2. Navigation --- */
nav {
    position: fixed; top: 0; width: 100%; z-index: 1000;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    padding: 15px 0;
}
.nav-container { display: flex; justify-content: center; gap: 30px; }
nav a {
    text-decoration: none; color: rgba(255, 255, 255, 0.7);
    font-weight: 300; transition: 0.3s; font-size: 0.9rem;
}
nav a.active, nav a:hover { color: var(--primary-color); text-shadow: 0 0 10px var(--primary-color); }

/* --- 3. Home Page --- */
.hero {
    position: relative; height: 100vh; width: 100%;
    display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.hero::before {
    content: ""; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background-image: url('img/1.jpg'); background-size: cover; background-position: center;
    filter: blur(12px); transform: scale(1.1); z-index: 1;
}
.hero-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(to bottom, var(--dark-overlay), var(--pink-tint), var(--dark-overlay));
    z-index: 2;
}
.hero-content { position: relative; z-index: 10; text-align: center; }
h1 { font-family: 'Mali', cursive; font-size: clamp(2rem, 8vw, 3.5rem); text-shadow: 0 0 20px rgba(255, 77, 109, 0.8); }

.counter-container { display: flex; justify-content: center; gap: 15px; margin: 30px 0; }
.time-box {
    background: var(--glass-bg); border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 15px; border-radius: 15px; min-width: 70px; backdrop-filter: blur(5px);
}
.time-box span { display: block; font-size: 2rem; font-weight: bold; color: white; }

/* --- 4. Timeline Page --- */
.timeline-wrapper { padding-top: 120px; text-align: center; min-height: 100vh; }
.horizontal-scroll {
    display: flex; align-items: center; overflow-x: auto; padding: 80px 50px;
    cursor: grab; position: relative; scrollbar-width: none;
}
.horizontal-scroll::-webkit-scrollbar { display: none; }
.timeline-line {
    position: absolute; height: 3px; background: var(--primary-color);
    width: 3000px; top: 52%; z-index: 1; opacity: 0.5;
}
.event-card {
    min-width: 220px; margin: 0 40px; position: relative; z-index: 5;
    display: flex; flex-direction: column; align-items: center; transition: 0.4s;
}
.event-card:hover { transform: translateY(-15px); cursor: pointer; }
.dot { width: 16px; height: 16px; background: var(--primary-color); border: 3px solid white; border-radius: 50%; margin-bottom: 15px; }
.card-thumb { width: 180px; height: 180px; border-radius: 15px; overflow: hidden; border: 3px solid white; }
.card-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* --- 5. Modal Display --- */
.modal {
    display: none; position: fixed; z-index: 2000;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.9); backdrop-filter: blur(10px);
    align-items: center; justify-content: center; padding: 20px; box-sizing: border-box;
}
.modal-content {
    background: white; color: #333; width: 100%; max-width: 450px;
    max-height: 90vh; border-radius: 25px; position: relative;
    display: flex; flex-direction: column; overflow: hidden;
}
.modal-content img, .modal-content video { width: 100%; max-height: 50vh; object-fit: contain; background: #000; }
.modal-text-container { padding: 20px; overflow-y: auto; text-align: center; }
.modal-text-container h2 { font-size: 0.9rem; color: var(--primary-color); margin: 0; }
.modal-text-container h3 { margin: 5px 0; }
.close { position: absolute; top: 10px; right: 20px; color: white; font-size: 35px; cursor: pointer; z-index: 2100; }

/* --- 6. My Letter Page (Clean & Not Faded) --- */
.letter-page {
    height: 100vh; width: 100vw;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden; background: var(--dark-bg);
}

.letter-bg-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 1;
}

.letter-wrapper {
    position: relative; z-index: 10;
    perspective: 2000px;
    display: flex; align-items: center; justify-content: center;
}

.envelope {
    position: relative;
    width: min(500px, 85vw); height: min(300px, 50vw);
    background: #ffb3c1;
    border-radius: 0 0 15px 15px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    cursor: pointer;
    transition: 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 11;
}

.flap {
    position: absolute; top: 0; width: 0; height: 0;
    border-left: min(250px, 42.5vw) solid transparent;
    border-right: min(250px, 42.5vw) solid transparent;
    border-top: min(150px, 25vw) solid #ff4d6d;
    transform-origin: top;
    transition: transform 0.6s 0.3s;
    z-index: 15;
}

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

/* แผ่นกระดาษ - ขาวสนิท 100% ไม่จาง */
.letter-paper {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(0.1);
    width: min(650px, 90vw);
    height: 75vh;
    background: #ffffff !important; /* บังคับขาว */
    opacity: 0;
    visibility: hidden;
    padding: 30px;
    border-radius: 15px;
    z-index: 2000; /* อยู่หน้าสุด */
    box-shadow: 0 20px 80px rgba(0,0,0,0.8);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* เมื่อซองเปิด กระดาษจะเด้งมากลางจอแบบขาวชัด */
.envelope.open + .letter-paper {
    opacity: 1 !important;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.letter-content {
    font-family: 'Mali', cursive;
    color: #1a1a1a !important;
    font-size: clamp(1rem, 4vw, 1.25rem);
    line-height: 2;
    
    /* --- บรรทัดสำคัญที่สุดที่ต้องมี --- */
    white-space: pre-line; 
    /* ----------------------------- */

    text-align: center;
    overflow-y: auto;
    height: 100%;
    padding: 10px;
}

.envelope.open {
    opacity: 0.4;
    transform: translateY(120px) scale(0.8);
}

.envelope .text {
    position: absolute; bottom: 25px; width: 100%;
    text-align: center; font-family: 'Mali', cursive;
    color: white; z-index: 16;
}