.mfg-gallery {
    --mfg-columns: auto-fit;
    --mfg-tile-min: 170px;
    --mfg-gap: 14px;
}

.mfg-gallery * {
    box-sizing: border-box;
}

.mfg-grid {
    display: grid;
    grid-template-columns: repeat(var(--mfg-columns), minmax(var(--mfg-tile-min), 1fr));
    gap: var(--mfg-gap);
}

.mfg-gallery[style*="--mfg-columns"] .mfg-grid {
    grid-template-columns: repeat(var(--mfg-columns), minmax(0, 1fr));
}

.mfg-item {
    position: relative;
    margin: 0;
    overflow: hidden;
    border-radius: 10px;
    background: #f3f3f3;
    aspect-ratio: 1 / 1;
}

.mfg-thumb-button {
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background-color: #f3f3f3;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    cursor: zoom-in;
    transition: transform 160ms ease, filter 160ms ease;
}


/* Keep themes/browsers from displaying attachment titles, aria-labels, or fallback text on top of thumbnails. */
.mfg-thumb-button,
.mfg-thumb-button * {
    color: transparent !important;
    font-size: 0 !important;
    line-height: 0 !important;
    text-shadow: none !important;
}

.mfg-thumb-button::before,
.mfg-thumb-button::after,
.mfg-thumb-button *::before,
.mfg-thumb-button *::after {
    content: "" !important;
    display: none !important;
}

.mfg-thumb-bg {
    display: block;
    width: 100%;
    height: 100%;
    font-size: 0;
    line-height: 0;
}

.mfg-item:hover .mfg-thumb-button,
.mfg-thumb-button:focus {
    transform: scale(1.025);
    filter: brightness(.92);
}

.mfg-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 6px;
    opacity: 1;
    transform: none;
    transition: opacity 140ms ease, transform 140ms ease;
}

.mfg-item:hover .mfg-actions,
.mfg-item:focus-within .mfg-actions {
    opacity: 1;
    transform: none;
}

.mfg-action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: 0;
    background: rgba(0, 0, 0, .72);
    color: #fff;
    text-decoration: none;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.mfg-action-button:hover,
.mfg-action-button:focus {
    background: rgba(0, 0, 0, .9);
    color: #fff;
    outline: 2px solid rgba(255, 255, 255, .8);
    outline-offset: 2px;
}

.mfg-caption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 8px 10px;
    background: linear-gradient(transparent, rgba(0, 0, 0, .68));
    color: #fff;
    font-size: 13px;
}

.mfg-lightbox[hidden] {
    display: none;
}

.mfg-lightbox {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .9);
    padding: 56px 64px;
}

.mfg-lightbox-stage {
    max-width: 100%;
    max-height: 100%;
    text-align: center;
}

.mfg-lightbox-image {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 130px);
    width: auto;
    height: auto;
    margin: 0 auto;
    object-fit: contain;
    box-shadow: 0 18px 45px rgba(0, 0, 0, .45);
}

.mfg-lightbox-title {
    min-height: 24px;
    margin-top: 10px;
    color: #fff;
    font-size: 14px;
    text-align: center;
}

.mfg-lightbox-close,
.mfg-lightbox-nav,
.mfg-lightbox-action {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: rgba(255, 255, 255, .14);
    color: #fff;
    cursor: pointer;
    text-decoration: none;
}

.mfg-lightbox-close:hover,
.mfg-lightbox-nav:hover,
.mfg-lightbox-action:hover,
.mfg-lightbox-close:focus,
.mfg-lightbox-nav:focus,
.mfg-lightbox-action:focus {
    background: rgba(255, 255, 255, .24);
    color: #fff;
    outline: 2px solid rgba(255, 255, 255, .75);
    outline-offset: 2px;
}

.mfg-lightbox-close {
    top: 16px;
    right: 18px;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    font-size: 34px;
    line-height: 1;
}

.mfg-lightbox-actions {
    position: absolute;
    top: 16px;
    left: 50%;
    right: auto;
    display: flex;
    gap: 12px;
    transform: translateX(-50%);
}

.mfg-lightbox-action {
    position: static;
    width: auto;
    min-width: 104px;
    height: 44px;
    padding: 0 16px;
    border-radius: 999px;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
}

.mfg-lightbox-action .mfg-action-icon {
    font-size: 21px;
    line-height: 1;
}

.mfg-lightbox-action .mfg-action-text {
    font-size: 15px;
    line-height: 1;
}

.mfg-lightbox-nav {
    top: 50%;
    width: 48px;
    height: 70px;
    border-radius: 10px;
    transform: translateY(-50%);
    font-size: 54px;
    line-height: 1;
}

.mfg-lightbox-prev {
    left: 14px;
}

