/* Grid */
.phocaimage-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 1.5em;
    margin-bottom: 1.5em;
    clear: both;
}

.phocaimage-gallery a {
    display: block;
    position: relative;
    overflow: hidden;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}

.phocaimage-gallery a:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

/* Hover overlay with a magnifying-glass icon, hinting that the thumbnail
   opens a larger view (same idea as the classic jw_sig-style galleries). */
.phocaimage-gallery a::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    transition: background 0.2s ease;
    pointer-events: none;
}

.phocaimage-gallery a:hover::before {
    background: rgba(0, 0, 0, 0.18);
}

.phocaimage-gallery a::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 42px;
    height: 42px;
    transform: translate(-50%, -50%) scale(0.75);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

.phocaimage-gallery a:hover::after {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.phocaimage-gallery img {
    width: 100%;
    height: auto;
    display: block;
}

/* Remove Joomla's generic field-list bullet/indent when it wraps this gallery. */
.fields-container:has(.phocaimage-gallery) {
    padding-left: 0;
    margin-left: 0;
}

.fields-container > .field-entry:has(.phocaimage-gallery) {
    list-style: none;
}

.fields-container > .field-entry > .field-value:has(.phocaimage-gallery) {
    display: block;
}



/* Flex */
.phocaimage-gallery.pi-flex-fluid,
.phocaimage-gallery.pi-flex {
    display: flex;
    flex-wrap: wrap;
}
.phocaimage-gallery.pi-flex a {
    max-height: 250px;
    width: auto;
    flex: 1 0 auto;
}

.phocaimage-gallery.pi-flex-fluid img,
.phocaimage-gallery.pi-flex img {
    height: 100%;
    width: auto;
    min-width: 100%;
    object-fit: cover;
}

.phocaimage-gallery.pi-flex.pi-count-3 a,
.phocaimage-gallery.pi-flex.pi-count-2 a,
.phocaimage-gallery.pi-flex.pi-count-1 a {
    flex: 0 1 auto;
    width: auto;
    max-width: 100%;
}

.phocaimage-gallery.pi-flex.pi-count-3 img,
.phocaimage-gallery.pi-flex.pi-count-2 img,
.phocaimage-gallery.pi-flex.pi-count-1 img {
    width: auto;
    max-width: 100%;
    object-fit: contain;
}

@media (max-width: 767.98px) {
    .phocaimage-gallery.pi-flex-fluid a,
    .phocaimage-gallery.pi-flex a {
        flex: 0 0 100%;
        height: auto;
    }

    .phocaimage-gallery.pi-flex-fluid img,
    .phocaimage-gallery.pi-flex img {
        width: 100%;
        height: auto;
        min-width: 0;
        object-fit: contain;
    }
}

/* GLightbox "X / N" counter - placed top-left so it never competes for
   space with the caption at the bottom, and stays clear of GLightbox's
   own close button (top-right) and prev/next arrows (side-centered). */
.phocaimage-counter {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 99999;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 13px;
    line-height: 1.3;
    padding: 4px 12px;
    border-radius: 12px;
    pointer-events: none;
}

/* Caption: GLightbox's default "clean" skin renders it as a solid white
   bar below the image. Restyle it to match the counter above instead -
   transparent bar, text in its own small dark pill, no box around it. */
.gslide-description {
    background: transparent !important;
}

.gdesc-inner {
    padding: 0 20px 16px !important;
    text-align: center;
}

.gslide-title {
    display: inline-block;
    background: rgba(0, 0, 0, 0.55);
    color: #fff !important;
    font-family: inherit !important;
    font-size: 13px !important;
    font-weight: normal !important;
    line-height: 1.3 !important;
    padding: 4px 12px;
    border-radius: 12px;
    margin-bottom: 0 !important;
}

/* A gentle, generous percentage-based cap (not a precise px calculation
   tied to caption/counter height, which is what caused the earlier
   "over-zoomed" bug) - just gives the image some breathing room on all
   sides instead of stretching to fill the entire viewport edge-to-edge. */
.glightbox-container .gslide-image img {
    max-height: 88vh;
}
