/*
Source: https://www.bram.us/2020/07/28/simple-image-gallery-with-display-grid-and-object-fit-cover/
*/

* {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

html {
	scroll-behavior: smooth;
}

ul.gallery {
	--numcolumns: 4;
	--gap: calc((min(100vw, 1000px) - 100px) / 450);
	--size: calc((min(100vw, 1000px) - 100px) / var(--numcolumns));
	display: grid;
	grid-template-columns: repeat(var(--numcolumns), 1fr);
	
	grid-template-rows: auto;
	gap: var(--gap);
	align-items: stretch;
	
	list-style: none;
}

@media screen and (max-width: 799px) {
    ul.gallery {
        --gap: 1px;
        --size: calc((100vw - 20px) / var(--numcolumns));
        gap: var(--gap);
    }
}

ul.gallery > li {
	display: block;
	height: calc(var(--size) - var(--gap));
	position: relative;
}

ul.gallery > li.w2h1 {
	grid-column: span 2;
}

ul.gallery > li.w3h1 {
	grid-column: span 3;
}

ul.gallery > li.w1h2 {
	grid-row: span 2;
	height: calc(2 * var(--size) - var(--gap));
}

ul.gallery > li > a.zoomout {
	display: none;
}

ul.gallery > li > a,
ul.gallery > li > a > img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
    border-radius: 0;
}

/* ul.gallery > li > a.zoomin:focus::after, */
ul.gallery > li > a.zoomin:hover::after {
	content: '';
	display: block;
	background: rgba(255, 255, 255, 0.2);
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	z-index: 10;
}

/* Show zoom out (close) link when the tile is targeted */
ul.gallery > li:target > a.zoomout {
	display: block;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	position: fixed;
	z-index: 12;
}

/* Stretch out the image */
ul.gallery > li > a.zoomout > img {
	object-fit: contain;
	padding: 1vw;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	position: fixed;
	z-index: 11;
	background: black;
}

pic-caption {
    position: absolute;
    bottom: 2em;
    padding-left: 2em;
    padding-right: 2em;
    height: 3em;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    z-index: 12;
    display: grid;
    justify-items: left;
    align-items: center;
}

@media screen and (max-width: 799px) {
    pic-caption {
        bottom: 0.5em;
        padding-left: 0.5em;
        padding-right: 0.5em;
        height: 2.6em;
        font-size: 0.8em;
    }
}