/**
 * Kalendarium (page-templates/timeline.php): timeline and galleries.
 * Lightbox: GLightbox (assets/vendor/glightbox).
 */

.timeline-page {
	padding-bottom: 88px;
}

.timeline-page__content {
	max-width: calc(1040px + 2 * var(--gutter));
	margin-top: 56px;
}

/* ==========================================================================
   Timeline
   ========================================================================== */

.timeline {
	--tl-year-w: 190px;
	--tl-dot: 14px;
	position: relative;
	margin: 0;
	padding: 0;
	list-style: none;
	counter-reset: none;
}

/* Vertical line */
.timeline::before {
	content: "";
	position: absolute;
	top: 8px;
	bottom: 8px;
	left: calc(var(--tl-dot) / 2 - 1px);
	width: 2px;
	background: linear-gradient(var(--c-brand), var(--c-border) 85%);
}

.timeline__item {
	position: relative;
	display: grid;
	gap: 10px;
	padding-left: calc(var(--tl-dot) + 22px);
	padding-bottom: 40px;
}

.timeline__item:last-child {
	padding-bottom: 0;
}

/* Dot */
.timeline__item::before {
	content: "";
	position: absolute;
	top: 6px;
	left: 0;
	width: var(--tl-dot);
	height: var(--tl-dot);
	border: 3px solid var(--c-white);
	border-radius: 50%;
	background: var(--c-brand);
	box-shadow: 0 0 0 2px var(--c-brand);
}

.timeline__year span {
	display: inline-block;
	color: var(--c-heading);
	font-family: var(--ff-heading);
	font-size: clamp(1.5rem, 1.25rem + 0.8vw, 1.875rem);
	font-weight: 700;
	line-height: 1;
	letter-spacing: -0.02em;
	white-space: nowrap;
}

.timeline__body {
	padding: 18px;
	border: 1px solid var(--c-border);
	border-radius: 8px;
	background: var(--c-white);
	color: var(--c-text);
	line-height: 1.7;
	transition: box-shadow 0.25s var(--ease);
}

.timeline__body:hover {
	box-shadow: var(--shadow);
}

.timeline__body > :first-child {
	margin-top: 0;
}

.timeline__body > :last-child {
	margin-bottom: 0;
}

.timeline__body b,
.timeline__body strong {
	color: var(--c-heading);
}

/* Remove empty legacy wrappers. */
.timeline__body .pi_wrap_fipg:empty,
.timeline__body [class^="vsig_slide"] {
	display: none;
}

@media (min-width: 768px) {
	.timeline::before {
		left: calc(var(--tl-year-w) + 28px + var(--tl-dot) / 2 - 1px);
	}

	.timeline__item {
		grid-template-columns: var(--tl-year-w) minmax(0, 1fr);
		gap: 0 calc(var(--tl-dot) + 56px);
		padding-left: 0;
		padding-bottom: 48px;
	}

	.timeline__item::before {
		top: 26px;
		left: calc(var(--tl-year-w) + 28px);
	}

	.timeline__year {
		padding-top: 18px;
		text-align: right;
	}

	.timeline__year span {
		position: sticky;
		/* Below the sticky header (and the WP admin bar when logged in). */
		top: calc(var(--wp-admin--admin-bar--height, 0px) + var(--header-h) + 24px);
	}

	.timeline__body {
		padding: 26px 30px;
	}

	.tl-gallery {
		grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
	}
}

/* ==========================================================================
   Galleries ([pi_ifg] replacement) + linked images in content
   ========================================================================== */

.entry-content .tl-gallery {
	padding: 0;
}

.tl-gallery {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 96px), 1fr));
	gap: 8px;
	margin: 18px 0;
	padding: 0;
	list-style: none;
}

.tl-gallery__link {
	display: block;
	overflow: hidden;
	border-radius: 6px;
	background: var(--c-surface);
	aspect-ratio: 4 / 3;
	cursor: zoom-in;
}

.tl-gallery__img {
	display: block;
	width: 100%;
	height: 100%;
	border-radius: 0 !important;
	object-fit: cover;
	transition: transform 0.5s var(--ease), opacity 0.3s var(--ease);
}

.tl-gallery__link:hover .tl-gallery__img {
	transform: scale(1.06);
}

/* Certificates (linked images with alignleft) → neat row of cards. */
.timeline__body p:has(> a > img) {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

.timeline__body a:has(> img) {
	display: block;
	cursor: zoom-in;
}

.timeline__body a > img.alignleft,
.timeline__body a > img.alignright {
	float: none;
	margin: 0;
}

.timeline__body a > img[class*="wp-image"] {
	width: 120px;
	height: auto;
	border: 1px solid var(--c-border);
	border-radius: 4px;
	transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}

.timeline__body a:hover > img[class*="wp-image"] {
	transform: translateY(-2px);
	box-shadow: var(--shadow);
}

@media (min-width: 768px) {
	.timeline__body a > img[class*="wp-image"] {
		width: 140px;
	}
}
