/**
 * Block styles for the single templates' editor content (registered in PHP
 * by cartrack_register_block_styles(), inc/singles.php). They load on the
 * singles and in the block editor.
 *
 * Enhancements only: plain lists and headings already look right in
 * .prose (assets/css/components/prose.css), and imported classic HTML never
 * carries these classes. Selectors don't depend on .prose, so the editor
 * shows the same result.
 *
 * - core/list "Challenge list": an orange circle-i icon instead of a bullet
 *   (case-study-single frame).
 * - core/heading "Numbered steps": numbers H3s in light-blue badges
 *   (optional; not in a frame, TODO).
 *
 * Selectors outrank .prose (specificity 0,2,x), so the load order of the
 * two files does not matter. Logical properties only. Tokens used only
 * here are local.
 *
 * @package cartrack
 */

:where(.prose, .editor-styles-wrapper) {
	/* TODO: verify in Figma (measured from case-study-single at 1920). */
	--block-challenge-icon-size: 1rem;
	--block-challenge-gap: 0.625rem;
	--block-challenge-pitch: 0.875rem;      /* ~38px row pitch with 24px lines. */
	--block-challenge-colour: var(--color-primary);
	--block-challenge-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v5.5M12 7.5v.5'/%3E%3C/svg%3E");
	--block-step-size: 1.875rem;            /* 30px badge, as the blog summary numbers. */
	--block-step-bg: var(--color-secondary-light);
	--block-step-colour: var(--color-text);
}

/* ---------- core/list: Challenge list ---------- */

:is(ul, ol, .wp-block-list).is-style-challenge-list {
	padding-inline-start: 0;
	list-style: none;
	color: var(--color-text);
}

:is(ul, ol, .wp-block-list).is-style-challenge-list > li {
	position: relative;
	padding-inline-start: calc(var(--block-challenge-icon-size) + var(--block-challenge-gap));
}

:is(ul, ol, .wp-block-list).is-style-challenge-list > li + li {
	margin-block-start: var(--block-challenge-pitch);
}

:is(ul, ol, .wp-block-list).is-style-challenge-list > li::before {
	content: "";
	position: absolute;
	inset-block-start: calc((1lh - var(--block-challenge-icon-size)) / 2);
	inset-inline-start: 0;
	inline-size: var(--block-challenge-icon-size);
	block-size: var(--block-challenge-icon-size);
	background-color: var(--block-challenge-colour);
	-webkit-mask: var(--block-challenge-icon) center / contain no-repeat;
	mask: var(--block-challenge-icon) center / contain no-repeat;
}

/* Browsers without the lh unit: centre on a 24px line. */
@supports not (inset-block-start: 1lh) {
	:is(ul, ol, .wp-block-list).is-style-challenge-list > li::before {
		inset-block-start: 0.25rem;
	}
}

/* ---------- core/heading: Numbered steps (optional, TODO) ---------- */

:where(.prose, .is-root-container) {
	counter-reset: cartrack-step;
}

:is(h3, .wp-block-heading).is-style-numbered-steps {
	display: flex;
	align-items: center;
	gap: var(--space-sm);
	counter-increment: cartrack-step;
}

:is(h3, .wp-block-heading).is-style-numbered-steps::before {
	content: counter(cartrack-step);
	display: inline-flex;
	flex: none;
	align-items: center;
	justify-content: center;
	inline-size: var(--block-step-size);
	block-size: var(--block-step-size);
	border-radius: var(--radius-sm);
	background-color: var(--block-step-bg);
	color: var(--block-step-colour);
	font-family: var(--t-small-bold-family);
	font-size: var(--t-small-bold-size);
	font-weight: var(--t-small-bold-weight);
}
