/*
 * en2x Teaser-Kachel – structural, instance-independent styles.
 *
 * Image on top (full tile width, 480x272 → object-fit cover), then inner padding
 * with headline (uppercase), text and a button in en2x style. Background, text
 * and button colour come inline per instance (scoped to the unique id);
 * everything here is colour-agnostic (uses inherit). The side gutter is the
 * shared token so it aligns to the hero/container edge like the sibling article
 * modules. Font inherited (Rubik).
 */

.en2x-teaser-kachel {
	/* Self-brought side gutter (same mechanism as the sibling modules) + bottom
	 * rhythm. Fluid width, so it fills a 2/3 or 1/3 column correctly. */
	margin: 0 var(--en2x-gutter-right) 32px var(--en2x-gutter-left);
	overflow: hidden;
	font-family: inherit;
	/* Inherit Salient's body font size for the copy (headline/button keep theirs). */
	font-size: inherit;
	line-height: 1.6;
	color: inherit;
}

/* Image: full tile width, fixed 480:272 ratio, cover-cropped. */
.en2x-teaser-kachel__media {
	margin: 0;
}

.en2x-teaser-kachel__img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 480 / 272;
	object-fit: cover;
}

/* Salient adds margin-bottom:15px to content images (.row .col img, specificity
 * 0,2,1). That shows as a gap below the (side-layout) teaser image. An ID anchor
 * (#ajax-content-wrap, always present) outranks that rule, so the image sits flush
 * and fills the column with no strip below. */
#ajax-content-wrap .en2x-teaser-kachel__img {
	margin: 0;
}

/* ---------------------------------------------------------------------------
 * Image position: side layouts (links / rechts). Default "oben" keeps the
 * original stacked layout above. The image column is a fixed share; the image
 * fills the tile height (object-fit cover) instead of its 480:272 ratio.
 * ------------------------------------------------------------------------- */
.en2x-teaser-kachel--bild-links,
.en2x-teaser-kachel--bild-rechts {
	display: flex;
	align-items: stretch;
	/* Display-relative minimum height (set per --hoehe-* class below). The tile
	 * grows with the text; the image column always fills the FULL tile height
	 * (cover), so there is never a grey strip below the image. Using a viewport-
	 * relative value (clamped) lets the tile adapt to the display/container
	 * instead of being a rigid pixel box. */
	min-height: var(--en2x-teaser-height, 45vh);
}

/* "Auto": no minimum height. The tile is exactly as tall as its text (min-height
 * resolves to auto), so there is never a grey area below; the image column simply
 * fills (covers) that content height. */
.en2x-teaser-kachel--hoehe-auto {
	--en2x-teaser-height: auto;
}

/* Height steps: relative to the display height, clamped to sane bounds so the
 * tile adapts to the container instead of sitting at a fixed pixel height. */
.en2x-teaser-kachel--hoehe-mittel {
	--en2x-teaser-height: clamp(300px, 45vh, 480px);
}

.en2x-teaser-kachel--hoehe-hoch {
	--en2x-teaser-height: clamp(380px, 60vh, 620px);
}

.en2x-teaser-kachel--bild-rechts {
	flex-direction: row-reverse;
}

/* Image column: a fixed share of the tile width, stretched to the FULL tile
 * height. The image is absolutely filled with object-fit cover, so it always
 * covers the whole column height (no grey strip) at any tile height. Ideal
 * upload is 4:3 landscape; the narrower column makes it less wide. */
.en2x-teaser-kachel--bild-links .en2x-teaser-kachel__media,
.en2x-teaser-kachel--bild-rechts .en2x-teaser-kachel__media {
	/* Narrow, consistent image band (a fixed "Satzspiegel"): capped at 250px, but
	 * never more than 40% so it still fits a narrow column. The band width is
	 * height-independent — it stays the same at any tile height; the image just
	 * fills (covers) the growing height. Tune via --en2x-teaser-img-width. */
	flex: 0 0 auto;
	width: var(--en2x-teaser-img-width, min(250px, 40%));
	align-self: stretch;
	overflow: hidden;
	/* Flex COLUMN so the image (its only child) grows to the full, content-
	 * determined column height via flex-grow. This "fill the remaining space"
	 * pattern is the most robust across browsers (incl. Safari) — more reliable
	 * than a percentage / absolute height, which fail to resolve against a flex
	 * item whose height comes from the sibling text. */
	display: flex;
	flex-direction: column;
}

.en2x-teaser-kachel--bild-links .en2x-teaser-kachel__img,
.en2x-teaser-kachel--bild-rechts .en2x-teaser-kachel__img {
	/* Full width; grow to fill the entire column height (no fixed aspect ratio),
	 * object-fit cover crops it centred. So the image always reaches the bottom –
	 * no grey strip – and just gets taller as the tile grows. */
	width: 100%;
	min-width: 0;
	height: auto;
	min-height: 0;
	/* flex-basis 0: the image grows purely by flex-grow to the FULL column height,
	 * so its intrinsic aspect ratio can't leave a short strip at the bottom. */
	flex: 1 1 0;
	aspect-ratio: auto;
	object-fit: cover;
	object-position: center;
}

