/**
 * Meridian Sections — Gallery
 *
 * Figma 13:8904. A bento grid: one tall photograph in the middle column with
 * pairs of smaller ones either side.
 *
 * Cells are .md-media-cell from sections.css, shared with the Mosaic List; this
 * file is only the arrangement.
 */

.md-section.md-gallery {
	padding-block: var(--md-section-pt, 2.8125rem) var(--md-section-pb, 2.8125rem);
	background-color: var(--md-white, #fff);
}

.md-gallery--ruled {
	border-block-end: var(--md-border-width, 1px) solid
		var(--md-color-rule, #ebebeb);
}

.md-gallery__grid {
	display: grid;
	gap: var(--md-gallery-gap, 0.75rem); /* 12px */
	/* Two columns until there is room for the bento. */
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

/*
 * 302.64 × 284 in the comp. Stated on the cells rather than as one ratio on the
 * grid, so the arrangement holds at any row count — the feature stretches to
 * whatever the rows add up to.
 */
.md-gallery__cell {
	aspect-ratio: 302.64 / 284;
}

/*
 * The feature is a different shape entirely (423.71 × 580), so it must not
 * inherit the side cells' ratio. Until the bento kicks in it runs full width as
 * a banner.
 */
.md-gallery__cell--feature {
	grid-column: 1 / -1;
	aspect-ratio: 16 / 10;
}

/* --- Bento -------------------------------------------------------------- */
@media (min-width: 62em) {
	.md-gallery__grid {
		/*
		 * 302.64 : 423.71 : 302.65 is exactly 5 : 7 : 5 — the middle column is
		 * 1.4× the outer ones.
		 */
		grid-template-columns: 5fr 7fr 5fr;
		grid-template-rows: repeat(var(--md-gallery-rows, 2), auto);
		/*
		 * Fill the left column top-to-bottom, then the right, as the comp is
		 * structured. The middle column is fully occupied by the feature, so
		 * auto-placement steps over it.
		 */
		grid-auto-flow: column;
	}

	.md-gallery__cell--feature {
		grid-column: 2;
		grid-row: 1 / -1;
		aspect-ratio: auto;
	}
}

/* One up on a phone: two 300px-wide cells side by side is not a gallery. */
@media (max-width: 35.9375em) {
	.md-gallery__grid {
		grid-template-columns: minmax(0, 1fr);
	}

	.md-gallery__cell--feature {
		aspect-ratio: 4 / 3;
	}
}

.md-gallery__notice {
	margin: 0;
	padding: var(--md-space-md, 1.5rem);
	border: var(--md-border-width, 1px) dashed var(--md-color-border, #d9dde3);
	border-radius: var(--md-radius-md, 0.5rem);
	color: var(--md-color-text-muted, rgba(10, 22, 40, 0.7));
	text-align: center;
}
