:root {
    /* Color Palette - Soft Pastel Pinks */
    --bg-color: #fdf8f8;
    --envelope-color: #f8e1e5;
    --envelope-shadow: #eecdd3;
    --seal-color: #e59a9a;
    --seal-hover: #d88282;
    --text-primary: #4a3b3c;
    --text-secondary: #7a6365;

    /* Typography */
    --font-heading: 'Cormorant Garamond', serif;
    --font-body: 'Inter', sans-serif;
    --font-script: 'Great Vibes', cursive;

    /* Animation Timing */
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-body);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 1.2s var(--ease-smooth), transform 1.2s var(--ease-smooth);
}

.screen.active {
    opacity: 1;
    pointer-events: all;
    z-index: 10;
}

/* Envelope Section */
#envelope-section {
    flex-direction: column;
}

.envelope-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3rem;
}

.envelope {
    position: relative;
    width: 320px;
    height: 200px;
    background-color: var(--envelope-color);
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(238, 205, 211, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.8s var(--ease-smooth);
}

/* Back of the envelope (the flap) */
.envelope-flap {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-left: 160px solid transparent;
    border-right: 160px solid transparent;
    border-top: 110px solid var(--envelope-shadow);
    transform-origin: top;
    transition: transform 0.6s var(--ease-smooth);
    z-index: 4;
}

/* Front of the envelope pocket */
.envelope-pocket {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 0;
    border-left: 160px solid var(--envelope-shadow);
    border-right: 160px solid var(--envelope-shadow);
    border-bottom: 100px solid var(--envelope-color);
    border-radius: 0 0 8px 8px;
    z-index: 3;
}

/* Inner Paper sticking out slightly */
.envelope-paper {
    position: absolute;
    bottom: 0;
    width: 280px;
    height: 180px;
    background: #ffffff;
    border-radius: 4px;
    z-index: 2;
    transition: transform 0.8s var(--ease-smooth);
}

/* Seal / Open Button */
.envelope-seal {
    position: absolute;
    z-index: 5;
    width: 60px;
    height: 60px;
    background-color: var(--seal-color);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-style: italic;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(229, 154, 154, 0.4);
    transition: all 0.3s var(--ease-smooth);
    display: flex;
    justify-content: center;
    align-items: center;
}

.envelope-seal:hover {
    background-color: var(--seal-hover);
    transform: scale(1.05);
}

.envelope-seal:active {
    transform: scale(0.95);
}

.envelope-hint {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-style: italic;
    color: var(--text-secondary);
    opacity: 0.8;
    letter-spacing: 1px;
}

/* Envelope Opening Animations */
.envelope.opening .envelope-flap {
    transform: rotateX(180deg);
    z-index: 1; /* Drop behind paper */
}

.envelope.opening .envelope-seal {
    opacity: 0;
    pointer-events: none;
    transform: scale(0);
}

.envelope.opening .envelope-paper {
    transform: translateY(-40px);
}

/* Transition to Letter */
#envelope-section.fading-out {
    opacity: 0;
    transform: scale(1.1) translateY(-20px);
    pointer-events: none;
}

/* Letter Section */
#letter-section {
    background-color: #fff;
    overflow-y: auto;
    align-items: flex-start;
    padding: 10vh 20px;
    transform: translateY(40px);
}

#letter-section.active {
    transform: translateY(0);
}

.letter-container {
    max-width: 650px;
    width: 100%;
    margin: 0 auto;
}

.letter-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Letterhead (place + date) */
.letter-meta {
    text-align: right;
    font-family: var(--font-heading);
    font-style: italic;
    font-size: 1rem;
    color: var(--text-secondary);
    opacity: 0.75;
    letter-spacing: 0.5px;
}

.letter-content h1 {
    font-family: var(--font-heading);
    font-size: 3rem;
    font-weight: 400;
    font-style: italic;
    color: var(--seal-hover);
    margin-bottom: 1rem;
}

.letter-content p {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-primary);
    font-weight: 300;
}

