/* ═══════════════════════════════════════════════════════════
   Rarity Pull Animation
   Full-screen reveal card that flips to show wish rarity.
═══════════════════════════════════════════════════════════ */

/* ── Overlay ─────────────────────────────────────────────── */
.rarity-pull-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    opacity: 0;
    transition: opacity 400ms ease;
    padding: 1rem;
}
.rarity-pull-overlay.is-visible {
    opacity: 1;
}

/* ── Scene — holds the 3D perspective ───────────────────── */
.rarity-pull__scene {
    perspective: 1000px;
    width: 300px;
    height: 420px;
    flex-shrink: 0;
}

/* ── Card — the flipping element ────────────────────────── */
.rarity-pull__card {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 900ms cubic-bezier(0.4, 0, 0.2, 1);
    cursor: default;
}
.rarity-pull__card.is-flipped {
    transform: rotateY(180deg);
}

/* ── Card sides ─────────────────────────────────────────── */
.rarity-pull__front,
.rarity-pull__back {
    position: absolute;
    inset: 0;
    border-radius: 20px;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
    text-align: center;
    border: 2px solid rgba(255, 255, 255, 0.12);
}

/* Back face (mystery) */
.rarity-pull__back {
    background: linear-gradient(160deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    border-color: rgba(124, 58, 237, 0.4);
}

/* Front face (revealed) */
.rarity-pull__front {
    transform: rotateY(180deg);
    background: linear-gradient(160deg, var(--rp-bg-from), var(--rp-bg-to));
    border-color: var(--rp-color);
    box-shadow: 0 0 60px var(--rp-glow), 0 0 120px var(--rp-glow-outer), inset 0 1px 0 rgba(255,255,255,0.1);
}

/* ── Mystery back content ────────────────────────────────── */
.rarity-pull__mystery-icon {
    font-size: 5rem;
    line-height: 1;
    margin-bottom: 1.5rem;
    filter: drop-shadow(0 0 20px rgba(124, 58, 237, 0.8));
    animation: rp-float 2s ease-in-out infinite;
}
.rarity-pull__mystery-text {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: rgba(124, 58, 237, 0.8);
    font-family: var(--w-font-sans);
}
.rarity-pull__mystery-stars {
    margin-top: 1.5rem;
    font-size: 0.65rem;
    letter-spacing: 8px;
    color: rgba(124, 58, 237, 0.5);
    animation: rp-pulse 2s ease-in-out infinite;
}

/* ── Rarity front content ────────────────────────────────── */
.rarity-pull__badge {
    display: inline-block;
    padding: 6px 18px;
    border-radius: 100px;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 3px;
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid var(--rp-color);
    color: var(--rp-color);
    margin-bottom: 1.25rem;
    font-family: var(--w-font-sans);
}
.rarity-pull__rarity-icon {
    font-size: 5rem;
    line-height: 1;
    margin-bottom: 1rem;
    filter: drop-shadow(0 0 24px var(--rp-glow));
    animation: rp-icon-pop 600ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    opacity: 0;
    transform: scale(0.5);
}
.rarity-pull__rarity-name {
    font-size: 2rem;
    font-weight: 900;
    letter-spacing: -0.02em;
    color: var(--rp-color);
    text-shadow: 0 0 30px var(--rp-glow);
    margin-bottom: 0.5rem;
    font-family: var(--w-font-sans);
    animation: rp-text-pop 600ms 200ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    opacity: 0;
    transform: translateY(10px);
}
.rarity-pull__product-name {
    font-size: 0.8rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.4;
    margin-bottom: 0;
    font-family: var(--w-font-sans);
    animation: rp-text-pop 600ms 350ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    opacity: 0;
    transform: translateY(10px);
}

/* ── Particles ───────────────────────────────────────────── */
.rarity-pull__particles {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    border-radius: 20px;
}
.rarity-pull__particle {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--rp-color);
    opacity: 0;
}

