/*
 * Layout utility classes for responsive alignment and dividers.
 *
 * Apply via block Advanced, Additional CSS class(es).
 * Alignment utilities override mobile only (max 767px) or tablet only (768px to 1024px).
 * kindling-text-center-tablet: text-align center on tablet only.
 * Divider utilities flip axis at 1024px (horizontal up to 1023px, vertical from 1024px).
 * kindling-stack-columns-mobile-only: apply to Columns blocks to stack at 767px and below
 * only; keeps columns side-by-side from 768px up with editor widths preserved
 * (auto-adds is-not-stacked-on-mobile via render_block in functions.php).
 * kindling-overlap-section-top: lifts a block in a Column out of its section's
 * top edge while Columns sit side by side (782px and up).
 *
 * @package Kindling
 */

@media (min-width: 1024px) {
	.kindling-divider-left {
		border-left: 1px solid var(--wp--custom--color--border);
		padding-left: var(--wp--preset--spacing--30);
		border-top: 0;
		padding-top: 0;
	}

	.kindling-divider-left-dark {
		border-left: 1px solid
			color-mix(
				in srgb,
				var(--wp--preset--color--theme-20) 20%,
				transparent
			);
		padding-left: var(--wp--custom--spacing--24);
		border-top: 0;
		padding-top: 0;
	}

	.kindling-divider-right {
		border-right: 1px solid var(--wp--custom--color--border);
		padding-right: var(--wp--preset--spacing--30);
		border-bottom: 0;
		padding-bottom: 0;
	}
}

@media (max-width: 767px) {
	.kindling-text-center-mobile {
		text-align: center;
	}

	.kindling-flex-content-center-mobile {
		justify-content: center !important;
	}

	.kindling-image-center-mobile {
		display: block;
		width: fit-content;
		max-width: 100%;
		margin-left: auto;
		margin-right: auto;

		img {
			display: block;
			margin-left: auto;
			margin-right: auto;
		}
	}

	.kindling-reverse-columns-mobile.is-layout-flex {
		flex-direction: column-reverse !important;
	}

	.kindling-stack-columns-mobile-only.wp-block-columns {
		flex-wrap: wrap !important;
	}

	.kindling-stack-columns-mobile-only.wp-block-columns > .wp-block-column {
		flex-basis: 100% !important;
	}
}

@media (max-width: 768px) {
	.kindling-reverse-rows-mobile.is-layout-flex {
		flex-direction: row-reverse !important;
	}
}

/*
 * Lift a block (usually a framed image in a Columns row) past its section's
 * top padding, so it overlaps the section above, as in the split callouts.
 * Only from 782px, where core Columns sit side by side; stacked, the block
 * would ride up into the content above it instead.
 *
 * The section's top padding is assumed to be spacing 80 (the standard section
 * padding); set --kindling-overlap-section-padding on the block if it differs.
 * The figure is positioned (core-image.css), so it paints over the section above.
 * Scoped to the column so it outranks core's `:root :where(.is-layout-flow) >
 * :first-child` margin reset.
 */
@media (min-width: 782px) {
	:root .wp-block-column > .kindling-overlap-section-top {
		margin-top: calc(
			-1 *
				(
					var(
							--kindling-overlap-section-padding,
							var(--wp--preset--spacing--80)
						) +
						var(--wp--preset--spacing--50)
				)
		);
	}
}

@media (max-width: 1023px) {
	.kindling-divider-left {
		border-left: 0;
		padding-left: 0;
		border-top: 1px solid var(--wp--custom--color--border);
		padding-top: var(--wp--preset--spacing--30);
	}

	.kindling-divider-left-dark {
		border-left: 0;
		padding-left: 0;
		border-top: 1px solid
			color-mix(
				in srgb,
				var(--wp--preset--color--theme-20) 20%,
				transparent
			);
		padding-top: var(--wp--custom--spacing--24);
	}

	.kindling-divider-right {
		border-right: 0;
		padding-right: 0;
		border-bottom: 1px solid var(--wp--custom--color--border);
		padding-bottom: var(--wp--preset--spacing--30);
	}
}

/* Tablet-only: stack Full to 1/2 grid items one per row (apply to Kindling Grid). */
@media (min-width: 768px) and (max-width: 1024px) {
	.kindling-stack-half-tablet .is-style-grid-item-span-full-to-half {
		grid-column: span 12 !important;
	}

	.kindling-text-center-tablet {
		text-align: center;
	}

	.kindling-flex-content-center-tablet {
		justify-content: center !important;
	}
}

/*
 * Compatibility class for the Subtle shadow.
 *
 * The value now lives in theme.json (settings.shadow.presets), so editors can
 * pick it from the native Shadow control. Shadow presets generate no class, so
 * this class stays for saved content that already applies it.
 */
.has-subtle-box-shadow {
	box-shadow: var(--wp--preset--shadow--subtle);
}

/*
 * Opt out of the underlined link default (links are underlined globally).
 * Apply to any block wrapping the links that should stay plain.
 */
.kindling-no-link-underline a:not(.wp-element-button) {
	text-decoration: none;
}

.kindling-no-link-underline a:not(.wp-element-button):hover {
	text-decoration: underline;
}

/*
 * Size a block to its content instead of the full row. Use it to centre items
 * relative to each other rather than to the column: for example, a vertical
 * Row/Stack with centred items holding a logo row and the social icons below
 * it. In a constrained parent, set the parent's justification to left (or
 * right) so the block is not also centred in the column.
 */
.kindling-width-fit {
	width: fit-content;
	max-width: 100%;
}
