.gmw-square-image {
    display: inline-block;
    width: 100%;
}

/* Clickable area wraps the square frame */
.gmw-square-image__link {
    display: inline-block;
    text-decoration: none;
    color: inherit;
}

/* Square frame showing middle portion only */
.gmw-square-image__frame {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;              /* modern browsers */
    overflow: hidden;                  /* crop to square */
    background: #f2f2f2;               /* subtle bg while loading */
}

/* Fallback if aspect-ratio unsupported */
@supports not (aspect-ratio: 1 / 1) {
    .gmw-square-image__frame::before {
        content: "";
        display: block;
        padding-top: 100%;            /* 1:1 square */
    }
    .gmw-square-image__img {
        position: absolute;
        top: 0; left: 0; right: 0; bottom: 0;
        width: 100%; height: 100%;
    }
}

/* The image fills the square and shows its center */
.gmw-square-image__img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;                 /* crop to square area */
    object-position: center center;    /* middle portion */
}

.gmw-square-image__caption {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: #555;
    text-align: center;
}

/* Lightbox overlay (CSS :target based) */
.gmw-square-image__lightbox {
    position: fixed;
    inset: 0;
    display: none;          /* hidden by default; shown via :target */
    z-index: 10000;
}

/* When targeted, show the overlay */
.gmw-square-image__lightbox:target {
    display: block;
}

/* Backdrop covers the whole screen and closes on click */
.gmw-square-image__lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.85);
    display: block;
}

/* Content is centered and above the backdrop */
.gmw-square-image__lightbox-content {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    max-width: 90vw;
    max-height: 90vh;
    z-index: 1;
}
.gmw-square-image__lightbox-content img {
    display: block;
    max-width: 100%;
    max-height: 90vh;
    height: auto;
    width: auto;
}

/* Close button */
.gmw-square-image__lightbox-close {
    position: absolute;
    top: 12px;
    right: 16px;
    color: #fff;
    text-decoration: none;
    font-size: 32px;
    line-height: 1;
    z-index: 2;
}
