.wp-block-custom-advanced-gallery {
    box-sizing: border-box;
    background: #fafafa;
    padding: 8px;
    border-radius: 8px;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
}

.wp-block-custom-advanced-gallery figure {
    margin: 0 4px 8px 0;
    background: #fff;
    border-radius: 4px;
    padding: 0;
}

.wp-block-custom-advanced-gallery .gallery-main-image {
    width: 100%;
    text-align: center;
    margin-bottom: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Alignment and layout for frontend slideshow */
.gallery-block-slideshow {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin: 0 auto;
    max-width: 800px;
}

/* --- CONSISTENT MAIN IMAGE AREA FOR SLIDESHOW --- */
.gallery-block-main-image {
    width: 100%;
    max-width: 100%;
    height: 400px;             /* Fixed height for consistency */
    text-align: center;
    margin-bottom: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #fafafa;
    position: relative;
    box-sizing: border-box;
    overflow: hidden;          /* Prevent image from overflowing container */
}

.gallery-block-main-link {
    display: inline-block;
    position: relative;
    cursor: pointer;
    max-width: 100%;
    height: 100%;              /* Ensure link fills container for vertical centering */
}

.gallery-block-main-img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    margin: 0 auto;
    background: transparent;
}

/* Label: position absolutely, centered at bottom of image */
.gallery-block-enlarge-label {
    position: absolute;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.66);
    color: #fff;
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 0.7em;
    pointer-events: none;
    font-family: inherit;
    letter-spacing: 0.02em;
    user-select: none;
    z-index: 3;
    white-space: nowrap;
    text-align: center;
}

/* --- SQUARE GRID MODE THUMBNAILS, NO CROPPING OR DISTORTION --- */
.wp-block-custom-advanced-gallery .gallery-thumbnails a,
.wp-block-custom-advanced-gallery .gallery-thumbnails .thumb-wrapper {
    display: block;
    width: 100%;
    aspect-ratio: 1/1;
    position: relative;
    background: #f1f1f1;
    border-radius: 4px;
    border: 1px solid #ccc;
    overflow: hidden;
}

.wp-block-custom-advanced-gallery .gallery-thumbnails img {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    border-radius: 4px;
    display: block;
    background: transparent;
    box-sizing: border-box;
    transition: border 0.2s;
    margin: 0;
    padding: 0;
    border: none;
}

.wp-block-custom-advanced-gallery .gallery-thumbnails img:hover {
    border: 2px solid #005880;
}

.wp-block-custom-advanced-gallery .active-thumb {
    border: 2px solid #007cba !important;
    background: #f0f6fc;
}

/* Slideshow thumbnails */
.gallery-block-thumbnails {
    display: flex;
    justify-content: center;
    gap: 8px;
    overflow-x: auto;
    margin-top: 12px;
}

/* --- Start: Static, visible border for slideshow thumbnails --- */

/* Button: reserve border space, add padding so border is outside image */
.gallery-block-thumbnails .gallery-block-thumb {
    border: 2px solid transparent;
    background: white;
    padding: 3px;
    margin: 0;
    box-sizing: border-box;
    transition: border-color 0.2s, background 0.2s;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    z-index: 1;
    display: inline-block;
}

.gallery-block-thumbnails .gallery-block-thumb.active-thumb {
    border-color: #007cba !important;
    background: #e6f3fb !important;
    z-index: 2;
}

.gallery-block-thumbnails .gallery-block-thumb:hover,
.gallery-block-thumbnails .gallery-block-thumb:focus {
    border-color: #007cba;
    background: #f0f6fc;
    outline: none;
}

.gallery-block-thumbnails .gallery-block-thumb:active,
.gallery-block-thumbnails .gallery-block-thumb:focus:active {
    border-color: #007cba;
    background: #f0f6fc;
    outline: none;
    box-shadow: none;
    transform: none;
}

.gallery-block-thumbnails .gallery-block-thumb img {
    width: 60px !important;
    height: 60px !important;
    object-fit: cover;
    border-radius: 4px;
    display: block;
    border: none !important;
    background: transparent;
    box-sizing: border-box;
    transition: none;
    margin: 0;
    padding: 0;
}

/* Remove tap highlight on mobile browsers for buttons */
.gallery-block-thumbnails .gallery-block-thumb {
    -webkit-tap-highlight-color: transparent;
}

.gallery-block-thumbnails .gallery-block-thumb:focus-visible {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* --- End: Static, visible border for slideshow thumbnails --- */

/* Legacy/fallback for grid thumbs, if present */
.gallery-block-thumbnails img:hover {
    border: 2px solid #005880;
}

.gallery-block-thumbnails .gallery-block-thumb:not(.active-thumb) {
    background: white;
}

.gallery-block-thumbnails,
.gallery-block-thumbnails .gallery-block-thumb {
    margin-bottom: 0;
}