/* =============================================
   ENVELOPE COMPONENT - CLASSIC ENVELOPE STYLE
   With triangular flap and wax seal
   ============================================= */

/* Envelope Wrapper */
.envelope-wrapper {
    position: relative;
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    animation: floatIn 1.8s ease-out 0.9s both;
    perspective: 1000px;
}

@keyframes floatIn {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Envelope Body - now styled as a gift box */
.envelope {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    /* Fallback for Safari < 15 */
    height: 0;
    padding-bottom: 100%;
    background:
        /* Vertical ribbon */
        linear-gradient(90deg,
            transparent 47%,
            rgba(177, 128, 88, 0.95) 47%,
            rgba(177, 128, 88, 0.95) 53%,
            transparent 53%),
        /* Horizontal ribbon */
        linear-gradient(0deg,
            transparent 47%,
            rgba(177, 128, 88, 0.95) 47%,
            rgba(177, 128, 88, 0.95) 53%,
            transparent 53%),
        /* Box body */
        linear-gradient(160deg,
            #f8f0e0 0%,
            #f4e8d0 30%,
            #efe3c8 60%,
            #e8dbc0 100%);
    border-radius: 12px;
    box-shadow:
        0 25px 60px rgba(139, 115, 85, 0.2),
        0 10px 30px rgba(139, 115, 85, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.45);
    cursor: pointer;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: visible;
}

.envelope:hover {
    transform: translateY(-12px) scale(1.02);
    box-shadow:
        0 35px 80px rgba(139, 115, 85, 0.25),
        0 15px 40px rgba(139, 115, 85, 0.15);
}

/* Paper/box texture overlay */
.envelope::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        repeating-linear-gradient(45deg,
            transparent,
            transparent 3px,
            rgba(139, 115, 85, 0.03) 3px,
            rgba(139, 115, 85, 0.03) 6px);
    pointer-events: none;
    z-index: 1;
    border-radius: 12px;
}

/* Lid highlight */
.envelope::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 34%;
    background: linear-gradient(180deg,
            rgba(255, 255, 255, 0.35) 0%,
            rgba(255, 255, 255, 0.1) 60%,
            rgba(0, 0, 0, 0.05) 100%);
    border-radius: 12px 12px 20% 20%;
    z-index: 2;
    box-shadow: 0 6px 18px rgba(139, 115, 85, 0.12);
}

/* Hide old flap lines */
.envelope .flap-lines {
    display: none;
}

/* Wax Seal Container */
/* Gift bow (reusing monogram container) */
.monogram {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 84px;
    height: 84px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.25));
}

.monogram::before {
    content: '';
    position: absolute;
    width: 76%;
    height: 76%;
    background: radial-gradient(ellipse at 30% 30%,
            #d9b07a 0%,
            #c89c63 45%,
            #b78652 70%,
            #9a6d3d 100%);
    border-radius: 16px;
    box-shadow:
        inset 0 2px 6px rgba(255, 255, 255, 0.35),
        inset 0 -3px 6px rgba(0, 0, 0, 0.25),
        0 6px 12px rgba(0, 0, 0, 0.2);
    transform: rotate(45deg);
    transition: transform 0.35s ease, box-shadow 0.35s ease;
}

.monogram::after {
    content: '';
    position: absolute;
    width: 92%;
    height: 92%;
    border-radius: 18px;
    border: 2px solid rgba(215, 180, 120, 0.65);
    box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.12);
    transform: rotate(45deg);
}

/* Logo in seal */
.monogram-logo {
    width: 46%;
    height: 46%;
    object-fit: contain;
    position: relative;
    z-index: 11;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35));
    opacity: 0.95;
    transition: transform 0.3s ease;
}

.envelope:hover .monogram-logo {
    transform: scale(1.1);
}

