/* Pixel Art Visual Effects - Image to Pixel */

/* Pixel-themed color palette */
:root {
    --pixel-primary: #8B5CF6;
    --pixel-secondary: #3B82F6;
    --pixel-accent: #F59E0B;
    --pixel-success: #10B981;
    --pixel-error: #EF4444;
    --pixel-dark: #1F2937;
    --pixel-light: #F9FAFB;
    --pixel-border: #E5E7EB;
    
    /* Gaming colors */
    --game-green: #4ADE80;
    --game-blue: #60A5FA;
    --game-yellow: #FBBF24;
    --game-red: #F87171;
    --game-purple: #A78BFA;
    --game-pink: #F472B6;
}

/* Priority 1: Pixel-Style Loading Animation */
.pixel-loader {
    display: inline-block;
    width: 48px;
    height: 48px;
    position: relative;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

.pixel-loader-grid {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 1px;
    background: var(--pixel-border);
    padding: 2px;
    border-radius: 4px;
}

.pixel-loader-cell {
    background: var(--pixel-light);
    border-radius: 1px;
    animation: pixelLoad 1.2s infinite;
}

.pixel-loader-cell:nth-child(1) { animation-delay: 0s; }
.pixel-loader-cell:nth-child(2) { animation-delay: 0.1s; }
.pixel-loader-cell:nth-child(3) { animation-delay: 0.2s; }
.pixel-loader-cell:nth-child(4) { animation-delay: 0.3s; }
.pixel-loader-cell:nth-child(5) { animation-delay: 0.4s; }
.pixel-loader-cell:nth-child(6) { animation-delay: 0.5s; }
.pixel-loader-cell:nth-child(7) { animation-delay: 0.6s; }
.pixel-loader-cell:nth-child(8) { animation-delay: 0.7s; }
.pixel-loader-cell:nth-child(9) { animation-delay: 0.8s; }
.pixel-loader-cell:nth-child(10) { animation-delay: 0.9s; }
.pixel-loader-cell:nth-child(11) { animation-delay: 1.0s; }
.pixel-loader-cell:nth-child(12) { animation-delay: 1.1s; }
.pixel-loader-cell:nth-child(13) { animation-delay: 0.2s; }
.pixel-loader-cell:nth-child(14) { animation-delay: 0.3s; }
.pixel-loader-cell:nth-child(15) { animation-delay: 0.4s; }
.pixel-loader-cell:nth-child(16) { animation-delay: 0.5s; }

@keyframes pixelLoad {
    0%, 100% {
        background: var(--pixel-light);
        transform: scale(1);
    }
    50% {
        background: var(--pixel-primary);
        transform: scale(0.8);
    }
}

/* Retro Gaming Progress Bar */
.gaming-progress {
    width: 100%;
    height: 24px;
    background: linear-gradient(90deg, #2D3748 0%, #4A5568 100%);
    border: 3px solid var(--pixel-dark);
    border-radius: 4px;
    position: relative;
    overflow: hidden;
    box-shadow: 
        inset 0 2px 4px rgba(0, 0, 0, 0.3),
        0 4px 8px rgba(0, 0, 0, 0.2);
}

.gaming-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, 
        var(--game-green) 0%, 
        var(--game-blue) 25%, 
        var(--game-purple) 50%, 
        var(--game-pink) 75%, 
        var(--game-yellow) 100%);
    background-size: 200% 100%;
    animation: rainbowShift 2s linear infinite;
    position: relative;
    transition: width 0.3s ease;
}

.gaming-progress-bar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(255, 255, 255, 0.3) 50%, 
        transparent 100%);
    animation: shimmer 1.5s infinite;
}

.gaming-progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: bold;
    font-size: 12px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    z-index: 10;
    font-family: 'Courier New', monospace;
}

@keyframes rainbowShift {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}

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

/* Processing visual feedback */
.processing-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.processing-content {
    text-align: center;
    color: white;
}

.processing-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 16px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    font-family: 'Courier New', monospace;
}

/* Priority 2: Gaming-Style Button Effects */
.gaming-button {
    position: relative;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.1s ease;
    font-family: 'Courier New', monospace;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    box-shadow: 
        0 8px 0 rgba(0, 0, 0, 0.2),
        0 12px 20px rgba(0, 0, 0, 0.2),
        inset 0 -2px 4px rgba(0, 0, 0, 0.2);
    transform: translateY(0);
    user-select: none;
}

.gaming-button::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    height: 30%;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.3), transparent);
    border-radius: 6px;
    pointer-events: none;
}

