
/* =========================================================
   M.A. MEDIA GALLERY
   Clean CSS - Grid, Masonry, Filters, Hover and Lightbox
   ========================================================= */

/* -------------------------
   MAIN GALLERY VARIABLES
-------------------------- */

.ma-gallery {
    --ma-columns: 3;
    --ma-tablet-columns: 2;
    --ma-mobile-columns: 2;

    --ma-column-gap: 15px;
    --ma-tablet-column-gap: 15px;
    --ma-mobile-column-gap: 10px;

    --ma-row-gap: 15px;
    --ma-tablet-row-gap: 15px;
    --ma-mobile-row-gap: 10px;

    --ma-image-height: 250px;
    --ma-object-fit: cover;
    --ma-filter-gap: 10px;

    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.ma-gallery *,
.ma-gallery *::before,
.ma-gallery *::after {
    box-sizing: border-box;
}

/* =========================================================
   FILTER TOOLBAR
========================================================= */

.ma-gallery-toolbar {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 12px;
    margin-bottom: 20px;
}

.ma-gallery-filters {
    display: flex;
    align-items: stretch;
    flex-wrap: wrap;
    gap: var(--ma-filter-gap);
    width: 100%;
}

.ma-gallery-filters button {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-width: 0;
    margin: 0;
    padding: 9px 18px;

    border: 1px solid #222;
    border-radius: 3px;

    background: transparent;
    color: #222;

    font: inherit;
    line-height: 1.35;
    text-align: center;

    cursor: pointer;

    transition:
        background-color .25s ease,
        color .25s ease,
        border-color .25s ease;

    transform: none !important;
}

.ma-gallery-filters button:hover,
.ma-gallery-filters button[aria-pressed="true"] {
    transform: none !important;
}

.ma-gallery-filters button:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 3px;
}

/* Automatic filter width */

.ma-gallery-filter-width-auto .ma-gallery-filters {
    justify-content: flex-start;
}

.ma-gallery-filter-width-auto .ma-gallery-filters button {
    flex: 0 0 auto;
}

/* Equal-width filter buttons */

.ma-gallery-filter-width-equal .ma-gallery-filters,
.ma-gallery-filter-width-full .ma-gallery-filters {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    width: 100%;
}

.ma-gallery-filter-width-equal .ma-gallery-filters button,
.ma-gallery-filter-width-full .ma-gallery-filters button {
    width: 100%;
    min-width: 0;
}

/* =========================================================
   GALLERY GRID
   IMPORTANT:
   Both Grid and Masonry use CSS Grid.
   Do not use column-count or column-fill here.
========================================================= */

.ma-gallery .ma-gallery-grid,
.ma-gallery.ma-gallery-layout-grid .ma-gallery-grid,
.ma-gallery.ma-gallery-layout-masonry .ma-gallery-grid {
    display: grid !important;

    grid-template-columns:
        repeat(var(--ma-columns, 3), minmax(0, 1fr)) !important;

    grid-auto-flow: row !important;
    grid-auto-rows: auto !important;

    column-gap: var(--ma-column-gap, 15px) !important;
    row-gap: var(--ma-row-gap, 15px) !important;

    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;

    margin: 0 !important;
    padding: 0 !important;

    align-items: start !important;

    column-count: initial !important;
    column-width: initial !important;
    column-fill: initial !important;
}

/* Individual gallery items */

.ma-gallery .ma-gallery-grid > .ma-gallery-item {
    display: block !important;

    position: relative !important;

    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;

    height: auto !important;

    margin: 0 !important;
    padding: 0 !important;

    overflow: hidden;

    background: transparent;

    break-inside: auto !important;

    opacity: 1;

    transition: opacity .25s ease;
}

/* Filtered items */

.ma-gallery .ma-gallery-item[hidden] {
    display: none !important;
}

.ma-gallery .ma-gallery-item-leaving {
    opacity: 0 !important;
    pointer-events: none;
}

.ma-gallery .ma-gallery-item-entering {
    opacity: 0;
}

/* =========================================================
   IMAGE AND VIDEO THUMBNAILS
========================================================= */

