/* Feature explorer
 * Classes from patterns/feature-explorer.php; the toggle buttons and
 * is-open come from assets/js/feature-explorer.js. Cards default to the
 * open look, so no-JS visitors see every item and video.
--------------------------------------------- */

.ldx-explorer__card {
	position: relative;
	display: grid;
	grid-template-columns: 48px minmax(0, 1fr);
	align-items: center;
	gap: 16px;
	padding: var(--wp--custom--card--padding);
	border: 1px solid transparent;
	border-radius: 20px;
	background: var(--wp--preset--color--purple-50);
}

.ldx-explorer__card > * {
	grid-column: 1 / -1;
	margin: 0;
}

.ldx-explorer__card > .wp-block-icon {
	grid-column: 1;
	box-sizing: border-box;
	width: 48px;
	height: 48px;
	padding: 12px;
	border-radius: var(--wp--custom--radius--md);
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--magenta-500);
}

.ldx-explorer__card > .wp-block-heading {
	grid-column: 2;
	color: var(--wp--preset--color--purple-800);
	font-size: 1.5rem;
}

.ldx-explorer__card > p {
	color: var(--wp--preset--color--gray-700);
	font-size: var(--wp--preset--font-size--medium);
	line-height: 1.5;
}

.ldx-explorer__card > .is-style-ldx-checklist {
	grid-template-columns: minmax(0, 1fr);
	gap: 8px;
	font-size: var(--wp--preset--font-size--medium);
}

.ldx-explorer__card > .is-style-ldx-checklist > li {
	padding-inline-start: 36px;
}

.ldx-explorer__card > .is-style-ldx-checklist > li::before {
	background: var(--wp--preset--color--magenta-500);
	-webkit-mask-image: url(../icons/circle-check.svg);
	mask-image: url(../icons/circle-check.svg);
}

.ldx-explorer .wp-block-embed__wrapper {
	overflow: hidden;
	border-radius: var(--wp--custom--radius--lg);
}

/* The toggle is the heading text; its ::after stretches over the card so
 * the whole card is the hit area. */
.ldx-explorer__toggle {
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	letter-spacing: inherit;
	text-align: start;
	cursor: pointer;
}

.ldx-explorer__toggle::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
}

.ldx-explorer__toggle:focus-visible {
	outline: none;
}

.ldx-explorer__card:has(.ldx-explorer__toggle:focus-visible) {
	outline: 2px solid var(--wp--preset--color--purple-500);
	outline-offset: 2px;
}

.ldx-explorer__item.is-open .ldx-explorer__toggle {
	cursor: default;
}

.ldx-explorer__item.is-open .ldx-explorer__toggle::after {
	display: none; /* keeps the open card's text selectable */
}

/* Front end only, and only when the script can run: is-open is in the saved
 * markup, so the first paint already matches what the script sets up. */
@media (scripting: enabled) {
	body:not(.editor-styles-wrapper) .ldx-explorer__item:not(.is-open) > .ldx-explorer__card {
		align-items: start;
		gap: 4px 16px;
		padding: 20px 24px;
		border-color: var(--wp--preset--color--purple-200);
		background: none;
	}

	body:not(.editor-styles-wrapper) .ldx-explorer__item:not(.is-open) > .ldx-explorer__card:hover {
		border-color: var(--wp--preset--color--purple-500);
	}

	body:not(.editor-styles-wrapper) .ldx-explorer__item:not(.is-open) > .ldx-explorer__card > .wp-block-icon {
		grid-row: 1 / span 2;
		align-self: center;
		background: var(--wp--preset--color--purple-50);
		color: var(--wp--preset--color--purple-500);
	}

	body:not(.editor-styles-wrapper) .ldx-explorer__item:not(.is-open) > .ldx-explorer__card > .wp-block-heading {
		align-self: end;
		font-size: var(--wp--preset--font-size--body-larger);
	}

	body:not(.editor-styles-wrapper) .ldx-explorer__item:not(.is-open) > .ldx-explorer__card > p {
		grid-column: 2;
		color: var(--wp--preset--color--gray-600);
		font-size: var(--wp--preset--font-size--small);
	}

	body:not(.editor-styles-wrapper) .ldx-explorer__item:not(.is-open) > .ldx-explorer__card > .wp-block-list,
	body:not(.editor-styles-wrapper) .ldx-explorer__item:not(.is-open) > .wp-block-embed {
		display: none;
	}

	/* Narrow: the open item's video sits under its card. */
	body:not(.editor-styles-wrapper) .ldx-explorer > .ldx-explorer__item > * {
		margin-block: 0;
	}

	body:not(.editor-styles-wrapper) .ldx-explorer > .ldx-explorer__item + .ldx-explorer__item {
		margin-block-start: 12px;
	}

	body:not(.editor-styles-wrapper) .ldx-explorer > .ldx-explorer__item > .wp-block-embed {
		margin-block-start: 12px;
	}

	/* Wide: cards in the left column, the open video spanning the right.
	 * --ldx-explorer-count comes from functions.php; the trailing 1fr row
	 * takes up any height the video needs beyond the cards. */
	@media (min-width: 960px) {
		body:not(.editor-styles-wrapper) .ldx-explorer {
			display: grid;
			grid-template-columns: minmax(0, 520fr) minmax(0, 856fr);
			grid-template-rows: repeat(var(--ldx-explorer-count, 1), auto) 1fr;
			align-items: start;
			column-gap: 64px;
		}

		body:not(.editor-styles-wrapper) .ldx-explorer > .ldx-explorer__item {
			display: contents;
		}

		body:not(.editor-styles-wrapper) .ldx-explorer > .ldx-explorer__item > .ldx-explorer__card {
			grid-column: 1;
		}

		body:not(.editor-styles-wrapper) .ldx-explorer > .ldx-explorer__item + .ldx-explorer__item > .ldx-explorer__card {
			margin-block-start: 12px;
		}

		body:not(.editor-styles-wrapper) .ldx-explorer > .ldx-explorer__item > .wp-block-embed {
			grid-column: 2;
			grid-row: 1 / -1;
			margin-block-start: 0;
		}
	}
}
