/* ==========================================================================
   PREFIXED STYLES: NAVY ENVELOPE COVER (Elementor-Compatible Full-Screen)
   ========================================================================== */

#nec-envelope-screen {
  --nec-primary-navy: #0a1128;
  --nec-navy-medium: #1c2541;
  --nec-gold-primary: #c5a880;
  --nec-gold-light: #e6d5b8;
  --nec-gold-dark: #a27b5c;
  --nec-text-white: #f4f6f9;
  --nec-text-muted: #a0aec0;
  
  --nec-font-serif: 'Playfair Display', Georgia, serif;
  --nec-font-sans: 'Montserrat', sans-serif;
  
  --nec-transition-smooth: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  --nec-shadow-premium: 0 20px 40px rgba(0, 0, 0, 0.5);
  --nec-shadow-glow: 0 0 15px rgba(197, 168, 128, 0.3);
}

/* Scroll Lock Helper */
html.nec-lock-scroll,
body.nec-lock-scroll {
  overflow: hidden !important;
  height: 100vh !important;
}

/* ==========================================================================
   FULLSCREEN OVERLAY
   ========================================================================== */
.nec-tilda-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 999999;
  background-color: transparent;
  overflow: hidden;
  box-sizing: border-box;
  font-family: var(--nec-font-sans);
  transition: opacity 0.8s ease, visibility 0.8s;
}

.nec-tilda-overlay.nec-fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.nec-tilda-overlay *,
.nec-tilda-overlay *::before,
.nec-tilda-overlay *::after {
  box-sizing: border-box;
}

.nec-tilda-envelope {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* ==========================================================================
   TEXTURE
   ========================================================================== */
.nec-navy-linen-texture {
  background-color: #0c152a;
  background-image: 
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 3px 3px;
}

/* ==========================================================================
   4 FULL-SCREEN FLAPS
   ========================================================================== */
.nec-tilda-flap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transition: transform 1.2s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

/* Wrapper for fixing iOS Safari drop-shadow + clip-path bugs */
.nec-flap-shadow-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transition: transform 3s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}
.nec-shadow-left {
  z-index: 1;
  filter: drop-shadow(4px 0 15px rgba(0,0,0,0.5));
}
.nec-shadow-right {
  z-index: 1;
  filter: drop-shadow(-4px 0 15px rgba(0,0,0,0.5));
}
.nec-shadow-bottom {
  z-index: 2;
  filter: drop-shadow(0 -8px 20px rgba(0,0,0,0.5));
}
.nec-shadow-top {
  z-index: 3;
  filter: drop-shadow(0 15px 30px rgba(0,0,0,0.6));
}

/* Base flap style */
.nec-tilda-flap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden; /* Fix Safari shrink/flicker */
  transform: translateZ(0); /* Force GPU */
}

