/* =============================================================
 * BakBak Widgets — shared stylesheet
 * ============================================================= */

.bakbak-tb,
.bakbak-tb * {
	box-sizing: border-box;
}

/* ---------------------------------------------------------------
 * TRUST BAND
 * --------------------------------------------------------------- */
.bakbak-tb {
	--bakbak-tb-divider: #111111;
	--bakbak-tb-divider-w: 1px;
	--bakbak-tb-divider-h: 70%;
	--bakbak-tb-divider-top: 50%;
	--bakbak-tb-col-gap: clamp(24px, 4vw, 64px);
	--bakbak-tb-row-gap: clamp(40px, 5vw, 72px);

	display: grid;
	grid-template-columns: repeat(2, 1fr);
	column-gap: var(--bakbak-tb-col-gap);
	row-gap: var(--bakbak-tb-row-gap);
	align-items: stretch;
	width: 100%;
	padding: clamp(24px, 4vw, 48px) 0;
	position: relative;
}

@media (min-width: 968px) {
	.bakbak-tb {
		grid-template-columns: repeat(4, 1fr);
	}
}

.bakbak-tb .bakbak-tb__item,
.bakbak-tb__item.bakbak-tb__item {
	position: relative;
	text-align: center;
	display: flex !important;
	flex-direction: column !important;
	align-items: center !important;
	padding: 0;
}

/* -------- Dividers --------
 * The line follows the CONTENT, not the item's full height.
 * Since content is centered vertically inside the item (justify-content: center),
 * we anchor the line to the same vertical centre and give it a height that
 * matches typical content (~ number + title + description = ~180-200px).
 *
 * Using a fixed max-height instead of percentage avoids the line extending
 * into the empty space above/below the content.
 */
.bakbak-tb--dividers-lines .bakbak-tb__item::before {
	content: "";
	position: absolute;
	top: var(--bakbak-tb-divider-top);
	left: calc(-1 * var(--bakbak-tb-col-gap) / 2);
	width: var(--bakbak-tb-divider-w);
	height: var(--bakbak-tb-divider-h);
	background: var(--bakbak-tb-divider);
	transform: translate(-50%, -50%);
	opacity: 0;
	pointer-events: none;
}

@media (max-width: 967.98px) {
	.bakbak-tb--dividers-lines .bakbak-tb__item:nth-child(2n)::before {
		opacity: 1;
	}
}

@media (min-width: 968px) {
	.bakbak-tb--dividers-lines .bakbak-tb__item:nth-child(4n+2)::before,
	.bakbak-tb--dividers-lines .bakbak-tb__item:nth-child(4n+3)::before,
	.bakbak-tb--dividers-lines .bakbak-tb__item:nth-child(4n+4)::before {
		opacity: 1;
	}
}

/* -------- Number row --------
 * Fixed min-height ensures all numbers share the same baseline
 * across the row.
 */
.bakbak-tb__number-wrap {
	display: flex;
	align-items: flex-end;
	justify-content: center;
	flex-wrap: nowrap;
	gap: 0.02em;
	line-height: 1;
	white-space: nowrap;
	min-height: 1.05em;
	/* Number → title: TIGHT, like the reference */
	margin: 0 0 0.08em;
	font-size: clamp(48px, 6.5vw, 88px);
}

.bakbak-tb__prefix,
.bakbak-tb__number,
.bakbak-tb__suffix {
	font-family: inherit;
	font-weight: 700;
	line-height: 1;
	letter-spacing: -0.02em;
	color: #111111;
	display: inline-block;
}

.bakbak-tb__number {
	font-size: 1em;
	font-variant-numeric: tabular-nums;
}

.bakbak-tb__prefix {
	font-size: 0.78em;
	margin-right: 0.04em;
	transform: translateY(-0.02em);
}

.bakbak-tb__suffix {
	font-size: 0.68em;
	margin-left: 0.04em;
	transform: translateY(-0.04em);
}

/* -------- Title --------
 * Sits TIGHT under the number (matches reference image).
 * Description sits TIGHT under the title too (small gap).
 */
.bakbak-tb__title {
	font-family: inherit;
	font-weight: 700;
	font-size: clamp(24px, 2.4vw, 34px);
	line-height: 1.15;
	letter-spacing: -0.01em;
	color: #111111;
	text-align: center;
	margin: 0 0 0.45em;
	width: 100%;
	text-wrap: balance;
}

/* -------- Description -------- */
.bakbak-tb__desc {
	font-family: inherit;
	font-weight: 400;
	font-size: clamp(14px, 1.1vw, 17px);
	line-height: 1.45;
	margin: 0 auto;
	max-width: 24ch;
	color: #555555;
	text-align: center;
	text-wrap: balance;
}

