/* Scope EVERYTHING to the widget wrapper so it doesn't affect the whole site */
.ca-project-gallery {
    width: 100%;
}

/* Do NOT style body globally inside a widget */
.ca-project-gallery a {
    text-decoration: none;
    color: inherit;
}

.ca-project-gallery .gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    grid-gap: 1rem;
    grid-auto-rows: 300px;
    grid-auto-flow: dense;
    list-style-type: none;
    padding: 0;
    margin: 0 0 20px 0;
}

.ca-project-gallery .gallery li figure {
    margin: 0;
    width: 100%;
    height: 100%;
    position: relative;
}

/* wide/tall helpers (same idea as CodePen) */
.ca-project-gallery .gallery li.wide { grid-column: span 2; }
.ca-project-gallery .gallery li.tall { grid-row: span 2; }

.ca-project-gallery .gallery img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

/* Filter effect */
.ca-project-gallery .gallery.filter img {
    transition: filter .3s ease-in-out;
    filter: grayscale(100%);
}
.ca-project-gallery .gallery.filter img:hover {
    filter: none;
}

/* Zoom effect */
.ca-project-gallery .gallery.zoom li { overflow: hidden; }
.ca-project-gallery .gallery.zoom img {
    transform: scale(1);
    transition: transform .3s ease-in-out;
}
.ca-project-gallery .gallery.zoom img:hover {
    transform: scale(1.2);
}

/* Caption 1 */
.ca-project-gallery .gallery.caption-1 figure figcaption {
    position: absolute;
    top: 0;
    left: 0;
    background: #fff;
    width: calc(100% - 2rem);
    height: calc(100% - 2rem);
    margin: 1rem;
    text-align: center;
    display: grid;
    align-content: center;
    opacity: 0;
    transform: scale(.95);
    transition: opacity .3s ease-in-out, transform .3s ease-in-out;
    pointer-events: none;
}
.ca-project-gallery .gallery.caption-1 figure h1 {
    margin: 0;
    font-size: 21px;
    color: rgba(0,0,0,.75);
}
.ca-project-gallery .gallery.caption-1 figure p {
    font-size: 13px;
    font-style: italic;
    color: rgba(0,0,0,.4);
}
.ca-project-gallery .gallery.caption-1 figure:hover figcaption {
    opacity: .9;
    transform: scale(1);
}

/* Caption 2 */
.ca-project-gallery .gallery.caption-2 figure { overflow: hidden; }
.ca-project-gallery .gallery.caption-2 img {
    filter: invert(25%);
    transform: scale(1.2);
    transition: all .3s ease-in-out;
}
.ca-project-gallery .gallery.caption-2 figure figcaption {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: grid;
    align-content: end;
    color: #fff;
    text-shadow: 1px 1px 3px rgba(0,0,0,.5);
    padding-left: 2rem;
    transform: translate3d(0, 1rem, 0);
    opacity: 0;
    transition: transform .3s ease-in-out, opacity .3s ease-in-out;
    pointer-events: none;
}
.ca-project-gallery .gallery.caption-2 figure h1 {
    margin: 0;
    font-size: 21px;
}
.ca-project-gallery .gallery.caption-2 figure p {
    font-size: 13px;
    margin-bottom: 2rem;
}
.ca-project-gallery .gallery.caption-2 figure:hover img {
    filter: none;
    transform: scale(1);
}
.ca-project-gallery .gallery.caption-2 figure:hover figcaption {
    transform: translate3d(0, 0, 0);
    opacity: 1;
}

/* Caption 3 */
.ca-project-gallery .gallery.caption-3 li figure { overflow: hidden; }
.ca-project-gallery .gallery.caption-3 li img {
    transform: scale(1.2);
    transition: transform .3s ease-in-out;
}
.ca-project-gallery .gallery.caption-3 figure figcaption {
    position: absolute;
    top: 5%;
    left: 5%;
    width: 90%;
    height: 90%;
    display: grid;
    align-content: center;
    text-align: center;
    border: 1px solid #fff;
    color: #fff;
    text-shadow: 1px 1px 3px rgba(0,0,0,.3);
    transform: scale(1.2);
    transition: all .3s ease-in-out;
    pointer-events: none;
}
.ca-project-gallery .gallery.caption-3 figure h1,
.ca-project-gallery .gallery.caption-3 figure p {
    opacity: 0;
    transition: all .4s;
}
.ca-project-gallery .gallery.caption-3 figure h1 {
    margin: 0;
    font-size: 21px;
    transform: translate3d(0, -1rem, 0);
}
.ca-project-gallery .gallery.caption-3 figure p {
    font-size: 13px;
    transform: translate3d(0, 1rem, 0);
}
.ca-project-gallery .gallery.caption-3 figure:hover img {
    filter: grayscale(100%);
    transform: scale(1);
}
.ca-project-gallery .gallery.caption-3 figure:hover figcaption {
    transform: scale(1);
}
.ca-project-gallery .gallery.caption-3 figure:hover h1,
.ca-project-gallery .gallery.caption-3 figure:hover p {
    opacity: 1;
    transform: none;
}
.ca-project-gallery .gallery{
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(var(--ca-min-width), 1fr));
    gap: 1rem;

    /* IMPORTANT: stop forcing row height */
    grid-auto-rows: auto;
}

.ca-project-gallery .gallery li{
    /* Put the aspect ratio on the grid item (the tile) */
    aspect-ratio: var(--ca-aspect-ratio);
    overflow: hidden;
}

.ca-project-gallery .gallery li figure,
.ca-project-gallery .gallery li a,
.ca-project-gallery .gallery li img{
    width: 100%;
    height: 100%;
}

.ca-project-gallery .gallery li img{
    object-fit: cover;
    display: block;
}
.ca-project-gallery .gallery{
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(var(--ca-min-width), 1fr));
    gap: 1rem;
    grid-auto-rows: auto; /* important */
}

.ca-project-gallery .gallery > li{
    aspect-ratio: var(--ca-aspect-ratio);
    overflow: hidden;
}

.ca-project-gallery .gallery > li > figure,
.ca-project-gallery .gallery > li > figure > a,
.ca-project-gallery .gallery > li > figure > a > img{
    width: 100%;
    height: 100%;
    display: block;
}