/* History Timeline */

.thula-history-timeline {
	position: relative;
}

.thula-history-timeline__viewport {
	height: 700px;
	overflow-y: auto;
	overflow-x: hidden;
	padding: var(--wp--preset--spacing--10) var(--wp--preset--spacing--20) var(--wp--preset--spacing--20);
	outline-offset: 2px;
	cursor: default;
	user-select: none;
	box-sizing: border-box;
}

/* Firefox only — Chromium 121+ also supports scrollbar-color, but when present
   it overrides ::-webkit-scrollbar rules, so we restrict it to Firefox. */
@supports not selector(::-webkit-scrollbar) {
	.thula-history-timeline__viewport {
		scrollbar-color: #029EB5 transparent;
		scrollbar-width: thin;
	}
}

/* WebKit scrollbar — thin grey line track, teal pill thumb.
   CSS variables do not resolve in scrollbar pseudo-elements in Chromium,
   so colours are hardcoded: #D9D9D9 = medium-grey, #029EB5 = thula-teal. */
.thula-history-timeline__viewport::-webkit-scrollbar {
	width: 3px;
}

.thula-history-timeline__viewport::-webkit-scrollbar-track {
	background: #D9D9D9;
	border-radius: 100px;
}

.thula-history-timeline__viewport::-webkit-scrollbar-thumb {
	background-color: #029EB5;
	border-radius: 100px;
	min-height: 70px;
}

/* Keyboard focus ring */
.thula-history-timeline__viewport:focus-visible {
	outline: 2px solid var(--wp--preset--color--thula-teal);
	outline-offset: 2px;
	border-radius: 2px;
}

.thula-history-timeline__viewport.is-dragging {
	cursor: grabbing;
	user-select: none;
}

.thula-history-timeline__track {
	list-style: none;
	margin: 0;
	padding: 0;
}

.thula-history-timeline__viewport img {
	-webkit-user-drag: none;
	pointer-events: none;
}

/* ── Items ─────────────────────────────────────────────── */

.thula-history-timeline__item {
	display: flex;
	align-items: flex-start;
	gap: var(--wp--preset--spacing--40);
	margin-bottom: var(--wp--preset--spacing--50);
	position: relative;
}

/* Vertical connecting line — per-item segments so it ends at the last icon's centre */
.thula-history-timeline__item::before {
	content: '';
	position: absolute;
	left: 35px;
	top: 0;
	bottom: calc(-1 * var(--wp--preset--spacing--50));
	width: 1.5px;
	background-color: var(--wp--preset--color--medium-grey);
	pointer-events: none;
	z-index: 0;
}

/* Sub items are indented — shift the line back to the main column */
.thula-history-timeline__item--sub::before {
	left: calc(35px - 7rem);
}

/* Dot on the line marking each sub-item's position */
.thula-history-timeline__item--sub::after {
	content: '';
	position: absolute;
	left: calc(35px - 7rem - 4px);
	top: 30px;
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background-color: var(--wp--preset--color--medium-grey);
	pointer-events: none;
	z-index: 2;
}

/* First item: line starts at icon centre, not the top of the row */
.thula-history-timeline__item:first-child::before {
	top: 35px;
}

/* Last item: line ends at icon centre, no extension below */
.thula-history-timeline__item:last-child::before {
	bottom: calc(100% - 35px);
}

/* Photo as last item — no line stub, it has no icon centre to terminate at */
.thula-history-timeline__item--photo:last-child::before {
	display: none;
}

.thula-history-timeline__item:last-child {
	margin-bottom: 0;
}

/* Icon box */
.thula-history-timeline__icon img {
	max-width: 60px;
	max-height: 60px;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.thula-history-timeline__icon svg {
	max-width: 50px;
	max-height: 50px;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.thula-icon--teal {
	fill: var(--wp--preset--color--thula-teal);
}


.thula-history-timeline__item--sub .thula-history-timeline__icon svg {
	max-width: 40px;
	max-height: 40px;
	fill: var(--wp--preset--color--thula-teal);
}

.thula-history-timeline__icon {
	flex-shrink: 0;
	width: 70px;
	height: 70px;
	display: flex;
	align-items: center;
	justify-content: center;
	position: relative;
	z-index: 1;
}

.thula-history-timeline__item--main .thula-history-timeline__icon {
	background-color: var(--wp--preset--color--white);
	border: 1.5px solid var(--wp--preset--color--medium-grey);
	border-radius: var(--wp--preset--border-radius--small);
}

/* Empty main icon — hide the box, show a dot instead */
.thula-history-timeline__item--main .thula-history-timeline__icon:not(:has(img, svg)) {
	background-color: transparent;
	border: none;
}

.thula-history-timeline__item--main .thula-history-timeline__icon:not(:has(img, svg))::after {
	content: '';
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background-color: var(--wp--preset--color--medium-grey);
}

/* Tighten the gap when a photo item follows */
.thula-history-timeline__item:has(+ .thula-history-timeline__item--photo) {
	margin-bottom: var(--wp--preset--spacing--20);
}

.thula-history-timeline__item:has(+ .thula-history-timeline__item--photo)::before {
	bottom: calc(-1 * var(--wp--preset--spacing--20));
}

/* Stop the line at the icon centre when the photo is the last item */
.thula-history-timeline__item:has(+ .thula-history-timeline__item--photo:last-child)::before {
	bottom: calc(100% - 35px);
}

/* Photo item — full-width image with rounded corners */
.thula-history-timeline__item--photo {
	display: block;
	margin-left: 5rem;
}

.thula-history-timeline__item--photo::before {
	left: calc(35px - 5rem);
}

.thula-history-timeline__photo {
	width: 100%;
	height: auto;
	border-radius: var(--wp--preset--border-radius--small);
	display: block;
}

/* Sub item — indented, no box */
.thula-history-timeline__item--sub {
	margin-left: 7rem;
	gap: var(--wp--preset--spacing--10);
	align-items: center;
}

/* Content */
.thula-history-timeline__content {
	margin-top:-6px;
}

.thula-history-timeline__year {
	display: block;
	font-size: var(--wp--preset--font-size--x-small);
	font-weight: 500;
	color: var(--wp--preset--color--thula-teal);
	text-transform: uppercase;
	letter-spacing: 0.06em;
	margin-bottom: 2px;
}

.thula-history-timeline__title {
	display: block;
	font-size: var(--wp--preset--font-size--medium);
	font-weight: 450;
	color: var(--wp--preset--color--thula-blue);
	margin-bottom: 4px;
}

.thula-history-timeline__body {
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--thula-grey);
	margin: 0;
	line-height: 1.55;
}

/* ── Responsive ────────────────────────────────────────── */

@media (max-width: 1150px) {
	.thula-two-columns--history {
		grid-template-columns: 1fr;
		gap: var(--wp--preset--spacing--70) !important;
		max-width: 75%;
		margin-left: auto;
		margin-right: auto;
	}
}

@media (max-width: 800px) {
	.thula-two-columns--history {
		max-width: 100%;
	}
}

@media (max-width: 600px) {
	.thula-history-timeline__viewport {
		height: 380px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.thula-history-timeline__viewport {
		scroll-behavior: auto;
	}
}
