/* Fullscreen Edge-to-Edge Reel Envelope (Vibrant Magenta & Blush Rose) */

/* Fullscreen Overlay Container */
#envelope-overlay {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    overflow: hidden;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    perspective: 1200px;
    background: #1a0008;
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Green Screen Mode */
#envelope-overlay.greenscreen-mode {
    background: #00FF00 !important;
}

/* Sparkle Canvas */
#sparkle-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
}

/* Fullscreen Envelope Stage */
.envelope-stage {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
}

.envelope-wrapper {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
}

/* Embossed Rose & Floral Damask Texture Layer */
.flap-emboss-pattern {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.18;
    background-repeat: repeat;
    background-size: 200px 200px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cg fill='%23ffffff'%3E%3Cpath d='M60 20 C65 35 80 45 95 48 C80 55 70 70 68 85 C62 70 50 60 35 58 C50 50 58 35 60 20 Z' opacity='0.9'/%3E%3Ccircle cx='60' cy='60' r='14' opacity='0.6'/%3E%3Ccircle cx='60' cy='60' r='8' opacity='0.8'/%3E%3Cpath d='M20 20 C25 30 35 35 45 38 C35 42 30 50 28 60 C25 50 18 45 10 42 C20 38 24 30 25 20 Z' opacity='0.6'/%3E%3Cpath d='M100 20 C105 30 115 35 125 38 C115 42 110 50 108 60 C105 50 98 45 90 42 C100 38 104 30 105 20 Z' opacity='0.6'/%3E%3Cpath d='M60 90 C63 98 72 103 80 105 C72 108 67 115 65 122 C62 115 57 110 50 108 C57 105 60 98 60 90 Z' opacity='0.6'/%3E%3C/g%3E%3C/svg%3E");
    mix-blend-mode: overlay;
}

/* -------------------------------------------------------------
   THE 4 FULL-SCREEN TRIANGULAR FLAPS (Meeting at Center X)
   ------------------------------------------------------------- */

/* Shared Flap Base */
.fs-flap {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

/* 1. TOP FLAP (Triangular flap pointing down to center) */
.fs-flap-top-container {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    transform-origin: top center;
    transform-style: preserve-3d;
    transition: transform 0.85s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
    pointer-events: none;
}

.fs-flap-top {
    clip-path: polygon(0 0, 100% 0, 50% 50%);
    background: linear-gradient(180deg, #d81159 0%, #b80c47 60%, #8c0533 100%);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* Crisp White/Gold Seam on Top Flap */
.fs-flap-top::after {
    content: '';
    position: absolute;
    inset: 0;
    clip-path: polygon(0 0, 100% 0, 50% 50%);
    background: linear-gradient(180deg, transparent 0%, rgba(255, 255, 255, 0.85) 99%, #ffffff 100%);
    mask: linear-gradient(to top, black 2px, transparent 2px);
    -webkit-mask: linear-gradient(to top, black 2px, transparent 2px);
}

/* 2. BOTTOM FLAP (Triangular flap pointing up to center) */
.fs-flap-bottom {
    clip-path: polygon(0 100%, 100% 100%, 50% 50%);
    background: linear-gradient(0deg, #990838 0%, #b80c47 50%, #c41250 100%);
    z-index: 8;
    transition: transform 0.85s cubic-bezier(0.4, 0, 0.2, 1) 0.1s;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.45);
}

/* 3. LEFT FLAP (Triangular flap pointing right to center) */
.fs-flap-left {
    clip-path: polygon(0 0, 0 100%, 50% 50%);
    background: linear-gradient(135deg, #c2185b 0%, #ad1457 50%, #880e4f 100%);
    z-index: 7;
    transition: transform 0.85s cubic-bezier(0.4, 0, 0.2, 1) 0.1s;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.45);
}

/* 4. RIGHT FLAP (Triangular flap pointing left to center) */
.fs-flap-right {
    clip-path: polygon(100% 0, 100% 100%, 50% 50%);
    background: linear-gradient(-135deg, #c2185b 0%, #ad1457 50%, #880e4f 100%);
    z-index: 7;
    transition: transform 0.85s cubic-bezier(0.4, 0, 0.2, 1) 0.1s;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.45);
}

/* Diagonal Seam Border Lines ('X' Pattern) */
.diagonal-seam-lines {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 9;
}

.seam-line-1 {
    position: absolute;
    top: 0;
    left: 0;
    width: 142%;
    height: 2px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.7) 0%, rgba(255, 240, 245, 0.95) 50%, rgba(255, 255, 255, 0.7) 100%);
    transform-origin: top left;
    transform: rotate(calc(atan2(100vh, 100vw)));
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.6);
}

/* -------------------------------------------------------------
   OPENING ANIMATION (4-WAY REVEAL)
   ------------------------------------------------------------- */
.envelope-wrapper.is-open .fs-flap-top-container {
    transform: rotateX(180deg);
    z-index: 1;
}

.envelope-wrapper.is-open .fs-flap-bottom {
    transform: translateY(105%);
}

.envelope-wrapper.is-open .fs-flap-left {
    transform: translateX(-105%);
}

.envelope-wrapper.is-open .fs-flap-right {
    transform: translateX(105%);
}

/* -------------------------------------------------------------
   PEARLESCENT BLUSH-PINK WAX SEAL (Centered at 50%, 50%)
   ------------------------------------------------------------- */
.wax-seal-wrapper {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 30;
    cursor: pointer;
    width: 124px;
    height: 124px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.45s ease;
    filter: drop-shadow(0 12px 24px rgba(60, 4, 20, 0.65));
    -webkit-tap-highlight-color: transparent;
}

@media (max-width: 640px) {
    .wax-seal-wrapper {
        width: 104px;
        height: 104px;
    }
}

.wax-seal-wrapper:hover {
    transform: translate(-50%, -50%) scale(1.08);
}

.wax-seal-wrapper:active {
    transform: translate(-50%, -50%) scale(0.95);
}

.wax-seal-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    animation: sealFloat 3s ease-in-out infinite;
}

