/* ============================================
   阶段一 · 信封拆封
   写实高级纸品质感 + 酒红火漆
   ============================================ */

#envelope-stage {
    background: radial-gradient(
        circle at 50% 42%,
        rgba(52, 38, 28, 0.46) 0%,
        rgba(26, 20, 16, 0.9) 52%,
        rgba(15, 11, 9, 1) 100%
    );
}

.envelope-wrapper {
    perspective: 1800px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.envelope {
    position: relative;
    width: 320px;
    height: 228px;
    transform-style: preserve-3d;
    filter:
        drop-shadow(0 18px 24px rgba(0, 0, 0, 0.32))
        drop-shadow(0 34px 64px rgba(0, 0, 0, 0.26));
    transition: transform 0.5s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.envelope:hover {
    transform: translateY(-6px) scale(1.01) rotateX(1.5deg);
}

.envelope-body {
    position: absolute;
    inset: 0;
    border-radius: 0 0 10px 10px;
    border: 1px solid rgba(127, 97, 73, 0.14);
    background:
        linear-gradient(rgba(47, 73, 94, 0.1), rgba(35, 57, 76, 0.2)),
        url("../assets/images/envelope-paper.png") center / cover;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.36),
        inset 0 -12px 20px rgba(33, 43, 45, 0.18),
        inset 1px 0 0 rgba(255, 255, 255, 0.08),
        inset -1px 0 0 rgba(112, 87, 64, 0.04);
    overflow: hidden;
    z-index: 3;
}

.envelope-body::before,
.envelope-body::after {
    content: '';
    position: absolute;
    bottom: 0;
    width: 50.5%;
    height: 78%;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(29, 40, 42, 0.13)),
        url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='paperNoise2'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.64' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23paperNoise2)' opacity='0.038'/%3E%3C/svg%3E");
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.envelope-body::before {
    left: 0;
    clip-path: polygon(0 100%, 100% 100%, 100% 0);
}

.envelope-body::after {
    right: 0;
    clip-path: polygon(0 100%, 100% 100%, 0 0);
}

.envelope-flap {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 58%;
    background:
        linear-gradient(rgba(207, 228, 239, 0.18), rgba(44, 76, 97, 0.08)),
        url("../assets/images/envelope-paper.png") center / cover;
    clip-path: polygon(0 0, 100% 0, 55% 94%, 50% 100%, 45% 94%);
    transform-origin: top center;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.45),
        0 5px 12px rgba(26, 35, 37, 0.2);
    will-change: transform;
    z-index: 4;
}

.envelope-flap::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.42) 20%,
        rgba(255, 255, 255, 0.32) 80%,
        transparent
    );
}

.envelope-flap::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.13),
        transparent 42%,
        rgba(95, 68, 47, 0.06) 100%
    );
    mix-blend-mode: multiply;
    pointer-events: none;
}

.wax-seal {
    position: absolute;
    top: 58%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 42px;
    height: 42px;
    z-index: 5;
    border-radius: 44% 56% 47% 53% / 49% 42% 58% 51%;
    background-image:
        radial-gradient(circle at 32% 28%, #a85a63 0%, #7f3945 34%, #5c2632 68%, #34131d 100%),
        radial-gradient(circle at 70% 75%, rgba(255, 255, 255, 0.06), transparent 40%),
        url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='waxNoise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.78' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23waxNoise)' opacity='0.045'/%3E%3C/svg%3E");
    box-shadow:
        0 6px 12px rgba(35, 9, 14, 0.34),
        0 1px 0 rgba(255, 255, 255, 0.08),
        inset 0 2px 4px rgba(255, 220, 220, 0.14),
        inset 0 -5px 8px rgba(59, 3, 13, 0.4);
    transition: transform 0.28s ease, box-shadow 0.28s ease;
}

.wax-seal:hover {
    transform: translate(-50%, -50%) scale(1.04);
    box-shadow:
        0 8px 16px rgba(35, 9, 14, 0.42),
        0 1px 0 rgba(255, 255, 255, 0.1),
        inset 0 2px 4px rgba(255, 220, 220, 0.16),
        inset 0 -5px 8px rgba(59, 3, 13, 0.45);
}

.wax-seal::before {
    content: '';
    position: absolute;
    inset: 4px;
    border-radius: 47% 53% 51% 49% / 51% 45% 55% 49%;
    border: 1px solid rgba(91, 12, 23, 0.42);
    background:
        radial-gradient(circle at 40% 35%, rgba(255, 255, 255, 0.07) 0%, transparent 45%),
        radial-gradient(circle at 50% 55%, rgba(62, 6, 15, 0.28) 0%, transparent 85%);
    box-shadow:
        inset 0 1px 3px rgba(255, 255, 255, 0.08),
        inset 0 -3px 5px rgba(0, 0, 0, 0.22);
}

.seal-inner {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 15px;
    color: #f3d6d8;
    text-shadow:
        0 1px 0 rgba(78, 9, 21, 0.62),
        0 0 6px rgba(255, 233, 235, 0.12);
    opacity: 0.88;
    z-index: 2;
}

