/* ========== GIFT BOX OPENING OVERLAY ========== */

/* --- Overlay Container --- */
.gift-overlay {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    inset: 0;
    z-index: 10001;
    background: var(--color-bg, #FFFFFF);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: opacity 0.6s ease;
}

.gift-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

.gift-overlay.hidden {
    display: none;
}

/* --- Particle Canvas --- */
.gift-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

/* --- Dual Gift Choice Layout --- */
.gift-choice {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 60px;
}

.gift-box-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s ease;
}

.gift-box-wrapper:hover {
    transform: scale(1.06) translateY(-4px);
}

.gift-box-wrapper.selected {
    transform: scale(1.15);
    z-index: 5;
}

.gift-box-wrapper.dismissed {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

.gift-label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--color-text-mid, #475569);
    letter-spacing: 0.06em;
    font-family: var(--font, 'Inter', 'Noto Sans SC', sans-serif);
    text-align: center;
    transition: color 0.3s ease;
}

.gift-box-wrapper:hover .gift-label {
    color: var(--color-text, #0F172A);
}

/* --- Gift Box Container --- */
.gift-box {
    position: relative;
    z-index: 1;
    width: 160px;
    height: 180px;
    transform-style: preserve-3d;
    perspective: 800px;
    animation: giftFloat 3s ease-in-out infinite;
}

/* Sparkle dots */
.gift-box::before {
    content: '';
    position: absolute;
    top: -20px;
    right: -15px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    animation: sparkle 3s ease-in-out infinite;
    z-index: 5;
    pointer-events: none;
}

@keyframes sparkle {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
}

/* --- Gift Lid --- */
.gift-lid {
    position: absolute;
    top: 0;
    left: -10px;
    right: -10px;
    height: 45px;
    transform-origin: top center;
    z-index: 3;
}

.gift-lid-top {
    width: 100%;
    height: 100%;
    border-radius: 8px 8px 4px 4px;
    position: relative;
    overflow: hidden;
}

.gift-lid-ribbon-v {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 100%;
    z-index: 1;
}

.gift-lid-ribbon-h {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    width: 100%;
    height: 24px;
    z-index: 1;
}

/* --- Gift Body --- */
.gift-body {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 140px;
    z-index: 1;
}

.gift-body-front {
    width: 100%;
    height: 100%;
    border-radius: 4px 4px 12px 12px;
    position: relative;
    overflow: hidden;
}

/* Shimmer effect */
.gift-body-front::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent 40%, rgba(255,255,255,0.03) 45%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 55%, transparent 60%);
    animation: giftShimmer 4s ease-in-out infinite;
    z-index: 2;
    pointer-events: none;
}

@keyframes giftShimmer {
    0% { transform: translateX(-100%) translateY(-100%); }
    100% { transform: translateX(100%) translateY(100%); }
}

.gift-ribbon-v {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 100%;
    z-index: 1;
}

.gift-ribbon-h {
    position: absolute;
    top: 45%;
    left: 0;
    transform: translateY(-50%);
    width: 100%;
    height: 24px;
    z-index: 1;
}

/* --- Bow --- */
.gift-bow {
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 4;
    width: 56px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gift-bow::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    opacity: 0.7;
}

.gift-bow-loop {
    position: absolute;
    width: 28px;
    height: 20px;
    border-radius: 50%;
}

.gift-bow-loop.left {
    right: 50%;
    transform: rotate(-25deg);
    border-right-color: transparent;
}

.gift-bow-loop.right {
    left: 50%;
    transform: rotate(25deg);
    border-left-color: transparent;
}

.gift-bow-knot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    position: relative;
    z-index: 2;
}

/* --- Glow Effect --- */
.gift-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 0;
    height: 0;
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    opacity: 0;
}

