*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
}

html{
    scroll-behavior: smooth;
}

body{
    background: #f0f4f8;
    color: #333;
    display: flex;
    flex-direction: column;
    align-items: center;
}

h1{
    text-align: center;
    margin: 100px auto 50px;
    font-weight: 600;
    font-size: 2.5rem;
    letter-spacing: 2px;
    color: #2c3e50;
}

form{
    width: 90%;
    max-width: 600px;
    margin: auto;
    height: 80px;
    background: #ffffff;
    display: flex;
    align-items: center;
    border-radius: 8px;
    box-shadow: 0px 4px 15px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
}

form input{
    flex: 1;
    height: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: #333;
    font-size: 18px;
    padding: 0 30px;
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
    transition: background 0.3s ease;
}

form input:focus{
    background: rgba(240, 244, 248, 0.7);
}

form button{
    padding: 0 40px;
    height: 100%;
    background: #3498db;
    color: white;
    font-size: 18px;
    border: 0;
    outline: 0;
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease;
}

form button:hover{
    background: #2980b9;
    transform: scale(1.05);
}

::placeholder{
    color: #aaa;
    font-size: 18px;
    opacity: 0.7;
}

#show-more-btn{
    background: #3498db;
    color: white;
    border: 0;
    outline: 0;
    padding: 10px 20px;
    border-radius: 4px;
    margin: 20px auto 100px;
    cursor: pointer;
    display: none;
    transition: background 0.3s ease, transform 0.2s ease;
}

#show-more-btn:hover{
    background: #2980b9;
    transform: scale(1.05);
}

#search-result{
    width: 80%;
    margin: 100px auto 50px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    grid-gap: 40px;
    justify-items: center;
}

#search-result img{
     width: 100%;
     aspect-ratio: 4 / 3;
     object-fit: cover;
     border-radius: 5px;
     transition: transform 0.3s ease, box-shadow 0.3s ease;
     box-shadow: 0px 4px 15px rgba(0, 0, 0, 0.1);
     opacity: 0;
}

#search-result img.loaded {
    opacity: 1; /* Show image */
}

.fade-in {
    animation: fadeIn 0.5s ease-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#search-result img:hover{
    transform: scale(1.05);
    box-shadow: 0px 8px 20px rgba(0, 0, 0, 0.15);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.fade-in {
    opacity: 0;
    transform: translateY(10px);
    animation: fadeIn 0.5s ease-out forwards;
}

@keyframes fadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top: 4px solid #3498db;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#error-message {
    width: 90%;
    max-width: 600px;
    margin: 20px auto;
    padding: 10px;
    color: #e74c3c; /* Bright red text */
    font-size: 18px;
    text-align: center;
    opacity: 0;
    transform: translateY(-10px);
    animation: bounceIn 1.4s ease-out forwards;
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: translateY(-100px);
    }
    60% {
        opacity: 1;
        transform: translateY(30px);
    }
    80% {
        transform: translateY(-10px);
    }
    100% {
        transform: translateY(0);
    }
}


@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
        margin: 60px auto 30px;
    }

    form {
        height: 60px;
    }

    form input {
        font-size: 16px;
        padding: 0 20px;
    }

    form button {
        padding: 0 30px;
        font-size: 16px;
    }

    #search-result {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        grid-gap: 15px;
    }

    #show-more-btn {
        margin: 20px auto 60px;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.8rem;
        margin: 40px auto 20px;
    }

    form {
        height: 50px;
    }

    form input {
        font-size: 14px;
        padding: 0 15px;
    }

    form button {
        padding: 0 20px;
        font-size: 14px;
    }

    #search-result {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        grid-gap: 10px;
    }

    #show-more-btn {
        margin: 20px auto 50px;
    }
}