/* Envelope Styles */
.envelope-wrapper {
    position: relative;
    width: 300px;
    /* Base size */
    height: 200px;
    cursor: pointer;
    transition: transform 0.6s cubic-bezier(0.25, 1.5, 0.5, 1);
    /* Bouncy spring effect */
    animation: entranceFadeSlide 1.5s ease-out forwards;
    /* Entrance Effect */
}

@keyframes entranceFadeSlide {
    0% {
        opacity: 0;
        transform: translateY(60px) scale(0.95);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.envelope-wrapper:not(.open):hover {
    transform: scale(1.05);
    /* Make it bigger */
}

/* Disable hover when open */
.envelope-wrapper.open:hover {
    transform: none;
}

.envelope {
    position: relative;
    width: 100%;
    height: 100%;
    /* perspective: 1000px; handled by container */
}

/* The actual letter inside */
.card {
    overflow: hidden;
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    height: 90%;
    background: #fffbf0;
    /* Parchment */
    border: 2px solid #e0c9a6;
    border-radius: 4px;
    transition: transform 0.8s ease-in-out, z-index 0.1s linear 0.4s;
    z-index: 5;
    padding: 20px;
    text-align: center;
    color: #022c33;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
}

/* Envelope Parts */
.flap {
    position: absolute;
    width: 0;
    height: 0;
    border-style: solid;
}

/* Envelope Parts - White/Off-White Theme */
.back {
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: #f0f0f0;
    /* Off-white */
    border-radius: 4px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    transition: box-shadow 0.4s ease;
    z-index: 1;
}

.envelope-wrapper:not(.open):hover .back {
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
    /* Enhanced shadow for "lifting" look */
}

.front {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 0;
    border-style: solid;
    /* Adjusted borders for front/pockets to be white */
    z-index: 10;
    border-width: 0 150px 120px 150px;
    border-color: transparent transparent #e6e6e6 transparent;
    /* Slightly darker for contrast */
}

.pocket-left {
    position: absolute;
    bottom: 0;
    left: 0;
    border-style: solid;
    border-width: 100px 0 100px 150px;
    border-color: transparent transparent transparent #f7f7f7;
    /* Light gray/white */
    z-index: 11;
}

.pocket-right {
    position: absolute;
    bottom: 0;
    right: 0;
    border-style: solid;
    border-width: 100px 150px 100px 0;
    border-color: transparent #f7f7f7 transparent transparent;
    /* Light gray/white */
    z-index: 11;
}

.pocket-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    border-style: solid;
    border-width: 0 150px 110px 150px;
    border-color: transparent transparent #ffffff transparent;
    /* Pure white */
    z-index: 12;
}

.flap-top {
    position: absolute;
    top: 0;
    left: 0;
    border-style: solid;
    border-width: 110px 150px 0 150px;
    border-color: #f0f0f0 transparent transparent transparent;
    /* Match back */
    z-index: 13;
    transform-origin: top;
    transition: transform 0.6s ease-in-out, z-index 0.1s linear 0.3s;
}

/* Open State */
.envelope-wrapper.open .flap-top {
    transform: rotateX(180deg);
    z-index: 0;
    /* Go behind card eventually */
}

/* Fullscreen Card Animation */
.envelope-wrapper.open .card {
    transition: all 1s ease-in-out 0.2s;
    /* Slower transition for drama, delay start */

    /* Move to center of screen regardless of envelope position */
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);

    /* Expand dimensions */
    width: 80vw;
    max-width: 600px;
    height: 80vh;
    max-height: 800px;

    background: #fffbf0;
    z-index: 1000;
    /* On top of everything */
    padding: 40px;

    /* Enhance shadow for pop */
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    border: 3px double #e0d0b8;
}

.envelope-wrapper.open {
    cursor: default;
    /* No need to move wrapper now since card pops out fully */
}

/* Seal */
.seal {
    position: absolute;
    bottom: 120px;
    top: 90px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    /* Slightly larger for image */
    height: 60px;
    z-index: 14;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.4s;
    cursor: pointer;
    /* Ensure it looks clickable */
}

.seal-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
    /* Drop shadow on the image shape itself */
}

.envelope-wrapper.open .seal {
    opacity: 0;
    pointer-events: none;
}

/* Full Card Image */
.card-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* Ensure whole image is seen */
    opacity: 0;
    transition: opacity 0.3s ease-out;
    border-radius: 4px;
}

.envelope-wrapper.open .card-image {
    opacity: 1;
    transition: opacity 1.5s ease-in-out 1.2s;
}

/* Card Content Typography - Ref Design */
.card-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 30px;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
    background: #fffcf5;
    /* Creamy white */
    color: #1a1a1a;
}

.envelope-wrapper.open .card-content {
    opacity: 1;
    transition-delay: 0.4s;
    /* Show text as it slides out */
}

.header-invite {
    font-family: var(--font-body);
    font-size: 0.9rem;
    letter-spacing: 4px;
    /* Wide tracking */
    text-transform: uppercase;
    margin-bottom: 20px;
    color: #333;
    margin-top: 10px;
}

.hero-image-container {
    position: relative;
    width: 150%;
    flex-grow: 1;
    /* Take up all available space */
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    margin: 10px 0;
}