/* -------- Animation states -------- */
.bakbak-tb[data-animate="1"] .bakbak-tb__number {
	opacity: 0;
	transition: opacity 0.2s ease;
}
.bakbak-tb[data-animate="1"].is-running .bakbak-tb__number,
.bakbak-tb[data-animate="1"].is-done .bakbak-tb__number {
	opacity: 1;
}

.elementor-editor-active .bakbak-tb[data-animate="1"] .bakbak-tb__number {
	opacity: 1;
}

/* ---------------------------------------------------------------
 * LOGO MARQUEE
 * ---------------------------------------------------------------
 * Strategy: viewport has overflow:hidden. Inside it two identical
 * tracks sit side-by-side. We translate the wrapper by -50%, which
 * is exactly one track width — when it loops back to 0, the second
 * (cloned) track is now where the first was, so there's no visible
 * "jump". Animation is CSS-only, GPU-accelerated (transform).
 * --------------------------------------------------------------- */

.bakbak-marquee {
	--bakbak-marquee-duration: 40s;

	width: 100%;
	overflow: hidden;
	position: relative;
}

.bakbak-marquee__viewport {
	display: flex;
	width: max-content;
	will-change: transform;
	animation: bakbak-marquee-rtl var(--bakbak-marquee-duration) linear infinite;
}

.bakbak-marquee--ltr .bakbak-marquee__viewport {
	animation-name: bakbak-marquee-ltr;
}

/* Edge fade — soft horizontal gradient mask */
.bakbak-marquee--fade {
	-webkit-mask-image: linear-gradient(
		to right,
		transparent 0,
		#000 8%,
		#000 92%,
		transparent 100%
	);
	mask-image: linear-gradient(
		to right,
		transparent 0,
		#000 8%,
		#000 92%,
		transparent 100%
	);
}

.bakbak-marquee__track {
	display: flex;
	align-items: center;
	gap: 80px;
	padding: 0 40px; /* half-gap on each side so visual gap between tracks equals inner gap */
	flex-shrink: 0;
}

.bakbak-marquee__item {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 64px;
	flex-shrink: 0;
}

.bakbak-marquee__item img {
	display: block;
	width: auto;
	height: 100%;
	max-height: 64px;
	max-width: none;
	object-fit: contain;
	transition: opacity 0.3s ease, filter 0.3s ease;
}

/* RTL (paremalt vasakule) — default */
@keyframes bakbak-marquee-rtl {
	from { transform: translate3d(0, 0, 0); }
	to   { transform: translate3d(-50%, 0, 0); }
}

/* LTR (vasakult paremale) */
@keyframes bakbak-marquee-ltr {
	from { transform: translate3d(-50%, 0, 0); }
	to   { transform: translate3d(0, 0, 0); }
}

/* Honour reduced motion preference */
@media (prefers-reduced-motion: reduce) {
	.bakbak-marquee__viewport {
		animation: none;
		transform: none !important;
	}
	.bakbak-marquee__track--clone {
		display: none; /* one set is enough when static */
	}
}

/* In Elementor editor, animation still runs — useful for previewing */

/* ---------------------------------------------------------------
 * SEGMENTS — 3 vertical cards with photo background
 * ---------------------------------------------------------------
 * Stacking order (z-index from bottom to top):
 *   1. .bakbak-seg__image     — bg photo, transform: scale on hover
 *   2. .bakbak-seg__overlay   — flat overlay color (default dim)
 *   3. .bakbak-seg__gradient  — bottom-to-top fade (reading aid)
 *   4. .bakbak-seg__content   — text + arrow
 *
 * The card is an <a> with display: block so the whole tile is clickable.
 * --------------------------------------------------------------- */

.bakbak-seg {
	display: grid;
	grid-template-columns: 1fr;
	gap: 12px;
	width: 100%;
}

/* Mobile: horizontal scroll with first-card-full + peek of next.
 * Use a horizontal flex container that overflows on the x-axis.
 * Each card is 85% of viewport width so the next one peeks ~15%.
 */
@media (max-width: 599.98px) {
	.bakbak-seg {
		display: flex;
		flex-direction: row;
		flex-wrap: nowrap;
		overflow-x: auto;
		overflow-y: hidden;
		/* edge padding so first card doesn't touch the screen edge */
		padding: 0 16px;
		gap: 12px;
		/* hide scrollbar for cleaner look */
		scrollbar-width: none;
		-ms-overflow-style: none;
		/* iOS momentum scrolling */
		-webkit-overflow-scrolling: touch;
	}

	.bakbak-seg::-webkit-scrollbar {
		display: none;
	}

	.bakbak-seg > .bakbak-seg__card {
		flex: 0 0 85%;
		min-width: 85%;
		scroll-snap-align: none;
	}
}

