/*
 * Content Section (Inline) — unitedway/content-inline
 *
 * Visual parity with unitedway/content-block's image-text (Bullets) layout, but
 * driven by inner blocks instead of ACF fields. Loaded on the front end and in
 * the editor (block.json style + editorStyle) so the canvas matches the page.
 *
 * Specificity note, and it is the reason this block is restylable in place:
 * every declaration below is at most one class deep, and the editor's own
 * controls emit `.has-red-color`, `.has-heading-2-font-size` and friends with
 * `!important`. So these rules set the design-system default, and anything an
 * editor chooses per instance overrides it.
 */

.uw-ci {
	background-color: var(--wp--preset--color--porcelain);
	padding-block: clamp(3rem, 6vw, 100px);
}
.uw-ci--bg-white { background-color: var(--wp--preset--color--white); }
.uw-ci--bg-parchment { background-color: var(--wp--preset--color--parchment); }
.uw-ci--no-top-pad { padding-block-start: 0; }
.uw-ci--no-bottom-pad { padding-block-end: 0; }
.uw-ci--top-border .uw-ci__inner {
	border-top: 1px solid color-mix(in srgb, var(--wp--preset--color--deep-navy) 12%, transparent);
	padding-top: clamp(2rem, 4vw, 64px);
}

/* Two columns from one flat list of inner blocks.
   WordPress allows a single InnerBlocks region per block, so the image cannot be
   its own separate region. The figure is placed in the left column and spans every
   row; everything else flows down the right column. That keeps the editor's block
   list flat and unnested while the reader still gets the side-by-side design. */
.uw-ci__row {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 470px);
	column-gap: clamp(2rem, 3.6vw, 148px);
	/* row-gap MUST stay 0. The figure spans a large number of implicit rows (see
	   below), and a row-gap would be inserted between every one of them, inflating
	   the figure far beyond the text. Vertical rhythm comes from the margin rule at
	   the end of this block instead. */
	row-gap: 0;
	/* min-content rows keep the text stack tight. The figure spans every row and
	   stretches to whatever height that stack comes to, rather than dictating the
	   row heights itself - which would space the text out to match the image. */
	grid-auto-rows: min-content;
	align-content: center;
}
/* The template stamps uw-ci__figure on the image block; the layout rules below
   target the figure element itself so they also catch an image added later
   without that class. Both selectors are kept in sync deliberately. */
.uw-ci__row > figure,
.uw-ci__row > .uw-ci__figure {
	grid-column: 1;
	max-width: 700px;
	/* `1 / -1` would only reach the end of the EXPLICIT grid, and these rows are
	   implicit (created by the inner blocks), so it collapses the figure to the
	   first row. A large span crosses every implicit row instead. */
	grid-row: 1 / span 100;
	align-self: stretch;
	margin: 0;
	border-radius: 12px;
	overflow: hidden;
	position: relative;
	/* The image is taken out of flow, the same technique unitedway/content-block
	   uses for its figure. A spanning grid item contributes its own height to every
	   row it crosses, so an in-flow image would push the text rows apart to match
	   the picture. Out of flow, the rows are sized by the text alone and the image
	   simply fills whatever height that comes to. */
	min-height: 0;
}
.uw-ci__row > figure img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}
.uw-ci__row > :not(figure) {
	grid-column: 2;
	margin: 0;
}
/* Vertical rhythm for the text stack, in place of the row-gap that the figure's
   row span rules out. Grid items do not collapse margins, so this is exact. */
.uw-ci__row > :not(figure) + :not(figure) { margin-top: clamp(1rem, 1.6vw, 24px); }

/* Empty state. A core/image with no image chosen renders nothing at all, which
   would otherwise leave column one blank and strand the text in a half-width
   column. With no figure present, let the text use the full width. */
.uw-ci__row:not(:has(> figure)) > * { grid-column: 1 / -1; }

/* Image on the right: swap the column assignments, nothing else changes. */
.uw-ci--img-right .uw-ci__row { grid-template-columns: minmax(0, 470px) minmax(0, 1fr); }
.uw-ci--img-right .uw-ci__row > figure { grid-column: 2; }
.uw-ci--img-right .uw-ci__row > :not(figure) { grid-column: 1; }

/* Eyebrow: the red dot is drawn, not typed, so it cannot be deleted by accident
   and is not announced by a screen reader. */
.uw-ci__eyebrow {
	display: inline-flex;
	align-items: center;
	gap: 12px;
	font-family: var(--wp--preset--font-family--marr-sans-cond);
	font-weight: 600;
	font-size: 20px;
	line-height: 1;
	text-transform: uppercase;
	color: var(--wp--preset--color--deep-navy);
}
.uw-ci__eyebrow::before {
	content: "";
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: var(--wp--preset--color--red);
	flex: none;
}