@keyframes sealFloat {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-3px); }
}

/* Soft Rose-Gold Glow Aura */
.wax-seal-glow {
    position: absolute;
    inset: -12px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 230, 238, 0.7) 0%, rgba(248, 187, 208, 0.4) 40%, transparent 70%);
    animation: sealPulse 2.4s ease-in-out infinite;
    pointer-events: none;
}

@keyframes sealPulse {
    0%, 100% {
        transform: scale(0.94);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.22);
        opacity: 0.95;
    }
}

/* Seal Dissolving upon Tap */
.envelope-wrapper.is-open .wax-seal-wrapper {
    transform: translate(-50%, -50%) scale(1.35);
    opacity: 0;
    pointer-events: none;
}

/* -------------------------------------------------------------
   TAP HINT (At Bottom of Screen)
   ------------------------------------------------------------- */
.tap-hint-container {
    position: absolute;
    bottom: 40px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    z-index: 35;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

@media (max-height: 600px) {
    .tap-hint-container {
        bottom: 20px;
    }
}

.envelope-wrapper.is-open ~ .tap-hint-container,
.envelope-wrapper.is-open .tap-hint-container {
    opacity: 0;
    pointer-events: none;
}

.tap-hint-text {
    font-family: 'Montserrat', sans-serif;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.28em;
    color: #ffffff;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
    animation: hintBreathe 2.4s ease-in-out infinite;
}

.tap-line {
    opacity: 0.75;
    font-weight: 300;
}

@keyframes hintBreathe {
    0%, 100% { opacity: 0.85; transform: scale(0.98); }
    50% { opacity: 1; transform: scale(1.02); }
}

/* Greenscreen card preview container if present */
.greenscreen-card-reveal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: 90vw;
    max-width: 440px;
    background: #fdfaf3;
    border-radius: 16px;
    border: 2px solid #ebd6a3;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
    padding: 32px 24px;
    text-align: center;
    z-index: 5;
    opacity: 0;
    transition: transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) 0.3s, opacity 0.6s ease 0.3s;
}

.greenscreen-mode .envelope-wrapper.is-open ~ .greenscreen-card-reveal,
.greenscreen-mode .envelope-wrapper.is-open .greenscreen-card-reveal {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}
