body {
    overflow: auto !important;
    margin: 0;
    padding: 0;
    background-color: #fff;
}

.art-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
    margin-top: 60px;
    padding: 40px;
}

@media (min-width: 900px) {
    .art-grid-container {
        grid-template-columns: repeat(3, 1fr); /* Maximum of 3 columns */
    }
}

.art-grid-item img {
    width: 100%;
    height: auto;
    cursor: pointer;
    border: none;
    border-radius: 0;
    transition: none;
}

.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff; /* Full white background */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding: 20px; /* Ensure consistent padding for spacing */
}

.image-modal.visible {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    position: relative;
    max-width: 80%;
    max-height: calc(100vh - 120px); /* Ensure consistent margin around image */
    display: flex;
    flex-direction: column;
    align-items: flex-start; /* Align image and caption to the left */
}

.modal-image {
    max-width: 100%;
    max-height: calc(100vh - 200px); /* Maintain margin for caption */
    display: block;
    margin: 0 auto;
}

.caption {
    color: #000;
    font-size: 16px;
    margin-top: 10px;
    text-align: left; /* Align text to the left */
    word-wrap: break-word;
    line-height: 1.5; /* Add line height for better readability */
    width: 100%; /* Ensure the caption takes the full width of the modal */
}

.caption-title {
    font-style: italic;
    font-size: 16px;
    margin-bottom: 4px; /* Add spacing between title and medium */
}

.caption-medium {
    font-size: 14px;
    margin-bottom: 4px; /* Add spacing between medium and year */
}

.caption-year {
    font-size: 14px;
    color: #777;
}

.close-modal {
    position: fixed;
    top: 10%; /* Adjust based on desired spacing */
    right: 20px;
    background: none;
    border: none;
    color: #000;
    font-size: 18px;
    cursor: pointer;
    z-index: 10;
}

.prev-modal,
.next-modal {
    position: fixed;
    top: 50%;
    background: none;
    border: none;
    color: #000;
    font-size: 18px;
    cursor: pointer;
    transform: translateY(-50%);
    z-index: 10;
    width: 50px; /* Expand clickable area */
    height: 100px; /* Expand clickable area */
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: manipulation; /* Prevent double-tap zooming */
    outline: none; /* Remove focus outline */
}

.prev-modal:active,
.next-modal:active {
    background: none; /* Remove grey rectangle on click */
}

.prev-modal {
    left: 10px;
}

.next-modal {
    right: 10px;
}

@media (max-width: 768px) {
    .art-grid-container {
        padding: 20px; /* Reduced padding for smaller screens */
    }
}

@media (max-width: 768px) {
    .prev-modal,
    .next-modal {
        display: none;
    }

    .modal-content {
        width: 100%; /* Ensure the image uses the full width */
        max-width: none;
    }

    .modal-image {
        max-width: 100%;
        max-height: calc(100vh - 120px); /* Maintain aspect ratio with appropriate margin */
    }
}