.uw-ci__heading {
	font-family: var(--wp--preset--font-family--marr-sans-cond);
	font-weight: 500;
	font-size: clamp(40px, 5vw, 80px);
	line-height: 0.95;
	letter-spacing: -0.01em;
	color: var(--wp--preset--color--deep-navy);
	text-wrap: balance;
}

.uw-ci__body {
	font-family: var(--wp--preset--font-family--pp-mori);
	font-weight: 400;
	font-size: var(--wp--preset--font-size--body-small);
	line-height: 1.5;
	color: var(--wp--preset--color--deep-navy);
}

.uw-ci__bullets {
	list-style: none;
	margin: 0;
	padding: 0;
	width: 100%;
}
.uw-ci__bullets li {
	position: relative;
	padding: 20px 0 20px 30px;
	border-top: 1px dashed color-mix(in srgb, var(--wp--preset--color--deep-navy) 12%, transparent);
	font-family: var(--wp--preset--font-family--pp-mori);
	font-weight: 400;
	font-size: 18px;
	line-height: 1.3;
	color: var(--wp--preset--color--deep-navy);
}
.uw-ci__bullets li::before {
	content: "";
	position: absolute;
	left: 0;
	top: 29px;
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--wp--preset--color--red);
}

/* The button group. Up to three buttons side by side, wrapping when they do not
   fit - the same row the ACF original draws for its cta / cta2 / cta3 fields
   (.uw-cb__ctas). It is a group rather than loose buttons because every direct
   child of .uw-ci__row is a grid item in a row of its own, so loose buttons
   stack. The group is a FLEX layout, which is also what keeps core from putting a
   `margin-block-start` on every child but the first, the way its flow layout
   does. The 1rem gap is the group's own blockGap (set in render.php's template and
   in the pattern) rather than a declaration here, because core prints
   `:root :where(.is-layout-flex) { gap: var(--wp--style--block-gap) }` at this
   block's own one-class specificity and after it; the declarations below only
   restate what core's flex layout already gives, so the row survives if that
   support ever moves. A single button left as a direct child of the region
   (instances saved before this group existed) still lays out on its own row. */
.uw-ci__ctas {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
}

/* Empty state. Every part of this block is a seeded inner block, and an untouched
   one still serializes and renders as an empty element: the eyebrow paints a bare
   red dot (the dot is drawn on the element itself), an empty heading goes into the
   accessibility tree, and each one eats a row of the grid. `:not([contenteditable])`
   keeps this off the editor canvas, where an empty block is precisely what the
   author has to be able to click into. */
.uw-ci__eyebrow:empty:not([contenteditable]),
.uw-ci__heading:empty:not([contenteditable]),
.uw-ci__body:empty:not([contenteditable]),
.uw-ci__bullets li:empty:not([contenteditable]) { display: none; }
.uw-ci__bullets:not(:has(li:not(:empty))) { display: none; }
.editor-styles-wrapper .uw-ci__bullets:not(:has(li:not(:empty))) { display: block; }
/* A button with no label or no link renders nothing at all (button/render.php
   returns early), so a group whose buttons are all unfilled is an empty box that
   still takes a grid row and its 24px margin. `:empty` does NOT match it: core
   emits the group wrapper with newlines inside, and a whitespace text node is
   enough to fail `:empty`. `:not(:has(*))` asks the question that actually
   matters - are there any element children - and it is also what keeps this off
   the editor canvas, where the group's child is .block-editor-inner-blocks.

   Scoped through .uw-ci__row for specificity, not for reach. `:not(:has(*))`
   contributes nothing (`:has()` takes its most specific argument, and `*` is
   zero), so the one-class form ties with core's
   `:root :where(.is-layout-flex) { display: flex }` and loses on order. This is
   the block's own layout plumbing rather than a design default an editor would
   restyle, so the second class costs nothing. */
.uw-ci__row .uw-ci__ctas:not(:has(*)) { display: none; }

@media (max-width: 900px) {
	.uw-ci__row,
	.uw-ci--img-right .uw-ci__row {
		grid-template-columns: minmax(0, 1fr);
		gap: 1.5rem;
	}
	.uw-ci__row > figure,
	.uw-ci--img-right .uw-ci__row > figure {
		grid-column: 1;
		grid-row: auto;
		aspect-ratio: 718 / 580;
		position: relative;
	}
	.uw-ci__row > :not(figure),
	.uw-ci--img-right .uw-ci__row > :not(figure) { grid-column: 1; }
	.uw-ci__heading { font-size: clamp(36px, 9vw, 56px); }
}
