/* ── ba-timeline-new ──────────────────────────────────────────────────────────── */
@import url("../../../assets/css/variables.css");

.ba-timeline-new {
	width: 100%;
}

/* Horizontal (desktop) rows: hidden by default, shown from 768px up */
.ba-timeline-new__rows {
	display: none;
}

/* ─── List: flex column + vertical spine ─────────────────────────────────── */

.ba-timeline-new__list {
	list-style: none;
	margin: 0;
	padding: 0;
	position: relative;
	display: flex;
	flex-direction: column;
	row-gap: 48px;
}

/* Vertical spine: uses CSS vars set via Elementor selectors. --ba-tl-spine is a
   hard-stop gradient built in ba-timeline-new.js so the line changes colour with the
   row groups, exactly like the desktop rows; without JS it stays a solid line. */
.ba-timeline-new__list::before {
	content: '';
	position: absolute;
	left: 50%;
	top: 0;
	bottom: 0;
	width: var(--ba-tl-lw, 2px);
	transform: translateX(-50%);
	background-color: var(--ba-tl-line, #79B933);
	background-image: var(--ba-tl-spine, none);
}

/* ─── Item: 3-column grid [content | pin | content] ─────────────────────── */

.ba-timeline-new__item {
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: flex-start;
}

/* Body: always positioned explicitly via nth-child */
.ba-timeline-new__body {
	position: relative;
	z-index: 1;
}

/* Odd items — body in left column, text right-aligned */
.ba-timeline-new__item:nth-child(odd) .ba-timeline-new__body {
	grid-column: 1;
	grid-row: 1;
	text-align: right;
	padding-right: 28px;
}

/* Horizontal connector: spans the right padding to meet the dot */
.ba-timeline-new__item:nth-child(odd) .ba-timeline-new__body::after {
	content: '';
	position: absolute;
	right: 0;
	top: 10px;
	width: 28px;
	height: var(--ba-tl-lw, 2px);
	background-color: var(--ba-tl-line, #79B933);
}

/* Even items — body in right column, text left-aligned */
.ba-timeline-new__item:nth-child(even) .ba-timeline-new__body {
	grid-column: 3;
	grid-row: 1;
	text-align: left;
	padding-left: 28px;
}

/* Horizontal connector: spans the left padding to meet the dot */
.ba-timeline-new__item:nth-child(even) .ba-timeline-new__body::before {
	content: '';
	position: absolute;
	left: 0;
	top: 10px;
	width: 28px;
	height: var(--ba-tl-lw, 2px);
	background-color: var(--ba-tl-line, #79B933);
}

/* ─── Pin: dot centered on the spine ─────────────────────────────────────── */

.ba-timeline-new__pin {
	grid-column: 2;
	grid-row: 1;
	display: flex;
	justify-content: center;
	align-items: flex-start;
	padding-top: 2px;
	position: relative;
	z-index: 2;
}

/* Border follows the row's colour so the dot matches its stretch of line, in both
   layouts. --ba-tl-dot-border is the Elementor control, used only as a fallback. */
.ba-timeline-new__dot {
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background-color: #ffffff;
	border: 3px solid var(--ba-tl-row-color, var(--ba-tl-dot-border, var(--color-primary, #0A71B4)));
	border-style: solid;
	flex-shrink: 0;
}

/* ─── Typography ─────────────────────────────────────────────────────────── */

.ba-timeline-new__year {
	display: block;
	font-size: 24px;
	font-weight: 700;
	color: var(--color-primary, #0A71B4);
	line-height: 1.2;
	margin-bottom: 8px;
}

.ba-timeline-new__desc {
	font-size: 16px;
	color: var(--color-text, #0F172A);
	line-height: 1.5;
}

.ba-timeline-new__desc p {
	margin: 0;
}

.ba-timeline-new__desc p + p {
	margin-top: 0.5em;
}

.ba-timeline-new__desc {
	display: inline-flex;
	flex-direction: column;
}

.ba-timeline-new__desc ul {
	display: inline-flex;
	flex-direction: column;
}

.ba-timeline-new__desc ul li {
	display: inline-block;
}

.ba-timeline-new__desc ul li::before {
	content: ' ';
	display: inline-block;
	margin-right: 7px;
	margin-bottom: 3px;
	width: 5px;
	height: 5px;
	border-radius: 50%;
	background-color: var(--color-primary, #0A71B4);
}

/* ─── Icon: shared by both layouts ───────────────────────────────────────── */

/* The ring behind the artwork is this colour at 12%, the artwork itself the same
   colour solid. On desktop it's the row's own colour; the vertical layout has no
   rows, so there it falls back to the primary colour. */
.ba-timeline-new__row-icon {
	width: var(--ba-tl-icon-size, 64px);
	height: var(--ba-tl-icon-size, 64px);
	border-radius: 50%;
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	margin-bottom: 12px;
	flex-shrink: 0;
	color: var(--ba-tl-row-color, var(--color-primary, #0A71B4));
}

.ba-timeline-new__row-icon::before {
	content: '';
	position: absolute;
	inset: 0;
	border-radius: 50%;
	background-color: currentColor;
	opacity: 0.12;
}

.ba-timeline-new__row-icon svg {
	position: relative;
	z-index: 1;
	width: 55%;
	height: 55%;
}

/* Recolour whatever was pasted, overriding the stroke/fill baked into the SVG.
   `none` values are left alone so outline icons don't get filled in. */
.ba-timeline-new__row-icon svg[stroke]:not([stroke="none"]),
.ba-timeline-new__row-icon svg [stroke]:not([stroke="none"]) {
	stroke: currentColor;
}

.ba-timeline-new__row-icon svg[fill]:not([fill="none"]),
.ba-timeline-new__row-icon svg [fill]:not([fill="none"]) {
	fill: currentColor;
}

/* ─── Mobile: line on left, items stacked to the right ──────────────────── */

@media (max-width: 767px) {
	/* The spine is revealed downwards as the page scrolls: --ba-tl-draw is the 0→1
	   progress set by ba-timeline-new.js, and defaults to a fully drawn line without JS.
	   Clipped rather than scaled, so the colour stops don't stretch as it grows. */
	.ba-timeline-new__list::before {
		left: calc(var(--ba-tl-dot, 16px) / 2 - var(--ba-tl-lw, 2px) / 2);
		transform: none;
		clip-path: inset(0 0 calc(100% - var(--ba-tl-draw, 1) * 100%) 0);
	}

	.ba-timeline-new__item {
		grid-template-columns: var(--ba-tl-dot, 16px) 1fr;
	}

	.ba-timeline-new__pin {
		grid-column: 1;
		grid-row: 1;
	}

	.ba-timeline-new__item:nth-child(odd) .ba-timeline-new__body,
	.ba-timeline-new__item:nth-child(even) .ba-timeline-new__body {
		grid-column: 2;
		grid-row: 1;
		text-align: left;
		padding-right: 0;
		padding-left: 20px;
	}

	/* Hide horizontal connectors — no room between pin and body */
	.ba-timeline-new__item:nth-child(odd) .ba-timeline-new__body::after,
	.ba-timeline-new__item:nth-child(even) .ba-timeline-new__body::before {
		display: none;
	}

	.ba-timeline-new__year {
		font-size: 18px;
	}
}

/* ─── Scroll animation: initial hidden states ────────────────────────────── */

/* Dot: invisible and scaled down until item enters viewport */
.ba-timeline-new__dot {
	opacity: 0;
	transform: scale(0);
	transition:
		transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) 0ms,
		opacity   0.3s ease 0ms;
}

/* Connector (odd): collapses toward the dot side, grows left → right */
.ba-timeline-new__item:nth-child(odd) .ba-timeline-new__body::after {
	transform: scaleX(0);
	transform-origin: right center;
	transition: transform 0.3s ease 0.1s;
}

/* Connector (even): collapses toward the dot side, grows right → left */
.ba-timeline-new__item:nth-child(even) .ba-timeline-new__body::before {
	transform: scaleX(0);
	transform-origin: left center;
	transition: transform 0.3s ease 0.1s;
}

/* Body (odd): faded and shifted left */
.ba-timeline-new__item:nth-child(odd) .ba-timeline-new__body {
	opacity: 0;
	transform: translateX(-16px);
	transition: opacity 0.4s ease 0.2s, transform 0.4s ease 0.2s;
}

/* Body (even): faded and shifted right */
.ba-timeline-new__item:nth-child(even) .ba-timeline-new__body {
	opacity: 0;
	transform: translateX(16px);
	transition: opacity 0.4s ease 0.2s, transform 0.4s ease 0.2s;
}

/* ─── Scroll animation: revealed state (.is-visible added by JS) ─────────── */

.ba-timeline-new__item.is-visible .ba-timeline-new__dot {
	opacity: 1;
	transform: scale(1);
}

.ba-timeline-new__item.is-visible .ba-timeline-new__body::after,
.ba-timeline-new__item.is-visible .ba-timeline-new__body::before {
	transform: scaleX(1);
}

.ba-timeline-new__item.is-visible .ba-timeline-new__body {
	opacity: 1;
	transform: translateX(0);
}

/* ─── Reduced motion ─────────────────────────────────────────────────────── */

/* JS adds .is-visible immediately — disable transitions for any residual flash */
@media (prefers-reduced-motion: reduce) {
	.ba-timeline-new__dot,
	.ba-timeline-new__item:nth-child(odd) .ba-timeline-new__body,
	.ba-timeline-new__item:nth-child(even) .ba-timeline-new__body,
	.ba-timeline-new__item:nth-child(odd) .ba-timeline-new__body::after,
	.ba-timeline-new__item:nth-child(even) .ba-timeline-new__body::before {
		transition: none;
	}
}

/* ═══ Horizontal (desktop) rows: serpentine layout ══════════════════════════ */

@media (min-width: 768px) {

	.ba-timeline-new__list {
		display: none;
	}

	/* Side padding reserves the gutters the connector routes through, so it
	   never crosses over the items — see drawConnectors() in ba-timeline-new.js */
	.ba-timeline-new__rows {
		display: flex;
		flex-direction: column;
		position: relative;
		row-gap: 72px;
		padding-left: 56px;
		padding-right: 56px;
	}

	/* SVG layer draws the row lines, the connecting curves and the end arrow — see ba-timeline-new.js.
	   The segments' stroke-dashoffset is driven per frame from the scroll position, so it
	   carries no transition of its own; only the closing arrowhead fades in. */
	.ba-timeline-new__connectors {
		position: absolute;
		inset: 0;
		overflow: visible;
		pointer-events: none;
	}

	.ba-timeline-new__arrow {
		transition: opacity 0.2s ease;
	}

	.ba-timeline-new__row {
		position: relative;
		z-index: 1;
	}

	/* Shared row tracks (year / dot / icon / desc). Each item opts into them via subgrid
	   so a year or description that wraps can't push its dot off the row's line. */
	.ba-timeline-new__row-list {
		list-style: none;
		margin: 0;
		padding: 0;
		display: grid;
		grid-auto-flow: column;
		grid-auto-columns: minmax(0, 1fr);
		grid-template-rows: repeat(var(--ba-tl-slots, 4), auto);
		column-gap: 16px;
	}

	.ba-timeline-new__row-item {
		display: grid;
		grid-template-rows: subgrid;
		grid-row: span var(--ba-tl-slots, 4);
		justify-items: center;
		justify-self: center;
		text-align: center;
		width: 100%;
		max-width: 220px;
		position: relative;
		z-index: 1;
	}

	/* Fallback for browsers without subgrid: dots align as long as the year stays ≤2 lines */
	@supports not (grid-template-rows: subgrid) {
		.ba-timeline-new__row-list {
			display: flex;
			align-items: flex-start;
			justify-content: space-between;
		}

		.ba-timeline-new__row-item {
			display: flex;
			flex-direction: column;
			align-items: center;
			width: auto;
		}

		.ba-timeline-new__row-item .ba-timeline-new__year {
			min-height: 2.4em;
		}
	}

	.ba-timeline-new__row-item .ba-timeline-new__year {
		margin-bottom: 8px;
		align-self: end;
	}

	/* Dot on the row line: border color follows the row's own color.
	   Overrides the vertical-only scale-in reveal — here the whole .ba-timeline-new__row-item fades in instead. */
	.ba-timeline-new__row-item .ba-timeline-new__dot {
		margin-bottom: 12px;
		border-color: var(--ba-tl-row-color, var(--color-primary, #0A71B4));
		opacity: 1;
		transform: none;
		transition: none;
	}

	.ba-timeline-new__row-item .ba-timeline-new__desc {
		font-weight: 700;
	}

	/* Fade-in reveal for horizontal items, mirrors the vertical scroll animation */
	.ba-timeline-new__row-item {
		opacity: 0;
		transform: translateY(12px);
		transition: opacity 0.4s ease, transform 0.4s ease;
	}

	.ba-timeline-new__row-item.is-visible {
		opacity: 1;
		transform: translateY(0);
	}

	@media (prefers-reduced-motion: reduce) {
		.ba-timeline-new__row-item {
			transition: none;
		}
	}
}