.hero-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.85;
    border-radius: 2px;
}

.footer-details {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
    width: 100%;
}

.date-large {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    letter-spacing: 5px;
    color: #1a1a1a;
    margin-bottom: 15px;
}

.venue-line,
.address-line {
    font-family: var(--font-body);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #555;
    font-weight: 300;
}

.rsvp-line {
    margin-top: 20px;
    font-family: var(--font-body);
    font-size: 0.75rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: #000;
    font-weight: 600;
}

/* --- Second Card Interaction --- */

/* Second Card Base - hidden initially */
.card-second {
    overflow: hidden;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) translateY(100px);
    /* Start slightly below */
    width: 80vw;
    max-width: 600px;
    height: 80vh;
    max-height: 800px;
    background: #fffcf5;
    z-index: 1001;
    /* On top of card 1 */
    padding: 40px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    border: 5px double #e0c9a6;
    opacity: 0;
    pointer-events: none;
    transition: all 0.8s ease-in-out;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* When active, show second card */
.envelope-wrapper.show-second-card .card-second {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) translateY(0);
}

/* When active, hide first card */
.envelope-wrapper.show-second-card .card {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
    pointer-events: none;
}

/* Second Card Content */

.header-reception {
    font-family: var(--font-body);
    font-size: 0.9rem;
    letter-spacing: 4px;
    /* Wide tracking */
    text-transform: uppercase;
    margin-bottom: 20px;
    color: #333;
    margin-top: 10px;
}

.details-body {
    text-align: center;
    width: 100%;
    margin-top: 20px;
}

.details-body h3 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    margin-bottom: 5px;
    color: var(--color-primary);
    margin-top: 20px;
}

.details-body p {
    font-family: var(--font-body);
    font-size: 1rem;
    color: #333;
    margin-bottom: 10px;
}

.rsvp-section {
    margin-top: 40px;
}

.rsvp-button {
    display: inline-block;
    padding: 15px 40px;
    background-color: var(--color-primary);
    color: white;
    text-decoration: none;
    font-family: var(--font-body);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 0.9rem;
    transition: background-color 0.3s ease;
    border: 1px solid var(--color-primary);
}

.rsvp-button:hover {
    background-color: white;
    color: var(--color-primary);
}

/* Phones only */
@media (max-width: 600px) {
    .card-content {
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        padding: 30px;
        opacity: 0;
        transition: opacity 0.5s ease-in-out;
        background: #fffcf5;
        /* Creamy white */
        color: #1a1a1a;
    }

    .header-invite {
        position: fixed;
        height: 75%;
        width: 60%;
        font-family: var(--font-body);
        font-size: 0.5rem;
        letter-spacing: 4px;
        /* Wide tracking */
        text-transform: uppercase;
        margin-bottom: 0rem;
        color: #333;
        margin-top: 0px;
    }

    .hero-image-container {
        position: fixed;
        width: 100%;
        margin-bottom: 50%;
        /* Take up all available space */
        display: flex;
        justify-content: center;
        align-items: center;
        overflow: hidden;
    }

    .hero-image {
        width: 100%;
        object-fit: cover;
        opacity: 0.85;
        border-radius: 2px;
    }

    .footer-details {
        position: fixed;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.1rem;
        margin-top: 80%;
        padding-top: 0.5rem;
        width: 60%;
    }

    .date-large {
        font-family: var(--font-heading);
        font-size: 1rem;
        letter-spacing: 5px;
        color: #1a1a1a;
        margin-bottom: 15px;
    }

    .venue-line,
    .address-line {
        font-family: var(--font-body);
        font-size: 0.6rem;
        text-transform: uppercase;
        letter-spacing: 1px;
        color: #555;
        font-weight: 300;
    }

    .rsvp-line {
        margin-top: 20px;
        font-family: var(--font-body);
        font-size: 0.5rem;
        letter-spacing: 3px;
        text-transform: uppercase;
        color: #000;
        font-weight: 600;
    }

    .header-reception {
        font-family: var(--font-body);
        font-size: 0.7rem;
        letter-spacing: 4px;
        /* Wide tracking */
        text-transform: uppercase;
        margin-bottom: 20px;
        color: #333;
        margin-top: 10px;
    }

    .details-body {
        text-align: center;
        width: 100%;
        height: 100%;
        margin-top: 0rem;
    }

    .details-body h3 {
        font-family: var(--font-heading);
        font-size: 1rem;
        margin-bottom: 5px;
        color: var(--color-primary);
        margin-top: 20px;
    }

    .details-body p {
        font-family: var(--font-body);
        font-size: 0.6rem;
        color: #333;
        margin-bottom: 10px;
    }

    .rsvp-section {
        margin-top: 40px;
    }

    .rsvp-button {
        display: inline-block;
        padding: 0.5rem 1rem;
        background-color: var(--color-primary);
        color: white;
        text-decoration: none;
        font-family: var(--font-body);
        text-transform: uppercase;
        letter-spacing: 2px;
        font-size: 0.5rem;
        transition: background-color 0.3s ease;
        border: 1px solid var(--color-primary);
    }
}