/* Text + button column: top aligned. The text flows naturally; the tile grows
 * to fit it and the image column fills the resulting height. */
.en2x-teaser-kachel--bild-links .en2x-teaser-kachel__body,
.en2x-teaser-kachel--bild-rechts .en2x-teaser-kachel__body {
	flex: 1 1 auto;
	align-self: flex-start;
	/* More breathing room around the text, with extra space towards the outer
	 * edge (away from the image). Less padding below the buttons so the tile
	 * (and thus the image column) is not taller than the content. */
	padding: 40px 56px 22px;
}

/* Bild links -> Text rechts: extra space on the right (outer) edge. */
.en2x-teaser-kachel--bild-links .en2x-teaser-kachel__body {
	padding-left: 48px;
	padding-right: 64px;
}

/* Bild rechts -> Text links: extra space on the left (outer) edge. */
.en2x-teaser-kachel--bild-rechts .en2x-teaser-kachel__body {
	padding-left: 64px;
	padding-right: 48px;
}

/* Inner padding area. */
.en2x-teaser-kachel__body {
	padding: 28px;
}

.en2x-teaser-kachel__headline {
	margin: 0 0 14px;
	font-size: 22px;
	font-weight: 700;
	line-height: 1.2;
	text-transform: uppercase;
	color: inherit;
}

.en2x-teaser-kachel__text {
	margin: 0 0 20px;
}

/* "Schriftgröße" option: relative steps, factors defined in global.css. */
.en2x-teaser-kachel--schrift-klein .en2x-teaser-kachel__text {
	font-size: var(--en2x-schrift-klein, 0.8em);
}

.en2x-teaser-kachel--schrift-gross .en2x-teaser-kachel__text {
	font-size: var(--en2x-schrift-gross, 1.2em);
}

.en2x-teaser-kachel__text p {
	margin: 0 0 12px;
}

.en2x-teaser-kachel__text :last-child {
	margin-bottom: 0;
}

.en2x-teaser-kachel__text a {
	color: var(--en2x-color-primary, #221182);
}

/* Button row: up to two buttons side by side; wraps when the column is tight. */
.en2x-teaser-kachel__buttons {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
}

/* Button – en2x style (pill roundness like all en2x buttons). Background colour
 * comes inline per instance; text is white for contrast on the filled button. */
.en2x-teaser-kachel__button {
	display: inline-block;
	padding: 9px 22px;
	color: #fff;
	font-size: 14px;
	font-weight: 600;
	text-decoration: none;
	border-radius: var(--en2x-button-radius, 999px);
	transition: opacity 0.15s ease;
}

.en2x-teaser-kachel__button:hover,
.en2x-teaser-kachel__button:focus {
	color: #fff;
	opacity: 0.9;
}

/* ---------------------------------------------------------------------------
 * Responsive: tighten padding on small screens.
 * ------------------------------------------------------------------------- */

@media (max-width: 600px) {
	.en2x-teaser-kachel__body {
		padding: 22px;
	}

	/* On mobile the side layouts collapse to the default stacked layout
	 * (image on top, full width) for readability — all desktop side overrides
	 * are reset here. */
	.en2x-teaser-kachel--bild-links,
	.en2x-teaser-kachel--bild-rechts {
		display: block;
		min-height: 0;
	}

	.en2x-teaser-kachel--bild-links .en2x-teaser-kachel__media,
	.en2x-teaser-kachel--bild-rechts .en2x-teaser-kachel__media {
		display: block;
		position: static;
		flex: none;
		width: auto;
		max-width: none;
	}

	.en2x-teaser-kachel--bild-links .en2x-teaser-kachel__img,
	.en2x-teaser-kachel--bild-rechts .en2x-teaser-kachel__img {
		width: 100%;
		height: auto;
		aspect-ratio: 480 / 272;
	}

	.en2x-teaser-kachel--bild-links .en2x-teaser-kachel__body,
	.en2x-teaser-kachel--bild-rechts .en2x-teaser-kachel__body {
		max-height: none;
		overflow: visible;
		padding: 22px;
	}

	.en2x-teaser-kachel--bild-links .en2x-teaser-kachel__headline,
	.en2x-teaser-kachel--bild-rechts .en2x-teaser-kachel__headline,
	.en2x-teaser-kachel--bild-links .en2x-teaser-kachel__text,
	.en2x-teaser-kachel--bild-rechts .en2x-teaser-kachel__text {
		display: block;
		-webkit-line-clamp: none;
		overflow: visible;
	}
}