/* Tablet: 2-column or stacked depending on mobile_layout */
@media (min-width: 600px) and (max-width: 968px) {
	.bakbak-seg--mobile-two-col {
		grid-template-columns: 1fr 1fr;
	}
	.bakbak-seg--mobile-two-col > .bakbak-seg__card:last-child:nth-child(odd) {
		grid-column: span 2;
	}
}

/* Desktop: always 3 columns */
@media (min-width: 969px) {
	.bakbak-seg {
		grid-template-columns: repeat(3, 1fr);
		gap: 16px;
	}
}

.bakbak-seg__card {
	--bakbak-seg-overlay: #000;
	--bakbak-seg-overlay-alpha: 0.35;
	--bakbak-seg-overlay-alpha-hover: 0.55;
	--bakbak-seg-grad-alpha: 0.8;
	--bakbak-seg-zoom: 1.06;

	position: relative;
	display: block;
	aspect-ratio: 3 / 4;
	overflow: hidden;
	text-decoration: none;
	color: inherit;
	background: #1a1518; /* visible while img loads */
	isolation: isolate;
}

.bakbak-seg__card:focus-visible {
	outline: 2px solid #ffffff;
	outline-offset: 2px;
}

/* Image — background-image approach (more robust than <img> against theme overrides) */
.bakbak-seg__image-wrap {
	position: absolute;
	inset: 0;
	z-index: 1;
	background-size: cover;
	background-position: center center;
	background-repeat: no-repeat;
	transform: scale(1);
	transition: transform 0.7s cubic-bezier(0.22, 0.61, 0.36, 1);
	will-change: transform;
}

.bakbak-seg__card:hover .bakbak-seg__image-wrap,
.bakbak-seg__card:focus-visible .bakbak-seg__image-wrap {
	transform: scale(var(--bakbak-seg-zoom));
}

/* Flat overlay — dims the whole photo, deepens on hover */
.bakbak-seg__overlay {
	position: absolute;
	inset: 0;
	z-index: 2;
	background: var(--bakbak-seg-overlay);
	opacity: var(--bakbak-seg-overlay-alpha);
	transition: opacity 0.5s ease;
	pointer-events: none;
}

.bakbak-seg__card:hover .bakbak-seg__overlay,
.bakbak-seg__card:focus-visible .bakbak-seg__overlay {
	opacity: var(--bakbak-seg-overlay-alpha-hover);
}

/* Bottom-up gradient — ensures title is always readable on light photos */
.bakbak-seg__gradient {
	position: absolute;
	inset: 0;
	z-index: 3;
	background: linear-gradient(
		to top,
		rgba(0, 0, 0, var(--bakbak-seg-grad-alpha)) 0%,
		rgba(0, 0, 0, calc(var(--bakbak-seg-grad-alpha) * 0.55)) 25%,
		rgba(0, 0, 0, 0) 60%
	);
	pointer-events: none;
}

/* Content (title + arrow) — sits at bottom */
.bakbak-seg__content {
	position: absolute;
	inset: 0;
	z-index: 4;
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
	padding: 32px;
}

.bakbak-seg__title {
	font-family: inherit;
	font-weight: 700;
	font-size: clamp(22px, 2.4vw, 36px);
	line-height: 1.1;
	letter-spacing: -0.01em;
	color: #ffffff;
	margin: 0 0 0.5em;
	text-wrap: balance;
}

/* Arrow — gentle slide on hover */
.bakbak-seg__arrow {
	display: inline-flex;
	align-items: center;
	color: #ffffff;
	transform: translateX(0);
	transition: transform 0.45s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.bakbak-seg__arrow svg {
	display: block;
	width: 32px;
	height: 14px;
}

.bakbak-seg__card:hover .bakbak-seg__arrow,
.bakbak-seg__card:focus-visible .bakbak-seg__arrow {
	transform: translateX(8px);
}

/* Honour reduced motion */
@media (prefers-reduced-motion: reduce) {
	.bakbak-seg__image-wrap,
	.bakbak-seg__overlay,
	.bakbak-seg__arrow {
		transition: none !important;
	}
	.bakbak-seg__card:hover .bakbak-seg__image-wrap,
	.bakbak-seg__card:focus-visible .bakbak-seg__image-wrap {
		transform: none;
	}
	.bakbak-seg__card:hover .bakbak-seg__arrow,
	.bakbak-seg__card:focus-visible .bakbak-seg__arrow {
		transform: none;
	}
}