.letter-card {
    position: absolute;
    left: 5%;
    bottom: 4%;
    width: 90%;
    height: 88%;
    border-radius: 5px;
    border: 1px solid rgba(152, 118, 88, 0.12);
    padding: 25px;
    background-image:
        linear-gradient(150deg, #f9f4ec 0%, #efe2d0 62%, #e5d5c1 100%),
        url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='paperNoise4'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.74' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23paperNoise4)' opacity='0.035'/%3E%3C/svg%3E");
    box-shadow:
        0 10px 18px rgba(45, 27, 11, 0.16),
        inset 0 1px 0 rgba(255, 255, 255, 0.76);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.letter-preview {
    text-align: center;
}

.letter-to {
    font-size: 1.1rem;
    letter-spacing: 4px;
    color: #354044;
    margin-bottom: 8px;
    font-family: 'Georgia', serif;
}

.letter-line {
    font-size: 0.85rem;
    color: #566568;
    letter-spacing: 1.5px;
}

.hint-text {
    margin-top: 30px;
    font-size: 0.72rem;
    letter-spacing: 2px;
    color: rgba(224, 232, 230, 0.76);
    animation: hint-pulse 3s ease-in-out infinite;
}

.tear-strip {
    --tear-progress: 0;
    --tear-width: 0%;
    --tear-lift: 0px;
    position: absolute;
    left: 4%;
    right: 4%;
    top: 22%;
    z-index: 7;
    height: 34px;
    cursor: ew-resize;
    touch-action: none;
}

.tear-strip:focus-visible { outline: 2px solid #d8b37a; outline-offset: 6px; }

.tear-start-hint {
    position: absolute;
    top: -10px;
    left: -54px;
    color: rgba(248, 224, 188, 0.92);
    font-size: 0.68rem;
    letter-spacing: 0.5px;
    line-height: 1;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    text-shadow: 0 1px 2px rgba(24, 14, 10, 0.64);
    pointer-events: none;
    animation: tear-start-hint 2.8s ease-in-out infinite;
}

.tear-start-hint::after {
    content: '';
    position: absolute;
    top: 50%;
    left: calc(100% + 7px);
    width: 34px;
    height: 1px;
    background: linear-gradient(90deg, rgba(248, 224, 188, 0.78), rgba(248, 224, 188, 0.28));
}

.tear-start-hint::before {
    content: '';
    position: absolute;
    top: calc(50% - 3px);
    left: calc(100% + 37px);
    width: 6px;
    height: 6px;
    border-top: 1px solid rgba(248, 224, 188, 0.78);
    border-right: 1px solid rgba(248, 224, 188, 0.78);
    transform: rotate(45deg);
}

.tear-strip.is-tearing .tear-start-hint {
    opacity: 0.2;
    animation: none;
}

.tear-piece,
.tear-rip {
    position: absolute;
    pointer-events: none;
}

.tear-piece {
    display: none;
}

.tear-piece-left {
    clip-path: polygon(0 0, 100% 0, 98% 28%, 100% 48%, 97% 68%, 100% 100%, 0 100%);
    transform: translateY(var(--tear-lift));
    transform-origin: left bottom;
    filter: drop-shadow(0 4px 3px rgba(9, 18, 21, 0.48));
}

.tear-piece-right {
    display: none;
}

.tear-rip {
    top: 6px;
    left: 0;
    width: var(--tear-width);
    height: 12px;
    background: linear-gradient(
        180deg,
        rgba(8, 12, 13, 0.78) 0%,
        rgba(1, 4, 5, 0.98) 32%,
        rgba(9, 14, 15, 0.88) 72%,
        rgba(29, 35, 36, 0.58) 100%
    );
    clip-path: polygon(0 38%, 4% 62%, 8% 24%, 13% 70%, 18% 33%, 23% 59%, 29% 18%, 35% 67%, 40% 31%, 46% 72%, 52% 21%, 58% 63%, 64% 34%, 70% 74%, 76% 25%, 82% 61%, 88% 29%, 94% 69%, 100% 42%, 100% 86%, 95% 100%, 90% 78%, 84% 100%, 78% 76%, 72% 100%, 66% 79%, 60% 100%, 54% 77%, 48% 100%, 42% 79%, 36% 100%, 30% 76%, 24% 100%, 18% 78%, 12% 100%, 6% 76%, 0 92%);
    filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.72));
}


@media (max-width: 480px) {
    .envelope {
        width: min(76vw, 290px);
        height: auto;
        aspect-ratio: 320 / 228;
    }

    .hint-text {
        margin-top: 28px;
        font-size: 0.72rem;
        letter-spacing: 2px;
    }
}

@keyframes hint-pulse {
    0%, 100% {
        opacity: 0.24;
        transform: translateY(0);
        filter: blur(0.3px);
    }
    50% {
        opacity: 0.66;
        transform: translateY(-3px);
        filter: blur(0);
    }
}

@keyframes tear-start-hint {
    0%, 100% {
        opacity: 0.56;
        transform: translateY(0);
    }
    50% {
        opacity: 1;
        transform: translateY(-2px);
    }
}