.gaming-button.primary {
    background: linear-gradient(135deg, #8B5CF6 0%, #7C3AED 100%);
    color: white;
}

.gaming-button.secondary {
    background: linear-gradient(135deg, #3B82F6 0%, #2563EB 100%);
    color: white;
}

.gaming-button.success {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    color: white;
}

.gaming-button.warning {
    background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
    color: white;
}

.gaming-button.danger {
    background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
    color: white;
}

/* Hover effects with floating animation */
.gaming-button:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 10px 0 rgba(0, 0, 0, 0.2),
        0 16px 24px rgba(0, 0, 0, 0.3),
        inset 0 -2px 4px rgba(0, 0, 0, 0.2);
    animation: float 2s ease-in-out infinite;
}

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

/* Active/click press animations */
.gaming-button:active {
    transform: translateY(4px);
    box-shadow: 
        0 2px 0 rgba(0, 0, 0, 0.2),
        0 4px 8px rgba(0, 0, 0, 0.2),
        inset 0 -2px 4px rgba(0, 0, 0, 0.2);
}

.gaming-button:active::before {
    height: 0;
}

/* Priority 3: Success/Completion Animation */
.pixel-explosion {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
}

.pixel-particle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--pixel-primary);
    border-radius: 1px;
    animation: explode 0.8s ease-out forwards;
}

@keyframes explode {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx), var(--ty)) scale(0);
        opacity: 0;
    }
}

/* Retro confetti animation */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

.confetti {
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--game-green);
    animation: confettiFall 3s ease-out forwards;
}

.confetti:nth-child(2n) { background: var(--game-blue); animation-delay: 0.1s; }
.confetti:nth-child(3n) { background: var(--game-yellow); animation-delay: 0.2s; }
.confetti:nth-child(4n) { background: var(--game-red); animation-delay: 0.3s; }
.confetti:nth-child(5n) { background: var(--game-purple); animation-delay: 0.4s; }
.confetti:nth-child(6n) { background: var(--game-pink); animation-delay: 0.5s; }

@keyframes confettiFall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Enhanced success notifications */
.pixel-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, var(--pixel-success) 0%, #059669 100%);
    color: white;
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: 
        0 8px 0 rgba(0, 0, 0, 0.2),
        0 12px 20px rgba(0, 0, 0, 0.2),
        inset 0 -2px 4px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    max-width: 300px;
    animation: slideIn 0.3s ease-out;
}

.pixel-notification::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    height: 30%;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.3), transparent);
    border-radius: 6px;
    pointer-events: none;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Priority 4: Interactive Canvas Enhancement */
.canvas-container {
    position: relative;
    display: inline-block;
    border: 3px solid var(--pixel-dark);
    border-radius: 8px;
    overflow: hidden;
    background: #f0f0f0;
    box-shadow: 
        0 8px 0 rgba(0, 0, 0, 0.2),
        0 12px 20px rgba(0, 0, 0, 0.2);
}

.pixel-grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.3;
    background-image: 
        linear-gradient(rgba(0, 0, 0, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 0, 0, 0.1) 1px, transparent 1px);
    background-size: var(--grid-size, 8px) var(--grid-size, 8px);
}

.zoom-controls {
    position: absolute;
    bottom: 10px;
    right: 10px;
    display: flex;
    gap: 5px;
    z-index: 10;
}

.zoom-btn {
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.2s ease;
}

.zoom-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

/* Color palette display */
.color-palette {
    margin-top: 16px;
    padding: 12px;
    background: var(--pixel-light);
    border: 2px solid var(--pixel-border);
    border-radius: 8px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.color-palette-title {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 8px;
    color: var(--pixel-dark);
    font-family: 'Courier New', monospace;
}

.color-palette-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(24px, 1fr));
    gap: 4px;
}

.color-swatch {
    width: 24px;
    height: 24px;
    border: 1px solid var(--pixel-border);
    border-radius: 2px;
    cursor: pointer;
    transition: transform 0.2s ease;
    position: relative;
}

.color-swatch:hover {
    transform: scale(1.2);
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.color-swatch::after {
    content: attr(data-color);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--pixel-dark);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    margin-bottom: 4px;
}

.color-swatch:hover::after {
    opacity: 1;
}

/* Performance optimizations */
.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
    will-change: transform;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .gaming-button {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    .pixel-notification {
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .zoom-controls {
        bottom: 5px;
        right: 5px;
    }
    
    .zoom-btn {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .canvas-container {
        background: #2D3748;
    }
    
    .color-palette {
        background: #2D3748;
        border-color: #4A5568;
    }
    
    .color-palette-title {
        color: #E2E8F0;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .pixel-loader-cell,
    .gaming-progress-bar,
    .gaming-button:hover,
    .pixel-particle,
    .confetti,
    .pixel-notification {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus indicators for accessibility */
.gaming-button:focus-visible {
    outline: 3px solid var(--pixel-primary);
    outline-offset: 2px;
}

.zoom-btn:focus-visible {
    outline: 2px solid var(--pixel-primary);
    outline-offset: 2px;
}