/*
 * Layout (cis/layout). Loaded with the block, front end and editor canvas.
 *
 * Moved here from the Etch style of the Block component (.block, id 7l4wu6j), flattened:
 *   - every selector is wrapped in :where(), so the whole file has ZERO specificity. The block registers the same Etch style
 *     (see bw_render_layout()), so Etch prints its own copy on the page in its own order, together with the page classes that tweak
 *     it (for example `.bw-step__card { ... }`). This file is the fallback for where Etch's copy is not there (the editor canvas) and
 *     it can never override Etch's copy or a page class, whatever the load order. The rules keep Etch's source order, which is what
 *     decided between them there (the deeper, more specific rule always came later).
 *   - the Etch @custom-media token is written out:  --block-query-large = inline-size >= 800px  (50rem).
 *
 * The container queries measure the nearest ancestor that is a size container: the container block (`.container`), or a Card
 * (`.bw-card`, a named size container). The block is not a container itself (its Etch `:has(> &)` rule was commented out).
 * Left out on purpose: nothing; the Etch rule has no invalid parts.
 * One note about `text-align`: the horizontal alignment rules also set it, as the Etch rules did.
 */

:where(.block) {
	position: relative;
	gap: var(--block-gap);
	align-items: var(--block-vertical-alignment);
	inline-size: 100%;
}

:where(.block[data-gap='custom']) {
	gap: var(--block-gap-custom);
}

:where(.block[data-layout='flex']) {
	display: var(--block-layout-type);
	flex-direction: column;
	flex-wrap: wrap;
}

@container (inline-size >= 50rem) {
	:where(.block[data-layout='flex']) {
		flex-direction: var(--block-flex-layout);
	}
}

:where(.block[data-layout='flex'][data-flex-layout='column'][data-vertical-alignment='start']) {
	justify-content: start;
}
:where(.block[data-layout='flex'][data-flex-layout='column'][data-vertical-alignment='center']) {
	justify-content: center;
}
:where(.block[data-layout='flex'][data-flex-layout='column'][data-vertical-alignment='end']) {
	justify-content: end;
}
:where(.block[data-layout='flex'][data-flex-layout='column'][data-vertical-alignment='stretch']) {
	justify-content: stretch;
}
:where(.block[data-layout='flex'][data-flex-layout='column'][data-vertical-alignment='space-between']) {
	justify-content: space-between;
}
:where(.block[data-layout='flex'][data-flex-layout='column'][data-horizontal-alignment='start']) {
	text-align: left;
	align-items: start;
}
:where(.block[data-layout='flex'][data-flex-layout='column'][data-horizontal-alignment='center']) {
	text-align: center;
	align-items: center;
}
:where(.block[data-layout='flex'][data-flex-layout='column'][data-horizontal-alignment='end']) {
	text-align: right;
	align-items: end;
}
:where(.block[data-layout='flex'][data-flex-layout='column'][data-horizontal-alignment='stretch']) {
	align-items: stretch;
}
:where(.block[data-layout='flex'][data-flex-layout='column'][data-horizontal-alignment='space-between']) {
	align-items: space-between;
}

:where(.block[data-layout='flex'][data-flex-layout='row'][data-vertical-alignment='start']) {
	align-items: start;
}
:where(.block[data-layout='flex'][data-flex-layout='row'][data-vertical-alignment='center']) {
	align-items: center;
}
:where(.block[data-layout='flex'][data-flex-layout='row'][data-vertical-alignment='end']) {
	align-items: end;
}
:where(.block[data-layout='flex'][data-flex-layout='row'][data-vertical-alignment='stretch']) {
	align-items: stretch;
}
:where(.block[data-layout='flex'][data-flex-layout='row'][data-vertical-alignment='space-between']) {
	align-items: space-between;
}
:where(.block[data-layout='flex'][data-flex-layout='row'][data-horizontal-alignment='start']) {
	text-align: left;
	justify-content: start;
}
:where(.block[data-layout='flex'][data-flex-layout='row'][data-horizontal-alignment='center']) {
	text-align: center;
	justify-content: center;
}
:where(.block[data-layout='flex'][data-flex-layout='row'][data-horizontal-alignment='end']) {
	text-align: right;
	justify-content: end;
}
:where(.block[data-layout='flex'][data-flex-layout='row'][data-horizontal-alignment='stretch']) {
	justify-content: stretch;
}
:where(.block[data-layout='flex'][data-flex-layout='row'][data-horizontal-alignment='space-between']) {
	justify-content: space-between;
}

