/* ============================================
   3D PROFILE CARD - Sunwell Midnight Theme
   ============================================
   Interactive 3D card with layered depth effect
   Integrates with game-economy.css Sunwell colors
   ============================================ */

/* ===== 3D CARD CONTAINER ===== */
.profile-card-3d-container {
    perspective: 1500px;
    perspective-origin: center center;
    width: 100%;
    max-width: 450px;
    margin: 0 auto 32px;
    padding: 0;
}

.profile-card-3d {
    position: relative;
    width: 100%;
    height: 500px;
    transform-style: preserve-3d;
    transition: transform 0.1s ease-out;
    cursor: pointer;
    border-radius: 24px;
    overflow: visible;
}

/* ===== LAYERED DEPTH SYSTEM ===== */

/* Layer 1: Deep Background (furthest back) */
.card-layer-background {
    position: absolute;
    inset: 0;
    border-radius: 24px;
    background: linear-gradient(135deg,
        var(--void-cosmic) 0%,
        var(--void-deep) 50%,
        var(--void-indigo) 100%
    );
    transform: translate3d(0, 0, -50px) scale(1.15);  /* GPU acceleration */
    filter: blur(8px);
    opacity: 0.9;
    box-shadow:
        0 30px 80px rgba(0, 0, 0, 0.8),
        0 15px 40px rgba(75, 0, 130, 0.6);
    will-change: transform;  /* Performance hint */
}

