/*
 * CTSFW 2.4.7 - Timeline block (blocks/block-timeline).
 *
 * Served only on pages that use the block: block.json names this stylesheet's
 * handle, and includes/blocks.php registers it. It is hand-written and sits
 * outside the Vite bundle, like the video-block stylesheet beside it, so an
 * edit here takes effect on upload with no rebuild.
 *
 * Unlayered, so it outranks the theme's layered rules without any
 * important flags.
 *
 * Colours are the theme's role tokens. default/dark.css gives those tokens
 * their dark values, so this file has no dark-mode rules of its own. Each
 * token carries its light value as a fallback.
 *
 * The marker is the CTSFW brick diamond: every edge sits 23.5 degrees off
 * horizontal, which makes it wider than tall. Height = width x tan(23.5deg),
 * and tan(23.5deg) = 0.4348. Change --tl-brick-ratio to change the angle.
 */

.ctsfw-timeline {
	--tl-gold: var(--color-beige-500, #cbb284);
	--tl-brick-ratio: 0.4348;

	container-type: inline-size;
	max-width: 54rem;
	margin-inline: auto;
	color: var(--color-ink, #000000);
}

.ctsfw-timeline__title {
	margin: 0 0 2.75rem;
	font: normal 400 clamp(2.25rem, 2rem + 1.25vw, 3rem) / 1.22 var(--font-secondary, "Century Gothic Pro", Helvetica, Arial, sans-serif);
	letter-spacing: -0.025em;
	text-wrap: pretty;
	color: var(--color-heading, #001846);
}

.ctsfw-timeline__list {
	--tl-date-col: 13rem;
	--tl-rail-col: 3.5rem;
	--tl-rail-x: calc(var(--tl-date-col) + var(--tl-rail-col) / 2);
	--tl-brick: 28px;
	--tl-brick-lg: 44px;
	--tl-mid: 13px; /* centre line of the date text: every marker and the rail hang from it */

	list-style: none;
	margin: 0;
	padding: 0;
}

.ctsfw-timeline__item {
	position: relative;
	display: grid;
	grid-template-columns: var(--tl-date-col) var(--tl-rail-col) minmax(0, 1fr);
	margin: 0;
	padding: 0 0 2.25rem;
}

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

/* The rail, one segment per milestone: grey underneath, gold on top. */
.ctsfw-timeline__item::before,
.ctsfw-timeline__item::after {
	content: "";
	position: absolute;
	left: var(--tl-rail-x);
	top: var(--tl-mid);
	width: 2px;
	height: 100%;
	margin-left: -1px;
}

.ctsfw-timeline__item::before {
	background: var(--color-hairline, #e2e2e2);
}

.ctsfw-timeline__item::after {
	background: var(--tl-gold);
	transform-origin: top;
}

.ctsfw-timeline__item:last-child::before,
.ctsfw-timeline__item:last-child::after {
	display: none;
}

.ctsfw-timeline__date {
	margin: 0;
	text-align: right;
	font: normal 700 1.25rem / 1.3 var(--font-secondary, "Century Gothic Pro", Helvetica, Arial, sans-serif);
	color: var(--color-accent, #002c81);
}

.ctsfw-timeline__marker {
	position: relative;
}

.ctsfw-timeline__brick,
.ctsfw-timeline__halo {
	position: absolute;
	z-index: 1;
	left: 50%;
	top: var(--tl-mid);
	width: var(--tl-brick);
	height: calc(var(--tl-brick) * var(--tl-brick-ratio));
	margin: calc(var(--tl-brick) * var(--tl-brick-ratio) / -2) 0 0 calc(var(--tl-brick) / -2);
	clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

/* Unlit brick: an outline in the accent colour. */
.ctsfw-timeline__brick {
	background: var(--color-accent, #002c81);
}

.ctsfw-timeline__brick::before,
.ctsfw-timeline__brick::after {
	content: "";
	position: absolute;
	inset: 0;
	clip-path: inherit;
}

.ctsfw-timeline__brick::before {
	background: var(--color-page, #ffffff);
	transform: scale(0.66);
}

/* Lit brick: a gold fill laid over the outline. */
.ctsfw-timeline__brick::after {
	background: var(--tl-gold);
}

.ctsfw-timeline__halo {
	z-index: 0;
	background: var(--tl-gold);
	opacity: 0;
	animation: ctsfw-timeline-shine 2.8s ease-out infinite;
}

.ctsfw-timeline__item-title {
	margin: 0 0 0.25rem;
	font: normal 700 1.25rem / 1.3 var(--font-primary, "Open Sans", Helvetica, Arial, sans-serif);
	color: var(--color-heading, #001846);
}

.ctsfw-timeline__content {
	font-size: 1.125rem;
	line-height: var(--line-height-prose, 1.44);
}

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

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

.ctsfw-timeline__more {
	margin: 0.5rem 0 0;
	font-size: 1rem;
	font-weight: 700;
}

.ctsfw-timeline__link {
	color: var(--color-accent, #002c81);
	text-decoration: underline;
	text-underline-offset: 0.2em;
}

.ctsfw-timeline__link:hover,
.ctsfw-timeline__link:focus-visible {
	text-decoration-thickness: 2px;
}

/* Highlighted milestone: a larger brick with a slow glow. */
.ctsfw-timeline__item.is-highlight {
	--tl-brick: var(--tl-brick-lg);
}

.ctsfw-timeline__item.is-highlight .ctsfw-timeline__date {
	color: var(--color-heading-em, #002c81);
}

.ctsfw-timeline__item.is-highlight .ctsfw-timeline__content {
	font-weight: 700;
	color: var(--color-heading, #001846);
}

/*
 * Scroll reveal.
 *
 * Nothing below applies until the timeline carries is-enhanced, which the
 * block's own one-line script adds only when the browser can do the reveal
 * and the visitor has not asked for reduced motion. Without it the timeline
 * is plain and complete.
 *
 * Only opacity and transform move. Neither changes the layout, so a
 * milestone holds its full space before it appears and nothing on the page
 * shifts when it does.
 */
.ctsfw-timeline.is-enhanced .ctsfw-timeline__date,
.ctsfw-timeline.is-enhanced .ctsfw-timeline__body {
	opacity: 0;
	transform: translateY(14px);
	transition:
		opacity 0.55s ease-out var(--tl-delay, 0ms),
		transform 0.55s cubic-bezier(0.2, 0.7, 0.2, 1) var(--tl-delay, 0ms);
}

.ctsfw-timeline.is-enhanced .ctsfw-timeline__brick::after {
	opacity: 0;
	transform: scale(0.3);
	transition:
		opacity 0.3s ease-out var(--tl-delay, 0ms),
		transform 0.45s cubic-bezier(0.3, 1.4, 0.5, 1) var(--tl-delay, 0ms);
}

.ctsfw-timeline.is-enhanced .ctsfw-timeline__item::after {
	transform: scaleY(0);
	transition: transform 0.8s ease-out calc(var(--tl-delay, 0ms) + 150ms);
}

.ctsfw-timeline.is-enhanced .ctsfw-timeline__item:not(.is-in) .ctsfw-timeline__halo {
	animation: none;
}

.ctsfw-timeline.is-enhanced .ctsfw-timeline__item.is-in .ctsfw-timeline__date,
.ctsfw-timeline.is-enhanced .ctsfw-timeline__item.is-in .ctsfw-timeline__body {
	opacity: 1;
	transform: none;
}

.ctsfw-timeline.is-enhanced .ctsfw-timeline__item.is-in .ctsfw-timeline__brick::after {
	opacity: 1;
	transform: none;
}

.ctsfw-timeline.is-enhanced .ctsfw-timeline__item.is-in::after {
	transform: scaleY(1);
}

@keyframes ctsfw-timeline-shine {
	0% {
		opacity: 0.55;
		transform: scale(1);
	}

	70%,
	100% {
		opacity: 0;
		transform: scale(2.6);
	}
}

/* Narrow: the rail moves to the left edge and the date stacks above the text. */
@container (max-width: 40rem) {
	.ctsfw-timeline__title {
		margin-bottom: 2rem;
	}

	.ctsfw-timeline__list {
		--tl-rail-col: 2.5rem;
		--tl-rail-x: 14px;
		--tl-brick: 24px;
		--tl-brick-lg: 28px;
	}

	.ctsfw-timeline__item {
		grid-template-columns: var(--tl-rail-col) minmax(0, 1fr);
		padding-bottom: 2rem;
	}

	.ctsfw-timeline__marker {
		grid-column: 1;
		grid-row: 1 / span 2;
	}

	.ctsfw-timeline__brick,
	.ctsfw-timeline__halo {
		left: var(--tl-rail-x);
	}

	.ctsfw-timeline__date {
		grid-column: 2;
		grid-row: 1;
		margin-bottom: 0.25rem;
		text-align: left;
	}

	.ctsfw-timeline__body {
		grid-column: 2;
		grid-row: 2;
	}

	.ctsfw-timeline__content {
		font-size: 1rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ctsfw-timeline__halo {
		animation: none;
	}
}

/* Paper always gets the whole timeline, lit. */
@media print {
	.ctsfw-timeline.is-enhanced .ctsfw-timeline__date,
	.ctsfw-timeline.is-enhanced .ctsfw-timeline__body,
	.ctsfw-timeline.is-enhanced .ctsfw-timeline__brick::after {
		opacity: 1;
		transform: none;
		transition: none;
	}

	.ctsfw-timeline.is-enhanced .ctsfw-timeline__item::after {
		transform: none;
		transition: none;
	}

	.ctsfw-timeline__halo {
		display: none;
	}
}
