/* === INTRO SCREEN === */
#intro-screen {
    position: fixed;
    inset: 0;
    background: #f5efe6;
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 1s ease-in-out, visibility 1s;
}

#intro-text {
    font-family: 'Dancing Script', cursive;
    color: #8a7968;
    font-size: 1.4rem;
    margin-bottom: 2.5rem;
    transition: opacity 0.5s ease, transform 0.5s ease;
    text-align: center;
    animation: gentlePulse 2.5s ease-in-out infinite;
}

/* === ENVELOPE === */
.envelope-wrapper {
    perspective: 1200px;
    transition: transform 0.3s ease;
    cursor: pointer;
}

.envelope-wrapper:not(.opened):hover {
    transform: scale(1.03) translateY(-4px);
}

.envelope-wrapper:not(.opened):hover .wax-seal {
    box-shadow:
        inset 0 2px 4px rgba(255, 255, 255, 0.4),
        inset 0 -2px 4px rgba(0, 0, 0, 0.2),
        0 4px 16px rgba(184, 134, 11, 0.5),
        0 2px 6px rgba(0, 0, 0, 0.3);
}

.envelope {
    position: relative;
    width: 320px;
    height: 220px;
    filter: drop-shadow(0 6px 20px rgba(0, 0, 0, 0.12)) drop-shadow(0 2px 6px rgba(0, 0, 0, 0.08));
}

@media (min-width: 640px) {
    .envelope {
        width: 400px;
        height: 270px;
    }
}

/* === ENVELOPE BACK === */
.envelope-back {
    position: absolute;
    inset: 0;
    background:
        /* Paper grain texture */
        repeating-linear-gradient(0deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.008) 2px,
            rgba(0, 0, 0, 0.008) 4px),
        repeating-linear-gradient(90deg,
            transparent,
            transparent 3px,
            rgba(0, 0, 0, 0.005) 3px,
            rgba(0, 0, 0, 0.005) 6px),
        /* Base gradient */
        linear-gradient(170deg, #ddd0ba 0%, #d4c4a8 40%, #c8b898 100%);
    border-radius: 8px;
    z-index: 1;
}

/* === ENVELOPE LINER (visible when flap opens) === */
.envelope-liner {
    position: absolute;
    top: 0;
    left: 3px;
    right: 3px;
    height: 62%;
    clip-path: polygon(0 0, 100% 0, 50% 100%);
    border-radius: 8px 8px 0 0;
    z-index: 2;
    background:
        repeating-linear-gradient(-45deg,
            transparent,
            transparent 6px,
            rgba(163, 133, 100, 0.1) 6px,
            rgba(163, 133, 100, 0.1) 7px),
        linear-gradient(to bottom, #f5ede0, #ece2d0);
}

/* === ENVELOPE CARD (mini card inside) === */
.envelope-card-inner {
    position: absolute;
    top: 10px;
    left: 12px;
    right: 12px;
    bottom: 10px;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.4) 0%, transparent 50%),
        #faf6ef;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 10;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.06),
        0 0 0 1px rgba(0, 0, 0, 0.02);
}

.envelope-card-inner.slide-out {
    transform: translateY(-180px);
}

@media (min-width: 640px) {
    .envelope-card-inner.slide-out {
        transform: translateY(-220px);
    }
}

.envelope-card-inner .mini-title {
    font-family: 'Dancing Script', cursive;
    color: #8a7968;
    font-size: 1.6rem;
    margin-bottom: 0.5rem;
}

.envelope-card-inner .mini-names {
    font-family: 'Cormorant Garamond', serif;
    color: #5a4e42;
    font-size: 0.85rem;
    letter-spacing: 0.1em;
}

.envelope-card-inner .mini-date {
    color: #a09080;
    font-size: 0.75rem;
    margin-top: 0.5rem;
    font-style: italic;
}

/* === ENVELOPE POCKETS === */
.envelope-pockets {
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: 8px;
    overflow: hidden;
    z-index: 20;
}

/* Left pocket - slightly lighter, catches light */
.pocket-left {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.06) 0%, transparent 60%),
        linear-gradient(to right, #e4d8c2, #dfd2bc);
    clip-path: polygon(0 0, 50% 50%, 0 100%);
}

/* Fold shadow on left pocket diagonal */
.pocket-left::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom right,
            transparent 46%,
            rgba(0, 0, 0, 0.06) 49%,
            rgba(0, 0, 0, 0.04) 50%,
            transparent 54%);
    clip-path: polygon(0 0, 50% 50%, 0 100%);
}

/* Right pocket - slightly darker, in shadow */
.pocket-right {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(225deg, rgba(255, 255, 255, 0.04) 0%, transparent 60%),
        linear-gradient(to left, #dcceb6, #d8c8b0);
    clip-path: polygon(100% 0, 50% 50%, 100% 100%);
}

/* Fold shadow on right pocket diagonal */
.pocket-right::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom left,
            transparent 46%,
            rgba(0, 0, 0, 0.06) 49%,
            rgba(0, 0, 0, 0.04) 50%,
            transparent 54%);
    clip-path: polygon(100% 0, 50% 50%, 100% 100%);
}

