/* ════════════════════════════════════════
       SECTION 1 — ENVELOPE
    ════════════════════════════════════════ */
#s1 {
    background: linear-gradient(
        180deg,
        #0c0400 0%,
        #2e0e00 20%,
        #7a2a00 44%,
        #c84010 62%,
        #ef7020 80%,
        #ffaa30 100%
    );
}

.savanna-layer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 46%;
    z-index: 1;
    pointer-events: none;
}

.env-scene {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(12px, 2.8vw, 24px);
}

.env-super {
    font-family: "Fredoka One", cursive;
    font-size: clamp(11px, 1.8vw, 16px);
    letter-spacing: 3px;
    color: #ffe060;
    text-transform: uppercase;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 40px;
    padding: 7px 22px;
    border: 3px solid rgba(255, 220, 80, 0.45);
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
    animation: popIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.45) rotate(-8deg);
    }

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

.env-title {
    font-family: "Fredoka One", cursive;
    font-size: clamp(22px, 4.8vw, 48px);
    color: #ffe060;
    text-align: center;
    line-height: 1.1;
    -webkit-text-stroke: 2px rgba(140, 60, 0, 0.4);
    animation: popIn 0.6s 0.14s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* Your original class */
.envelope-wrap {
    perspective: 1000px;
    cursor: pointer;
    animation:
        popIn 0.6s 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) both,
        wobble 1.5s 1.2s ease-in-out infinite;
    transition: transform 0.2s;
}

.envelope-wrap.is-open {
    animation: none;
    /* Deletes the entire animation sequence */
}

@keyframes wobble {
    0%,
    100% {
        transform: rotate(0deg);
    }

    18% {
        transform: rotate(-3.5deg);
    }

    36% {
        transform: rotate(3deg);
    }

    54% {
        transform: rotate(-2deg);
    }

    72% {
        transform: rotate(1.5deg);
    }
}

.envelope {
    position: relative;
    width: clamp(260px, 54vw, 560px);
    height: clamp(170px, 29vw, 322px);
    transform-style: preserve-3d;
}

.env-body {
    position: absolute;
    inset: 0;
    background: linear-gradient(145deg, #d04010, #e86030, #c83808);
    border-radius: 20px;
    border: 4px solid #7a1e00;
    box-shadow:
        0 8px 0 #4e1200,
        0 14px 32px rgba(0, 0, 0, 0.5),
        inset 0 2px 0 rgba(255, 180, 80, 0.18);
    overflow: hidden;
}

.env-body::after {
    content: "";
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        -45deg,
        transparent,
        transparent 20px,
        rgba(255, 160, 40, 0.05) 20px,
        rgba(255, 160, 40, 0.05) 22px
    );
}

.env-folds {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.env-flap {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 55%;
    transform-origin: top center;
    transform: rotateX(0deg);
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 6;
    clip-path: polygon(0 0, 100% 0, 50% 88%);
    background: linear-gradient(155deg, #b42c06, #d0480e, #b02806);
    border-top: 4px solid #7a1e00;
    border-radius: 20px;
}

.envelope.is-open .env-flap {
    transform: rotateX(-180deg);
}

.env-seal {
    position: absolute;
    top: 46%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: clamp(46px, 9vw, 68px);
    height: clamp(46px, 9vw, 68px);
    border-radius: 50%;
    background: radial-gradient(circle at 38% 34%, #ffe878, #c89000, #6a3800);
    border: 3px solid #7a1e00;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(18px, 3.2vw, 28px);
    color: #3a1400;
    box-shadow:
        0 4px 0 #4e1200,
        0 6px 16px rgba(0, 0, 0, 0.4);
    z-index: 7;
    transition:
        opacity 0.2s 0.1s,
        transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.envelope.is-open .env-seal {
    opacity: 0;
    transform: translate(-50%, -72%) scale(0.35) rotate(200deg);
    pointer-events: none;
}

.env-letter {
    position: absolute;
    /* width: 30vw; */
    bottom: 3px;
    transform: translateY(120px);
    left: 8px;
    right: 8px;
    background: #fffbef;
    border-radius: 14px;
    border: 3px solid rgba(180, 100, 0, 0.18);

    /* 1. Initial State */
    opacity: 0;
    z-index: -1;
    /* Avoid -999 unless necessary; -1 is usually enough */

    /* 2. Combined Transition */
    /* We list both opacity and transform here */
    transition:
        opacity 0.2s ease-in-out,
        transform 0.55s 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);

    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
}

.envelope.is-open .env-letter.is-open {
    /* 3. Final State */
    opacity: 1;
    z-index: 999;

    transition:
        opacity 0.2s ease-in-out,
        transform 2.55s 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* transform: translateY(0%); */

/* ══ PLACEABLE DIV — replace .letter-inner contents with anything ══ */
.letter-inner {
    text-align: center;
    /* padding: clamp(12px, 3vw, 28px); */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.letter-inner h2 {
    font-family: "Fredoka One", cursive;
    font-size: clamp(12px, 2.2vw, 22px);
    color: #7a2e00;
}

.letter-inner p {
    font-family: "Nunito", sans-serif;
    font-weight: 700;
    font-size: clamp(10px, 1.8vw, 14px);
    line-height: 1.65;
    color: #4a2000;
}

.letter-deco {
    color: #c08000;
    font-size: clamp(16px, 2.8vw, 26px);
    letter-spacing: 8px;
}

.env-hint {
    font-family: "Fredoka One", cursive;
    font-size: clamp(12px, 1.9vw, 16px);
    letter-spacing: 1px;
    color: #ffe060;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 40px;
    padding: 7px 20px;
    border: 3px solid rgba(255, 220, 80, 0.38);
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
    animation:
        pulse 2s ease-in-out infinite,
        popIn 0.6s 0.42s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.env-hint.is-open {
    display: none;
}

@keyframes pulse {
    0%,
    100% {
        opacity: 0.75;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.05);
    }
}