/* ── Claim button ────────────────────────────────────────── */
.rarity-pull__claim {
    margin-top: 2.5rem;
    padding: 14px 40px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 700;
    color: #ffffff;
    background: linear-gradient(135deg, var(--rp-bg-from), var(--rp-bg-to));
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px var(--rp-glow);
    font-family: var(--w-font-sans);
    transition: transform 150ms ease, box-shadow 150ms ease;
    opacity: 0;
    transform: translateY(20px);
    animation: rp-text-pop 500ms 700ms ease forwards;
}
.rarity-pull__claim:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 8px 30px var(--rp-glow);
}
.rarity-pull__claim:active {
    transform: translateY(0) scale(0.98);
}

/* ── Wrapper (scene + button stacked) ───────────────────── */
.rarity-pull__wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ── Pulsing ring on back card ───────────────────────────── */
.rarity-pull__ring {
    position: absolute;
    inset: -12px;
    border-radius: 28px;
    border: 2px solid rgba(124, 58, 237, 0.3);
    animation: rp-ring-pulse 2s ease-in-out infinite;
    pointer-events: none;
}

/* ── Rarity theme variables ──────────────────────────────── */
.rarity-pull--common {
    --rp-color: #a1a1aa;
    --rp-glow: rgba(161, 161, 170, 0.4);
    --rp-glow-outer: rgba(161, 161, 170, 0.15);
    --rp-bg-from: #18181b;
    --rp-bg-to: #27272a;
}
.rarity-pull--uncommon {
    --rp-color: #4ade80;
    --rp-glow: rgba(74, 222, 128, 0.5);
    --rp-glow-outer: rgba(74, 222, 128, 0.2);
    --rp-bg-from: #052e16;
    --rp-bg-to: #064e3b;
}
.rarity-pull--rare {
    --rp-color: #60a5fa;
    --rp-glow: rgba(96, 165, 250, 0.55);
    --rp-glow-outer: rgba(96, 165, 250, 0.2);
    --rp-bg-from: #0c1a3d;
    --rp-bg-to: #1e3a8a;
}
.rarity-pull--epic {
    --rp-color: #c084fc;
    --rp-glow: rgba(192, 132, 252, 0.6);
    --rp-glow-outer: rgba(192, 132, 252, 0.25);
    --rp-bg-from: #2e1065;
    --rp-bg-to: #4c1d95;
}
.rarity-pull--legendary {
    --rp-color: #fbbf24;
    --rp-glow: rgba(251, 191, 36, 0.65);
    --rp-glow-outer: rgba(251, 191, 36, 0.3);
    --rp-bg-from: #451a03;
    --rp-bg-to: #78350f;
}

/* ── Legendary extra ray effect ──────────────────────────── */
.rarity-pull--legendary .rarity-pull__front::before {
    content: '';
    position: absolute;
    inset: -50%;
    background: conic-gradient(
        from 0deg,
        transparent 0deg,
        rgba(251, 191, 36, 0.08) 10deg,
        transparent 20deg,
        transparent 40deg,
        rgba(251, 191, 36, 0.06) 50deg,
        transparent 60deg
    );
    animation: rp-rays-spin 8s linear infinite;
    border-radius: 50%;
    pointer-events: none;
}

/* ── Keyframes ───────────────────────────────────────────── */
@keyframes rp-float {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-10px); }
}
@keyframes rp-pulse {
    0%, 100% { opacity: 0.5; }
    50%       { opacity: 1; }
}
@keyframes rp-ring-pulse {
    0%, 100% { transform: scale(1);   opacity: 0.4; }
    50%       { transform: scale(1.05); opacity: 0.8; }
}
@keyframes rp-icon-pop {
    to { opacity: 1; transform: scale(1); }
}
@keyframes rp-text-pop {
    to { opacity: 1; transform: translateY(0); }
}
@keyframes rp-particle-burst {
    0%   { opacity: 1; transform: translate(0, 0) scale(1); }
    100% { opacity: 0; transform: translate(var(--rp-tx), var(--rp-ty)) scale(0); }
}
@keyframes rp-rays-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 480px) {
    .rarity-pull__scene {
        width: 260px;
        height: 370px;
    }
    .rarity-pull__mystery-icon,
    .rarity-pull__rarity-icon {
        font-size: 4rem;
    }
    .rarity-pull__rarity-name {
        font-size: 1.6rem;
    }
    .rarity-pull__claim {
        padding: 12px 32px;
        font-size: 0.875rem;
    }
}
