/* Timeline sidebar redesign (feature/timeline-sidebar-redesign).
   Loaded AFTER elections.css so these rules win the cascade without touching
   the legacy Part A sidebar styles.

   Theme: every colour reads from a --tl-* custom property declared on
   #sidebar-col. The default palette keeps the original darkslategrey scheme
   (the site's "light" mode); panel-theme.js toggles .tl-dark on #sidebar-col
   in step with the right-hand results panel, switching to the results-desk
   card surfaces (same tokens as --rd-* in results-desk.css). */

#sidebar-col {
	/* current / light scheme: the original darkslategrey sidebar */	--tl-bg: darkslategrey;
	--tl-text: #ffffff;
	--tl-text2: #e6eded;
	--tl-muted: #a7b8b8;
	--tl-faint: #7f9494;
	--tl-hairline: rgba(255,255,255,0.22);
	--tl-raised: rgba(255,255,255,0.07);
	--tl-link: #ffffff;
	--tl-chip-on: #ffffff;
	--tl-chip-on-text: #2f4f4f;
	--tl-chip-bd: rgba(255,255,255,0.4);
	--tl-defect: #e8c15a;
	--tl-today: #6fd08c;

	background-color: var(--tl-bg);
	font-family: 'Libre Franklin', 'PT Sans', sans-serif;
	display: flex;
	flex-direction: column;
	padding: 14px 12px 10px 12px;
	box-sizing: border-box;

	/* wider than bootstrap's col-1: the row grid (date gutter + marker +
	   wrapping titles) needs ~250px to breathe; the map and data columns
	   split the remainder in their original 50 : 41.67 ratio */
	width: 250px;
	max-width: none;
	flex: none;
}

#map-col { width: calc((100% - 250px) * 0.5455); max-width: none; }
#data-col { width: calc((100% - 250px) * 0.4545); max-width: none; }

#sidebar-col.tl-dark {
	/* results-desk scheme (matches --rd-* in results-desk.css) */
	--tl-bg: #15171d;
	--tl-text: #e8e6e1;
	--tl-text2: #c9c6bf;
	--tl-muted: #8b8fa0;
	--tl-faint: #5d6270;
	--tl-hairline: #262a34;
	--tl-raised: #1d2029;
	--tl-link: #7fb3e8;
	--tl-chip-on: #e8e6e1;
	--tl-chip-on-text: #15171d;
	--tl-chip-bd: #363b48;
	--tl-defect: #e8c15a;
	--tl-today: #6fd08c;
}

/* ---- header: previous GE + current GE ---- */

#previouselection {
	text-align: left;
	margin-bottom: 2px;
}

#previouselection a.tl-prev,
#previouselection a.tl-prev:hover {
	font-size: 11px;
	font-weight: 600;
	color: var(--tl-muted) !important;
	text-decoration: none;
	cursor: pointer;
}

#previouselection a.tl-prev:hover { color: var(--tl-text) !important; }

#currentyear {
	text-align: left;
	color: var(--tl-text);
	margin-top: 6px;
}

#currentgeneral {
	font-size: 28px;
	font-weight: 800;
	line-height: 1.05;
	text-align: left;
}

#currentyear a.generalelection {
	font-size: 12px;
	font-weight: 700;
	color: var(--tl-link);
	text-decoration: none;
}

#currentyear a.generalelection.activeelection { text-decoration: underline; }

/* ---- filter chips ---- */

#timeline-filters {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	margin: 12px 0 0 0;
	padding-bottom: 10px;
	border-bottom: 1px solid var(--tl-hairline);
}

.tl-chip-filter {
	font-size: 10px;
	font-weight: 700;
	padding: 2px 8px;
	border-radius: 999px;
	cursor: pointer;
	color: var(--tl-muted);
	border: 1px solid var(--tl-chip-bd);
	white-space: nowrap;
}

.tl-chip-filter:hover { color: var(--tl-text); }

.tl-chip-filter.tl-chip-active {
	background: var(--tl-chip-on);
	border-color: var(--tl-chip-on);
	color: var(--tl-chip-on-text);
}

/* ---- event list ---- */

#byelections {
	height: auto;          /* was 80% - the column is a flexbox now */
	flex: 1;
	margin-top: 4px;
	font-size: 11.5px;
	text-align: left;
	overflow-y: auto;
	-ms-overflow-style: none;
	scrollbar-width: none;
}

