/* General Body Styling */
@keyframes background-pan {
    0% {
        background-position: 0% center;
    }
    100% {
        background-position: 100% center;
    }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: linear-gradient(90deg, #0f0c29, #302b63, #24243e);
    background-size: 200% 200%;
    animation: background-pan 15s ease infinite alternate;
    color: #e0e0e0;
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
}

.main-container {
    width: 100%;
    max-width: 1200px;
    text-align: center;
}

header h1 {
    font-size: 3rem;
    background: linear-gradient(45deg, #a1c4fd, #c2e9fb);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    font-weight: 800;
    text-shadow: 0 0 15px rgba(194, 233, 251, 0.3);
}

header p {
    color: #a0a0a0;
    font-size: 1.1rem;
}

/* Controls Styling */
.controls {
    margin: 30px 0;
    display: flex;
    justify-content: center;
    gap: 20px;
}

/* Hide the default file input */
#image-upload {
    display: none;
}

/* Style the label to look like a button */
.upload-button, .download-button {
    background: linear-gradient(45deg, #007BFF, #00BFFF);
    color: white;
    padding: 12px 25px;
    border-radius: 8px;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 150, 255, 0.2);
}

.upload-button:hover, .download-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 150, 255, 0.4);
}

.download-button:active {
    transform: translateY(0);
}

/* Image Grid Layout */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 30px;
    margin-top: 40px;
}

/* The wrapper enforces the 3:4 aspect ratio and holds the glow effect */
@keyframes fadeInScaleUp {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.image-wrapper {
    /* Enforce 3:4 aspect ratio */
    aspect-ratio: 3 / 4;
    background-color: rgba(0, 0, 0, 0.3); /* Slightly transparent background */
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px; /* A little space around the image */
    box-sizing: border-box;
    border: 1px solid rgba(255, 255, 255, 0.1);
    
    /* Attach the glow and fade-in animations */
    animation: glow 4s infinite alternate, fadeInScaleUp 0.6s ease-out forwards;
}

/* The image itself */
.image-wrapper img {
    max-width: 100%;
    max-height: 100%;
    /* This is the key: it fits the image within the container without changing its proportion */
    object-fit: contain; 
    display: block;
}

/* Glow Animation Keyframes */
@keyframes glow {
    0% {
        box-shadow: 0 0 5px rgba(0, 191, 255, 0.4), 
                    0 0 10px rgba(0, 191, 255, 0.3);
    }
    100% {
        box-shadow: 0 0 20px rgba(0, 191, 255, 0.8), 
                    0 0 35px rgba(0, 191, 255, 0.6),
                    0 0 50px rgba(0, 191, 255, 0.4);
    }
}