.mfg-lightbox-next {
    right: 14px;
}

body.mfg-lightbox-open {
    overflow: hidden;
}

@media (max-width: 700px) {
    .mfg-gallery {
        --mfg-tile-min: 120px;
        --mfg-gap: 8px;
    }

    .mfg-actions {
        opacity: 1;
        transform: none;
        top: 6px;
        right: 6px;
    }

    .mfg-action-button {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }

    .mfg-lightbox {
        padding: 58px 14px 70px;
    }

    .mfg-lightbox-close {
        top: 8px;
        right: 10px;
        width: 42px;
        height: 42px;
    }

    .mfg-lightbox-actions {
        top: 9px;
        left: 50%;
        right: auto;
        gap: 10px;
        transform: translateX(-50%);
    }

    .mfg-lightbox-action {
        min-width: 96px;
        height: 42px;
        padding: 0 12px;
        gap: 7px;
    }

    .mfg-lightbox-action .mfg-action-icon {
        font-size: 19px;
    }

    .mfg-lightbox-action .mfg-action-text {
        font-size: 14px;
    }

    .mfg-lightbox-image {
        max-height: calc(100vh - 150px);
    }

    .mfg-lightbox-nav {
        top: auto;
        bottom: 12px;
        width: 48px;
        height: 46px;
        transform: none;
        font-size: 44px;
    }

    .mfg-lightbox-prev {
        left: calc(50% - 58px);
    }

    .mfg-lightbox-next {
        right: calc(50% - 58px);
    }
}

/* Version 1.0.7: force modal action labels/icons to stay white, even if the active theme styles links/buttons globally. */
.mfg-lightbox .mfg-lightbox-action,
.mfg-lightbox .mfg-lightbox-action:link,
.mfg-lightbox .mfg-lightbox-action:visited,
.mfg-lightbox .mfg-lightbox-action:hover,
.mfg-lightbox .mfg-lightbox-action:focus,
.mfg-lightbox .mfg-lightbox-action:active,
.mfg-lightbox .mfg-lightbox-action .mfg-action-icon,
.mfg-lightbox .mfg-lightbox-action .mfg-action-text {
    color: #fff !important;
    text-decoration: none !important;
}

.mfg-lightbox .mfg-lightbox-download,
.mfg-lightbox .mfg-lightbox-download:link,
.mfg-lightbox .mfg-lightbox-download:visited,
.mfg-lightbox .mfg-lightbox-download:hover,
.mfg-lightbox .mfg-lightbox-download:focus,
.mfg-lightbox .mfg-lightbox-download:active,
.mfg-lightbox .mfg-lightbox-download .mfg-action-icon,
.mfg-lightbox .mfg-lightbox-download .mfg-action-text {
    color: #fff !important;
    fill: #fff !important;
    stroke: #fff !important;
    text-decoration: none !important;
}


/* Version 1.0.8: keep thumbnail action buttons visible on desktop and mobile. */
.mfg-gallery .mfg-actions {
    opacity: 1 !important;
    transform: none !important;
}

/* Version 1.0.8: force all action button text/icons white against dark button backgrounds. */
.mfg-gallery .mfg-action-button,
.mfg-gallery .mfg-action-button:link,
.mfg-gallery .mfg-action-button:visited,
.mfg-gallery .mfg-action-button:hover,
.mfg-gallery .mfg-action-button:focus,
.mfg-gallery .mfg-action-button:active,
.mfg-gallery .mfg-action-button *,
.mfg-gallery .mfg-lightbox-action,
.mfg-gallery .mfg-lightbox-action:link,
.mfg-gallery .mfg-lightbox-action:visited,
.mfg-gallery .mfg-lightbox-action:hover,
.mfg-gallery .mfg-lightbox-action:focus,
.mfg-gallery .mfg-lightbox-action:active,
.mfg-gallery .mfg-lightbox-action *,
.mfg-gallery .mfg-lightbox a.mfg-lightbox-download,
.mfg-gallery .mfg-lightbox a.mfg-lightbox-download:link,
.mfg-gallery .mfg-lightbox a.mfg-lightbox-download:visited,
.mfg-gallery .mfg-lightbox a.mfg-lightbox-download:hover,
.mfg-gallery .mfg-lightbox a.mfg-lightbox-download:focus,
.mfg-gallery .mfg-lightbox a.mfg-lightbox-download:active,
.mfg-gallery .mfg-lightbox a.mfg-lightbox-download *,
.mfg-gallery .mfg-lightbox-download .mfg-action-icon,
.mfg-gallery .mfg-lightbox-download .mfg-action-text {
    color: #fff !important;
    -webkit-text-fill-color: #fff !important;
    fill: #fff !important;
    stroke: #fff !important;
    text-decoration: none !important;
}
