/* MEDDIC Game - Visual Enhancement Layer (enhance.css) */
/* Design Theme: Gamified Corporate Tech / Cyberpunk Blue / Glassmorphism */

:root {
    /* Core Palette */
    --primary-color: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.5);
    --secondary-color: #10b981;
    --secondary-glow: rgba(16, 185, 129, 0.5);
    --accent-color: #f59e0b;
    --accent-glow: rgba(245, 158, 11, 0.5);
    --danger-color: #ef4444;
    
    /* Backgrounds & Glass */
    --bg-color: #0b1220;
    --bg-gradient-start: #0b1220;
    --bg-gradient-end: #1e293b;
    --glass-bg: rgba(17, 24, 39, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-highlight: rgba(255, 255, 255, 0.05);
    
    /* Text */
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
}

/* 2. Body Background & Animated Grid */
body {
    background-color: var(--bg-color);
    background-image: 
        linear-gradient(rgba(59, 130, 246, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(59, 130, 246, 0.03) 1px, transparent 1px),
        radial-gradient(circle at 50% 0%, #1e3a8a 0%, var(--bg-color) 60%);
    background-size: 50px 50px, 50px 50px, 100% 100%;
    color: var(--text-main);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    overflow-x: hidden;
    animation: cyber-grid-scroll 60s linear infinite;
}

@keyframes cyber-grid-scroll {
    0% { background-position: 0 0, 0 0, 50% 0%; }
    100% { background-position: 50px 50px, 50px 50px, 50% 0%; }
}

/* 13. Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-color);
}
::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 4px;
    border: 1px solid var(--bg-color);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* 9 & 10. Glassmorphism Panels & Modals */
.modal-content, 
.intel-panel, 
#resource-board, 
.auth-modal,
.game-screen,
.action-menu {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    box-shadow: 
        0 4px 30px rgba(0, 0, 0, 0.5),
        inset 0 0 0 1px var(--glass-highlight);
    border-radius: 16px;
    color: var(--text-main);
}

.auth-modal {
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
}

/* 3. Welcome Screen Button Pulse */
.welcome-screen .btn-primary {
    position: relative;
    background: linear-gradient(135deg, var(--primary-color), #2563eb);
    border: none;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    overflow: hidden;
    z-index: 1;
    animation: btn-pulse 2s infinite;
}

@keyframes btn-pulse {
    0% { box-shadow: 0 0 0 0 var(--primary-glow); }
    70% { box-shadow: 0 0 0 15px rgba(59, 130, 246, 0); }
    100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}

/* 4. Choice Buttons Hover & Glow */
.choice-btn {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
}

.choice-btn::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    transition: 0.5s;
}

.choice-btn:hover {
    transform: scale(1.02) translateY(-2px);
    border-color: var(--primary-color);
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
    background: rgba(59, 130, 246, 0.15);
}

.choice-btn:hover::before {
    left: 100%;
}

/* 5. Result Feedback */
.result-correct {
    border-color: var(--secondary-color) !important;
    background: rgba(16, 185, 129, 0.15) !important;
    box-shadow: 0 0 30px var(--secondary-glow);
    animation: success-pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.result-wrong {
    border-color: var(--danger-color) !important;
    background: rgba(239, 68, 68, 0.15) !important;
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.4);
    animation: error-shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes success-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes error-shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* 6. Map Building Selected */
.map-building {
    transition: transform 0.4s ease, filter 0.4s ease;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.5));
}

.map-building.selected {
    transform: scale(1.15) translateY(-5px);
    filter: drop-shadow(0 0 15px var(--primary-color)) brightness(1.2);
    z-index: 100;
}

/* 7. Map Avatar Breathing Effect */
.map-avatar {
    border: 2px solid #fff;
    box-shadow: 0 0 15px var(--primary-color);
    animation: avatar-breathe 3s ease-in-out infinite;
}

@keyframes avatar-breathe {
    0%, 100% { box-shadow: 0 0 10px var(--primary-glow), 0 0 0 2px rgba(59, 130, 246, 0.2); }
    50% { box-shadow: 0 0 25px var(--primary-color), 0 0 0 6px rgba(59, 130, 246, 0.1); }
}

/* 8. Tutorial Bubble */
.tutorial-bubble {
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid var(--accent-color);
    box-shadow: 0 0 20px var(--accent-glow);
    color: #fff;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 0.9rem;
    position: relative;
    animation: float-bubble 3s ease-in-out infinite;
}

.tutorial-bubble::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;
    border-top: 6px solid var(--accent-color);
}

@keyframes float-bubble {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* 11. Confetti CSS Animation (Triggered via JS adding classes or elements) */
.confetti-piece {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--primary-color);
    top: -10px;
    opacity: 0;
}

.result-correct .confetti-piece {
    animation: confetti-fall 2.5s ease-out forwards;
}

/* Generate random positions/colors for confetti via nth-child if elements exist, 
   otherwise this is a fallback visual for the correct result container */
.result-correct::before {
    content: '';
    position: absolute;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background-image: radial-gradient(circle, var(--secondary-color) 2px, transparent 2.5px);
    background-size: 30px 30px;
    opacity: 0;
    pointer-events: none;
    animation: sparkle-burst 0.8s ease-out forwards;
}

@keyframes sparkle-burst {
    0% { transform: scale(0.5); opacity: 1; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* 12. Achievement Badge 3D Flip */
.badge-card {
    perspective: 1000px;
    background: transparent;
}

.badge-card .badge-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.8s;
    transform-style: preserve-3d;
}

.badge-card.unlocked .badge-inner {
    animation: badge-flip-unlock 1.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.badge-card.unlocked .badge-front,
.badge-card.unlocked .badge-back {
    box-shadow: 0 0 20px var(--accent-glow);
    border: 1px solid var(--accent-color);
}

@keyframes badge-flip-unlock {
    0% { transform: rotateY(0); }
    100% { transform: rotateY(360deg); }
}

/* General UI Enhancements */
h1, h2, h3 {
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
    letter-spacing: -0.5px;
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
}

.btn-secondary:hover {
    border-color: var(--text-main);
    color: var(--text-main);
    background: rgba(255,255,255,0.05);
}

#resource-board {
    border-top: 2px solid var(--primary-color);
}

.intel-panel {
    border-left: 2px solid var(--secondary-color);
}
