/* The journey in time: a band that is drawn in the map's own frame, on the same
   sheet, and scrolled sideways. Above the line stand the stories of their own,
   below it the road of the King. (js/timeline.js) */

/* The switch between the two views, beside the atlas's heading */
#chooser .atlas-views {
	display: inline-flex;
	gap: 0;
	margin-left: auto;
	border: 1px solid #b99550;
	border-radius: 6px;
	overflow: hidden;
	pointer-events: auto;
}
#chooser .atlas-views button {
	min-height: 30px;
	padding: 4px 12px;
	font:
		600 12px/1.2 -apple-system,
		BlinkMacSystemFont,
		'Segoe UI',
		sans-serif;
	letter-spacing: 0.03em;
	color: #d9cfa6;
	background: #1a2f24;
	border: 0;
	cursor: pointer;
}
#chooser .atlas-views button + button {
	border-left: 1px solid #b99550;
}
#chooser .atlas-views button[aria-pressed='true'] {
	color: #23180a;
	background: linear-gradient(#e6c877, #b88a43);
}
#chooser .atlas-views button:focus-visible {
	outline: 2px solid #f7df9e;
	outline-offset: -3px;
}

/* (the map's marks have nothing to say about the band) */
#chooser.in-time .atlas-legend .legend-locked {
	border-style: dashed;
}

#chooser #mapBox > .timeline {
	--seal: 44px;
	position: relative;
	display: flex;
	align-items: stretch;
	width: 100%;
	height: 100%;
	padding: 10px 6px;
	overflow-x: auto;
	overflow-y: hidden;
	overscroll-behavior-x: contain;
	scrollbar-width: thin;
	scrollbar-color: #8a6f3c #cbb47d;
	background: radial-gradient(ellipse at 20% 0%, #e2cf98, transparent 60%), #cbb47d;
	-webkit-user-select: none;
	user-select: none;
	touch-action: pan-x;
}

