/* Keep the two zones side by side while allowing each zone to manage its own
 * background, padding and nested blocks. */
.wp-block-lpu-split-section {
	display: grid;
	grid-template-columns: repeat( 2, minmax( 0, 1fr ) );
	align-items: stretch;
	gap: 0;
	/* Use the section's width even in a narrower Gutenberg canvas. */
	container-type: inline-size;
	/* The sections that have the full-width option set must take the entire
     * horizontal space. To do that WordPress uses negative left-right margins.
     * It allows those sections to extend into the page's left and right padding.
     * Keep the width automatic so the section expands to fill that extra space.
     */
	width: auto;
}

/* Use half the section width to start with square zones. Cap the minimum
 * on very wide screens and let longer content set the row height. */
.wp-block-lpu-split-section .wp-block-lpu-split-zone {
	box-sizing: border-box;
	display: flex;
	min-width: 0;
	min-height: min( 50cqi, 45rem );
	flex-direction: column;
	justify-content: center;
	padding: var( --wp--custom--spacing--section-inset ) var( --wp--preset--spacing--xl-fluid );
}

/* Position a full-width content area, as Cover does by default. A fit-content
 * track can collapse percentage-sized Images or Groups to zero width. */
.wp-block-lpu-split-zone[class*="is-position-"]:not(.wp-block-lpu-split-zone--content-fill) {
	display: grid;
	grid-template-columns: minmax( 0, 1fr );
	align-content: center;
}

.wp-block-lpu-split-zone:is(.is-position-top-left, .is-position-top-center, .is-position-top-right):not(.wp-block-lpu-split-zone--content-fill) {
	align-content: start;
}

.wp-block-lpu-split-zone:is(.is-position-bottom-left, .is-position-bottom-center, .is-position-bottom-right):not(.wp-block-lpu-split-zone--content-fill) {
	align-content: end;
}

/* Share the inset between the zone and its inner panel so the text still
 * starts at the same distance from the edge of the section.
 *
 * This rule also applies in the editor, where Gutenberg inserts extra elements
 * between the section and its zones. Using :where() keeps this rule from
 * outranking the later content-fill rule: selecting "Contenu en pleine zone"
 * can then remove the zone's padding while keeping the Group's own padding. */
.wp-block-lpu-split-section .wp-block-lpu-split-zone:where(:has( .wp-block-lpu-split-zone__inset )),
.wp-block-lpu-split-zone__inset {
	padding: calc( var( --wp--custom--spacing--section-inset ) / 2 ) calc( var( --wp--preset--spacing--xl-fluid ) / 2 );
}

.wp-block-lpu-split-zone > * {
	box-sizing: border-box;
}

/* Image blocks (including Images inside a Group) use percentage sizing. Give
 * them a definite width without making text and Buttons fill the whole zone;
 * those blocks need their native width for layout justification to work. */
.wp-block-lpu-split-zone > :is(.wp-block-image, :has(.wp-block-image)) {
	width: 100%;
}

.wp-block-lpu-split-zone > .wp-block-image {
	margin-block: 0;
}

.wp-block-lpu-split-section .wp-block-lpu-split-zone--content-fill {
	padding: 0;
}

/* With "Contenu en pleine zone" enabled, the inner Group should reach the left
 * and right edges of its zone. Removing the zone's padding is not enough:
 * WordPress's constrained layout still limits the Group's width on wide screens.
 * Remove that limit without changing the Group's padding around its text. */
.wp-block-lpu-split-zone--content-fill > .wp-block-lpu-split-zone__inset {
	max-width: none;
}

.wp-block-lpu-split-zone--content-fill > .wp-block-image,
.wp-block-lpu-split-zone--content-fill > *:has( .wp-block-image ) {
	align-self: stretch;
	display: flex;
	flex: 1 1 0;
	flex-direction: column;
	width: 100%;
	min-width: 0;
	min-height: 0;
	height: 100%;
	max-width: none;
	margin: 0;
	overflow: hidden;
}

.wp-block-lpu-split-zone--content-fill .wp-block-image {
	/* A nested full-width image must include any editor border in its width. */
	box-sizing: border-box;
	display: flex;
	flex: 1 1 0;
	width: 100%;
	min-width: 0;
	min-height: 0;
	height: 100%;
	max-width: none;
	margin: 0;
	overflow: hidden;
}

.wp-block-lpu-split-zone--content-fill .wp-block-image img {
	display: block;
	width: 100%;
	height: 100%;
	max-height: none;
	object-fit: cover;
}

.wp-block-lpu-split-zone__inset {
	width: 100%;
}

.wp-block-lpu-split-zone__logo {
	width: min( 100%, 18rem );
	margin: auto;
}

.wp-block-lpu-split-zone__logo img {
	display: block;
	width: 100%;
	height: auto;
	max-height: 12rem;
	object-fit: contain;
}

@media ( max-width: 781px ) {
	.wp-block-lpu-split-section {
		grid-template-columns: 1fr;
	}

	/* On phones, stacked text zones take the height their content needs. */
	.wp-block-lpu-split-section .wp-block-lpu-split-zone {
		min-height: 0;
	}

	/* A stacked image no longer has an adjacent zone to set its height. */
	.wp-block-lpu-split-section .wp-block-lpu-split-zone--content-fill {
		min-height: min( 100vw, 30rem );
	}

	.wp-block-lpu-split-zone__logo {
		width: min( 100%, 15rem );
	}
}