.tl-group {
	position: relative;
	padding-bottom: 4px;
}

.tl-group .tl-spine {
	position: absolute;
	left: 50px;
	top: 24px;
	bottom: 0;
	width: 2px;
	background: var(--tl-hairline);
}

.tl-year {
	font-size: 10px;
	font-weight: 800;
	letter-spacing: 0.12em;
	color: var(--tl-faint);
	padding: 8px 0 3px 0;
}

/* the year heading collapses/expands its whole group */
.tl-year-click { cursor: pointer; user-select: none; -webkit-user-select: none; }
.tl-year-click:hover { color: var(--tl-muted); }
.tl-caret { display: inline-block; width: 11px; font-size: 8px; vertical-align: 1px; }
.tl-year-n {
	font-weight: 600;
	letter-spacing: normal;
	color: var(--tl-muted);
}
.tl-coll { padding-bottom: 0; }
.tl-coll .tl-ybody, .tl-coll .tl-spine { display: none; }

.tl-row, .tl-more {
	position: relative;
	display: grid;
	grid-template-columns: 40px 20px 1fr;
	align-items: start;
	padding: 4px 0;
}

.tl-row:hover { background: var(--tl-raised); }

.tl-date {
	font-size: 9.5px;
	color: var(--tl-muted);
	font-variant-numeric: tabular-nums;
	text-align: right;
	padding-top: 2px;
	white-space: nowrap;
}

.tl-mk {
	justify-self: center;
	margin-top: 4px;
	width: 9px;
	height: 9px;
	border-radius: 50%;
	box-sizing: border-box;
	border: 2px solid var(--tl-text);
	background: var(--tl-text);
}

.tl-mk-defect {
	border-radius: 1px;
	transform: rotate(45deg);
	background: var(--tl-defect);
	border-color: var(--tl-defect);
	width: 8px;
	height: 8px;
}

.tl-mk-whip { background: transparent; border-color: var(--tl-muted); }
.tl-mk-more { background: transparent; border-style: dashed; border-color: var(--tl-faint); }
.tl-mk-today { background: transparent; border-width: 3px; border-color: var(--tl-today); width: 11px; height: 11px; }

#byelections a.tl-link {
	display: block;
	font-size: 11.5px;
	line-height: 1.35;
	color: var(--tl-text2);
	text-decoration: none;
	padding-left: 4px;
}

#byelections a.tl-link:hover { color: var(--tl-text); }

#byelections .tl-row-bye a.tl-link { font-weight: 700; }

#byelections a.tl-link.activeelection {
	color: var(--tl-text);
	font-weight: 700;
	text-decoration: underline;
}

/* the "Today" row reads as an endpoint, not an ordinary event */
#byelections a.tl-link.tl-today-link {
	font-size: 13px;
	font-weight: 800;
	color: var(--tl-text);
}

.tl-res {
	display: inline-block;
	margin-left: 5px;
	font-size: 8.5px;
	font-weight: 800;
	letter-spacing: 0.06em;
	border: 1px solid;
	border-radius: 3px;
	padding: 0px 4px;
	vertical-align: 1px;
	white-space: nowrap;
}

.tl-more { cursor: pointer; }

.tl-more .tl-more-lbl {
	font-size: 10.5px;
	font-weight: 700;
	color: var(--tl-link);
	padding-left: 4px;
}

.tl-more:hover .tl-more-lbl { text-decoration: underline; }

/* ---- endpoints (next GE / Today), appended to #sidebar-col ---- */

#nextbigthing, #nextgeneral {
	flex-shrink: 0;
}

#nextgeneral, a.nextgeneralelection, #lastgeneral, #lastgeneralsmall, #previouselection {
	color: var(--tl-muted) !important;
}

#nextgeneral {
	font-size: 24px;
	font-weight: 800;
	text-align: center;
}

a.nextgeneralelection.nexterpos:hover, #nextgeneral.nexterpos:hover {
	color: var(--tl-text) !important;
	text-decoration: none;
}

/* ---- playback bar (moved from the map column into the sidebar) ----
   playback.js only addresses it by id, so relocating the markup needs no JS
   change. In the narrow column the bar becomes a static, full-width block at
   the very bottom (order beats the JS-appended Today/next-GE endpoint, which
   keeps the default order 0), themed with the --tl-* tokens. */

