/**
 * Feature Card — shared frontend + editor styles.
 *
 * One stylesheet drives both contexts (block.json registers this as `style`),
 * so the canvas and the front end resolve identical geometry. editor.css only
 * adds affordances the front end has no use for.
 *
 * THE CURVED EDGE
 * ---------------
 * The card colour bulges into the photograph — widest at ~26% of the card's
 * height, narrowest at the bottom. That is drawn by *removing* the matching
 * sliver from the image with a CSS mask, not by painting a shape on top of it.
 * The card's own background then shows through, so the curve stays correct for
 * any card colour without the colour being written down twice.
 *
 * The mask SVG carries `preserveAspectRatio="none"`, so its 100x100 viewBox
 * stretches to whatever the media pane measures — the curve scales with the
 * card instead of drifting out of it. Where masks are unsupported the image
 * simply keeps a straight edge; nothing else changes.
 *
 * Path coordinates are percentages of the media pane, traced from the approved
 * design: the bulge peaks at 8.4% of the pane's width, 26% down.
 *
 * Tokens come from theme.json — see DESIGN.md.
 */

.wp-block-nblocks-feature-card {
	--fc-bg: var(--wp--preset--color--primary);
	--fc-text: var(--wp--preset--color--white, #fff);
	--fc-radius: var(--wp--custom--border--radius--medium, 24px);
	--fc-pad: var(--wp--preset--spacing--large);
	--fc-gap: var(--wp--preset--spacing--medium);
	--fc-panel: 49%;
	--fc-min-height: 420px;
	--fc-focal: 50% 50%;
	--fc-text-size: var(--wp--preset--font-size--jumbo);

	/* White at 50% over the card colour — the mark reads as lightened, not as
	   a second colour. Sampled from the approved design. */
	--fc-mark-opacity: 0.5;
	--fc-mark-width: clamp(30px, 6.5%, 44px);
	--fc-mark: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2042%2036'%3E%3Cpath%20fill='%23fff'%20d='M6,0h3v13.2a4.2,4.2,0,0,0,4.2,4.2H19V31a5,5,0,0,1-5,5H5a5,5,0,0,1-5-5V6a6,6,0,0,1,6-6ZM29,0h3v13.2a4.2,4.2,0,0,0,4.2,4.2H42V31a5,5,0,0,1-5,5h-9a5,5,0,0,1-5-5V6a6,6,0,0,1,6-6Z'/%3E%3C/svg%3E");

	--fc-curve-right: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%20preserveAspectRatio='none'%3E%3Cpath%20fill='%23fff'%20d='M100,0H7.5C8.1,6,8.4,14,8.4,26C8.4,47,6.2,77,0,100H100Z'/%3E%3C/svg%3E");
	--fc-curve-left: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%20preserveAspectRatio='none'%3E%3Cg%20transform='translate(100,0)%20scale(-1,1)'%3E%3Cpath%20fill='%23fff'%20d='M100,0H7.5C8.1,6,8.4,14,8.4,26C8.4,47,6.2,77,0,100H100Z'/%3E%3C/g%3E%3C/svg%3E");

	position: relative;
	display: grid;
	grid-template-columns: var(--fc-panel) 1fr;
	align-items: stretch;
	min-height: var(--fc-min-height);
	background-color: var(--fc-bg);
	color: var(--fc-text);
	overflow: hidden;
}

.wp-block-nblocks-feature-card.is-media-left {
	grid-template-columns: 1fr var(--fc-panel);
}

/* Full-bleed, the radius would round against the viewport edge. */

/* -------------------------------------------------------------------------- */
/*  Panes                                                                     */
/* -------------------------------------------------------------------------- */

.wp-block-nblocks-feature-card.is-media-right .feature-card__panel,
.wp-block-nblocks-feature-card.is-media-left .feature-card__media {
	grid-column: 1;
}

.wp-block-nblocks-feature-card.is-media-right .feature-card__media,
.wp-block-nblocks-feature-card.is-media-left .feature-card__panel {
	grid-column: 2;
}

/*
 * The panel sits above the media so the bulge always reads as card, never as
 * a gap — the mask cuts the image back past the panel's own edge.
 *
 * Cross-axis stretch is deliberate and load-bearing: the quote has to wrap at
 * the panel's edge, not at its own longest line. The two children that must
 * hug their content — the mark and the button — opt out by carrying an
 * explicit width and an `align-self` of their own.
 */
.feature-card__panel {
	position: relative;
	z-index: 1;
	grid-row: 1;
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: var(--fc-gap);
	min-width: 0;
	padding: var(--fc-pad);
	background-color: var(--fc-bg);
}

.feature-card__media {
	position: relative;
	grid-row: 1;
	min-width: 0;
	-webkit-mask-image: var(--fc-curve-right);
	mask-image: var(--fc-curve-right);
	-webkit-mask-size: 100% 100%;
	mask-size: 100% 100%;
	-webkit-mask-repeat: no-repeat;
	mask-repeat: no-repeat;
}

.wp-block-nblocks-feature-card.is-media-left .feature-card__media {
	-webkit-mask-image: var(--fc-curve-left);
	mask-image: var(--fc-curve-left);
}

.feature-card__image {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: var(--fc-focal);
}

/* -------------------------------------------------------------------------- */
/*  Panel content                                                             */
/* -------------------------------------------------------------------------- */

/* Drawn as a mask over `currentColor` so the mark follows the text colour —
   set a dark text colour on a pale card and the mark darkens with it. */
.wp-block-nblocks-feature-card.has-quote-mark .feature-card__panel::before {
	content: "";
	display: block;
	flex: none;
	width: var(--fc-mark-width);
	aspect-ratio: 42 / 36;
	background-color: currentColor;
	opacity: var(--fc-mark-opacity);
	-webkit-mask: var(--fc-mark) no-repeat center / contain;
	mask: var(--fc-mark) no-repeat center / contain;
}

.feature-card__body {
	display: flex;
	flex-direction: column;
	gap: var(--fc-gap);
	margin: 0;
	padding: 0;
	border: 0;
}

.feature-card__text {
	margin: 0;
	font-size: var(--fc-text-size);
	font-weight: 600;
	line-height: var(--wp--custom--line-height--tight, 1.25);
	letter-spacing: -0.01em;
}

.feature-card__text p {
	margin: 0;
}

.feature-card__meta {
	display: block;
	font-size: var(--wp--preset--font-size--tiny);
	font-style: normal;
	font-weight: 600;
	line-height: var(--wp--custom--line-height--medium, 1.4);
}

/* -------------------------------------------------------------------------- */
/*  Button                                                                    */
/* -------------------------------------------------------------------------- */

/*
 * Same box as every other theme button (DESIGN.md → Button): one set of
 * padding/radius/border-width tokens, and geometry never changes between
 * states.
 *
 * Deliberate deviation: the theme's outline button flips border and label to
 * magenta on hover and never fills. On a solid brand-colour card magenta on
 * green is not legible, and the card colour is author-chosen, so the hover
 * inverts instead — it is the one flip guaranteed to keep contrast on any
 * card colour. Override --fc-button-hover-bg / --fc-button-hover-text to
 * change it.
 */
.feature-card__button {
	--fc-button-hover-bg: var(--fc-text);
	--fc-button-hover-text: var(--fc-bg);

	display: inline-flex;
	align-items: center;
	justify-content: center;
	align-self: flex-start;
	padding: var(--wp--custom--button--padding-block) var(--wp--custom--button--padding-inline);
	/* The theme's 1px outline disappears against a saturated card; the design
	   doubles it. Geometry is still constant across every state. */
	border: var(--fc-button-border-width, 2px) solid currentColor;
	background-color: transparent;
	color: inherit;
	font-size: var(--wp--preset--font-size--tiny);
	font-weight: 600;
	line-height: var(--wp--custom--line-height--medium, 1.4);
	text-decoration: none;
	transition: background-color 200ms ease-out, color 200ms ease-out;
}

.feature-card__button:hover,
.feature-card__button:focus-visible {
	background-color: var(--fc-button-hover-bg);
	color: var(--fc-button-hover-text);
	text-decoration: none;
}

.feature-card__button:active {
	transform: scale(0.98);
}

/* -------------------------------------------------------------------------- */
/*  Guards                                                                    */
/* -------------------------------------------------------------------------- */

/*
 * Two article-body rules reach inside any block dropped into a post and would
 * otherwise redress this one (see CLAUDE.md → Gotchas):
 *
 *   .single-post .post-body-content a:not(.wp-element-button, …)   (0,2,1)
 *   .single-post .post-body-content img                            (0,2,1)
 *
 * The first repaints the call to action as a green underlined prose link; the
 * second rounds the photograph's corners and resets its height to auto, which
 * collapses the media pane. Both are answered here at (0,3,1) rather than by
 * adding another exclusion to single-post.css — that file is hand-mirrored in
 * editor-single-post.css, and a block should not need edits in two other
 * stylesheets to survive being used. theme.json's `:root :where(a)` element
 * style (0,1,0) is covered by the same weight.
 */
.wp-block-nblocks-feature-card .feature-card__panel a.feature-card__button {
	color: inherit;
	text-decoration: none;
}

.wp-block-nblocks-feature-card .feature-card__panel a.feature-card__button:hover,
.wp-block-nblocks-feature-card .feature-card__panel a.feature-card__button:focus-visible {
	color: var(--fc-button-hover-text);
	text-decoration: none;
}

.wp-block-nblocks-feature-card .feature-card__media img.feature-card__image {
	height: 100%;
}

@media (prefers-reduced-motion: reduce) {
	.feature-card__button {
		transition: none;
	}

	.feature-card__button:active {
		transform: none;
	}
}

/* -------------------------------------------------------------------------- */
/*  Stacked                                                                   */
/* -------------------------------------------------------------------------- */

/*
 * Below 900px the two panes stack, image first. The curve is a vertical edge —
 * it has no meaning across a horizontal join — so it is dropped and the panel
 * rides up over the photograph on a large radius instead. Same brand move,
 * expressed the way round that fits the axis.
 */
/* The `.is-media-*` column rules above carry three classes; these have to match
   that weight or the panes keep their desktop columns in a one-column grid. */
@media (max-width: 900px) {
	.wp-block-nblocks-feature-card,
	.wp-block-nblocks-feature-card.is-media-left {
		grid-template-columns: 1fr;
		min-height: 0;
	}

	.wp-block-nblocks-feature-card.is-media-right .feature-card__media,
	.wp-block-nblocks-feature-card.is-media-left .feature-card__media {
		grid-column: 1;
		grid-row: 1;
		aspect-ratio: 16 / 10;
		-webkit-mask-image: none;
		mask-image: none;
	}

	.wp-block-nblocks-feature-card.is-media-right .feature-card__panel,
	.wp-block-nblocks-feature-card.is-media-left .feature-card__panel {
		grid-column: 1;
		grid-row: 2;
		margin-top: calc(-1 * var(--fc-stack-overlap, 32px));
	}

	/* No image to ride up over — drop the overlap so the top edge stays flush. */
	.wp-block-nblocks-feature-card.is-media-right:not(.has-image) .feature-card__panel,
	.wp-block-nblocks-feature-card.is-media-left:not(.has-image) .feature-card__panel {
		margin-top: 0;
	}
}