.ma-gallery-open {
    appearance: none;

    display: block;
    position: relative;

    width: 100% !important;
    max-width: 100% !important;

    height: auto;

    margin: 0;
    padding: 0;

    overflow: hidden;

    border: 0;
    border-radius: inherit;

    background: #f4f4f4;

    cursor: pointer;

    text-align: inherit;
    line-height: 0;
}

/* Images and videos share the same thumbnail dimensions */

.ma-gallery .ma-gallery-open img,
.ma-gallery .ma-gallery-video video {
    display: block;

    width: 100% !important;
    max-width: 100% !important;

    height: var(--ma-image-height, 250px);

    margin: 0;

    object-fit: var(--ma-object-fit, cover);

    transition:
        transform .55s cubic-bezier(.2, .7, .2, 1),
        filter .55s ease;

    will-change: transform;
}

/* Video wrapper */

.ma-gallery-video {
    display: block;
    position: relative;

    width: 100%;
    min-width: 0;

    overflow: hidden;
    background: #111;
}

.ma-gallery-video video {
    background: #111;
}

/* Smooth image zoom */

.ma-gallery .ma-gallery-open:hover img {
    transform: scale(1.06);
}

/* Smooth video zoom */

.ma-gallery .ma-gallery-open:hover .ma-gallery-video video,
.ma-gallery .ma-gallery-open:hover video {
    transform: scale(1.06);
}

/* =========================================================
   THUMBNAIL ASPECT RATIOS
========================================================= */

.ma-gallery-ratio-1-1 .ma-gallery-open img,
.ma-gallery-ratio-1-1 .ma-gallery-video video {
    aspect-ratio: 1 / 1;
    height: auto;
}

.ma-gallery-ratio-4-3 .ma-gallery-open img,
.ma-gallery-ratio-4-3 .ma-gallery-video video {
    aspect-ratio: 4 / 3;
    height: auto;
}

.ma-gallery-ratio-3-2 .ma-gallery-open img,
.ma-gallery-ratio-3-2 .ma-gallery-video video {
    aspect-ratio: 3 / 2;
    height: auto;
}

.ma-gallery-ratio-16-9 .ma-gallery-open img,
.ma-gallery-ratio-16-9 .ma-gallery-video video {
    aspect-ratio: 16 / 9;
    height: auto;
}

.ma-gallery-ratio-3-4 .ma-gallery-open img,
.ma-gallery-ratio-3-4 .ma-gallery-video video {
    aspect-ratio: 3 / 4;
    height: auto;
}

.ma-gallery-ratio-auto .ma-gallery-open img,
.ma-gallery-ratio-auto .ma-gallery-video video {
    height: var(--ma-image-height, 250px);
}

/* =========================================================
   VIDEO PLAY ICON
========================================================= */

.ma-gallery-play {
    position: absolute;

    top: 50%;
    left: 50%;

    z-index: 2;

    display: flex;
    align-items: center;
    justify-content: center;

    width: 58px;
    height: 58px;

    transform: translate(-50%, -50%);

    border-radius: 50%;

    background: rgba(0, 0, 0, .72);
    color: #fff;

    pointer-events: none;

    transition:
        background-color .3s ease,
        color .3s ease,
        transform .3s ease;
}

.ma-gallery-play span {
    display: block;

    width: 0;
    height: 0;

    margin-left: 5px;

    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    border-left: 15px solid currentColor;
}

/* Play icon hover */

.ma-gallery-open:hover .ma-gallery-play {
    transform: translate(-50%, -50%) scale(1.12);
}

/* =========================================================
   CAPTIONS
========================================================= */

.ma-gallery-caption {
    display: block;

    width: 100%;

    padding: 10px 0;

    color: #222;

    font-size: 14px;
    line-height: 1.5;

    overflow-wrap: anywhere;
}

/* =========================================================
   EMPTY GALLERY
========================================================= */

.ma-gallery-no-results {
    display: block;
    width: 100%;
}

.ma-gallery-no-results[hidden] {
    display: none !important;
}

.ma-gallery-empty {
    padding: 20px;
    background: #f5f5f5;
}

/* =========================================================
   VIEW ALL VIDEOS BUTTON
========================================================= */

.ma-gallery-view-all-wrap {
    display: flex;
    width: 100%;
    margin-top: 28px;
}

.ma-gallery-view-all-left {
    justify-content: flex-start;
}

.ma-gallery-view-all-center {
    justify-content: center;
}

