/* Grid layout for the gallery */
#gallery-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 15px; 
    justify-content: center;
    padding: 0;
    margin: 0;
}

.catItemImageBlock {
    flex: 0 0 auto;
    position: relative;
    overflow: hidden;
    line-height: 0; /* remove bottom space from inline-block a */
}

a.gallery-link {
    display: block;
    position: relative;
}

/* Zoom icon hover effect */
.zoomIcon {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    pointer-events: none; 
    color: white;
    font-size: 80px;
    font-weight: 100;
    line-height: 1;
    text-shadow: 0 1px 10px rgba(0, 0, 0, 0.8);
}

a.gallery-link:hover .zoomIcon {
    opacity: 1;
}

/* Gallery Modal (Lightbox) Styles */
.gallery-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: rgba(0, 0, 0, 0.9);
    align-items: center;
    justify-content: center;
}

#gallery-image-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    overflow: hidden; /* Important for continuous slide effect */
}

#gallery-image-wrapper.zoom-in {
    animation: zoom 0.4s;
}

.gallery-modal-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    /* Transition is now controlled via JS for more precise control */
}

/* Animations */
@keyframes zoom {
    from {transform: scale(0.1)}
    to {transform: scale(1)}
}

/* Close Button */
.gallery-close {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
    z-index: 1001;
}

.gallery-close:hover,
.gallery-close:focus {
    color: #bbb;
    text-decoration: none;
}

/* Navigation Arrows */
.gallery-prev, .gallery-next {
    cursor: pointer;
    position: absolute;
    top: 50%;
    width: auto;
    padding: 16px;
    margin-top: -30px;
    color: white;
    font-weight: bold;
    font-size: 24px;
    transition: background-color 0.4s ease;
    -webkit-user-select: none; /* Safari */
    -moz-user-select: none;    /* Firefox */
    -ms-user-select: none;     /* IE 10+ and Edge */
    user-select: none;         /* Standard syntax */
    z-index: 1001;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
}

.gallery-prev {
    left: 10px;
}

.gallery-next {
    right: 10px;
}

.gallery-prev:hover, .gallery-next:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

/* Loader styles */
.gallery-loader {
    display: none; /* Hidden by default, shown by JS */
    position: absolute;
    left: 50%;
    top: 50%;
    margin-left: -30px; /* Half of width */
    margin-top: -30px;  /* Half of height */
    width: 60px;
    height: 60px;
    border: 8px solid #f3f3f3; /* Light grey */
    border-top: 8px solid #555; /* Darker grey */
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 1002;
}

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