:where(.block[data-layout='grid']) {
	display: var(--block-layout-type);
	grid-template-columns: var(--grid-1);
}

@container (inline-size >= 50rem) {
	:where(.block[data-layout='grid']) {
		grid-template-columns: var(--block-grid-layout);
	}
}

:where(.block[data-layout='grid'][data-vertical-alignment='start']) {
	align-items: start;
}
:where(.block[data-layout='grid'][data-vertical-alignment='center']) {
	align-items: center;
}
:where(.block[data-layout='grid'][data-vertical-alignment='end']) {
	align-items: end;
}
:where(.block[data-layout='grid'][data-vertical-alignment='stretch']) {
	align-items: stretch;
}
:where(.block[data-layout='grid'][data-vertical-alignment='space-between']) {
	align-items: space-between;
}
:where(.block[data-layout='grid'][data-horizontal-alignment='start']) {
	text-align: left;
	justify-items: start;
}
:where(.block[data-layout='grid'][data-horizontal-alignment='center']) {
	text-align: center;
	justify-items: center;
}
:where(.block[data-layout='grid'][data-horizontal-alignment='end']) {
	text-align: right;
	justify-items: end;
}
:where(.block[data-layout='grid'][data-horizontal-alignment='stretch']) {
	justify-items: stretch;
}
:where(.block[data-layout='grid'][data-horizontal-alignment='space-between']) {
	justify-items: space-between;
}

@container (inline-size >= 50rem) {
	:where(.block[data-layout='flex'][data-flex-layout='column'][data-vertical-alignment-large='start']) {
		justify-content: start;
	}
	:where(.block[data-layout='flex'][data-flex-layout='column'][data-vertical-alignment-large='center']) {
		justify-content: center;
	}
	:where(.block[data-layout='flex'][data-flex-layout='column'][data-vertical-alignment-large='end']) {
		justify-content: end;
	}
	:where(.block[data-layout='flex'][data-flex-layout='column'][data-vertical-alignment-large='stretch']) {
		justify-content: stretch;
	}
	:where(.block[data-layout='flex'][data-flex-layout='column'][data-vertical-alignment-large='space-between']) {
		justify-content: space-between;
	}
	:where(.block[data-layout='flex'][data-flex-layout='column'][data-horizontal-alignment-large='start']) {
		text-align: left;
		align-items: start;
	}
	:where(.block[data-layout='flex'][data-flex-layout='column'][data-horizontal-alignment-large='center']) {
		text-align: center;
		align-items: center;
	}
	:where(.block[data-layout='flex'][data-flex-layout='column'][data-horizontal-alignment-large='end']) {
		text-align: right;
		align-items: end;
	}
	:where(.block[data-layout='flex'][data-flex-layout='column'][data-horizontal-alignment-large='stretch']) {
		align-items: stretch;
	}
	:where(.block[data-layout='flex'][data-flex-layout='column'][data-horizontal-alignment-large='space-between']) {
		align-items: space-between;
	}
}

