body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: #080b12;
    color: #f1f5f9;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

/* Glassmorphism card effects */
.glass-card {
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(212, 175, 55, 0.22);
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.8), 0 0 15px rgba(212, 175, 55, 0.1);
}

.glass-nav {
    background: rgba(10, 14, 26, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(212, 175, 55, 0.3);
    box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.5);
}

/* Gold Gradient Text */
.text-gold-gradient {
    background: linear-gradient(135deg, #fff8e7 0%, #f3e5ab 30%, #d4af37 70%, #aa7c11 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.gold-border-glow {
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.3);
}

/* Animated Pin & Pulse */
@keyframes subtlePulse {
    0%,
    100% {
        transform: scale(1);
        opacity: 0.9;
    }
    50% {
        transform: scale(1.05);
        opacity: 1;
    }
}

.animate-pulse-subtle {
    animation: subtlePulse 3s infinite ease-in-out;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: #080b12;
}

::-webkit-scrollbar-thumb {
    background: #d4af37;
    border-radius: 10px;
}

/* Canvas Background Fix */
#stars-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* Modal Slide Animation */
.modal-enter {
    animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes modalSlideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Prevent touch scroll on backdrop */
#modalBackdrop {
    touch-action: none;
    overscroll-behavior: contain;
}

/* Allow scrolling inside modal panels */
.modal-enter > div {
    max-height: 85vh;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.invitation-content {
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.invitation-content.is-locked {
    opacity: 0;
    transform: translateY(1rem);
    pointer-events: none;
    visibility: hidden;
}

#openingScreen {
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

#openingScreen.is-dismissed {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* ===== ENVELOPE OPENING SEQUENCE ===== */

@keyframes envelopeBreathe {
    0%, 100% { transform: translateY(0px) scale(1); }
    50%       { transform: translateY(-5px) scale(1.012); }
}

/* Opening screen gets perspective so rotateX on flap works in 3D */
#openingScreen {
    perspective: 1400px;
    perspective-origin: 50% 40%;
}

/* Container: holds everything */
.envelope-container {
    position: relative;
    width: 340px;
    height: 230px;
    cursor: pointer;
    overflow: visible;
}
@media (min-width: 768px) {
    .envelope-container { width: 420px; height: 285px; }
}
.envelope-container.is-open {
    /* Container stays visible, child elements handle their own fading */
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

/* Wrapper: idle breathe while still closed; perspective here ensures rotateX on flap is 3D */
.env-wrapper {
    position: absolute;
    inset: 0;
    transform-style: preserve-3d;
    perspective: 1200px;
    perspective-origin: 50% -20%;
}
.envelope-container:not(.is-open) .env-wrapper {
    animation: envelopeBreathe 4s ease-in-out infinite;
}

/* ── LAYER 1: Envelope back ── */
.env-back {
    position: absolute;
    inset: 0;
    background: linear-gradient(160deg, #fdfcf8 0%, #f4f2ea 100%);
    border-radius: 3px;
    z-index: 1;
    box-shadow:
        0 16px 50px rgba(0, 0, 0, 0.6),
        0  4px 14px rgba(0, 0, 0, 0.35),
        inset 0  2px 0 rgba(255, 255, 255, 0.85),
        inset 0 -2px 0 rgba(0, 0, 0, 0.06);
    transition: opacity 0.8s ease 0.6s;
}
.is-open .env-back {
    opacity: 0;
}

/* ── LAYER 2: Card clip container + invitation card ── */
.env-card-clip {
    position: absolute;
    inset: 0;
    z-index: 2;
    clip-path: inset(0 0 0 0);
}
.is-open .env-card-clip {
    /* Instantly release clip-path on all sides so it can scale and translate */
    clip-path: inset(-300% -300% -300% -300%);
    transition: clip-path 0s linear 0s;
}

.env-card {
    position: absolute;
    left: 8%;
    right: 8%;
    bottom: 5%;
    height: 84%;
    background: #080f1e;
    border: 1px solid rgba(212, 175, 55, 0.45);
    border-radius: 2px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 1rem;
    box-shadow: inset 0 0 25px rgba(212, 175, 55, 0.08);
}

@keyframes cardSequence {
    0%   { transform: translateY(0) scale(1); opacity: 1; }
    30%  { transform: translateY(-70%) scale(1); opacity: 1; } /* 0.6s: slides out */
    70%  { transform: translateY(-10%) scale(1.2); opacity: 1; } /* 1.4s: centers & zooms */
    100% { transform: translateY(-10%) scale(1.2); opacity: 0; } /* 2.0s: fades out */
}

.is-open .env-card {
    animation: cardSequence 2.0s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

/* ── LAYER 3: Front face panels — fully seal the envelope when closed ── */
/* Left/right panels use FULL side triangles (corner-to-corner) so the entire
   front face is covered. The flap (L4) seals the top triangle. Together the
   four panels tile the entire envelope face → card is 100% hidden. */
.env-pocket-left,
.env-pocket-right,
.env-pocket-bottom {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    transition: opacity 0.8s ease 0.6s;
}
.is-open .env-pocket-left,
.is-open .env-pocket-right,
.is-open .env-pocket-bottom {
    opacity: 0;
}

.env-pocket-left {
    background: linear-gradient(135deg, #f5f3eb 0%, #eae7dd 100%);
    clip-path: polygon(0 0, 50% 62%, 0 100%);
    box-shadow: 3px 0 8px rgba(0, 0, 0, 0.14);
}
.env-pocket-right {
    background: linear-gradient(225deg, #f5f3eb 0%, #eae7dd 100%);
    clip-path: polygon(100% 0, 50% 62%, 100% 100%);
    box-shadow: -3px 0 8px rgba(0, 0, 0, 0.14);
}
.env-pocket-bottom {
    background: linear-gradient(to bottom, #e5e2d8, #dedad0);
    clip-path: polygon(0 100%, 50% 62%, 100% 100%);
    box-shadow: 0 -3px 8px rgba(0, 0, 0, 0.1);
}

/* ── LAYER 4: Top flap ── */
.env-flap {
    position: absolute;
    inset: 0;
    background: linear-gradient(175deg, #fefdfa 0%, #f3f1e8 100%);
    clip-path: polygon(0 0, 100% 0, 50% 62%);
    z-index: 4;
    transform-origin: top center;
    transform: rotateX(0deg);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.28));
}
.env-flap::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 20%;
    right: 20%;
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(212, 175, 55, 0.7), transparent);
}
.is-open .env-flap {
    transform: rotateX(200deg);
    opacity: 0;
    transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1) 0s, opacity 0.8s ease 0.6s;
}

/* ── Wax seal (child of flap) ── */
.env-seal {
    position: absolute;
    /* sits at the flap's tip (62% from top of the full height = 38% from bottom) */
    bottom: 38%;
    left: 50%;
    transform: translate(-50%, 50%);
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: radial-gradient(circle at 32% 28%, #e8c84a 0%, #c9900a 52%, #7a4e04 100%);
    z-index: 5;
    box-shadow:
        0 4px 10px rgba(0, 0, 0, 0.5),
        inset 0  2px 6px rgba(255, 255, 255, 0.35),
        inset 0 -2px 6px rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    /* seal dissolves quickly when flap opens */
    transition: opacity 0.18s ease 0.12s, transform 0.30s ease 0.12s;
}
.env-seal::before {
    content: 'A\26S'; /* A&S in CSS unicode */
    font-family: 'Cinzel', serif;
    font-size: 12px;
    font-weight: 700;
    color: #ffe070;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65), 0 -1px 1px rgba(255, 255, 255, 0.2);
    letter-spacing: 0.5px;
}
.is-open .env-seal {
    opacity: 0;
    transform: translate(-50%, 50%) scale(1.45);
}

.message-card {
    background: rgba(15, 23, 42, 0.6);
    border-left: 2px solid #d4af37;
    padding: 0.75rem 1rem;
    border-radius: 0 0.5rem 0.5rem 0;
    margin-bottom: 0.5rem;
}

/* Loader for RSVP */
.loader {
    border: 3px solid rgba(212, 175, 55, 0.3);
    border-radius: 50%;
    border-top: 3px solid #d4af37;
    width: 20px;
    height: 20px;
    -webkit-animation: spin 1s linear infinite; /* Safari */
    animation: spin 1s linear infinite;
    display: none;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
