/**
 * GIF Rain System - CSS Animations
 * Handles the falling animation and visual effects for GIF rain items
 */

/* Container for all falling GIFs */
.gif-rain-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999999 !important;
    overflow: hidden;
}

/* Individual falling GIF item */
.gif-rain-item {
    position: absolute;
    pointer-events: auto;
    cursor: pointer;
    transition: transform 0.2s ease;
    z-index: 1000000 !important;
    /* Debug: make sure they're visible */
    border: 2px solid red !important;
    background: yellow !important;
    min-width: 40px !important;
    min-height: 40px !important;
}

/* Hover effect for interactive GIFs */
.gif-rain-item:hover {
    transform: scale(1.1);
    filter: brightness(1.2);
}

/* Animation for falling from top to bottom */
@keyframes fallDown {
    0% {
        transform: translateY(-100px) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(calc(100vh + 100px)) rotate(360deg);
        opacity: 0;
    }
}

/* Apply the falling animation */
.gif-rain-item.falling {
    animation: fallDown linear forwards;
}

/* Specific position classes */
.gif-rain-item.position-left {
    left: 10%;
}

.gif-rain-item.position-center {
    left: 50%;
    transform: translateX(-50%);
}

.gif-rain-item.position-right {
    right: 10%;
}

.gif-rain-item.position-random {
    /* Position will be set by JavaScript */
}

/* Special effects for clicked items */
.gif-rain-item.clicked {
    animation-play-state: paused;
    transform: scale(1.3);
    filter: brightness(1.5) drop-shadow(0 0 20px rgba(255, 255, 255, 0.8));
}

/* Pulse effect for items with sound */
.gif-rain-item.has-sound::after {
    content: '🔊';
    position: absolute;
    top: -5px;
    right: -5px;
    font-size: 12px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
}

/* Spinning animation for special items like globe */
.gif-rain-item.spinning {
    animation: fallDown linear forwards, spin 2s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .gif-rain-item {
        max-width: 30px;
        max-height: 30px;
    }
    
    .gif-rain-item:hover {
        transform: scale(1.05);
    }
    
    .gif-rain-item.clicked {
        transform: scale(1.2);
    }
}

/* Accessibility - reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .gif-rain-item.falling {
        animation-duration: 0.5s;
        animation-iteration-count: 1;
    }
    
    .gif-rain-item.spinning {
        animation: fallDown 0.5s linear forwards;
    }
}

/* Debug mode styles (for development) */
body.gif-rain-debug .gif-rain-item {
    border: 2px dashed red;
}

body.gif-rain-debug .gif-rain-item::before {
    content: attr(data-name);
    position: absolute;
    top: -20px;
    left: 0;
    background: black;
    color: white;
    font-size: 10px;
    padding: 2px 4px;
    border-radius: 2px;
    white-space: nowrap;
    z-index: 1002;
}

/* Smooth entrance animation */
.gif-rain-item.entering {
    animation: enterFromTop 0.5s ease-out forwards;
}

@keyframes enterFromTop {
    0% {
        transform: translateY(-100px) scale(0.5);
        opacity: 0;
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* Special glow effect for magical items */
.gif-rain-item.magical {
    filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.6));
}

.gif-rain-item.magical:hover {
    filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.9));
}

/* Click ripple effect */
.gif-rain-item.ripple {
    position: relative;
    overflow: hidden;
}

.gif-rain-item.ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    transform: translate(-50%, -50%);
    animation: rippleEffect 0.6s ease-out;
}

@keyframes rippleEffect {
    to {
        width: 200px;
        height: 200px;
        opacity: 0;
    }
}

/* Performance optimizations */
.gif-rain-item {
    will-change: transform, opacity;
    backface-visibility: hidden;
    transform-style: preserve-3d;
}

/* Hide items that are off-screen for performance */
.gif-rain-item.off-screen {
    display: none;
}

/* Pause animation when tab is not active */
body.tab-inactive .gif-rain-item.falling {
    animation-play-state: paused;
}

/* CSS Globe Integration - Perfect transparent background globe */
.spinning-globe {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    position: relative;
    background: linear-gradient(135deg, 
        #1e3c72 0%, 
        #2a5298 25%, 
        #87ceeb 50%, 
        #4682b4 75%, 
        #1e3c72 100%);
    box-shadow: 
        inset -8px -8px 20px rgba(0, 0, 0, 0.3),
        inset 8px 8px 20px rgba(255, 255, 255, 0.1),
        0 0 20px rgba(30, 60, 114, 0.4);
    animation: globeSpin 4s linear infinite;
    overflow: hidden;
    cursor: pointer;
}

.spinning-globe::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: 
        radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.3) 0%, transparent 50%),
        linear-gradient(45deg, 
            transparent 20%, 
            rgba(34, 139, 34, 0.6) 30%, 
            transparent 40%,
            rgba(34, 139, 34, 0.4) 50%,
            transparent 60%,
            rgba(34, 139, 34, 0.5) 70%,
            transparent 80%);
    animation: continentSpin 8s linear infinite;
}

.spinning-globe::after {
    content: '';
    position: absolute;
    top: 10%;
    left: 10%;
    width: 80%;
    height: 80%;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 40%, 
        rgba(255, 255, 255, 0.4) 0%, 
        rgba(255, 255, 255, 0.1) 30%, 
        transparent 50%);
    animation: globeSpin 4s linear infinite reverse;
}

@keyframes globeSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes continentSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.spinning-globe:hover {
    transform: scale(1.1);
    box-shadow: 
        inset -8px -8px 20px rgba(0, 0, 0, 0.4),
        inset 8px 8px 20px rgba(255, 255, 255, 0.2),
        0 0 30px rgba(30, 60, 114, 0.6);
}

/* Globe size variations */
.spinning-globe.small { width: 30px; height: 30px; }
.spinning-globe.medium { width: 50px; height: 50px; }
.spinning-globe.large { width: 60px; height: 60px; }

/* Glowing globe effect */
.spinning-globe.glow {
    box-shadow: 
        inset -8px -8px 20px rgba(0, 0, 0, 0.3),
        inset 8px 8px 20px rgba(255, 255, 255, 0.1),
        0 0 30px rgba(30, 60, 114, 0.6),
        0 0 50px rgba(135, 206, 235, 0.3);
    animation: globeSpin 4s linear infinite, globeGlow 2s ease-in-out infinite alternate;
}

@keyframes globeGlow {
    from {
        box-shadow: 
            inset -8px -8px 20px rgba(0, 0, 0, 0.3),
            inset 8px 8px 20px rgba(255, 255, 255, 0.1),
            0 0 30px rgba(30, 60, 114, 0.6),
            0 0 50px rgba(135, 206, 235, 0.3);
    }
    to {
        box-shadow: 
            inset -8px -8px 20px rgba(0, 0, 0, 0.3),
            inset 8px 8px 20px rgba(255, 255, 255, 0.1),
            0 0 40px rgba(30, 60, 114, 0.8),
            0 0 70px rgba(135, 206, 235, 0.5);
    }
}

/* When CSS globe is used as a rain item */
.gif-rain-item .spinning-globe {
    display: block;
    margin: 0 auto;
} 