/* Governed CC4/CC5 structure for native Post Template and Gallery layouts. */
:where(.has-nexus-collection-profile),
:where(.nexus-collection-editor .wp-block-post-template),
:where(.nexus-collection-editor.wp-block-post-template) {
	--nexus-collection-min: 18rem;
	--nexus-collection-column-gap: var(--nexus-space-md, 1rem);
	--nexus-collection-row-gap: var(--nexus-space-md, 1rem);
	display: grid;
	box-sizing: border-box;
	min-width: 0;
	max-width: 100%;
	column-gap: var(--nexus-collection-column-gap);
	row-gap: var(--nexus-collection-row-gap);
	list-style: none;
}

:where(.nexus-collection--list),
:where(.nexus-collection-editor--list .wp-block-post-template),
:where(.nexus-collection-editor--list.wp-block-post-template) {
	grid-template-columns: minmax(0, 1fr);
}

:where(.nexus-collection--alternating),
:where(.nexus-collection-editor--alternating .wp-block-post-template),
:where(.nexus-collection-editor--alternating.wp-block-post-template) {
	grid-template-columns: minmax(0, 1fr);
}

:where(.nexus-collection--alternating) > * {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	grid-template-areas: "media" "content";
	column-gap: var(--nexus-collection-column-gap);
	row-gap: var(--nexus-collection-row-gap);
	align-items: center;
}

:where(.nexus-collection-editor--alternating .wp-block-post-template),
:where(.nexus-collection-editor--alternating.wp-block-post-template) {
	grid-template-areas: "media" "content";
	align-items: center;
}

:where(.nexus-collection--alternating) > * > .wp-block-post-featured-image,
:where(.nexus-collection-editor--alternating .wp-block-post-template) > .wp-block-post-featured-image,
:where(.nexus-collection-editor--alternating.wp-block-post-template) > .wp-block-post-featured-image { grid-area: media; }

:where(.nexus-collection--alternating) > * > .wp-block-group,
:where(.nexus-collection-editor--alternating .wp-block-post-template) > .wp-block-group,
:where(.nexus-collection-editor--alternating.wp-block-post-template) > .wp-block-group { grid-area: content; }

@media (min-width: 48rem) {
	:where(.nexus-collection--alternating) > *,
	:where(.nexus-collection-editor--alternating .wp-block-post-template),
	:where(.nexus-collection-editor--alternating.wp-block-post-template) {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		grid-template-areas: "media content";
	}
	:where(.nexus-collection--alternating) > :nth-child(even) {
		grid-template-areas: "content media";
	}
}

:where(.nexus-collection--responsive-grid, .nexus-collection--compact-grid, .nexus-collection--editorial-grid, .nexus-collection--masonry),
:where(.nexus-collection-editor--responsive-grid .wp-block-post-template, .nexus-collection-editor--compact-grid .wp-block-post-template, .nexus-collection-editor--editorial-grid .wp-block-post-template, .nexus-collection-editor--masonry .wp-block-post-template),
:where(.nexus-collection-editor--responsive-grid.wp-block-post-template, .nexus-collection-editor--compact-grid.wp-block-post-template, .nexus-collection-editor--editorial-grid.wp-block-post-template, .nexus-collection-editor--masonry.wp-block-post-template) {
	grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--nexus-collection-min)), 1fr));
}

.wp-block-gallery.has-nexus-gallery-profile,
.nexus-gallery-editor--masonry .wp-block-gallery,
.wp-block-gallery.nexus-gallery-editor--masonry {
	--nexus-gallery-columns: 3;
	display: grid;
	grid-template-columns: repeat(var(--nexus-gallery-columns), minmax(0, 1fr));
	box-sizing: border-box;
	min-width: 0;
	max-width: 100%;
	list-style: none;
}

.wp-block-gallery:where(.has-nexus-gallery-profile, .nexus-gallery-editor--masonry).columns-1,
.nexus-gallery-editor--masonry .wp-block-gallery.columns-1 { --nexus-gallery-columns: 1; }
.wp-block-gallery:where(.has-nexus-gallery-profile, .nexus-gallery-editor--masonry).columns-2,
.nexus-gallery-editor--masonry .wp-block-gallery.columns-2 { --nexus-gallery-columns: 2; }
.wp-block-gallery:where(.has-nexus-gallery-profile, .nexus-gallery-editor--masonry).columns-3,
.nexus-gallery-editor--masonry .wp-block-gallery.columns-3 { --nexus-gallery-columns: 3; }
.wp-block-gallery:where(.has-nexus-gallery-profile, .nexus-gallery-editor--masonry).columns-4,
.nexus-gallery-editor--masonry .wp-block-gallery.columns-4 { --nexus-gallery-columns: 4; }
.wp-block-gallery:where(.has-nexus-gallery-profile, .nexus-gallery-editor--masonry).columns-5,
.nexus-gallery-editor--masonry .wp-block-gallery.columns-5 { --nexus-gallery-columns: 5; }
.wp-block-gallery:where(.has-nexus-gallery-profile, .nexus-gallery-editor--masonry).columns-6,
.nexus-gallery-editor--masonry .wp-block-gallery.columns-6 { --nexus-gallery-columns: 6; }
.wp-block-gallery:where(.has-nexus-gallery-profile, .nexus-gallery-editor--masonry).columns-7,
.nexus-gallery-editor--masonry .wp-block-gallery.columns-7 { --nexus-gallery-columns: 7; }
.wp-block-gallery:where(.has-nexus-gallery-profile, .nexus-gallery-editor--masonry).columns-8,
.nexus-gallery-editor--masonry .wp-block-gallery.columns-8 { --nexus-gallery-columns: 8; }