/* One age: its name, the stories above the line, the line, the road below it */
.timeline .age {
	flex: none;
	display: grid;
	grid-template-rows: auto minmax(0, 1fr) 14px minmax(0, 1fr);
	min-width: 0;
	padding: 0 10px;
	border-left: 1px dashed #7c6a4866;
}
.timeline .age-head {
	position: sticky;
	left: 0;
	z-index: 2;
	width: 92px;
	padding: 0 8px 0 4px;
	border-left: 0;
	background: linear-gradient(90deg, #cbb47d 78%, transparent);
}
.timeline .age-title {
	display: flex;
	flex-direction: column;
	min-height: 34px;
	padding-bottom: 4px;
	white-space: nowrap;
	color: #463b27;
}
/* (an age's name stays in view while its places are scrolled past) */
.timeline .age:not(.age-head) .age-title {
	position: sticky;
	left: 100px;
	justify-self: start;
	width: max-content;
}
.timeline .age-title b {
	font: 700 15px/1.2 var(--serif);
	font-variant: small-caps;
	letter-spacing: 0.04em;
}
.timeline .age-title small {
	font: italic 11px/1.3 var(--serif);
	color: #6b5a3c;
}

/* The line of time, with a bead where each age begins */
.timeline .age-axis {
	position: relative;
	align-self: center;
	height: 3px;
	margin: 0 -10px;
	background: #7e4329;
}
.timeline .age:not(.age-head) .age-axis::before {
	content: '';
	position: absolute;
	top: 50%;
	left: -5px;
	width: 9px;
	height: 9px;
	background: #ecda9c;
	border: 2px solid #7e4329;
	border-radius: 50%;
	transform: translateY(-50%);
}
.timeline .age-head .age-axis {
	margin: 0 -8px 0 -4px;
	background: linear-gradient(90deg, transparent, #7e4329);
}
.timeline .age:last-child .age-axis {
	background: linear-gradient(90deg, #7e4329 70%, transparent);
}

.timeline .lane {
	display: flex;
	gap: 6px;
	min-height: 0;
}
.timeline .lane-side {
	align-items: flex-end;
	padding-bottom: 4px;
}
.timeline .lane-road {
	align-items: flex-start;
	padding-top: 4px;
}
.timeline .lane-name {
	align-self: center;
	font: italic 11px/1.25 var(--serif);
	color: #6b5a3c;
}

/* One place on the band */
.timeline .when {
	flex: none;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 3px;
	width: 74px;
	padding: 2px;
	font: inherit;
	color: #463b27;
	background: none;
	border: 0;
	border-radius: 8px;
	cursor: pointer;
}
/* (above the line the name stands over its seal, so the seal sits on the line) */
.timeline .when-side {
	flex-direction: column-reverse;
}
.timeline .when-seal {
	position: relative;
	flex: none;
	display: grid;
	place-items: center;
	width: var(--seal);
	height: var(--seal);
	color: #463b27;
	background: #f7eed4;
	border: 2px solid #463b27;
	border-radius: 50%;
	box-shadow: 0 2px 4px #3d2c1640;
}
/* (the map's own drawing is framed and shadowed as a sheet: a sign is not) */
#chooser #mapBox .timeline .when-seal svg {
	width: 62%;
	height: 62%;
	max-height: none;
	margin: 0;
	background: none;
	border: 0;
	border-radius: 0;
	box-shadow: none;
}
.timeline .when-name {
	max-width: 100%;
	font: 600 11.5px/1.15 var(--serif);
	text-align: center;
	text-wrap: balance;
	overflow-wrap: anywhere;
}
/* (roughly when: small and quiet under the name) */
.timeline .when-year {
	margin-top: -1px;
	font: italic 500 9.5px/1.1 var(--serif);
	text-align: center;
	white-space: nowrap;
	opacity: 0.7;
}
.timeline .when-tick {
	position: absolute;
	top: -5px;
	right: -5px;
	display: grid;
	place-items: center;
	width: 16px;
	height: 16px;
	font: 700 10px/1 sans-serif;
	font-style: normal;
	color: #fff;
	background: #45633b;
	border-radius: 50%;
}

/* A stop that is finished, and one that is still ahead */
.timeline .is-done .when-seal {
	border-color: #45633b;
}
.timeline .is-ahead {
	opacity: 0.55;
}
.timeline .is-ahead .when-seal {
	border-style: dashed;
	background: #eadfbf;
}
/* A story of its own: open in the map's red-brown ink, or only planned */
.timeline .when-side.is-open .when-seal {
	color: #7e4329;
	background: #fff3c4;
	border-color: #7e4329;
}
.timeline .when-side.is-open .when-name {
	font-style: italic;
	color: #7e4329;
}
.timeline .is-planned {
	opacity: 0.6;
}
.timeline .is-planned .when-seal {
	width: calc(var(--seal) * 0.72);
	height: calc(var(--seal) * 0.72);
	margin: calc(var(--seal) * 0.14);
	color: #7c6a48;
	background: #eadfbf;
	border: 2px dashed #7c6a48;
	border-radius: 4px;
	box-shadow: none;
	transform: rotate(45deg);
}
.timeline .is-planned .when-seal svg {
	transform: rotate(-45deg);
}
.timeline .is-planned .when-name {
	font-weight: 400;
}

/* Where the traveller stands, and what has been chosen */
.timeline .when.next .when-seal {
	color: #8e4229;
	border-color: #8e4229;
	box-shadow:
		0 0 0 4px #8e422933,
		0 2px 4px #3d2c1640;
}
.timeline .when.selected,
.timeline .when:hover {
	opacity: 1;
}
.timeline .when.selected .when-seal {
	color: #23180a;
	background: #e6c877;
	box-shadow:
		0 0 0 3px #f7eed4,
		0 0 0 5px #a98440;
}
.timeline .when.selected .when-name {
	font-weight: 700;
}
.timeline .when:focus-visible {
	outline: 2px solid #7e4329;
	outline-offset: 1px;
}

/* A phone held upright: the atlas's heading lies over the top of the frame and
   its caption over the foot, so the band keeps clear of both */
@media (max-width: 759px) and (min-height: 521px) {
	/* What was tapped is read at once: its card comes straight under the frame,
	   before the journey's own counts */
	#chooser .map-shell > .map-sidebar > #placeCard {
		order: -1;
	}
	#chooser #mapBox > .timeline {
		padding: 62px 4px 36px;
	}
	#chooser .atlas-views button {
		min-height: 28px;
		padding: 3px 10px;
		font-size: 11px;
	}
}

/* Little height (a phone on its side): smaller seals, and no dates */
@media (max-height: 520px) {
	#chooser #mapBox > .timeline {
		--seal: 32px;
		padding: 4px 4px 2px;
	}
	.timeline .age {
		grid-template-rows: auto minmax(0, 1fr) 10px minmax(0, 1fr);
	}
	.timeline .age-title {
		min-height: 0;
		padding-bottom: 1px;
	}
	.timeline .age-title b {
		font-size: 12px;
	}
	.timeline .age-title small {
		display: none;
	}
	.timeline .when {
		width: 62px;
		gap: 1px;
	}
	.timeline .when-name {
		font-size: 10px;
	}
	.timeline .when-year {
		font-size: 8.5px;
	}
	.timeline .age-head {
		width: 74px;
	}
	.timeline .age:not(.age-head) .age-title {
		left: 80px;
	}
	.timeline .lane-name {
		font-size: 9.5px;
	}
}

/* How much of a stop is done: its count, over a thin gold bar */
.timeline .when-count {
	padding-bottom: 3px;
	font: 700 10px/1.1 var(--serif);
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
	background:
		linear-gradient(var(--gold, #b8862b), var(--gold, #b8862b)) 0 100% / var(--share, 0%) 2px no-repeat,
		linear-gradient(rgba(51, 35, 15, 0.2), rgba(51, 35, 15, 0.2)) 0 100% / 100% 2px no-repeat;
}
