/**
 * Kubota Europe case studies block (WPBakery element `vc_kbeu_stories`).
 *
 * Figma design node 4595-1741 ("Case Studies"): a vertically scrolling list where
 * each row pairs a light grey text card (title, paragraph, teal button) with the
 * case study photo on its right; three rows are visible at a time and a
 * vertical indicator on the far right shows the current page out of the total.
 *
 * The scrolling is native (the viewport is a `overflow-y: auto` box with the
 * scrollbar hidden), so wheel, touch and keyboard all work without JavaScript;
 * `kbeu-stories.js` only reveals and drives the indicator.
 *
 * Font family "Inter" comes from the plugin's fonts stylesheet
 * (this handle depends on `kbeu-fonts`) and is referenced via `--kbeu-font-principal`.
 */

.kbeu-stories {
	--kbeu-stories-radius: 20px;
	/* Row height and gap from Figma (card 295px, 25px between rows). The viewport
	   height is derived from them and the "Stories per view" param. */
	--kbeu-stories-row: 295px;
	--kbeu-stories-gap: 25px;
	--kbeu-stories-column-gap: 53px;
	--kbeu-stories-teal: var( --kbeu-color-teal );
	--kbeu-stories-ink: var( --kbeu-color-ink );

	font-family: var( --kbeu-font-principal );	
}

.kbeu-stories__inner {
	display: flex;
	align-items: stretch;
	gap: var( --kbeu-stories-column-gap );
	max-width: var( --kbeu-stories-max-width, 1780px );
	margin: 0 auto;
}

/* "View all case stories" call-to-action, centered below the list (Figma 85px gap). */
.kbeu-stories__viewall {
	display: flex;
	justify-content: center;
	margin-top: 85px;
}

.kbeu-stories__viewall-btn
{
	border: 1px solid var( --kbeu-stories-ink );
}
/* Scrolling box: `--kbeu-stories-per-view` rows tall. Rows grow with their content
   (a case study with a paragraph is taller than one with only a title), so this
   height is the no-JavaScript fallback: `kbeu-stories.js` replaces it with the
   measured height of the first rows, which is what makes a "page" land exactly on a
   row. The native scrollbar is hidden because the block draws its own indicator. */
.kbeu-stories__viewport {
	flex: 1 1 auto;
	min-width: 0;
	height: calc(
		var( --kbeu-stories-per-view, 3 ) * var( --kbeu-stories-row ) +
		( var( --kbeu-stories-per-view, 3 ) - 1 ) * var( --kbeu-stories-gap )
	);
	overflow-y: auto;
	overscroll-behavior: contain;
	scroll-snap-type: y proximity;
	scrollbar-width: none;
}

.kbeu-stories__viewport::-webkit-scrollbar {
	display: none;
}

.kbeu-stories__viewport:focus-visible {
	outline: 2px solid var( --kbeu-stories-teal );
	outline-offset: 4px;
}

.kbeu-stories__list {
	display: flex;
	flex-direction: column;
	gap: var( --kbeu-stories-gap );
}

/* One case study: text card (left) + photo (right), in the 960 / 770 Figma proportion. */
.kbeu-stories__row {
	display: grid;
	grid-template-columns: minmax( 0, 960fr ) minmax( 0, 770fr );
	gap: var( --kbeu-stories-column-gap );
	/* A minimum, not a fixed height: a case study that carries a paragraph needs more
	   room, and a fixed height would squash it (the clamped texts have
	   `overflow: hidden`, so flexbox would happily shrink them to nothing). */
	min-height: var( --kbeu-stories-row );
	scroll-snap-align: start;
}

.kbeu-stories__card {
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 35px;
	padding: 50px 25px 44px;
	border-radius: var( --kbeu-stories-radius );
	background: var( --kbeu-color-surface );
	overflow: hidden;
}

/* Nothing inside the card may be shrunk by the flex layout. */
.kbeu-stories__title,
.kbeu-stories__text,
.kbeu-stories__btn {
	flex: 0 0 auto;
}

.kbeu-stories__title {
	margin: 0;
	color: var( --kbeu-stories-ink );
	font-size: clamp( 22px, 1.8vw, 32px );
	font-weight: 700;
	line-height: 1.37;
	/* Feed titles can be long (they are a "before" + "highlight" pair). */
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	overflow: hidden;
}

.kbeu-stories__text {
	margin: 0;
	color: var( --kbeu-stories-ink );
	font-size: clamp( 16px, 1.35vw, 24px );
	font-weight: 300;
	line-height: 1.55;
	/* Two lines like the design; longer feed excerpts are cut with an ellipsis. */
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	overflow: hidden;
}

/* The shared `.kbeu-btn .kbeu-btn--primary` shape with the design's own size. */
.kbeu-stories__btn {
	align-self: flex-start;
}

.kbeu-stories__media {
	display: block;
	position: relative;
	border-radius: var( --kbeu-stories-radius );
	overflow: hidden;
	background: var( --kbeu-color-border );
}

/* Absolutely positioned so the photo's natural size never drives the row height:
   the row is as tall as its card and the image simply covers the space. */
.kbeu-stories__img {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* A case study with no image keeps the row's proportions without a fake photo. */
.kbeu-stories__media--empty {
	background: none;
}

/* Vertical progress indicator: current page, track with the draggable thumb and the
   total. Hidden until the script measures the viewport (and on mobile, where the
   block scrolls with the page). */
.kbeu-stories__progress {
	flex: 0 0 53px;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 12px;
	padding: 40px 0;
	color: var( --kbeu-stories-teal );
	font-size: clamp( 16px, 1.35vw, 24px );
	font-weight: 300;
	line-height: 1.3;
}

.kbeu-stories__progress[hidden] {
	display: none;
}

.kbeu-stories__track {
	position: relative;
	flex: 1 1 auto;
	width: 10.8px;
	border-radius: 10px;
	background: rgba( 89, 89, 89, 0.45 );
}

.kbeu-stories__thumb {
	position: absolute;
	left: 50%;
	top: 0;
	width: 27px;
	height: 30%;
	transform: translateX( -50% );
	border-radius: 10px;
	background: var( --kbeu-stories-teal );
	cursor: grab;
	touch-action: none;
	transition: top 0.15s ease;
}

.kbeu-stories__thumb.is-dragging {
	cursor: grabbing;
	transition: none;
}

.kbeu-stories__thumb:focus-visible {
	outline: 2px solid var( --kbeu-stories-ink );
	outline-offset: 3px;
}

/* Mobile: the photo goes above its card, the inner scroll is released to the normal
   page flow and the indicator (which measures that scroll) is dropped. */
@media ( max-width: 860px ) {
	.kbeu-stories {
		padding: 40px 16px;
	}

	.kbeu-stories__viewport {
		height: auto;
		overflow: visible;
	}

	.kbeu-stories__row {
		grid-template-columns: 1fr;
		gap: 16px;
		min-height: 0;
	}

	.kbeu-stories__media {
		order: -1;
		aspect-ratio: 770 / 298;
	}

	.kbeu-stories__media--empty {
		display: none;
	}

	.kbeu-stories__card {
		gap: 20px;
		padding: 28px 20px;
	}

	.kbeu-stories__btn {
		min-width: 0;
		width: 100%;
	}

	.kbeu-stories__progress {
		display: none;
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.kbeu-stories__viewport {
		scroll-behavior: auto;
	}

	.kbeu-stories__thumb {
		transition: none;
	}
}