/* Cherry Blossom Petals - Left & Right */
.monogram .leaf-left,
.monogram .leaf-right {
    position: absolute;
    width: 18px;
    height: 18px;
    background: radial-gradient(ellipse at 30% 30%,
            #FFE4E8 0%,
            #FFD4DC 30%,
            #F8B4C0 60%,
            #E8A0AC 100%);
    border-radius: 150% 0 150% 0;
    z-index: 9;
    box-shadow:
        inset -2px -2px 4px rgba(255, 255, 255, 0.5),
        inset 1px 1px 2px rgba(200, 120, 140, 0.2),
        0 2px 6px rgba(200, 120, 140, 0.3);
    animation: petalFloat 3s ease-in-out infinite;
}

.monogram .leaf-left {
    top: -5px;
    left: -15px;
    transform: rotate(-45deg);
    animation-delay: 0s;
}

.monogram .leaf-right {
    top: -5px;
    right: -15px;
    border-radius: 0 150% 0 150%;
    transform: rotate(45deg);
    animation-delay: 1.5s;
}

@keyframes petalFloat {

    0%,
    100% {
        transform: rotate(-45deg) translateY(0);
        opacity: 0.9;
    }

    50% {
        transform: rotate(-45deg) translateY(-5px);
        opacity: 1;
    }
}

.monogram .leaf-right {
    animation-name: petalFloatRight;
}

@keyframes petalFloatRight {

    0%,
    100% {
        transform: rotate(45deg) translateY(0);
        opacity: 0.9;
    }

    50% {
        transform: rotate(45deg) translateY(-5px);
        opacity: 1;
    }
}

/* Hide unused elements */
.monogram-circle,
.monogram-text,
.floral-accent,
.monogram .leaf-left,
.monogram .leaf-right {
    display: none;
}

/* =============================================
   ENVELOPE OPENING ANIMATION
   ============================================= */

/* Opening state - flap opens upward */
/* Opening animation disabled for gift box look */
.envelope.opening::after,
.envelope.opening .flap-lines {
    animation: none;
    transform: none;
    opacity: 1;
}

/* Seal breaking animation */
.envelope.opening .monogram {
    animation: sealBreak 0.6s ease-out 0.3s forwards;
}

@keyframes sealBreak {
    0% {
        transform: translate(-50%, -50%) scale(1) rotate(0deg);
        opacity: 1;
    }

    30% {
        transform: translate(-50%, -50%) scale(1.3) rotate(10deg);
    }

    60% {
        transform: translate(-50%, -50%) scale(1.5) rotate(-5deg);
        opacity: 0.8;
    }

    100% {
        transform: translate(-50%, -50%) scale(0) rotate(360deg);
        opacity: 0;
    }
}

/* Light burst effect */
.envelope.opening::before {
    animation: lightBurst 0.8s ease-out 0.2s forwards;
}

@keyframes lightBurst {
    0% {
        background: radial-gradient(circle at 50% 50%,
                transparent 0%,
                transparent 100%);
    }

    50% {
        background: radial-gradient(circle at 50% 50%,
                rgba(255, 215, 0, 0.3) 0%,
                rgba(255, 215, 0, 0.1) 40%,
                transparent 70%);
    }

    100% {
        background: radial-gradient(circle at 50% 50%,
                rgba(255, 255, 255, 0.5) 0%,
                rgba(255, 255, 255, 0.2) 30%,
                transparent 60%);
    }
}

/* Envelope rises and fades out */
.envelope.opening {
    animation: envelopeOpen 1.2s ease-out forwards;
}

@keyframes envelopeOpen {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }

    40% {
        transform: translateY(-30px) scale(1.05);
        opacity: 1;
    }

    70% {
        transform: translateY(-60px) scale(1.1);
        opacity: 0.8;
    }

    100% {
        transform: translateY(-100px) scale(1.15);
        opacity: 0;
    }
}

/* CTA text fade out */
.envelope-wrapper.opening .cta-text {
    animation: ctaFade 0.4s ease-out forwards;
}

@keyframes ctaFade {
    0% {
        opacity: 1;
        transform: translateY(0);
    }

    100% {
        opacity: 0;
        transform: translateY(10px);
    }
}

/* Sparkle particles on open */
.envelope-sparkle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: radial-gradient(circle, #FFD700, #FFA500);
    border-radius: 50%;
    pointer-events: none;
    z-index: 100;
    animation: sparkleExplode 0.8s ease-out forwards;
}

@keyframes sparkleExplode {
    0% {
        transform: translate(0, 0) scale(0);
        opacity: 1;
    }

    100% {
        transform: translate(var(--tx), var(--ty)) scale(1);
        opacity: 0;
    }
}

/* =============================================
   RESPONSIVE DESIGN
   ============================================= */

@media screen and (min-width: 1400px) {
    .envelope-wrapper {
        max-width: 480px;
    }

    .monogram {
        width: 90px;
        height: 90px;
    }
}

@media screen and (min-width: 768px) and (max-width: 1023px) {
    .envelope-wrapper {
        max-width: 380px;
    }

    .monogram {
        width: 75px;
        height: 75px;
    }
}

@media screen and (max-width: 767px) {
    .envelope-wrapper {
        max-width: 320px;
    }

    .monogram {
        width: 65px;
        height: 65px;
    }
}

@media screen and (max-width: 480px) {
    .envelope-wrapper {
        max-width: 280px;
    }

    .monogram {
        width: 55px;
        height: 55px;
    }
}

/* Touch device */
@media (hover: none) and (pointer: coarse) {
    .envelope:hover {
        transform: none;
    }

    .envelope:active {
        transform: scale(0.98);
    }
}