/* envelope.css */
/* ==================================================
   ORIGINAL 3D FROSTED PAPER ENVELOPE
   ================================================== */
.envelope-wrapper { position: absolute; top: 50%; left: 50%; margin-top: 20px; width: var(--env-width); max-width: 90vw; height: var(--env-height); z-index: 25; opacity: 0; transform: translate(-50%, -50%) scale(var(--env-start-scale)); pointer-events: none; perspective: 1500px; }
.scene.envelope-revealing .envelope-wrapper { opacity: 1; transform: translate(-50%, -50%) scale(1); transition: opacity var(--env-duration) ease-out, transform var(--env-duration) cubic-bezier(0.2, 0.8, 0.2, 1); }
.scene.envelope-settled .envelope-wrapper { opacity: 1; transform: translate(-50%, -50%) scale(1); pointer-events: auto; }
.envelope-wrapper.dissolve-envelope { opacity: 0 !important; transform: translate(-50%, -50%) scale(1.3) !important; transition: all 1s ease-in-out !important; pointer-events: none !important; }

.envelope-card { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); will-change: transform; cursor: grab; }
.envelope-card:active { cursor: grabbing; }

.env-face { position: absolute; inset: 0; border-radius: 6px; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: flex; background: rgba(240, 245, 255, 0.08); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); border: 1px solid rgba(255, 255, 255, 0.15); box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.05), 0 15px 40px rgba(0, 0, 0, 0.6); }
.envelope-card.opened .env-face { overflow: visible !important; }

.env-front { transform: rotateY(0deg); }
.env-back { transform: rotateY(180deg); flex-direction: column; padding: 24px; justify-content: center; }

