/**
 * Kubota Europe badge card & image (WPBakery element `vc_kbeu_badge_card`).
 *
 * Based on the Kubota Care block of the Figma design, drawn as loose layers:
 * a white card with a 1px black outline and 14px corners (4221-1842, 1351 × 602 on
 * the 2560 artboard) and, ~33px to its right, a picture with 15px corners on a light
 * grey frame (4221-1849, 512 × 602). Inside the card, 60px from the top and ~71px
 * from the left: the orange badge (4221-1850, #d85324, 9px corners, ~20 / 42px
 * padding) with the white title (4221-1853, 48px / Bold, 1.2 line height); ~77px
 * below it the bold lead (32px / Bold, 1.37) and ~29px lower the light text
 * (24px / Light, 1.55). The lead and text share the image & text element's type
 * scale, so both blocks read as one family.
 *
 * Layout: the picture's column is an exact share of the row minus the gap (27% =
 * the design's 512 of 1896px, by default) and the card takes the rest — an explicit
 * basis, not grow factors, for the reason given in kbeu-image-text.css (the card's
 * padding would skew the split). The share comes from the `data-image-width`
 * attribute, NOT an inline custom property, so the stacking override below wins.
 * The source order is always card → picture; the `--image-left` modifier reverses
 * the row, so the stacked layout keeps the texts first. Both columns stretch to the
 * same height: the picture's `aspect-ratio` (the design's 512 / 602) is only a
 * floor, and when the card is taller the frame grows with it.
 *
 * The element takes the width its WPBakery row gives it (no breakout, no inner
 * max-width). Sizes are `clamp()`s whose maximum is the Figma value. Below 861px
 * there is no design to follow: the columns stack, card first.
 *
 * Font family "Inter" is provided by the plugin's fonts stylesheet
 * (this handle depends on `kbeu-fonts`), referenced via `--kbeu-font-principal`.
 */

.kbeu-badge-card {
	/* The image's share of the row, in percent (the card takes the rest).
	   Overridden per preset by the `data-image-width` rules below. */
	--kbeu-bc-image: 27;
	--kbeu-bc-gap: clamp( 20px, 1.3vw, 33px );
	--kbeu-bc-radius: 15px;
	--kbeu-bc-card-radius: 14px;
	--kbeu-bc-outline: #000;
	--kbeu-bc-surface: var( --kbeu-color-surface );
	--kbeu-bc-accent: var( --kbeu-color-orange );
	--kbeu-bc-fit: cover;

	/* Fills whatever width its WPBakery row/column gives it (no breakout, no
	   own max width): the row decides between site width and full width. */
	width: 100%;
	display: flex;
	align-items: stretch;
	gap: var( --kbeu-bc-gap );
	font-family: var( --kbeu-font-principal );
}

/* The paddings and radii are the design's own measurements, so they have to
   stay inside the columns whatever the theme's box model. */
.kbeu-badge-card,
.kbeu-badge-card *,
.kbeu-badge-card *::before,
.kbeu-badge-card *::after {
	box-sizing: border-box;
}

/* Image on the left: keep source order card → image but flip it. */
.kbeu-badge-card--image-left {
	flex-direction: row-reverse;
}

/* Width presets (the `image_width` param). 27% is the default above. */
.kbeu-badge-card[data-image-width='33'] {
	--kbeu-bc-image: 33;
}

.kbeu-badge-card[data-image-width='40'] {
	--kbeu-bc-image: 40;
}

.kbeu-badge-card[data-image-width='50'] {
	--kbeu-bc-image: 50;
}

/* Fit presets (the `image_fit` param). Cover is the default above. */
.kbeu-badge-card[data-fit='contain'] {
	--kbeu-bc-fit: contain;
}

/* --- Card ---------------------------------------------------------------- */

/* Takes whatever the picture leaves (its padding does not change the split).
   The badge sits at the top; the lead and text follow at the design's distances. */
.kbeu-badge-card__card {
	flex: 1 1 0;
	min-width: 0;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	padding:
		clamp( 24px, 2.35vw, 60px )
		clamp( 24px, 4.5vw, 116px )
		clamp( 24px, 2.35vw, 60px )
		clamp( 24px, 2.8vw, 71px );
	background: #fff;
	border: 1px solid var( --kbeu-bc-outline );
	border-radius: var( --kbeu-bc-card-radius );
	color: #000;
	text-align: left;
}

/* A single column left (no picture / no texts) spans the whole row. */
.kbeu-badge-card--no-image .kbeu-badge-card__card,
.kbeu-badge-card--no-card .kbeu-badge-card__media {
	flex: 1 1 100%;
}

/* The orange (or turquoise) badge: as wide as its text (the design's 664px box is the title plus
   its padding), wrapping onto more lines rather than overflowing the card. */