/* Layer 2: Void/Sunwell Pattern Overlay */
.card-layer-pattern {
    position: absolute;
    inset: 0;
    border-radius: 24px;
    background:
        radial-gradient(circle at 20% 30%, rgba(153, 50, 204, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(0, 206, 209, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(255, 215, 0, 0.08) 0%, transparent 70%);
    transform: translate3d(0, 0, -25px) scale(1.08);  /* GPU acceleration */
    opacity: 0.7;
    will-change: transform;
}

/* Layer 3: Border Glow */
.card-layer-border {
    position: absolute;
    inset: -2px;
    border-radius: 24px;
    background: linear-gradient(135deg,
        var(--sunwell-gold) 0%,
        var(--void-pink) 25%,
        var(--bio-cyan) 50%,
        var(--void-blue) 75%,
        var(--sunwell-gold) 100%
    );
    transform: translate3d(0, 0, -10px) scale(1.02);  /* GPU acceleration */
    opacity: 0.6;
    filter: blur(2px);
    will-change: transform;
}

/* Layer 4: Main Content Surface */
.card-layer-content {
    position: absolute;
    inset: 0;
    border-radius: 24px;
    background: linear-gradient(135deg,
        rgba(13, 0, 26, 0.95) 0%,
        rgba(46, 8, 84, 0.95) 100%
    );
    backdrop-filter: blur(10px);  /* Will be removed on mobile */
    border: 1px solid rgba(153, 50, 204, 0.3);
    transform: translate3d(0, 0, 0);  /* GPU acceleration */
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    will-change: transform;
}

/* Layer 5: Floating Particles (front-most) */
.card-layer-particles {
    position: absolute;
    inset: 0;
    border-radius: 24px;
    transform: translate3d(0, 0, 50px);  /* GPU acceleration */
    pointer-events: none;
    overflow: hidden;
    will-change: transform;
}

/* ===== SUNWELL PARTICLES ===== */
.firefly {
    position: absolute;
    width: 3px;
    height: 3px;
    background: var(--sunwell-gold);
    border-radius: 50%;
    box-shadow:
        0 0 10px var(--sunwell-gold),
        0 0 20px var(--sunwell-amber),
        0 0 30px rgba(255, 215, 0, 0.5);
    animation: float 6s infinite ease-in-out;
    opacity: 0.8;
}

.firefly:nth-child(1) { top: 20%; left: 15%; animation-delay: 0s; animation-duration: 5s; }
.firefly:nth-child(2) { top: 60%; left: 80%; animation-delay: 1s; animation-duration: 7s; }
.firefly:nth-child(3) { top: 35%; left: 50%; animation-delay: 2s; animation-duration: 6s; }
.firefly:nth-child(4) { top: 75%; left: 25%; animation-delay: 3s; animation-duration: 8s; }
.firefly:nth-child(5) { top: 45%; left: 70%; animation-delay: 1.5s; animation-duration: 6.5s; }
.firefly:nth-child(6) { top: 85%; left: 60%; animation-delay: 2.5s; animation-duration: 7.5s; }

@keyframes float {
    0%, 100% {
        transform: translateY(0px) translateX(0px);
        opacity: 0.4;
    }
    25% {
        transform: translateY(-15px) translateX(10px);
        opacity: 0.8;
    }
    50% {
        transform: translateY(-5px) translateX(-10px);
        opacity: 1;
    }
    75% {
        transform: translateY(-20px) translateX(5px);
        opacity: 0.6;
    }
}

/* ===== CONTENT SECTIONS ===== */

/* Header Section */
.card-header-3d {
    display: flex;
    align-items: center;
    gap: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(153, 50, 204, 0.3);
}

.card-avatar-3d {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg,
        var(--void-pink) 0%,
        var(--bio-cyan) 100%
    );
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    box-shadow:
        0 0 30px rgba(153, 50, 204, 0.4),
        0 8px 20px rgba(0, 0, 0, 0.4);
    transform: translate3d(0, 0, 20px);
    will-change: transform;
}

.card-info-3d {
    flex: 1;
}

.card-username-3d {
    font-size: 28px;
    font-weight: 800;
    color: #FFD700;
    margin-bottom: 4px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

@keyframes shimmer {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.card-level-3d {
    font-size: 14px;
    color: var(--sunwell-light);
    font-weight: 600;
    opacity: 0.9;
}

/* Stats Grid */
.card-stats-3d {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.stat-item-3d {
    background: rgba(13, 0, 26, 0.6);
    border: 1px solid rgba(153, 50, 204, 0.2);
    border-radius: 16px;
    padding: 16px 12px;
    text-align: center;
    transition: all 0.3s ease;
    transform: translate3d(0, 0, 10px);
    will-change: transform;
}

.stat-item-3d:hover {
    border-color: rgba(153, 50, 204, 0.5);
    background: rgba(13, 0, 26, 0.8);
    transform: translate3d(0, 0, 15px) scale(1.05);
}

.stat-value-3d {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 4px;
    display: block;
}

.stat-value-3d.points {
    color: var(--sunwell-gold);
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}

.stat-value-3d.streak {
    color: var(--bio-cyan);
    text-shadow: 0 0 15px rgba(0, 206, 209, 0.5);
}

.stat-value-3d.level {
    color: var(--void-pink);
    text-shadow: 0 0 15px rgba(153, 50, 204, 0.5);
}

.stat-label-3d {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* Progress Section */
.card-progress-3d {
    background: rgba(13, 0, 26, 0.6);
    border: 1px solid rgba(153, 50, 204, 0.2);
    border-radius: 16px;
    padding: 16px;
    transform: translate3d(0, 0, 10px);
    will-change: transform;
}

.progress-header-3d {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.progress-label-3d {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
}

.progress-text-3d {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
}

.progress-bar-3d {
    height: 12px;
    background: rgba(13, 0, 26, 0.8);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(153, 50, 204, 0.3);
}

.progress-fill-3d {
    height: 100%;
    background: linear-gradient(90deg,
        var(--void-pink) 0%,
        var(--bio-cyan) 50%,
        var(--sunwell-gold) 100%
    );
    border-radius: 12px;
    transition: width 1s ease-out;
    box-shadow:
        0 0 15px rgba(153, 50, 204, 0.6),
        inset 0 1px 2px rgba(255, 255, 255, 0.3);
    position: relative;
    overflow: hidden;
}

.progress-fill-3d::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: progressShine 2s infinite;
}

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

/* Badges Section */
.card-badges-3d {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.badge-3d {
    font-size: 28px;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.4));
    transition: all 0.3s ease;
    transform: translate3d(0, 0, 15px);
    will-change: transform;
}

.badge-3d:hover {
    transform: translate3d(0, 0, 25px) scale(1.2);
    filter: drop-shadow(0 4px 16px rgba(255, 215, 0, 0.6));
}

/* ===== RESPONSIVE DESIGN ===== */

@media (max-width: 768px) {
    /* 🔥 PHASE 1: CRITICAL PERFORMANCE OPTIMIZATIONS */

    /* Reduce 3D intensity on mobile */
    .profile-card-3d-container {
        perspective: 1200px;
        max-width: min(360px, 95vw);
        margin: 0 auto 24px;
    }

    .profile-card-3d {
        height: auto;
        min-height: 420px;
    }

    /* ⚡ CRITICAL: Hide decorative layers - NO BLUR on mobile! */
    .card-layer-background,
    .card-layer-pattern,
    .card-layer-particles {
        display: none !important;
    }

    .card-layer-border {
        display: none !important;
    }

    /* ⚡ CRITICAL: Clean solid background - NO blur, NO transparency */
    .card-layer-content {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        filter: none !important;
        background: linear-gradient(135deg,
            #2E0854 0%,
            #4B0082 100%
        ) !important;
        padding: 24px 20px;
        gap: 20px;
        border: 2px solid rgba(153, 50, 204, 0.6) !important;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5) !important;
    }

    /* Disable particles on mobile */
    .firefly {
        display: none !important;
    }

    /* Smaller header */
    .card-header-3d {
        gap: 16px;
        padding-bottom: 16px;
    }

    .card-avatar-3d {
        width: 64px;
        height: 64px;
        font-size: 32px;
        transform: translate3d(0, 0, 10px);
        box-shadow:
            0 0 20px rgba(153, 50, 204, 0.3),  /* Void pink */
            0 4px 12px rgba(0, 0, 0, 0.3);  /* Lighter shadow */
    }

    .card-username-3d {
        font-size: 24px;
    }

    .card-level-3d {
        font-size: 12px;
    }

    /* Stats grid adjustment */
    .card-stats-3d {
        gap: 12px;
    }

    .stat-item-3d {
        padding: 12px 8px;
        transform: translate3d(0, 0, 5px);
    }

    .stat-item-3d:hover {
        transform: translate3d(0, 0, 8px) scale(1.03);
    }

    .stat-value-3d {
        font-size: 20px;
    }

    .stat-label-3d {
        font-size: 11px;
    }

    /* Progress section */
    .card-progress-3d {
        padding: 14px;
        transform: translate3d(0, 0, 5px);
    }

    .progress-bar-3d {
        height: 10px;
    }

    /* Badges */
    .badge-3d {
        font-size: 24px;
        transform: translate3d(0, 0, 8px);
    }

    .badge-3d:hover {
        transform: translate3d(0, 0, 12px) scale(1.15);
    }

    /* 🔥 PHASE 2: ANIMATION OPTIMIZATIONS */

    /* Simplify username shimmer - slower, less frequent */
    .card-username-3d {
        animation: shimmer 6s ease-in-out infinite;  /* 3s → 6s (50% slower) */
    }

    /* Disable progress bar shine on mobile (saves GPU cycles) */
    .progress-fill-3d::after {
        animation: none;  /* Disable shine animation */
        display: none;  /* Hide the shine element entirely */
    }

    /* Simplify hover effects on mobile (already reduced, but ensure consistent) */
    .stat-item-3d:hover {
        transform: translate3d(0, 0, 8px) scale(1.03);  /* Already optimized */
    }
}

/* ===== TOUCH INTERACTIONS ===== */

/* Smooth reset animation */
.profile-card-3d.resetting {
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Active state for mobile tap */
@media (hover: none) and (pointer: coarse) {
    .profile-card-3d:active {
        transform: scale(0.98);
    }
}

/* ===== ACCESSIBILITY ===== */

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .profile-card-3d {
        transition: none;
    }

    .firefly {
        animation: none;
        opacity: 0.5;
    }

    .card-username-3d {
        animation: none;
        background-position: 0% 50%;
    }

    .progress-fill-3d::after {
        animation: none;
    }

    .stat-item-3d,
    .badge-3d {
        transition: none;
    }
}

/* ===== LOADING STATE ===== */

.profile-card-3d.loading {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.6s ease-out;
}

.profile-card-3d.loaded {
    opacity: 1;
    transform: translateY(0);
}

/* Mobile optimizations are in the first @media block above */