/* Bottom pocket - slightly different shade, overlaps left/right */
.pocket-bottom {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(to top, rgba(255, 255, 255, 0.05), transparent 60%),
        linear-gradient(to top, #d6c8ae, #ddd0ba);
    clip-path: polygon(0 100%, 50% 50%, 100% 100%);
}

/* Shadow at top edge of bottom pocket */
.pocket-bottom::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom,
            transparent 46%,
            rgba(0, 0, 0, 0.05) 49%,
            rgba(0, 0, 0, 0.03) 50%,
            transparent 54%);
    clip-path: polygon(0 100%, 50% 50%, 100% 100%);
}

/* === ENVELOPE FLAP === */
.envelope-flap {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 62%;
    z-index: 30;
    transform-origin: top center;
    transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

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

.flap-front {
    position: absolute;
    inset: 0;
    background:
        /* Subtle light gradient for depth */
        linear-gradient(to bottom,
            rgba(255, 255, 255, 0.06) 0%,
            transparent 30%,
            rgba(0, 0, 0, 0.04) 90%),
        /* Paper grain */
        repeating-linear-gradient(0deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.006) 2px,
            rgba(0, 0, 0, 0.006) 4px),
        /* Base color matching envelope */
        linear-gradient(170deg, #d8cab2 0%, #d2c2a4 60%, #ccb898 100%);
    clip-path: polygon(0 0, 100% 0, 50% 100%);
    backface-visibility: hidden;
    border-radius: 8px 8px 0 0;
}

/* Shadow at bottom of flap triangle */
.flap-front::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top,
            rgba(0, 0, 0, 0.08) 0%,
            transparent 20%);
    clip-path: polygon(0 0, 100% 0, 50% 100%);
}

.flap-back {
    position: absolute;
    inset: 0;
    /* Liner pattern on back of flap */
    background:
        repeating-linear-gradient(-45deg,
            transparent,
            transparent 6px,
            rgba(163, 133, 100, 0.1) 6px,
            rgba(163, 133, 100, 0.1) 7px),
        linear-gradient(to top, #f0e8d8, #e8dcc8);
    clip-path: polygon(50% 0%, 0 100%, 100% 100%);
    transform: rotateX(180deg);
    backface-visibility: hidden;
}

/* === WAX SEAL (realistic) === */
.wax-seal {
    position: absolute;
    top: 62%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 56px;
    height: 56px;
    background:
        radial-gradient(circle at 35% 35%,
            #d4a030 0%,
            #c49420 20%,
            #b8860b 50%,
            #a07008 75%,
            #8a6006 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        inset 0 2px 4px rgba(255, 255, 255, 0.3),
        inset 0 -2px 4px rgba(0, 0, 0, 0.2),
        0 3px 10px rgba(0, 0, 0, 0.3),
        0 1px 3px rgba(0, 0, 0, 0.2);
    z-index: 40;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

/* Wax drip / irregular edge */
.wax-seal::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background:
        radial-gradient(circle at 30% 30%, #c49420, #96700a);
    z-index: -1;
    clip-path: polygon(8% 2%, 20% 0%, 32% 3%, 45% 0%, 58% 2%, 72% 0%, 85% 3%, 95% 1%,
            100% 12%, 98% 25%, 100% 38%, 97% 52%, 100% 65%, 98% 78%, 100% 90%, 97% 100%,
            88% 98%, 75% 100%, 62% 97%, 48% 100%, 35% 98%, 22% 100%, 8% 97%, 0% 100%,
            2% 88%, 0% 75%, 3% 62%, 0% 48%, 2% 35%, 0% 22%, 3% 8%);
}

/* Inner ring detail on seal */
.wax-seal::after {
    content: '';
    position: absolute;
    inset: 6px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 215, 0, 0.25);
}

.wax-seal.broken {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.5) rotate(15deg) !important;
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.wax-seal span {
    font-family: 'Dancing Script', cursive;
    color: #faf6ef;
    font-size: 1.2rem;
    padding-top: 2px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    z-index: 1;
}

/* === FLOATING HEARTS === */
.envelope-hearts {
    position: absolute;
    top: 30%;
    left: 0;
    right: 0;
    z-index: 5;
    pointer-events: none;
    opacity: 0;
}

.envelope-hearts.show {
    opacity: 1;
}

.envelope-heart {
    position: absolute;
    width: 12px;
    height: 12px;
    opacity: 0;
}

.envelope-heart::before,
.envelope-heart::after {
    content: '';
    position: absolute;
    width: 12px;
    height: 18px;
    background: #c9956b;
    border-radius: 12px 12px 0 0;
}

.envelope-heart::before {
    left: 6px;
    transform: rotate(-45deg);
    transform-origin: 0 100%;
}

.envelope-heart::after {
    left: 0;
    transform: rotate(45deg);
    transform-origin: 100% 100%;
}

.envelope-hearts.show .eh1 {
    left: 25%;
    animation: heartFloat 3s ease-out 0.8s forwards;
}

.envelope-hearts.show .eh2 {
    left: 55%;
    animation: heartFloat 3.5s ease-out 1s forwards;
}

.envelope-hearts.show .eh3 {
    left: 40%;
    animation: heartFloat 4s ease-out 1.3s forwards;
}