#playback-bar {
	position: static;
	transform: none;
	left: auto;
	top: auto;
	width: auto;
	max-width: none;
	flex-shrink: 0;
	order: 10;
	margin-top: 8px;
	padding: 8px 2px 2px 2px;
	background-color: transparent;
	border-radius: 0;
	box-shadow: none;
	border-top: 1px solid var(--tl-hairline);
	font-family: 'Libre Franklin', 'PT Sans', sans-serif;
}

#playback-bar .pb-controls {
	flex-wrap: wrap;
	gap: 5px;
}

/* scrubber takes its own full-width row above the buttons */
#pb-scrub {
	flex: 1 1 100%;
	min-width: 0;
	margin: 0;
	height: 14px;
}
#pb-scrub::-webkit-slider-runnable-track {
	height: 6px;
	background: var(--tl-hairline);
	border: none;
	border-radius: 3px;
}
#pb-scrub::-moz-range-track {
	height: 6px;
	background: var(--tl-hairline);
	border: none;
	border-radius: 3px;
}
#pb-scrub::-webkit-slider-thumb {
	margin-top: -4px;
	height: 14px;
	width: 8px;
	border-radius: 3px;
	background: var(--tl-link);
	border: none;
}
#pb-scrub::-moz-range-thumb {
	height: 14px;
	width: 8px;
	border-radius: 3px;
	background: var(--tl-link);
	border: none;
}

#playback-bar .pb-btn {
	width: 24px;
	height: 22px;
	border-radius: 6px;
	background-color: var(--tl-raised);
	border: 1px solid var(--tl-chip-bd);
	color: var(--tl-text);
	font-size: 10px;
}
#playback-bar .pb-btn:hover { background-color: var(--tl-hairline); }

#playback-bar .pb-speeds { margin-left: auto; }
#playback-bar .pb-speed {
	background: transparent;
	border: 1px solid var(--tl-chip-bd);
	color: var(--tl-muted);
	font-size: 9px;
	border-radius: 3px;
	padding: 2px 3px;
}
#playback-bar .pb-speed:hover { color: var(--tl-text); }
#playback-bar .pb-speed-active {
	background: var(--tl-chip-on);
	border-color: var(--tl-chip-on);
	color: var(--tl-chip-on-text);
}

/* play-on-through-history toggle (2.14): reads as a normal pb-btn when off,
   and takes the filled "active chip" look (like the selected speed) when on */
#playback-bar .pb-through { font-size: 13px; line-height: 1; }
#playback-bar .pb-through.pb-through-active {
	background: var(--tl-chip-on);
	border-color: var(--tl-chip-on);
	color: var(--tl-chip-on-text);
}

#playback-bar .pb-readout {
	margin-top: 4px;
	flex-wrap: wrap;
	gap: 3px 8px;
	min-height: 0;
}
#pb-caption {
	font-size: 10px;
	color: var(--tl-muted);
	white-space: normal;
	line-height: 1.3;
}
#pb-tally { flex-wrap: wrap; gap: 3px 6px; }
#playback-bar .pb-chip { font-size: 9.5px; color: var(--tl-text2); }

/* ---- cross-election playback transition banner (2.14) ----
   A brief centred banner over the map while playback rolls on from one general
   election into the next (a full-page reload). It sits outside #sidebar-col, so
   the --tl-* tokens don't reach it: colours are self-contained and read over the
   map in both themes. */
#pb-transition {
	position: fixed;
	left: 50%; top: 18%;
	transform: translateX(-50%);
	z-index: 9999;
	background: rgba(21,23,29,0.92);
	color: #f5f3ee;
	padding: 10px 18px;
	border-radius: 8px;
	font-family: 'Libre Franklin', 'PT Sans', sans-serif;
	font-size: 14px;
	letter-spacing: 0.02em;
	box-shadow: 0 6px 24px rgba(0,0,0,0.35);
	pointer-events: none;
	max-width: 80vw;
}
#pb-transition-text::before {
	content: "\25B8";   /* ▸ */
	margin-right: 8px;
	color: #6fd08c;
	animation: pb-blink 0.9s steps(2, start) infinite;
}
@keyframes pb-blink { 50% { opacity: 0.2; } }

