/**
 * @file
 * Grid component.
 *
 * A view's rows in columns. The column count comes from the modifier class
 * (viewspress-grid--columns-1 to -6), never from inline styles. Small screens
 * get fewer columns: at most 2 below 782px and 1 below 600px.
 *
 * A masonry grid (viewspress-grid--masonry, from 0.6.0) packs items of
 * different heights into its columns, each in the shortest column in the
 * markup's order: with display: grid-lanes where the browser has it, and
 * elsewhere through view-masonry.js, which marks the grid with
 * data-viewspress-packed and writes each item's grid-row-end span on fine
 * rows. Without either, it is the plain grid.
 *
 * Contents:
 * 1. Grid
 * 2. Items
 * 3. Masonry
 * 4. Media queries
 */

/* 1. Grid
   ========================================================================== */

.viewspress-grid {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--viewspress-gap, var(--wp--custom--viewspress--gap, 1.5em));
	margin: 0;
	padding: 0;
	list-style: none;
}

/* End of 1. Grid */

/* 2. Items
   ========================================================================== */

.viewspress-grid .viewspress-grid__item {
	min-width: 0;
	padding: 0;
	border-bottom: 0;
}

/* End of 2. Items */

/* 3. Masonry
   ========================================================================== */

@supports (display: grid-lanes) {
	.viewspress-grid--masonry {
		display: grid-lanes;
	}
}

/* The script's fine rows: each item spans its height and the gap below it. */
.viewspress-grid--masonry[data-viewspress-packed] {
	grid-auto-rows: 4px;
	row-gap: 0;
	align-items: start;
}

/* End of 3. Masonry */

/* 4. Media queries
   ========================================================================== */

@media (min-width: 600px) {
	.viewspress-grid--columns-2,
	.viewspress-grid--columns-3,
	.viewspress-grid--columns-4,
	.viewspress-grid--columns-5,
	.viewspress-grid--columns-6 {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (min-width: 782px) {
	.viewspress-grid--columns-3 {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}

	.viewspress-grid--columns-4 {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}

	.viewspress-grid--columns-5 {
		grid-template-columns: repeat(5, minmax(0, 1fr));
	}

	.viewspress-grid--columns-6 {
		grid-template-columns: repeat(6, minmax(0, 1fr));
	}
}

/* End of 4. Media queries */