:where(.nexus-collection-min--compact) { --nexus-collection-min: 14rem; }
:where(.nexus-collection-min--standard) { --nexus-collection-min: 18rem; }
:where(.nexus-collection-min--wide) { --nexus-collection-min: 24rem; }
:where(.nexus-collection-column-gap--none) { --nexus-collection-column-gap: 0; }
:where(.nexus-collection-column-gap--xs) { --nexus-collection-column-gap: var(--nexus-space-xs, .5rem); }
:where(.nexus-collection-column-gap--sm) { --nexus-collection-column-gap: var(--nexus-space-sm, .75rem); }
:where(.nexus-collection-column-gap--md) { --nexus-collection-column-gap: var(--nexus-space-md, 1rem); }
:where(.nexus-collection-column-gap--lg) { --nexus-collection-column-gap: var(--nexus-space-lg, 1.5rem); }
:where(.nexus-collection-row-gap--none) { --nexus-collection-row-gap: 0; }
:where(.nexus-collection-row-gap--xs) { --nexus-collection-row-gap: var(--nexus-space-xs, .5rem); }
:where(.nexus-collection-row-gap--sm) { --nexus-collection-row-gap: var(--nexus-space-sm, .75rem); }
:where(.nexus-collection-row-gap--md) { --nexus-collection-row-gap: var(--nexus-space-md, 1rem); }
:where(.nexus-collection-row-gap--lg) { --nexus-collection-row-gap: var(--nexus-space-lg, 1.5rem); }
:where(.nexus-collection-align--start) { align-items: start; }
:where(.nexus-collection-align--center) { align-items: center; }
:where(.nexus-collection-align--stretch) { align-items: stretch; }

:where(.has-nexus-collection-profile, .nexus-collection-editor) > * {
	box-sizing: border-box;
	min-width: 0;
	max-width: 100%;
}

:where(.has-nexus-collection-profile, .nexus-collection-editor) img,
:where(.has-nexus-collection-profile, .nexus-collection-editor) video {
	max-width: 100%;
	height: auto;
}

:where(.has-nexus-gallery-profile, .nexus-gallery-editor--masonry) > *,
:where(.nexus-gallery-editor--masonry .wp-block-gallery) > * {
	box-sizing: border-box;
	width: 100%;
	min-width: 0;
	max-width: 100%;
	margin-block: 0;
}

:where(.has-nexus-gallery-profile, .nexus-gallery-editor--masonry) img,
:where(.nexus-gallery-editor--masonry .wp-block-gallery) img {
	display: block;
	width: 100%;
	max-width: 100%;
	height: auto;
}

:where(.is-nexus-equal-height) > * { height: 100%; }
:where(.is-nexus-equal-height) > * > .wp-block-group { height: 100%; }

/*
 * Grid Lanes is enhancement-only. Browsers without the Level 3 display value
 * ignore this block and keep the complete source-ordered Grid above.
 */
@supports (display: grid-lanes) {
	:where(.nexus-collection--masonry),
	:where(.nexus-collection-editor--masonry .wp-block-post-template),
	:where(.nexus-collection-editor--masonry.wp-block-post-template),
	.wp-block-gallery.has-nexus-gallery-profile,
	.nexus-gallery-editor--masonry .wp-block-gallery,
	.wp-block-gallery.nexus-gallery-editor--masonry {
		display: grid-lanes;
		flow-tolerance: normal;
	}
}

@media (min-width: 64rem) {
	:where(.nexus-collection--editorial-grid),
	:where(.nexus-collection-editor--editorial-grid .wp-block-post-template),
	:where(.nexus-collection-editor--editorial-grid.wp-block-post-template) {
		grid-template-columns: repeat(12, minmax(0, 1fr));
	}
	:where(.nexus-collection--editorial-grid) > *,
	:where(.nexus-collection-editor--editorial-grid .wp-block-post-template) > *,
	:where(.nexus-collection-editor--editorial-grid.wp-block-post-template) > * {
		grid-column: span 4;
	}
	:where(.nexus-collection--editorial-grid) > :first-child,
	:where(.nexus-collection-editor--editorial-grid .wp-block-post-template) > :first-child,
	:where(.nexus-collection-editor--editorial-grid.wp-block-post-template) > :first-child {
		grid-column: span 8;
	}
}

@media (max-width: 36rem) {
	:where(.has-nexus-collection-profile),
	:where(.nexus-collection-editor .wp-block-post-template),
	:where(.nexus-collection-editor.wp-block-post-template),
	.wp-block-gallery.has-nexus-gallery-profile,
	.nexus-gallery-editor--masonry .wp-block-gallery,
	.wp-block-gallery.nexus-gallery-editor--masonry {
		grid-template-columns: minmax(0, 1fr);
	}
	:where(.nexus-collection--editorial-grid) > :first-child,
	:where(.nexus-collection-editor--editorial-grid .wp-block-post-template) > :first-child,
	:where(.nexus-collection-editor--editorial-grid.wp-block-post-template) > :first-child {
		grid-column: auto;
	}
}