/* Left & Right Flaps (Bottom layer) */
.nec-tilda-flap-left {
  clip-path: polygon(0 30%, 50% 55%, 0 75%); /* Fallback */
  clip-path: url(#nec-clip-left);
}
.nec-tilda-flap-right {
  clip-path: polygon(100% 30%, 50% 55%, 100% 75%); /* Fallback */
  clip-path: url(#nec-clip-right);
}

/* Bottom Flap (Middle layer) */
.nec-tilda-flap-bottom {
  clip-path: polygon(0 100%, 100% 100%, 100% 75%, 50% 55%, 0 75%); /* Fallback */
  clip-path: url(#nec-clip-bottom);
}

/* Top Flap (Front layer) */
.nec-tilda-flap-top {
  clip-path: polygon(0 0, 100% 0, 100% 30%, 50% 55%, 0 30%); /* Fallback */
  clip-path: url(#nec-clip-top);
  background-color: #11223f; /* Slightly lighter navy for depth */
}

/* Animation on Open */
.nec-tilda-envelope.open .nec-tilda-flap-left-wrap {
  transform: translateX(-100vw);
  transition: transform 4s cubic-bezier(0.4, 0, 0.2, 1);
}
.nec-tilda-envelope.open .nec-tilda-flap-right-wrap {
  transform: translateX(100vw);
  transition: transform 4s cubic-bezier(0.4, 0, 0.2, 1);
}
.nec-tilda-envelope.open .nec-tilda-flap-top-wrap {
  transform: translateY(-100vh);
  transition: transform 6s ease-out; /* Slower top animation */
}
.nec-tilda-envelope.open .nec-tilda-flap-bottom-wrap {
  transform: translateY(100vh);
  transition: transform 4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Prevent double-transitioning the inner children */
.nec-tilda-flap-top-wrap .nec-tilda-flap,
.nec-tilda-flap-bottom-wrap .nec-tilda-flap,
.nec-tilda-flap-left-wrap .nec-tilda-flap,
.nec-tilda-flap-right-wrap .nec-tilda-flap {
  transition: none !important;
  transform: none !important;
}

/* ==========================================================================
   CONTENT ON TOP OF ENVELOPE
   ========================================================================== */
.nec-tilda-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 8vh 20px;
  pointer-events: none; /* Let clicks pass to the seal only */
  transition: opacity 0.5s ease;
}

/* Fade out all text/content immediately when opening */
.nec-tilda-envelope.open .nec-tilda-content {
  opacity: 0;
}

/* Seal Lift Animation */
.nec-tilda-overlay.seal-opening .nec-wax-seal-container {
  transform: translate(-50%, -50%) scale(1.3);
  opacity: 0;
  pointer-events: none;
  transition: transform 1.5s ease-in-out, opacity 1s ease-in-out 0.5s;
}
.nec-tilda-overlay.seal-opening .nec-click-to-open,
.nec-tilda-overlay.seal-opening .nec-pulse-ring {
  opacity: 0;
  transition: opacity 0.5s ease;
}

/* ==========================================================================
   WAX SEAL TRIGGER
   ========================================================================== */
.nec-wax-seal-container {
  pointer-events: auto; /* Clickable */
  position: absolute;
  top: 54.5%;
  left: 50%;
  transform: translate(-50%, -50%);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.nec-wax-seal {
  width: 130px;
  height: 130px;
  position: relative;
  z-index: 10;
  border-radius: 50%;
  transition: transform 0.3s ease, filter 0.3s ease;
  filter: drop-shadow(0 5px 15px rgba(0,0,0,0.4));
}

.nec-wax-seal:hover {
  transform: scale(1.05);
}

.nec-seal-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.nec-pulse-ring {
  position: absolute;
  top: 0;
  left: 0;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 2px solid var(--nec-gold-primary);
  animation: nec-pulse 2s infinite;
  pointer-events: none;
  opacity: 0.6;
}

.nec-click-to-open {
  margin-top: 5px;
  font-size: 1rem;
  font-family: var(--nec-font-serif);
  font-style: normal;
  text-shadow: 0 1px 3px rgba(255,255,255,0.4);
  animation: nec-fadeInOut 2s infinite;
}

/* ==========================================================================
   KEYFRAME ANIMATIONS
   ========================================================================== */
@keyframes nec-pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(197, 168, 128, 0.6);
  }
  70% {
    transform: scale(1.08);
    box-shadow: 0 0 0 15px rgba(197, 168, 128, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(197, 168, 128, 0);
  }
}

@keyframes nec-fadeInOut {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.nec-animate-fade-in {
  animation: nec-fadeIn 1s ease forwards;
}

.nec-animate-fade-in-delayed {
  opacity: 0;
  animation: nec-fadeIn 1s ease 0.5s forwards;
}

@keyframes nec-fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */
@media (max-width: 768px) {
  .nec-couple-title {
    font-size: 2.2rem;
  }
}

@media (max-width: 480px) {
  .nec-tilda-content {
    padding: 10vh 15px;
  }
  .nec-couple-title {
    font-size: 1.8rem;
  }
  .nec-wax-seal {
    width: 110px;
    height: 110px;
  }
}