.kbeu-badge-card .kbeu-badge-card__badge {
	display: inline-block;
	max-width: 100%;
	margin: 0;
	/* Impreza gives every heading that is not a first child a 1.5rem padding-top;
	   the badge's own padding replaces it. */
	padding: clamp( 10px, 0.8vw, 20px ) clamp( 16px, 1.65vw, 42px );
	background: var( --kbeu-bc-accent );
	border-radius: 9px;
	font-family: var( --kbeu-font-principal );
	font-weight: 700;
	font-size: clamp( 26px, 1.9vw, 48px );
	line-height: 1.2;
	color: #fff;
	overflow-wrap: break-word;
}

/* Turquoise badge (`accent=teal`, after-sales Kubota Care, Figma 5286-5171). */
.kbeu-badge-card--accent-teal {
	--kbeu-bc-accent: var( --kbeu-color-teal );
}

.kbeu-badge-card__lead {
	margin: 0;
	font-weight: 700;
	line-height: 1.37;
	font-size: clamp( 22px, 1.25vw, 32px );
	color: #000;
	/* Long translations wrap instead of overflowing on narrow screens. */
	overflow-wrap: break-word;
}

.kbeu-badge-card__text {
	margin: 0;
	font-weight: 300;
	line-height: 1.55;
	font-size: clamp( 17px, 0.94vw, 24px );
	color: var( --kbeu-color-ink );
	/* Long unbroken strings (URLs) wrap instead of pushing the column wider. */
	overflow-wrap: break-word;
}

/* Design: ~77px between the badge and the lead. Also applies when the text
   follows the badge directly (no lead). */
.kbeu-badge-card .kbeu-badge-card__badge + .kbeu-badge-card__lead,
.kbeu-badge-card .kbeu-badge-card__badge + .kbeu-badge-card__text {
	margin-top: clamp( 24px, 3vw, 77px );
}

/* Design: ~29px between the lead's line box and the text's. */
.kbeu-badge-card .kbeu-badge-card__lead + .kbeu-badge-card__text {
	margin-top: clamp( 16px, 1.15vw, 29px );
}

/* The text is editor HTML: the theme's own block margins are replaced by one
   blank line between blocks. */
.kbeu-badge-card .kbeu-badge-card__text > * {
	margin: 0;
}

.kbeu-badge-card .kbeu-badge-card__text > * + * {
	margin-top: 1.55em;
}

.kbeu-badge-card__text ul,
.kbeu-badge-card__text ol {
	padding-left: 1.25em;
}

.kbeu-badge-card .kbeu-badge-card__text li + li {
	margin-top: 0.35em;
}

.kbeu-badge-card__lead strong,
.kbeu-badge-card__lead b,
.kbeu-badge-card__text strong,
.kbeu-badge-card__text b {
	font-weight: 700;
}

.kbeu-badge-card__text a {
	color: var( --kbeu-color-teal );
	text-decoration: underline;
	text-underline-offset: 0.15em;
}

.kbeu-badge-card__text a:hover,
.kbeu-badge-card__text a:focus-visible {
	text-decoration: none;
}

/* --- Picture ------------------------------------------------------------ */

/* The ratio is a floor: `align-items: stretch` grows the frame to the card's
   height when the texts are taller. The grey is the design's frame: it shows
   around a `contain` picture, behind a transparent one and while it loads. */
.kbeu-badge-card__media {
	flex: 0 0 calc( ( 100% - var( --kbeu-bc-gap ) ) * var( --kbeu-bc-image ) / 100 );
	min-width: 0;
	aspect-ratio: 512 / 602;
	border-radius: var( --kbeu-bc-radius );
	background-color: var( --kbeu-bc-surface );
	overflow: hidden;
}

/* Scoped with the block class so the theme's generic `img` sizing (max-width /
   height: auto) cannot win over the fit. */
.kbeu-badge-card .kbeu-badge-card__img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: var( --kbeu-bc-fit );
}

/* --- Front-end editor placeholder ----------------------------------------- */

/* Shown in the WPBakery front-end editor when the image and every text are empty. */
.kbeu-badge-card__card--empty {
	padding: 24px;
}

.kbeu-badge-card__placeholder {
	margin: 0;
	padding: 24px;
	width: 100%;
	border: 1px dashed var( --kbeu-bc-accent );
	border-radius: 8px;
	font-weight: 300;
	font-size: 15px;
	color: var( --kbeu-color-gray-blue );
	text-align: left;
}

/* --- Responsive --------------------------------------------------------- */

/* Stack on narrow viewports: the card first whatever side the image had, then the
   picture in a square frame (the design's picture is portrait, 512 / 602: a
   landscape frame would crop most of it; a square one only trims its ends). These rules must beat the preset ones above, which
   is why the share is a `data-` attribute rather than an inline style. */
@media ( max-width: 860px ) {
	.kbeu-badge-card,
	.kbeu-badge-card--image-left {
		flex-direction: column;
	}

	.kbeu-badge-card__media,
	.kbeu-badge-card__card {
		flex: none;
		width: 100%;
	}

	.kbeu-badge-card__media {
		aspect-ratio: 1 / 1;
		border-radius: 12px;
	}

	.kbeu-badge-card__card {
		padding: 24px;
		border-radius: 12px;
	}
}
