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

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

body {
    font-family: 'Crimson Text', serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    position: relative;
    overflow-x: hidden;
}

/* Envelope Animation */
.envelope-wrapper {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    transition: all 0.8s ease;
}

.envelope-wrapper.opened {
    transform: translate(-50%, -150%) scale(0.5);
    opacity: 0;
    pointer-events: none;
}

.envelope {
    width: 400px;
    height: 266px;
    background: #f4f1de;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.envelope::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-left: 200px solid transparent;
    border-right: 200px solid transparent;
    border-top: 133px solid #e07a5f;
    transform-origin: top;
    transition: transform 0.6s ease;
}

.envelope-wrapper.opened .envelope::before {
    transform: rotateX(180deg);
}

.envelope::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 0;
    border-left: 200px solid transparent;
    border-right: 200px solid transparent;
    border-bottom: 133px solid #d4a373;
}

/* Envelope From Address */
.envelope-from {
    position: absolute;
    top: 25px;
    left: 25px;
    text-align: left;
    color: #2d2d2d;
    font-family: 'Crimson Text', serif;
    z-index: 1;
}

.from-label {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 5px;
    color: #c85a44;
}

.from-name {
    font-family: 'Dancing Script', cursive;
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 5px;
    color: #2d2d2d;
}

.from-address {
    font-size: 13px;
    line-height: 1.4;
    font-style: italic;
    color: #5a7d6e;
}

/* Envelope To Address */
.envelope-to {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -20%);
    text-align: center;
    color: #2d2d2d;
    font-family: 'Crimson Text', serif;
    z-index: 1;
}

.to-label {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 10px;
    color: #c85a44;
}

.recipient-name {
    font-family: 'Dancing Script', cursive;
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 12px;
    color: #2d2d2d;
}

.recipient-address {
    font-size: 15px;
    line-height: 1.6;
    font-style: italic;
    color: #5a7d6e;
}

/* Open Button */
.open-button {
    position: fixed;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    background: #f4f1de;
    color: #3d405b;
    border: none;
    padding: 15px 40px;
    font-size: 18px;
    font-family: 'Crimson Text', serif;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    z-index: 11;
}

.open-button:hover {
    background: #e07a5f;
    color: #f4f1de;
    transform: translateX(-50%) translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

.open-button.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Letter Container */
.letter-container {
    opacity: 0;
    transform: scale(0.8) translateY(50px);
    transition: all 0.8s ease;
    pointer-events: none;
    max-width: 800px;
    width: 100%;
}

.letter-container.show {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: all;
}

.letter {
    background: #f4f1de;
    padding: 60px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
    border: 1px solid #d4a373;
}

.letter::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    bottom: 20px;
    border: 2px solid #e07a5f;
    opacity: 0.3;
    pointer-events: none;
}

/* Letter Header */
.letter-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 30px;
}

.stamp {
    width: 60px;
    height: 60px;
    background: #e07a5f;
    border: 3px dashed #f4f1de;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: rotate(12deg);
}

.stamp-inner {
    font-size: 28px;
}

.postmark {
    font-size: 12px;
    text-align: right;
    color: #3d405b;
    opacity: 0.6;
    font-style: italic;
    line-height: 1.4;
}

/* Letter Content */
.letter-content {
    color: #3d405b;
    line-height: 1.8;
    font-size: 18px;
}

.date {
    text-align: right;
    margin-bottom: 30px;
    font-style: italic;
    color: #81b29a;
}

.greeting {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 20px;
    color: #e07a5f;
}

.letter-content p {
    margin-bottom: 20px;
    text-align: justify;
}

.first-paragraph {
    font-size: 20px;
    font-weight: 600;
}

em {
    color: #e07a5f;
    font-style: italic;
}

strong {
    color: #e07a5f;
    font-weight: 600;
}

.mysterious {
    background: linear-gradient(45deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 600;
}

.closing-paragraph {
    margin-top: 30px;
    font-style: italic;
}

/* Signature Section */
.signature-section {
    margin-top: 40px;
}

.signature-line {
    margin-bottom: 10px;
}

.signature {
    font-family: 'Dancing Script', cursive;
    font-size: 32px;
    color: #3d405b;
    margin-bottom: 20px;
}

.ps {
    font-size: 16px;
    font-style: italic;
    color: #81b29a;
    margin-top: 20px;
}

/* Wax Seal */
.wax-seal {
    position: absolute;
    bottom: -30px;
    right: 60px;
    width: 80px;
    height: 80px;
    background: #e07a5f;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 5px 20px rgba(224, 122, 95, 0.5);
    border: 3px solid #d4a373;
}

.seal-text {
    font-family: 'Dancing Script', cursive;
    font-size: 24px;
    color: #f4f1de;
    font-weight: 700;
}

/* Responsive Design */
@media (max-width: 768px) {
    .letter {
        padding: 40px 30px;
    }
    
    .letter-content {
        font-size: 16px;
    }
    
    .greeting {
        font-size: 20px;
    }
    
    .first-paragraph {
        font-size: 18px;
    }
    
    .envelope {
        width: 320px;
        height: 213px;
    }
    
    .envelope::before {
        border-left: 160px solid transparent;
        border-right: 160px solid transparent;
        border-top: 106px solid #e07a5f;
    }
    
    .envelope::after {
        border-left: 160px solid transparent;
        border-right: 160px solid transparent;
        border-bottom: 106px solid #d4a373;
    }
    
    .recipient-name {
        font-size: 26px;
    }
    
    .recipient-address {
        font-size: 12px;
    }
    
    .to-label {
        font-size: 13px;
    }
    
    .from-name {
        font-size: 15px;
    }
    
    .from-address {
        font-size: 11px;
    }
    
    .from-label {
        font-size: 11px;
    }
    
    .wax-seal {
        bottom: -25px;
        right: 30px;
        width: 60px;
        height: 60px;
    }
    
    .seal-text {
        font-size: 18px;
    }
}

/* Animation for paper texture */
@keyframes subtle-float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

.letter-container.show .letter {
    animation: subtle-float 6s ease-in-out infinite;
}