@container (inline-size >= 50rem) {
	:where(.block[data-layout='flex'][data-flex-layout='row'][data-vertical-alignment-large='start']) {
		align-items: start;
	}
	:where(.block[data-layout='flex'][data-flex-layout='row'][data-vertical-alignment-large='center']) {
		align-items: center;
	}
	:where(.block[data-layout='flex'][data-flex-layout='row'][data-vertical-alignment-large='end']) {
		align-items: end;
	}
	:where(.block[data-layout='flex'][data-flex-layout='row'][data-vertical-alignment-large='stretch']) {
		align-items: stretch;
	}
	:where(.block[data-layout='flex'][data-flex-layout='row'][data-vertical-alignment-large='space-between']) {
		align-items: space-between;
	}
	:where(.block[data-layout='flex'][data-flex-layout='row'][data-horizontal-alignment-large='start']) {
		text-align: left;
		justify-content: start;
	}
	:where(.block[data-layout='flex'][data-flex-layout='row'][data-horizontal-alignment-large='center']) {
		text-align: center;
		justify-content: center;
	}
	:where(.block[data-layout='flex'][data-flex-layout='row'][data-horizontal-alignment-large='end']) {
		text-align: right;
		justify-content: end;
	}
	:where(.block[data-layout='flex'][data-flex-layout='row'][data-horizontal-alignment-large='stretch']) {
		justify-content: stretch;
	}
	:where(.block[data-layout='flex'][data-flex-layout='row'][data-horizontal-alignment-large='space-between']) {
		justify-content: space-between;
	}
}

@container (inline-size >= 50rem) {
	:where(.block[data-layout='grid'][data-vertical-alignment-large='start']) {
		align-items: start;
	}
	:where(.block[data-layout='grid'][data-vertical-alignment-large='center']) {
		align-items: center;
	}
	:where(.block[data-layout='grid'][data-vertical-alignment-large='end']) {
		align-items: end;
	}
	:where(.block[data-layout='grid'][data-vertical-alignment-large='stretch']) {
		align-items: stretch;
	}
	:where(.block[data-layout='grid'][data-vertical-alignment-large='space-between']) {
		align-items: space-between;
	}
	:where(.block[data-layout='grid'][data-horizontal-alignment-large='start']) {
		text-align: left;
		justify-items: start;
	}
	:where(.block[data-layout='grid'][data-horizontal-alignment-large='center']) {
		text-align: center;
		justify-items: center;
	}
	:where(.block[data-layout='grid'][data-horizontal-alignment-large='end']) {
		text-align: right;
		justify-items: end;
	}
	:where(.block[data-layout='grid'][data-horizontal-alignment-large='stretch']) {
		justify-items: stretch;
	}
	:where(.block[data-layout='grid'][data-horizontal-alignment-large='space-between']) {
		justify-items: space-between;
	}
}

/* ---- Row at every width (flexLayoutSmall = row) ----------------------------------------------------------------
 * Not in the Etch Block component. For wrappers that must be a row from the narrowest container up (the title row of a minimal card:
 * the title on the left and the arrow on the right, a client request from the mockup). The Etch / block rules above give a flex
 * layout `flex-direction: column` below 800px and `flex-wrap: wrap`; these rules are NOT in :where() (specificity 0,3,0) so they win over
 * Etch's copy of the .block style (0,2,0) wherever it is printed. A row from the small setting does not wrap, like the Etch wrapper did.
 * From a wide container the direction goes back to the layout's own direction setting. The alignment rules key on data-flex-layout, so a
 * row layout (flexLayout = row) keeps the row meaning of its alignments at every width. */
.block[data-layout='flex'][data-flex-layout-small='row'] {
	flex-direction: row;
	flex-wrap: nowrap;
}

@container (inline-size >= 50rem) {
	.block[data-layout='flex'][data-flex-layout-small='row'] {
		flex-direction: var(--block-flex-layout);
	}
}

/* ---- No wrapping (noWrap) -----------------------------------------------------------------------------------
 * Not in the Etch Block component. The Block component wraps its items (flex-wrap: wrap); an Etch flex-div did not. For a wrapper that
 * must never wrap (the directory row: the sidebar and the results side by side). Not in :where() (0,3,0), so it wins over Etch's copy of
 * the .block style (0,2,0). */
.block[data-layout='flex'][data-no-wrap='true'] {
	flex-wrap: nowrap;
}

/* ---- Editor canvas only ---------------------------------------------------------------------------
 * The block wrapper is the layout element itself. The editor adds its own margins and a content width to every block; the
 * layout lays its children out, so those are removed (the wrapper keeps the full width the Etch Block had). */
.block.wp-block {
	margin-block: 0;
	max-inline-size: none;
}

.block > .wp-block {
	max-inline-size: none;
	margin-block: 0;
}