.ma-gallery-view-all-right {
    justify-content: flex-end;
}

.ma-gallery-view-all-videos {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-height: 46px;

    padding: 12px 28px;

    border: 1px solid #222;
    border-radius: 3px;

    background: #222;
    color: #fff;

    font: inherit;
    line-height: 1.3;
    text-align: center;
    text-decoration: none !important;

    cursor: pointer;

    transition:
        background-color .25s ease,
        color .25s ease,
        border-color .25s ease;
}

.ma-gallery-view-all-videos:hover {
    background: #444;
    border-color: #444;
    color: #fff;
}

/* =========================================================
   PAGINATION
========================================================= */

.ma-gallery-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;

    width: 100%;
    margin-top: 30px;
}

.ma-gallery-pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-width: 38px;
    min-height: 38px;

    padding: 8px 12px;

    border: 1px solid #ddd;
    border-radius: 3px;

    color: #222;
    text-decoration: none;

    transition:
        color .2s ease,
        background-color .2s ease,
        border-color .2s ease;
}

.ma-gallery-pagination .page-numbers:hover,
.ma-gallery-pagination .page-numbers.current {
    background: #222;
    border-color: #222;
    color: #fff;
}

/* =========================================================
   LIGHTBOX
========================================================= */

.ma-gallery-lightbox {
    display: none;

    position: fixed;
    inset: 0;

    z-index: 999999;

    align-items: center;
    justify-content: center;

    padding: 30px;

    background: rgba(0, 0, 0, .92);
}

.ma-gallery-lightbox.is-open {
    display: flex;
}

.ma-gallery-lightbox-content {
    display: flex;
    align-items: center;
    justify-content: center;

    max-width: 100%;
    max-height: 100%;
}

.ma-gallery-lightbox-content img,
.ma-gallery-lightbox-content video {
    display: block;

    width: auto;
    height: auto;

    max-width: 90vw;
    max-height: 85vh;

    object-fit: contain;
}

.ma-gallery-close {
    position: absolute;

    top: 16px;
    right: 24px;

    z-index: 2;

    width: 44px;
    height: 44px;

    padding: 0;

    border: 0;

    background: transparent;
    color: #fff;

    font-size: 38px;
    line-height: 1;

    cursor: pointer;
}

/* =========================================================
   TABLET RESPONSIVE
========================================================= */

@media (max-width: 1024px) {

    .ma-gallery .ma-gallery-grid,
    .ma-gallery.ma-gallery-layout-grid .ma-gallery-grid,
    .ma-gallery.ma-gallery-layout-masonry .ma-gallery-grid {
        grid-template-columns:
            repeat(var(--ma-tablet-columns, 2), minmax(0, 1fr)) !important;

        column-gap: var(--ma-tablet-column-gap, 15px) !important;
        row-gap: var(--ma-tablet-row-gap, 15px) !important;

        display: grid !important;

        column-count: initial !important;
        column-width: initial !important;
        column-fill: initial !important;
    }
}

/* =========================================================
   MOBILE RESPONSIVE
========================================================= */

@media (max-width: 767px) {

    .ma-gallery .ma-gallery-grid,
    .ma-gallery.ma-gallery-layout-grid .ma-gallery-grid,
    .ma-gallery.ma-gallery-layout-masonry .ma-gallery-grid {
        grid-template-columns:
            repeat(var(--ma-mobile-columns, 2), minmax(0, 1fr)) !important;

        column-gap: var(--ma-mobile-column-gap, 10px) !important;
        row-gap: var(--ma-mobile-row-gap, 10px) !important;

        display: grid !important;

        column-count: initial !important;
        column-width: initial !important;
        column-fill: initial !important;
    }

    .ma-gallery-filters button {
        padding: 8px 12px;
    }

    .ma-gallery-lightbox {
        padding: 16px;
    }

    .ma-gallery-close {
        top: 8px;
        right: 10px;
    }

    .ma-gallery-view-all-wrap {
        margin-top: 22px;
    }
}

/* =========================================================
   REDUCED MOTION
========================================================= */

@media (prefers-reduced-motion: reduce) {

    .ma-gallery *,
    .ma-gallery *::before,
    .ma-gallery *::after {
        transition: none !important;
        animation: none !important;
        scroll-behavior: auto !important;
    }
}