/* ===== PURPLE VARIANT ===== */
.gift-box--purple .gift-lid-top {
    background: linear-gradient(180deg, #4a3590 0%, #3d2d7a 40%, #2a1f5e 100%);
    border: 1.5px solid rgba(99, 102, 241, 0.45);
    box-shadow: 0 -4px 24px rgba(99, 102, 241, 0.22), inset 0 1px 0 rgba(255,255,255,0.1), inset 0 -1px 0 rgba(0,0,0,0.2);
}
.gift-box--purple .gift-lid-ribbon-v { background: linear-gradient(180deg, #8b5cf6, #7c3aed, #6366f1); }
.gift-box--purple .gift-lid-ribbon-h { background: linear-gradient(90deg, #8b5cf6, #7c3aed, #6366f1); }
.gift-box--purple .gift-body-front {
    background: linear-gradient(180deg, #2a1f5e 0%, #1e1545 60%, #1a1240 100%);
    border: 1.5px solid rgba(99, 102, 241, 0.35);
    box-shadow: 0 12px 40px rgba(0,0,0,0.6), 0 0 60px rgba(99,102,241,0.12), 0 0 40px rgba(99,102,241,0.08), inset 0 1px 0 rgba(255,255,255,0.08), inset 0 -4px 12px rgba(0,0,0,0.3);
}
.gift-box--purple .gift-ribbon-v { background: linear-gradient(180deg, #8b5cf6, #7c3aed, #6366f1); }
.gift-box--purple .gift-ribbon-h { background: linear-gradient(90deg, #8b5cf6, #7c3aed, #6366f1); }
.gift-box--purple .gift-bow-loop { border: 2.5px solid #a78bfa; background: linear-gradient(135deg, rgba(167,139,250,0.25), rgba(139,92,246,0.15)); box-shadow: 0 2px 6px rgba(124,58,237,0.2); }
.gift-box--purple .gift-bow-loop.left { border-right-color: transparent; }
.gift-box--purple .gift-bow-loop.right { border-left-color: transparent; }
.gift-box--purple .gift-bow-knot { background: radial-gradient(circle at 35% 35%, #c4b5fd, #a78bfa 40%, #7c3aed 100%); box-shadow: 0 2px 8px rgba(124,58,237,0.5), inset 0 1px 2px rgba(255,255,255,0.3); }
.gift-box--purple .gift-bow::after { border-top-color: #7c3aed; }
.gift-box--purple .gift-glow { background: radial-gradient(circle, rgba(99,102,241,0.5), rgba(139,92,246,0.2) 40%, transparent 70%); }
.gift-box--purple::before {
    background: #a78bfa;
    box-shadow: -140px 30px 0 1px rgba(167,139,250,0.6), -40px -15px 0 0.5px rgba(196,181,253,0.5), 50px 120px 0 1px rgba(167,139,250,0.4), -80px 150px 0 0.5px rgba(196,181,253,0.6), 30px -10px 0 1px rgba(99,102,241,0.5);
}

/* ===== RED VARIANT ===== */
.gift-box--red .gift-lid-top {
    background: linear-gradient(180deg, #9a3333 0%, #7a2d2d 40%, #5e1a1a 100%);
    border: 1.5px solid rgba(239, 68, 68, 0.45);
    box-shadow: 0 -4px 24px rgba(239, 68, 68, 0.22), inset 0 1px 0 rgba(255,255,255,0.1), inset 0 -1px 0 rgba(0,0,0,0.2);
}
.gift-box--red .gift-lid-ribbon-v { background: linear-gradient(180deg, #ef4444, #dc2626, #b91c1c); }
.gift-box--red .gift-lid-ribbon-h { background: linear-gradient(90deg, #ef4444, #dc2626, #b91c1c); }
.gift-box--red .gift-body-front {
    background: linear-gradient(180deg, #5e1a1a 0%, #451515 60%, #3a1010 100%);
    border: 1.5px solid rgba(239, 68, 68, 0.35);
    box-shadow: 0 12px 40px rgba(0,0,0,0.6), 0 0 60px rgba(239,68,68,0.12), 0 0 40px rgba(239,68,68,0.08), inset 0 1px 0 rgba(255,255,255,0.08), inset 0 -4px 12px rgba(0,0,0,0.3);
}
.gift-box--red .gift-ribbon-v { background: linear-gradient(180deg, #ef4444, #dc2626, #b91c1c); }
.gift-box--red .gift-ribbon-h { background: linear-gradient(90deg, #ef4444, #dc2626, #b91c1c); }
.gift-box--red .gift-bow-loop { border: 2.5px solid #fca5a5; background: linear-gradient(135deg, rgba(252,165,165,0.25), rgba(239,68,68,0.15)); box-shadow: 0 2px 6px rgba(220,38,38,0.2); }
.gift-box--red .gift-bow-loop.left { border-right-color: transparent; }
.gift-box--red .gift-bow-loop.right { border-left-color: transparent; }
.gift-box--red .gift-bow-knot { background: radial-gradient(circle at 35% 35%, #fecaca, #fca5a5 40%, #dc2626 100%); box-shadow: 0 2px 8px rgba(220,38,38,0.5), inset 0 1px 2px rgba(255,255,255,0.3); }
.gift-box--red .gift-bow::after { border-top-color: #dc2626; }
.gift-box--red .gift-glow { background: radial-gradient(circle, rgba(239,68,68,0.5), rgba(220,38,38,0.2) 40%, transparent 70%); }
.gift-box--red::before {
    background: #fca5a5;
    box-shadow: -140px 30px 0 1px rgba(252,165,165,0.6), -40px -15px 0 0.5px rgba(254,202,202,0.5), 50px 120px 0 1px rgba(252,165,165,0.4), -80px 150px 0 0.5px rgba(254,202,202,0.6), 30px -10px 0 1px rgba(239,68,68,0.5);
}

/* --- Float animation --- */
@keyframes giftFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* --- Open state animations --- */
.gift-box.open { animation: none; }
.gift-box.open .gift-lid { animation: lidOpen 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }
.gift-box.open .gift-body { animation: bodyShrink 0.5s 0.15s ease forwards; }
.gift-box.open .gift-bow { animation: bowFly 0.4s ease-out forwards; }
.gift-box.open .gift-glow { animation: glowBurst 0.7s ease-out forwards; }

@keyframes lidOpen {
    0%   { transform: rotateX(0deg) translateY(0); opacity: 1; }
    40%  { transform: rotateX(-80deg) translateY(-10px); opacity: 1; }
    100% { transform: rotateX(-140deg) translateY(-30px); opacity: 0; }
}

@keyframes bodyShrink {
    0%   { transform: scale(1); opacity: 1; }
    60%  { transform: scale(1.05); opacity: 0.8; }
    100% { transform: scale(0.2); opacity: 0; }
}

@keyframes bowFly {
    0%   { transform: translateX(-50%) translateY(0) scale(1); opacity: 1; }
    100% { transform: translateX(-50%) translateY(-60px) scale(0.3); opacity: 0; }
}

@keyframes glowBurst {
    0%   { width: 0; height: 0; opacity: 0; }
    20%  { opacity: 1; }
    100% { width: 700px; height: 700px; opacity: 0; }
}

/* --- Hint Text --- */
.gift-hint {
    position: absolute;
    bottom: 14%;
    left: 50%;
    transform: translateX(-50%);
    color: var(--color-text-mid, #475569);
    font-size: 0.92rem;
    font-weight: 400;
    font-family: var(--font, 'Inter', 'Noto Sans SC', sans-serif);
    letter-spacing: 0.04em;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 3;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.gift-hint.visible {
    opacity: 1;
    animation: hintBounce 2.5s ease-in-out infinite;
}

@keyframes hintBounce {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50%      { transform: translateX(-50%) translateY(-6px); }
}

/* --- Skip Button --- */
.gift-skip {
    position: absolute;
    top: 28px;
    right: 28px;
    z-index: 3;
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: var(--color-text-dim, #94A3B8);
    font-size: 0.82rem;
    font-family: var(--font, 'Inter', 'Noto Sans SC', sans-serif);
    padding: 8px 22px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.gift-skip:hover {
    background: rgba(0, 0, 0, 0.08);
    color: var(--color-text-mid, #475569);
    border-color: rgba(0, 0, 0, 0.15);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .gift-choice {
        flex-direction: column;
        gap: 30px;
    }

    .gift-box {
        width: 130px;
        height: 150px;
    }

    .gift-lid {
        height: 38px;
        left: -8px;
        right: -8px;
    }

    .gift-body { height: 115px; }

    .gift-lid-ribbon-v, .gift-ribbon-v { width: 20px; }
    .gift-lid-ribbon-h, .gift-ribbon-h { height: 20px; }

    .gift-bow {
        top: -14px;
        width: 44px;
        height: 22px;
    }

    .gift-bow-loop { width: 22px; height: 16px; }
    .gift-bow-knot { width: 12px; height: 12px; }

    .gift-label { font-size: 0.78rem; }

    .gift-hint {
        font-size: 0.82rem;
        bottom: 8%;
    }

    .gift-skip {
        top: 18px;
        right: 18px;
        font-size: 0.78rem;
        padding: 6px 16px;
    }
}

@media (max-width: 480px) {
    .gift-choice { gap: 24px; }

    .gift-box {
        width: 110px;
        height: 130px;
    }

    .gift-lid {
        height: 32px;
        left: -6px;
        right: -6px;
    }

    .gift-body { height: 100px; }
    .gift-lid-ribbon-v, .gift-ribbon-v { width: 18px; }
    .gift-lid-ribbon-h, .gift-ribbon-h { height: 18px; }

    .gift-bow { top: -12px; width: 40px; height: 20px; }
    .gift-bow-loop { width: 20px; height: 14px; }
    .gift-bow-knot { width: 10px; height: 10px; }

    .gift-label { font-size: 0.72rem; }

    .gift-hint {
        font-size: 0.76rem;
        bottom: 6%;
    }
}

/* --- Reduced motion: keep overlay visible but disable animations --- */
@media (prefers-reduced-motion: reduce) {
    .gift-box { animation: none; }
    .gift-hint.visible { animation: none; }
}