/* ---- key-event call-outs (playback) ----
   Fleeting, semi-transparent cards flashed in the middle of the map as playback
   crosses a key event. Sits outside #sidebar-col so the --tl-* tokens don't reach
   it; colours are self-contained and read over the map in both themes. */
#pb-callouts {
	position: fixed;
	left: 50%; top: 42%;
	transform: translateX(-50%);
	z-index: 9998;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 10px;
	pointer-events: none;
	width: max-content;
	max-width: 72vw;
}
.pb-callout {
	background: rgba(21,23,29,0.82);
	color: #f5f3ee;
	border-left: 4px solid #9aa3af;
	padding: 9px 20px;
	border-radius: 9px;
	box-shadow: 0 8px 28px rgba(0,0,0,0.32);
	text-align: center;
	font-family: 'Libre Franklin', 'PT Sans', sans-serif;
	opacity: 0;
	animation-name: pb-callout-life;
	animation-duration: 2600ms;   /* overridden inline, scaled by speed */
	animation-timing-function: ease;
	animation-fill-mode: forwards;
}
.pb-callout .pb-co-head { font-size: 17px; font-weight: 600; line-height: 1.2; }
.pb-callout .pb-co-meta { font-size: 12px; color: #cfd3dc; margin-top: 3px; letter-spacing: 0.02em; }

/* context "milestone" cards (standalone key events, e.g. wartime landmarks):
   distinct from the political call-outs - gold accent, an italic headline and a
   flagged, uppercased meta line, no party colour */
.pb-callout-milestone { border-left-color: #e8c15a; }
.pb-callout-milestone .pb-co-head { font-style: italic; font-weight: 600; }
.pb-callout-milestone .pb-co-meta {
	color: #e8c15a;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	font-size: 11px;
}
.pb-callout-milestone .pb-co-meta::before { content: "\2691\00a0"; }   /* ⚑ */

@keyframes pb-callout-life {
	0%   { opacity: 0; transform: translateY(8px) scale(0.98); }
	12%  { opacity: 0.94; transform: translateY(0) scale(1); }
	72%  { opacity: 0.94; transform: translateY(0) scale(1); }
	100% { opacity: 0; transform: translateY(-6px) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
	.pb-callout { animation-timing-function: linear; }
}

/* ---- government majority tracker, fused with the scrub track (majority-track.js) ---- */
/* The scrubber is wrapped so the majority chart can sit behind the range input;
   the input keeps all interaction (drag/keys) but its track/thumb are made
   transparent while the tracker is on, so the SVG line + playhead show through.
   Without .mt-on (tracker not built) the scrubber renders exactly as before. */
#pb-scrub-wrap { position: relative; flex: 1 1 100%; width: 100%;
	--mt-zero: rgba(255,255,255,0.34); --mt-head: rgba(255,255,255,0.85); --mt-dot-ring: #2f4f4f; }
#sidebar-col.tl-dark #pb-scrub-wrap { --mt-dot-ring: #15171d; }
#mt-chart { display: none; }

#pb-scrub-wrap.mt-on { height: 50px; }
#pb-scrub-wrap.mt-on #mt-chart {
	display: block; position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none;
}
#pb-scrub-wrap.mt-on #pb-scrub {
	position: absolute; left: 0; top: 0; width: 100%; height: 100%; margin: 0;
	-webkit-appearance: none; appearance: none; background: transparent; cursor: pointer;
}
#pb-scrub-wrap.mt-on #pb-scrub::-webkit-slider-runnable-track { background: transparent; height: 100%; border: none; }
#pb-scrub-wrap.mt-on #pb-scrub::-moz-range-track { background: transparent; height: 100%; border: none; }
#pb-scrub-wrap.mt-on #pb-scrub::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 16px; height: 100%; background: transparent; opacity: 0; }
#pb-scrub-wrap.mt-on #pb-scrub::-moz-range-thumb { width: 16px; height: 16px; background: transparent; opacity: 0; border: none; }

#mt-readout { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 2px 2px 5px; }
#mt-readout:empty { display: none; }
.mt-label { text-transform: uppercase; letter-spacing: 0.05em; font-size: 9.5px; color: var(--tl-text2, #b6c8c8); }
.mt-value { font-weight: 800; font-size: 13px; color: var(--tl-text, #eef0f3); }
.mt-word { font-weight: 600; font-size: 10px; color: var(--tl-text2, #b6c8c8); margin-left: 2px; }
