@import url('https://fonts.googleapis.com/css2?family=Dancing+Script:wght@400;500;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Dancing Script', cursive, sans-serif;
    background: linear-gradient(135deg, #0c1445, #1a237e, #283593);
    min-height: 100vh;
    color: #1a237e;
    line-height: 1.8;
    padding: 20px 0;
    position: relative;
    overflow-x: hidden;
}

/* Night sky background elements */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.1) 0px, transparent 1px),
        radial-gradient(circle at 80% 10%, rgba(255, 255, 255, 0.1) 0px, transparent 1px),
        radial-gradient(circle at 40% 70%, rgba(255, 255, 255, 0.1) 0px, transparent 1px),
        radial-gradient(circle at 60% 50%, rgba(255, 255, 255, 0.1) 0px, transparent 1px),
        radial-gradient(circle at 10% 80%, rgba(255, 255, 255, 0.1) 0px, transparent 1px);
    background-size: 300px 300px, 400px 400px, 350px 350px, 250px 250px, 500px 500px;
    pointer-events: none;
    z-index: -1;
}

/* Moon */
body::after {
    content: '';
    position: fixed;
    top: 10%;
    right: 15%;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, #f5f5f5 0%, #e0e0e0 70%, #b0bec5 100%);
    border-radius: 50%;
    box-shadow: 0 0 30px rgba(255, 255, 200, 0.6), 0 0 60px rgba(255, 255, 200, 0.3);
    z-index: -1;
}

/* Clouds */
.cloud {
    position: fixed;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50px;
    filter: blur(10px);
    z-index: -1;
}

.cloud1 {
    top: 20%;
    left: 10%;
    width: 120px;
    height: 40px;
}

.cloud2 {
    top: 35%;
    right: 20%;
    width: 150px;
    height: 50px;
}

.cloud3 {
    bottom: 25%;
    left: 20%;
    width: 100px;
    height: 35px;
}

/* Twinkling stars */
.star {
    position: fixed;
    background-color: white;
    border-radius: 50%;
    z-index: -1;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 20px;
    position: relative;
    z-index: 1;
    /* Add a subtle glow to highlight the paper */
    box-shadow: 0 0 30px rgba(255, 240, 200, 0.2);
    border-radius: 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

h1 {
    text-align: center;
    font-size: 2.8em;
    color: #5c6bc0;
    margin-bottom: 30px;
    font-weight: 600;
    letter-spacing: 1px;
    font-family: 'Dancing Script', cursive;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

/* Envelope styles */
.envelope-wrapper {
    position: relative;
    cursor: pointer;
    transition: transform 0.3s ease, opacity 1s ease;
    z-index: 10;
    margin-bottom: 50px;
}

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

.envelope-wrapper.opened {
    opacity: 0;
    pointer-events: none;
}

.envelope {
    position: relative;
    width: 300px;
    height: 200px;
    background: #f0e6d2;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.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 #d4c8b0;
    transform-origin: top center;
    transition: transform 0.8s ease;
    z-index: 3;
}

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

.envelope-label {
    position: absolute;
    color: #1565c0;
    font-size: 1.1em;
    z-index: 2;
    width: 45%;
    bottom: 20px;
}

.label-to {
    right: 20px;
    text-align: right;
    font-weight: 600;
}

.label-from {
    left: 20px;
    text-align: left;
}

.click-hint {
    position: absolute;
    bottom: -50px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 1.1em;
    animation: pulse 2s infinite;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
    white-space: nowrap;
}

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

.letter-wrapper {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 1s ease;
    z-index: 5;
}

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

.letter {
    width: 90vw;
    max-width: 800px;
    height: 85vh;
    background: linear-gradient(135deg, #f7f0e0 0%, #f0e6d2 50%, #e8dcc8 100%);
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    padding: 40px;
    overflow-y: scroll;
    border: 2px solid #d4c8b0;
    /* Hide scrollbar for Chrome, Safari and Opera */
    scrollbar-width: none; /* For Firefox */
    -ms-overflow-style: none; /* For Internet Explorer and Edge */
}

/* Hide scrollbar for Chrome, Safari and Opera */
.letter::-webkit-scrollbar {
    display: none;
}

.letter h1 {
    text-align: center;
    font-size: 2.2em;
    color: #5c6bc0;
    margin-bottom: 20px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.letter-text {
    font-size: 1.2em;
    line-height: 1.8;
    color: #1565c0;
}

.word {
    display: inline-block;
    opacity: 0;
    transform: translateY(20px) rotate(1deg);
    transition: opacity 0.4s ease, transform 0.4s ease;
    color: #1565c0; /* Deep blue color */
}

.word.visible {
    opacity: 1;
    transform: translateY(0) rotate(0deg);
}

/* Style for indentation */
.word.indent {
    display: inline-block;
    width: 2em; /* Indent by 2em */
}

/* Ensure emojis are also deep blue */
.word span {
    color: #1565c0;
}

/* Style for links */
.word.link {
    color: #1565c0; /* Deep blue color */
    text-decoration: underline;
    cursor: pointer;
    display: inline-block;
}

.word.link:hover {
    color: #0d47a1; /* Darker blue on hover */
    text-decoration: underline;
}

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

p {
    margin-bottom: 0px;
}

/* Additional styles for night sky theme */
#loveLetter {
    font-size: 1.4em;
    line-height: 2;
    position: relative;
    padding: 30px;
    background:
        /* Aged paper background */
        linear-gradient(135deg, #f7f0e0 0%, #f0e6d2 50%, #e8dcc8 100%),
        /* Lined paper effect */
        linear-gradient(#f7f0e0 2px, transparent 2px),
        linear-gradient(90deg, rgba(210, 180, 140, 0.3) 2px, transparent 2px),
        /* Subtle paper texture */
        url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><filter id="noise"><feTurbulence type="fractalNoise" baseFrequency="0.8" numOctaves="2" stitchTiles="stitch"></feTurbulence></filter><rect width="100%" height="100%" filter="url(%23noise)" opacity="0.05"></rect></svg>');
    background-size: 100% 100%, 100% 32px, 32px 100%, 200px 200px;
    background-position: 0 0, -2px -2px, -2px -2px, 0 0;
    /* Curved corners */
    border-radius: 20px;
    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.3),
        inset 0 0 20px rgba(210, 180, 140, 0.6);
    border: 1px solid #d4c8b0;
    min-height: 500px;
    color: #1565c0; /* Deep blue color */
    backdrop-filter: blur(2px);
    /* Paper texture overlay */
    background-blend-mode: multiply, normal, normal, normal;
}

@media (max-width: 768px) {
    .container {
        padding: 20px 15px;
    }

    h1 {
        font-size: 2.2em;
    }

    #loveLetter {
        font-size: 1.2em;
        padding: 20px;
        line-height: 1.9;
    }

    body::after {
        width: 70px;
        height: 70px;
        top: 5%;
        right: 10%;
    }

    .envelope {
        width: 250px;
        height: 170px;
    }

    .flap {
        border-left: 125px solid transparent;
        border-right: 125px solid transparent;
        border-top: 85px solid #d4c8b0;
    }

    .letter {
        padding: 25px;
    }

    .letter h1 {
        font-size: 1.8em;
    }

    .letter-text {
        font-size: 1em;
    }
}
