/**
 * 琳琅拆箱动画 V2.0
 * 参考优秀设计，实现精致的三阶段拆箱体验
 */

/* ========== 拆箱遮罩层 ========== */
.treasure-unbox-overlay {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(45, 35, 25, 0.55);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    z-index: 99999 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    animation: treasureFadeIn 0.4s;
    overflow: hidden !important;
}

@keyframes treasureFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ========== 关闭按钮 ========== */
.treasure-unbox-close {
    position: absolute;
    top: max(env(safe-area-inset-top), 50px);
    right: 20px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 18px;
    z-index: 99999;
    transition: all 0.2s;
}

.treasure-unbox-close:active {
    background: rgba(255, 255, 255, 0.22);
}

/* ========== 三阶段容器 ========== */
.treasure-unbox-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 20px;
    position: absolute;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}

.treasure-unbox-stage.active {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

/* ========== 阶段1：精致包裹设计 ========== */
.treasure-package-box {
    width: 170px;
    height: 170px;
    position: relative;
    cursor: pointer;
    margin-bottom: 28px;
    transition: transform 0.2s;
}

.treasure-package-box:active {
    transform: scale(0.98);
}

/* 盒子主体 */
.treasure-box-body {
    width: 100%;
    height: 72%;
    position: absolute;
    bottom: 0;
    left: 0;
    background: linear-gradient(145deg, #f0dcc8, #e2c8aa);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(100, 70, 40, 0.25),
                inset 0 -4px 10px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.treasure-box-body::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: rgba(180, 150, 110, 0.15);
}

/* 竖向胶带 */
.treasure-box-tape-v {
    width: 24px;
    height: 100%;
    background: linear-gradient(180deg, rgba(200, 168, 130, 0.35), rgba(200, 168, 130, 0.55));
    border-radius: 2px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
}

/* 盒子盖子 */
.treasure-box-lid {
    width: 110%;
    height: 28px;
    position: absolute;
    top: 24%;
    left: -5%;
    background: linear-gradient(145deg, #f5e2d0, #e8ceae);
    border-radius: 6px 6px 2px 2px;
    box-shadow: 0 4px 12px rgba(100, 70, 40, 0.12);
    z-index: 2;
    transform-origin: bottom center;
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 横向胶带 */
.treasure-box-tape-h {
    width: 55px;
    height: 16px;
    background: linear-gradient(90deg, rgba(200, 168, 130, 0.45), rgba(200, 168, 130, 0.65));
    border-radius: 2px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* 蝴蝶结装饰 */
.treasure-box-ribbon {
    position: absolute;
    top: 16%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    font-size: 34px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
    transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 盒子光晕 */
.treasure-box-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200px;
    height: 200px;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(244, 220, 180, 0.35) 0%, transparent 70%);
    border-radius: 50%;
    animation: treasureBoxGlow 2s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes treasureBoxGlow {
    0%, 100% { 
        transform: translate(-50%, -50%) scale(1); 
        opacity: 0.5; 
    }
    50% { 
        transform: translate(-50%, -50%) scale(1.15); 
        opacity: 1; 
    }
}

/* 包裹标签 */
.treasure-package-label {
    text-align: center;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 6px;
}

.treasure-package-product-name {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 5px;
    letter-spacing: 0.5px;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.treasure-package-product-sub {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
}

/* 拆开按钮 */
.treasure-unbox-action-btn {
    padding: 14px 48px;
    border: none;
    border-radius: 50px;
    background: linear-gradient(135deg, #c4a882, #a08060);
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 2px;
    box-shadow: 0 6px 24px rgba(160, 128, 96, 0.4);
    margin-top: 8px;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s;
}

.treasure-unbox-action-btn:active {
    transform: scale(0.96);
}

.treasure-unbox-action-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25), transparent);
    animation: treasureShimmerBtn 2.5s ease-in-out infinite;
}

@keyframes treasureShimmerBtn {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* ========== 开启动画 ========== */
.treasure-package-box.opening .treasure-box-lid {
    transform: rotateX(-120deg) translateY(-10px);
}

.treasure-package-box.opening .treasure-box-ribbon {
    transform: translateX(-50%) translateY(-60px) scale(0.4);
    opacity: 0;
}

/* ========== 阶段2：开启光效 ========== */
.treasure-opening-effects {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    height: 300px;
    pointer-events: none;
    z-index: 10;
}

/* 爆发光环 */
.treasure-burst-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 3px solid rgba(244, 220, 180, 0.7);
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
}

.treasure-burst-ring.animate {
    animation: treasureBurstExpand 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes treasureBurstExpand {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(30);
        opacity: 0;
    }
}

/* 闪烁粒子 */
.treasure-sparkle-particle {
    position: absolute;
    font-size: 14px;
    pointer-events: none;
    z-index: 15;
}

/* ========== 阶段3：商品展示 ========== */
.treasure-reveal-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

/* 收货成功徽章 */
.treasure-reveal-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.12);
    padding: 8px 20px;
    border-radius: 20px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 13px;
    font-weight: 500;
    backdrop-filter: blur(4px);
}

.treasure-reveal-badge .check-icon {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(122, 184, 106, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: white;
}

/* 商品图片容器 */
.treasure-reveal-image-wrap {
    width: 200px;
    height: 200px;
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.1);
    padding: 10px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.12);
    position: relative;
    overflow: hidden;
}

.treasure-reveal-image-wrap::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(transparent 0deg, rgba(255, 255, 255, 0.08) 60deg, transparent 120deg);
    animation: treasureRotateShine 4s linear infinite;
    z-index: 0;
}

@keyframes treasureRotateShine {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.treasure-reveal-image-inner {
    width: 100%;
    height: 100%;
    border-radius: 20px;
    overflow: hidden;
    position: relative;
    z-index: 1;
    background: white;
}

.treasure-reveal-image-inner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 商品名称 */
.treasure-reveal-product-name {
    font-size: 20px;
    font-weight: 700;
    color: white;
    text-align: center;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.treasure-reveal-product-desc {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
    text-align: center;
}

/* 完成按钮 */
.treasure-reveal-done-btn {
    padding: 12px 44px;
    border: none;
    border-radius: 50px;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    letter-spacing: 1px;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    margin-top: 4px;
    transition: all 0.2s;
}

.treasure-reveal-done-btn:active {
    transform: scale(0.96);
    background: rgba(255, 255, 255, 0.22);
}

/* ========== 漂浮装饰粒子 ========== */
.treasure-floating-decor {
    position: absolute;
    pointer-events: none;
    font-size: 20px;
    opacity: 0;
    animation: treasureFloatUp 3s ease-out forwards;
}

@keyframes treasureFloatUp {
    0% {
        opacity: 0;
        transform: translateY(40px) scale(0.5) rotate(0deg);
    }
    20% {
        opacity: 0.7;
    }
    100% {
        opacity: 0;
        transform: translateY(-200px) scale(1) rotate(30deg);
    }
}

/* V1 兼容旧版代码已清理 */