.paper-noise { position: absolute; inset: 0; z-index: 0; pointer-events: none; opacity: 0.3; mix-blend-mode: overlay; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); border-radius: inherit; }
.env-flap { 
    position: absolute; top: 0; left: 0; width: 100%; height: 55%; 
    clip-path: polygon(0 0, 100% 0, 50% 100%); 
    z-index: 10; 
    background: linear-gradient(to bottom, rgba(255,255,255,0.08), transparent); 
    border-bottom: 1px solid rgba(255,255,255,0.2); 
    transform-origin: top center; 
}
.envelope-card.opened .env-flap { 
    transform: rotateX(180deg); /* Folds outward towards the user instead of inward */
    transition: transform 0.9s cubic-bezier(0.25, 1, 0.5, 1); 
    z-index: 10; /* Keeps the flap in front of the emerging letter */
    pointer-events: none; 
}
.wax-seal { position: absolute; top: 55%; left: 50%; transform: translate(-50%, -50%); width: 34px; height: 34px; border-radius: 50%; z-index: 11; transition: transform 0.2s ease; background: #fdfbf7; border: 1px solid rgba(255,255,255,0.8); box-shadow: inset 0 -2px 6px rgba(0,0,0,0.2), 0 4px 10px rgba(0,0,0,0.4); cursor: pointer;}
.wax-seal:hover { transform: translate(-50%, -50%) scale(1.15); }
.scene.envelope-settled .wax-seal { animation: wax-pulse var(--env-pulse) infinite ease-in-out; }
.envelope-card.opened .wax-seal { opacity: 0; transform: translate(-50%, -50%) scale(0.6); transition: all 0.5s ease; pointer-events: none; }
@keyframes wax-pulse { 0%, 100% { box-shadow: inset 0 -2px 6px rgba(0,0,0,0.2), 0 0 5px rgba(253, 251, 247, 0.4); filter: brightness(1); } 50% { box-shadow: inset 0 -2px 6px rgba(0,0,0,0.2), 0 0 20px 4px rgba(253, 251, 247, 0.8); filter: brightness(1.2); } }

.env-scribble { position: absolute; top: 45%; left: 15%; font-family: "Comic Sans MS", cursive, sans-serif; font-size: 1.1rem; color: rgba(255,255,255,0.7); transform: rotate(-5deg); z-index: 5; }
.env-stamp { position: absolute; top: 30px; right: 20px; width: 35px; height: 45px; border: 1px solid rgba(200, 160, 255, 0.4); border-radius: 2px; background: rgba(200, 160, 255, 0.1); z-index: 5; transform: rotate(3deg); display: flex; flex-direction: column; align-items: center; padding: 3px; }
.stamp-inner { width: 100%; height: 60%; background: rgba(200, 160, 255, 0.2); margin-top: 2px; position: relative; }
.stamp-inner::after { content: '❁'; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: rgba(255,255,255,0.6); font-size: 14px; }
.env-doodles { position: absolute; bottom: 15px; left: 15px; width: 40px; height: 50px; border-left: 1px solid rgba(255,255,255,0.3); border-bottom: 1px solid transparent; border-radius: 0 0 0 15px; z-index: 5; }
.env-doodles::after { content: '♡'; position: absolute; top: -10px; left: -8px; color: rgba(255,255,255,0.5); font-size: 16px; transform: rotate(-15deg); }

.back-content { position: relative; z-index: 5; color: rgba(255,255,255,0.9); font-family: "Brush Script MT", "Lucida Handwriting", cursive; font-size: 1.1rem; width: 100%; height: 100%; display: flex; flex-direction: column; align-items: flex-start; text-align: left; }
.hw-title { margin-bottom: 12px; }
.hw-address-block { margin-bottom: 15px; text-align: left; line-height: 1.4; }
.hw-pin { letter-spacing: 1px; margin-bottom: auto; }
.hw-sender { text-align: right; margin-top: 15px; width: 100%; }

.directional-guide { position: absolute; bottom: 12%; left: 50%; transform: translateX(-50%); opacity: 0; pointer-events: none; transition: opacity 0.8s ease; z-index: 15; color: rgba(255,255,255,0.8); display: flex; align-items: center; justify-content: center; width: 100%; }
.directional-guide.visible { opacity: 1; }
.guide-c-text { display: block; font-family: cursive; font-size: 0.9rem; opacity: 0.6; animation: drift-h 3s infinite alternate ease-in-out; }
@keyframes drift-h { 0% { transform: translateX(-5px); } 100% { transform: translateX(5px); } }

/* ==================================================
   PURE GLOWING ARROW HINT OVERLAY
   ================================================== */
.flip-hint-overlay { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 12px; pointer-events: none; opacity: 0; transition: opacity 0.4s ease; z-index: 30; }
.flip-hint-overlay.visible { opacity: 1; }
.flip-hint-text { font-family: cursive; font-size: 0.85rem; color: #ffffff; text-shadow: 0 0 10px rgba(255,255,255,0.8), 0 0 20px rgba(200, 220, 255, 0.6); opacity: 0.9; letter-spacing: 2px; }
.glowing-arrow { width: 22px; height: 22px; border-top: 4px solid #ffffff; border-left: 4px solid #ffffff; filter: drop-shadow(0 0 6px rgba(255, 255, 255, 1)) drop-shadow(0 0 15px rgba(200, 220, 255, 0.8)); }
.flip-hint-overlay.visible .glowing-arrow { animation: glow-swipe-left 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite; }
@keyframes glow-swipe-left { 0% { transform: translateX(15px) rotate(-45deg); opacity: 0; } 30% { opacity: 1; } 70% { opacity: 1; } 100% { transform: translateX(-20px) rotate(-45deg); opacity: 0; } }
.flip-hint-overlay.reverse-hint .glowing-arrow { animation: glow-swipe-right 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite; }
@keyframes glow-swipe-right { 0% { transform: translateX(-15px) rotate(135deg); opacity: 0; } 30% { opacity: 1; } 70% { opacity: 1; } 100% { transform: translateX(20px) rotate(135deg); opacity: 0; } }

/* ==================================================
   MINIMALIST NIGHT SKY LETTER SYSTEM
   ================================================== */
.notes-container { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 4; clip-path: inset(-500% -20% 45% -20%); pointer-events: none; }

/* Hide old paper stacks */
.note-stack-bg { display: none !important; }

/* Premium Dark Glassmorphic Note */
.love-note { 
    position: absolute; 
    top: 12%; 
    left: 5%; 
    width: 90%; 
    height: 160%; 
    background: rgba(8, 12, 24, 0.65); /* Obsidian transparency */
    backdrop-filter: blur(16px); 
    -webkit-backdrop-filter: blur(16px);
    border-radius: 8px; 
    border: 1px solid rgba(255,255,255,0.15); 
    box-shadow: 0 -15px 40px rgba(0,0,0,0.6), inset 0 0 30px rgba(163, 194, 255, 0.05); 
    transform: translateY(100%) rotate(-3deg); 
    pointer-events: auto; 
    display: flex; 
    flex-direction: column; 
    z-index: 5; 
    overflow: hidden; 
    will-change: transform; 
}

.love-note.revealed { animation: note-emerge 1.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; }
@keyframes note-emerge { 
    0% { transform: translateY(100%) rotate(-3deg); } 
    70% { transform: translateY(-112%) rotate(0.5deg); } 
    100% { transform: translateY(-110%) rotate(0deg); } 
}

.love-note.dismissed { animation: note-drift-away 1.2s cubic-bezier(0.4, 0, 0.2, 1) forwards; pointer-events: none; }
@keyframes note-drift-away { 
    0% { transform: translateY(-110%) rotate(0deg); opacity: 1; filter: blur(0px); } 
    100% { transform: translateY(-135%) rotate(3deg); opacity: 0; filter: blur(8px); } 
}

.scene.envelope-settled .envelope-wrapper.reading-mode { 
    transform: translate(-50%, 22vh) scale(0.95); 
    transition: transform 1.2s cubic-bezier(0.2, 0.8, 0.2, 1); 
}

/* Ethereal Glow overlays instead of paper noise */
.note-moonlight-wash { 
    position: absolute; 
    inset: 0; 
    pointer-events: none; 
    z-index: 1; 
    background: radial-gradient(circle at 50% 0%, rgba(163, 194, 255, 0.15) 0%, transparent 60%); 
}

/* Clean, centered typography layout with unified scrolling */
.night-sky-layout { 
    position: relative; 
    z-index: 3; 
    padding: 40px 30px 80px 30px; /* Generous bottom padding to clear the fade mask */
    display: flex; 
    flex-direction: column; 
    height: 100%; 
    box-sizing: border-box; 
    align-items: center;
    
    /* Global scroll applied here */
    overflow-y: auto;          
    touch-action: pan-y;
    scrollbar-width: none; 
    -ms-overflow-style: none;
    
    /* Elegant fade-out at the bottom */
    -webkit-mask-image: linear-gradient(to bottom, black 80%, transparent 100%);
    mask-image: linear-gradient(to bottom, black 80%, transparent 100%);
}
.night-sky-layout::-webkit-scrollbar { display: none; }

.note-greeting { 
    font-family: 'Spectral', 'Georgia', serif; 
    font-size: 1.4rem; 
    color: #ffffff; 
    font-style: italic; 
    margin-top: 20px;
    margin-bottom: 30px; 
    letter-spacing: 1px; 
    text-shadow: 0 0 15px rgba(255,255,255,0.4); 
    width: 100%;
    text-align: center;
    flex-shrink: 0; /* Prevents text from squishing */
}

.poetic-body { 
    font-family: 'Spectral', 'Georgia', serif; 
    font-size: 1.15rem; 
    color: rgba(230, 240, 255, 0.85); 
    line-height: 1.9; 
    text-align: center; 
    text-shadow: 0 2px 5px rgba(0,0,0,0.5); 
    margin-bottom: 40px;
    flex-shrink: 0; /* Prevents text from squishing */
}

/* Beautiful, cinematic CTA Button */
.night-sky-cta { 
    font-family: 'Spectral', serif; 
    font-style: italic; 
    font-size: 1.05rem; 
    color: #ffffff; 
    letter-spacing: 2px; 
    padding: 14px 35px; 
    background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.02)); 
    border: 1px solid rgba(255,255,255,0.3); 
    border-radius: 40px; 
    cursor: pointer; 
    transition: all 0.4s ease; 
    box-shadow: 0 4px 20px rgba(0,0,0,0.3), inset 0 0 10px rgba(255,255,255,0.1); 
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    flex-shrink: 0; /* Ensures the button maintains its shape */
    margin-bottom: 20px;
}

.night-sky-cta:hover { 
    background: rgba(255,255,255,0.2); 
    border-color: rgba(255,255,255,0.6);
    box-shadow: 0 6px 25px rgba(163, 194, 255, 0.4), inset 0 0 15px rgba(255,255,255,0.3); 
    transform: translateY(-2px); 
}

@media (prefers-reduced-motion: reduce) { 
    .scene.envelope-settled .envelope-wrapper.reading-mode { transition-duration: 0.1s; }
    .love-note.revealed { animation: none; transform: translateY(-110%) rotate(0deg); }
    .love-note.dismissed { animation: none; opacity: 0; }
}

/* Cinematic Viewer for photos */
.cinematic-viewer { position: fixed; inset: 0; z-index: 9999; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; opacity: 0; transition: opacity 0.5s ease; }
.cinematic-viewer.active { pointer-events: auto; opacity: 1; }
.cinematic-backdrop { position: absolute; inset: 0; background: rgba(12, 8, 5, 0.7); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.cinematic-image-wrapper { position: relative; z-index: 2; max-width: 85vw; max-height: 80vh; padding: 10px; background: #FDFCF9; box-shadow: 0 20px 50px rgba(0,0,0,0.5); opacity: 0; filter: blur(20px); transform: scale(1.1); transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1); }
.cinematic-viewer.active .cinematic-image-wrapper { opacity: 1; filter: blur(0px); transform: scale(1) rotate(-1deg); }
.cinematic-image { display: block; max-width: 100%; max-height: calc(80vh - 20px); object-fit: contain; }
.cinematic-hint { position: absolute; bottom: 5vh; z-index: 2; font-family: 'Georgia', 'Times New Roman', serif; font-style: italic; color: rgba(255,255,255,0.6); font-size: 0.85rem; letter-spacing: 2px; opacity: 0; transform: translateY(10px); transition: all 0.8s ease 0.4s; }
.cinematic-viewer.active .cinematic-hint { opacity: 1; transform: translateY(0); }

/* Magical Reveal Text */
.magical-reveal-container { margin-top: 30px; margin-bottom: 20px; display: flex; flex-direction: column; gap: 24px; }
.magical-line { font-family: 'Georgia', 'Times New Roman', serif; font-size: 1.05rem; color: #4A3A35; line-height: 1.6; text-align: center; margin: 0; opacity: 0; filter: blur(12px); transform: translateY(18px) scale(0.96); transition: opacity 1.4s cubic-bezier(0.2, 0.8, 0.2, 1), filter 1.4s cubic-bezier(0.2, 0.8, 0.2, 1), transform 1.4s cubic-bezier(0.2, 0.8, 0.2, 1); will-change: opacity, filter, transform; }
.magical-line.revealed { opacity: 1; filter: blur(0px); transform: translateY(0) scale(1); }

/* Note Finale Threshold */
.finale-layout { display: flex; flex-direction: column; align-items: center; width: 100%; height: 100%; flex-grow: 1; padding-bottom: 10px; box-sizing: border-box; }
.finale-text-wrapper { flex-grow: 1; display: flex; align-items: center; justify-content: center; width: 100%; }
.finale-main-text { font-family: 'Georgia', 'Times New Roman', serif; font-size: clamp(1.1rem, 4.5vw, 1.35rem); color: #2C2621; line-height: 1.8; text-align: center; max-width: 95%; margin: 0; opacity: 0; filter: blur(20px); transform: translateY(25px) scale(0.95); }
.love-note.revealed .finale-main-text { animation: finale-morph-reveal 3s cubic-bezier(0.2, 0.8, 0.2, 1) forwards 1.2s; }
@keyframes finale-morph-reveal { 0% { opacity: 0; filter: blur(20px); transform: translateY(25px) scale(0.95); } 40% { opacity: 1; filter: blur(0px); transform: translateY(-2px) scale(1.01); } 100% { opacity: 1; filter: blur(0px); transform: translateY(0) scale(1); } }
.magical-cta { margin-top: auto; flex-shrink: 0; font-family: 'Georgia', 'Times New Roman', serif; font-style: italic; font-size: 1.15rem; color: #7A6A63; letter-spacing: 2px; cursor: pointer; padding: 15px 25px; opacity: 0; pointer-events: none; transform: translateY(10px); }
.love-note.revealed .magical-cta { animation: cta-soft-emerge 2s ease-out forwards 3.5s, cta-moonlight-shimmer 4s ease-in-out infinite 5.5s; }
@keyframes cta-soft-emerge { 0% { opacity: 0; transform: translateY(10px); pointer-events: none; } 100% { opacity: 0.85; transform: translateY(0); pointer-events: auto; } }
@keyframes cta-moonlight-shimmer { 0%, 100% { opacity: 0.85; text-shadow: 0 0 0px rgba(255, 255, 255, 0); transform: scale(1); } 50% { opacity: 1; text-shadow: 0 0 12px rgba(255, 255, 255, 0.8), 0 0 25px rgba(200, 220, 255, 0.5); transform: scale(1.04); color: #4A3A35; } }
.magical-cta:hover { color: #2C2621; text-shadow: 0 0 15px rgba(255, 255, 255, 1), 0 0 30px rgba(200, 220, 255, 0.8); transition: all 0.4s ease; }

.finale-sanctuary { display: flex; flex-direction: column; align-items: center; width: 100%; height: 100%; padding: 30px 20px; box-sizing: border-box; overflow-y: auto; scrollbar-width: none; -ms-overflow-style: none; }
.finale-sanctuary::-webkit-scrollbar { display: none; }
.finale-poem { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; margin-top: auto; margin-bottom: 40px; opacity: 0; filter: blur(15px); transform: translateY(15px) scale(0.96); }
.love-note.revealed .finale-poem { animation: poem-materialize 3.5s cubic-bezier(0.2, 0.8, 0.2, 1) forwards 1s; }
@keyframes poem-materialize { 0% { opacity: 0; filter: blur(15px); transform: translateY(15px) scale(0.96); } 50% { opacity: 1; filter: blur(2px); transform: translateY(-2px) scale(1.01); } 100% { opacity: 1; filter: blur(0px); transform: translateY(0) scale(1); } }
.poem-line { font-family: 'Baskerville', 'Palatino Linotype', 'Georgia', serif; font-size: clamp(1.05rem, 4.5vw, 1.25rem); color: #3D342E; line-height: 1.9; text-align: center; letter-spacing: 0.5px; display: block; width: 100%; text-shadow: 0 1px 1px rgba(255, 255, 255, 0.4); }
.poem-spacer { height: 22px; display: block; }
.poem-emphasis { font-style: italic; font-size: 1.08em; color: #2A221E; letter-spacing: 0.8px; text-shadow: 0 0 8px rgba(255, 255, 255, 0.7); }

.whisper-cta { margin-top: auto; margin-bottom: 10px; font-family: 'Baskerville', 'Palatino Linotype', 'Georgia', serif; font-style: italic; font-size: 1.1rem; font-weight: bold; color: #3D342E; letter-spacing: 2px; cursor: pointer; padding: 14px 32px; background: linear-gradient(135deg, rgba(255,255,255,0.7), rgba(255,255,255,0.3)); border: 1px solid rgba(140, 126, 119, 0.3); border-radius: 40px; box-shadow: 0 4px 15px rgba(0,0,0,0.05), inset 0 0 10px rgba(255,255,255,0.6); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); opacity: 0; pointer-events: none; transform: translateY(15px); }
.love-note.revealed .whisper-cta { animation: cta-emerge 2s ease-out forwards 4.5s, cta-glow-pulse 4s ease-in-out infinite 6.5s; }
@keyframes cta-emerge { 0% { opacity: 0; transform: translateY(15px); pointer-events: none; } 100% { opacity: 0.9; transform: translateY(0); pointer-events: auto; } }
@keyframes cta-glow-pulse { 0%, 100% { box-shadow: 0 4px 15px rgba(0,0,0,0.05), inset 0 0 10px rgba(255,255,255,0.6); } 50% { box-shadow: 0 4px 25px rgba(200, 220, 255, 0.4), inset 0 0 15px rgba(255,255,255,0.9); transform: scale(1.02); } }
.whisper-cta:hover { background: rgba(255,255,255,0.95); color: #1A1512; box-shadow: 0 6px 25px rgba(200, 220, 255, 0.7); transform: translateY(-2px) scale(1.02); transition: all 0.4s ease; }

@media (prefers-reduced-motion: reduce) { 
    .scene.envelope-settled .envelope-wrapper.reading-mode { transition-duration: 0.1s; }
    .love-note.revealed { animation: none; transform: translateY(-110%) rotate(0deg); }
    .love-note.dismissed { animation: none; opacity: 0; }
    .guide-c-text { animation: none !important; }
    .magical-line { filter: none !important; transform: none !important; transition: opacity 1s ease !important; }
    .finale-main-text { filter: none !important; transform: none !important; }
    .love-note.revealed .finale-main-text { animation: simple-fade 2s ease forwards 1s; }
    .love-note.revealed .magical-cta { animation: simple-fade 2s ease forwards 2.5s; }
    .finale-poem { filter: none !important; transform: none !important; }
    .love-note.revealed .finale-poem { animation: simple-fade 2s ease forwards 0.5s; }
    .love-note.revealed .whisper-cta { animation: simple-fade 2s ease forwards 2s; }
    .note-helper-cta { animation: none !important; } /* ADDED */
    @keyframes simple-fade { to { opacity: 1; pointer-events: auto; } }
}