/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial Black', Arial, sans-serif;
    background: linear-gradient(45deg, #1a1a1a, #2d2d2d, #1a1a1a);
    background-size: 400% 400%;
    animation: gradientShift 9s ease infinite;
    color: #fff;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 30% 30%, rgba(255, 107, 157, 0.12) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 70%, rgba(23, 162, 184, 0.10) 0%, transparent 65%),
        radial-gradient(circle at 50% 10%, rgba(255, 193, 7, 0.08) 0%, transparent 55%);
    animation: mediumFlicker 7s ease-in-out infinite;
    pointer-events: none;
    z-index: 1;
}

body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(ellipse at 20% 80%, rgba(255, 107, 157, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 30%, rgba(23, 162, 184, 0.10) 0%, transparent 60%);
    animation: mediumFlicker2 9s ease-in-out infinite reverse;
    pointer-events: none;
    z-index: 1;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    33% { background-position: 100% 30%; }
    66% { background-position: 100% 70%; }
    100% { background-position: 0% 50%; }
}

@keyframes mediumFlicker {
    0%, 100% { 
        opacity: 0.4;
        transform: scale(1) rotate(0deg);
    }
    50% { 
        opacity: 0.75;
        transform: scale(1.08) rotate(15deg);
    }
}

@keyframes mediumFlicker2 {
    0%, 100% { 
        opacity: 0.35;
        transform: scale(1.05) rotate(-10deg);
    }
    50% { 
        opacity: 0.7;
        transform: scale(0.95) rotate(10deg);
    }
}

/* Container layout */
.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    position: relative;
    z-index: 2;
}

/* Image morphing container */
.image-morph-container {
    position: relative;
    width: 90vw;
    max-width: 600px;
    height: 70vh;
    max-height: 600px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 
        0 0 50px rgba(255, 107, 157, 0.3),
        0 0 100px rgba(23, 162, 184, 0.2),
        inset 0 0 30px rgba(0, 0, 0, 0.3);
    border: 3px solid transparent;
    background: linear-gradient(45deg, #ff6b9d, #ffc107, #17a2b8) border-box;
    background-clip: padding-box;
    animation: containerPulse 8s ease-in-out infinite;
}

@keyframes containerPulse {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 
            0 0 50px rgba(255, 107, 157, 0.25),
            0 0 100px rgba(23, 162, 184, 0.15);
    }
    50% { 
        transform: scale(1.015);
        box-shadow: 
            0 0 65px rgba(255, 107, 157, 0.4),
            0 0 115px rgba(23, 162, 184, 0.25);
    }
}

.image-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
}

/* Morphing images */
.morph-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 2.8s ease-in-out;
    filter: saturate(1.2) contrast(1.1);
}

.morph-image.active {
    opacity: 1;
}

/* Individual image animations */
#image1 {
    animation: morphCycle1 8.4s infinite;
}

#image3 {
    animation: morphCycle3 8.4s infinite;
}

@keyframes morphCycle1 {
    0%, 45% { opacity: 1; transform: scale(1) rotate(0deg); }
    55%, 95% { opacity: 0; transform: scale(1.1) rotate(2deg); }
    100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

@keyframes morphCycle3 {
    0%, 45% { opacity: 0; transform: scale(1.1) rotate(1deg); }
    55%, 95% { opacity: 1; transform: scale(1) rotate(0deg); }
    100% { opacity: 0; transform: scale(1.1) rotate(1deg); }
}

/* Particle effect overlay */
.image-morph-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 25% 75%, rgba(255, 107, 157, 0.12) 0%, transparent 55%),
        radial-gradient(ellipse at 75% 25%, rgba(23, 162, 184, 0.10) 0%, transparent 60%),
        radial-gradient(circle at 50% 50%, rgba(255, 193, 7, 0.06) 0%, transparent 45%);
    animation: moderateFloat 8s ease-in-out infinite, moderateFlicker 5s ease-in-out infinite;
    pointer-events: none;
    z-index: 1;
}

@keyframes moderateFloat {
    0%, 100% { 
        transform: translate(0, 0) rotate(0deg) scale(1);
    }
    50% { 
        transform: translate(5px, -3px) rotate(8deg) scale(1.04);
    }
}

@keyframes moderateFlicker {
    0%, 100% { 
        opacity: 0.3;
        filter: brightness(1);
    }
    33% { 
        opacity: 0.6;
        filter: brightness(1.15);
    }
    66% { 
        opacity: 0.45;
        filter: brightness(0.95);
    }
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .image-morph-container {
        width: 95vw;
        height: 60vh;
        max-height: 400px;
    }
    
    .title {
        margin-bottom: 1rem;
    }
    
    .info {
        margin-top: 1rem;
    }
}

@media (max-width: 480px) {
    .image-morph-container {
        height: 50vh;
        max-height: 300px;
        border-radius: 15px;
    }
    
    .info p {
        font-size: 0.9rem;
    }
}

/* Loading animation */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.container > * {
    animation: fadeIn 1s ease-out forwards;
}

.image-morph-container { animation-delay: 0.2s; }

/* Accessibility - Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Interactive states */
.image-morph-container {
    cursor: pointer;
    transition: transform 0.2s ease;
}

.image-morph-container:hover {
    transform: scale(1.01);
}

.image-morph-container:active {
    transform: scale(0.99);
}

/* Loading state */
body:not(.loaded) .container {
    opacity: 0;
}

body.loaded .container {
    opacity: 1;
    transition: opacity 0.5s ease;
}