/* Scroll reveal: blocks reserve space, fade up when scrolled into view */
.reveal-block {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.9s var(--ease-smooth), transform 0.9s var(--ease-smooth);
}

.reveal-block.is-revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Signature */
.letter-content .signature {
    margin-top: 3rem;
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-style: italic;
    color: var(--text-secondary);
}

.signature-name {
    display: inline-block;
    margin-top: 0.5rem;
    font-family: var(--font-script);
    font-style: normal;
    font-size: 2.4rem;
    color: var(--seal-hover);
    line-height: 1.2;
}

/* Finale (P.S. + photo) */
.finale {
    margin-top: 1rem;
}

.ps {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text-secondary);
    font-weight: 300;
}

.ps-label {
    font-family: var(--font-heading);
    font-style: italic;
    color: var(--seal-hover);
    font-size: 1.4rem;
    margin-right: 0.35em;
}

.photo-frame {
    margin-top: 2rem;
    align-self: center;
    width: 100%;
    max-width: 440px;
    aspect-ratio: 4 / 3;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 12px 40px rgba(229, 154, 154, 0.18);
    display: flex;
    position: relative;
}

.couples-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.8s var(--ease-smooth);
}

.photo-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 0.4rem;
    color: var(--text-secondary);
    font-family: var(--font-heading);
    font-style: italic;
    font-size: 1.15rem;
    padding: 1.5rem;
    background: var(--bg-color);
    border: 2px dashed var(--seal-color);
    border-radius: 10px;
}

.photo-placeholder-icon {
    font-size: 2.2rem;
    font-style: normal;
    line-height: 1;
}

.photo-placeholder small {
    font-style: normal;
    font-family: var(--font-body);
    font-size: 0.8rem;
    opacity: 0.7;
}

/* Reler button (inline at the end of the letter, appears after the finale) */
.reler-btn {
    align-self: center;
    margin-top: 1rem;
    padding: 0.85rem 2.4rem;
    background: var(--seal-color);
    border: none;
    border-radius: 999px;
    color: #fff;
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-style: italic;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(229, 154, 154, 0.45);
    opacity: 0;
    pointer-events: none;
    transform: translateY(16px);
    transition: opacity 0.6s var(--ease-smooth), transform 0.6s var(--ease-spring), background-color 0.3s var(--ease-smooth);
    min-height: 48px;
}

.reler-btn.is-visible {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0);
}

.reler-btn:hover,
.reler-btn:focus-visible {
    background: var(--seal-hover);
    outline: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .envelope {
        width: 280px;
    }

    .envelope-flap {
        border-left: 140px solid transparent;
        border-right: 140px solid transparent;
    }

    .envelope-pocket {
        border-left: 140px solid var(--envelope-shadow);
        border-right: 140px solid var(--envelope-shadow);
    }

    .envelope-paper {
        width: 250px;
    }

    #letter-section {
        padding: 6vh 18px;
    }

    .letter-content h1 {
        font-size: 2.5rem;
    }

    .letter-content p {
        font-size: 1rem;
        line-height: 1.75;
    }

    .signature-name {
        font-size: 2.1rem;
    }

    .reler-btn {
        width: auto;
        max-width: 280px;
    }
}

@media (max-width: 480px) {
    .envelope {
        width: 240px;
        height: 160px;
    }

    .envelope-flap {
        border-left: 120px solid transparent;
        border-right: 120px solid transparent;
        border-top: 90px solid var(--envelope-shadow);
    }

    .envelope-pocket {
        border-left: 120px solid var(--envelope-shadow);
        border-right: 120px solid var(--envelope-shadow);
        border-bottom: 80px solid var(--envelope-color);
    }

    .envelope-paper {
        width: 210px;
        height: 150px;
    }

    .envelope-hint {
        font-size: 1.25rem;
    }

    .letter-content h1 {
        font-size: 2.1rem;
    }

    .letter-content p {
        font-size: 0.95rem;
    }

    .letter-meta {
        font-size: 0.85rem;
    }
}
