/*
 * Diditon Timeline: front end (design option D).
 * All colours, fonts and sizes are variables on .dtl, so style modes and dark mode
 * (milestone 4) only change variable values, never the layout rules below.
 */

.dtl {
	--dtl-bg: #f5f2ec;
	--dtl-surface: #f5f2ec;
	--dtl-ink: #1d1c1a;
	--dtl-ink-2: #5e5a53;
	--dtl-accent: #8b4a1e;
	--dtl-rule: #e2dcd2;
	--dtl-ph: #e7e0d5;
	--dtl-font-head: "Newsreader", Georgia, "Times New Roman", serif;
	--dtl-font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	--dtl-pad: 32px;
	--dtl-band: 6px;
	--dtl-band-left: 7px;
	--dtl-band-area: 28px;
	--dtl-yearcol: 112px;
	--dtl-thumb-w: 150px;
	--dtl-thumb-h: 200px;
	--dtl-feature-w: 300px;
	--dtl-bar-h: 72px;
	--dtl-sticky-top: 0px;
	/* Width: the panel fills its container; the content stops growing at --dtl-max (panel width
	   including the side padding, Timeline › Settings). --dtl-e is the extra inset each side,
	   measured against this wrapper (container units), and is 0 when there is room to spare. */
	--dtl-max: 1160px;
	--dtl-e: max(0px, (100cqi + 2 * var(--dtl-pad) - var(--dtl-max)) / 2);

	box-sizing: border-box;
	container-type: inline-size;
	padding: 0 var(--dtl-pad) 80px;
	background: var(--dtl-bg);
	color: var(--dtl-ink);
	font-family: var(--dtl-font-body);
	font-size: 17px;
	line-height: 1.6;
	text-align: left;
}

/* WordPress admin bar is fixed above the page; milestone 3 measures the site header as well. */
body.admin-bar .dtl {
	--dtl-sticky-top: 32px;
}

@media (max-width: 782px) {
	body.admin-bar .dtl {
		--dtl-sticky-top: 46px;
	}
}

@media (max-width: 600px) {
	/* The admin bar scrolls away on small phones. */
	body.admin-bar .dtl {
		--dtl-sticky-top: 0px;
	}
}

/* Neutralise theme spacing and list styles inside the timeline. */
.dtl *,
.dtl *::before,
.dtl *::after {
	box-sizing: inherit;
}

.dtl :where(h2, h3, p, ul, li, figure, figcaption) {
	margin: 0;
	padding: 0;
	border: 0;
}

.dtl :where(ul) {
	list-style: none;
}

.dtl :where(h2, h3) {
	color: inherit;
	letter-spacing: normal;
	text-transform: none;
}

/* Plugin style: headings and links keep the timeline's colours even when the theme's dark mode
   recolours all headings and hovered links (Themify: html.tf_darkmode h2, a:hover { color: #fff }). */
.dtl:not(.dtl--theme) :is(h2, h3) {
	color: var(--dtl-ink);
}

.dtl:not(.dtl--theme) a,
.dtl:not(.dtl--theme) a:hover {
	color: var(--dtl-accent);
}

.dtl a {
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 3px;
}

.dtl a:hover {
	text-decoration-thickness: 2px;
}

.dtl a:focus-visible {
	outline: 2px solid var(--dtl-accent);
	outline-offset: 2px;
	border-radius: 2px;
}

.dtl-sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
}

/* Heading and intro */
.dtl-head {
	padding-top: 72px;
}

.dtl-eyebrow {
	margin-bottom: 12px;
	color: var(--dtl-ink-2);
	font-size: 13px;
	letter-spacing: 0.12em;
	text-transform: uppercase;
}

.dtl .dtl-title {
	font-family: var(--dtl-font-head);
	font-size: clamp(40px, 7vw, 72px);
	font-weight: 400;
	line-height: 1.05;
	letter-spacing: -0.01em;
}

.dtl-intro {
	max-width: 680px;
	margin-top: 24px;
	color: var(--dtl-ink-2);
	font-size: 19px;
	line-height: 1.6;
}

.dtl-intro p + p {
	margin-top: 0.8em;
}

/* Country key: pills (buttons in milestone 3) */
.dtl-key {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 6px;
	padding: 28px 0 32px;
}

.dtl .dtl-key-btn {
	display: inline-flex;
	align-items: center;
	gap: 9px;
	min-height: 44px;
	padding: 0 14px 0 12px;
	border: 1px solid var(--dtl-rule);
	border-radius: 999px;
	background: transparent;
	color: var(--dtl-ink);
	font: 500 14px/1 var(--dtl-font-body);
	letter-spacing: normal;
	text-transform: none;
	cursor: pointer;
}

.dtl .dtl-key-btn:hover,
.dtl .dtl-key-btn[aria-pressed="true"] {
	border-color: var(--dtl-ink);
}

/* Country filter switched off: the key is a plain legend. */
.dtl .dtl-key-legend,
.dtl .dtl-key-legend:hover {
	border-color: var(--dtl-rule);
	cursor: default;
}

.dtl-seg,
.dtl-key-btn,
.dtl-filter {
	--band: var(--c);
}

.dtl-swatch {
	display: inline-block;
	width: 5px;
	height: 18px;
	border-radius: 1px;
	background: var(--band, transparent);
}

/* Content centred within the width set; edge-to-edge rows below widen their padding to match. */
.dtl > * {
	margin-inline: var(--dtl-e);
}

/* Sticky bar with section tabs: rules run edge to edge */
.dtl-bar {
	position: sticky;
	top: var(--dtl-sticky-top);
	z-index: 20;
	margin: 0 calc(-1 * var(--dtl-pad)); /* a direct child: no --dtl-e margin, so only the padding to undo */
	padding: 0 calc(var(--dtl-pad) + var(--dtl-e));
	border-top: 1px solid var(--dtl-rule);
	border-bottom: 1px solid var(--dtl-rule);
	background: var(--dtl-surface);
}

.dtl-tabs {
	display: flex;
	gap: 4px;
	overflow-x: auto;
	scrollbar-width: none;
}

.dtl-tabs::-webkit-scrollbar {
	display: none;
}

.dtl .dtl-tabs a {
	display: flex;
	flex-direction: column;
	justify-content: center;
	min-height: 44px;
	padding: 14px 14px 11px;
	border-bottom: 3px solid transparent;
	line-height: 1.3;
	text-decoration: none;
	white-space: nowrap;
}

.dtl .dtl-tabs a:hover,
.dtl .dtl-tabs a[aria-current] {
	border-bottom-color: var(--dtl-accent);
}

.dtl-tab-range {
	color: var(--dtl-ink);
	font-size: 15px;
	font-weight: 500;
}

.dtl-tabs a[aria-current] .dtl-tab-range {
	font-weight: 600;
}

.dtl-tab-title {
	color: var(--dtl-ink-2);
	font-size: 13px;
}

/* Sections */
.dtl-section {
	scroll-margin-top: calc(var(--dtl-sticky-top) + var(--dtl-bar-h));
}

.dtl-section-head {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 56px;
	align-items: end;
	padding: 80px 0 44px;
}

.dtl-section-head.has-image {
	grid-template-columns: var(--dtl-feature-w) minmax(0, 1fr);
}

.dtl-section-text {
	padding-bottom: 28px;
}

.dtl-range {
	color: var(--dtl-accent);
	font-family: var(--dtl-font-head);
	font-size: clamp(24px, 3vw, 32px);
	line-height: 1.2;
}

.dtl .dtl-section-title {
	margin-top: 2px;
	font-family: var(--dtl-font-head);
	font-size: clamp(32px, 5vw, 56px);
	font-weight: 400;
	line-height: 1.08;
	letter-spacing: -0.005em;
}

.dtl-summary {
	max-width: 560px;
	margin-top: 20px;
	color: var(--dtl-ink-2);
	font-size: 19px;
	line-height: 1.55;
}

.dtl-feature {
	width: var(--dtl-feature-w);
}

.dtl-feature > a {
	display: block;
}

/* Images are shown whole, scaled down to fit the 3:4 frame (wide works come out less tall);
   the placeholder keeps the full frame. */
.dtl-feature img {
	display: block;
	width: auto;
	height: auto;
	max-width: 100%;
	max-height: calc(var(--dtl-feature-w) * 4 / 3);
}

.dtl-ph-feature {
	display: block;
	width: 100%;
	aspect-ratio: 3 / 4;
	background: var(--dtl-ph);
}

.dtl-feature figcaption,
.dtl-thumb figcaption {
	margin-top: 12px;
	color: var(--dtl-ink-2);
	font-size: 14px;
	line-height: 1.4;
}

/* Year rows: band | year | content | thumbnails, with a rule between rows */
.dtl-years {
	border-top: 1px solid var(--dtl-rule);
}

.dtl-year {
	display: grid;
	grid-template-columns: var(--dtl-band-area) var(--dtl-yearcol) minmax(0, 1fr) auto;
	padding: 22px 0;
	border-bottom: 1px solid var(--dtl-rule);
	scroll-margin-top: calc(var(--dtl-sticky-top) + var(--dtl-bar-h) + 8px);
}

.dtl-band {
	display: flex;
	flex-direction: column;
	width: var(--dtl-band-area);
}

.dtl .dtl-seg {
	position: relative;
	display: block;
	flex: 1 1 0;
	width: 100%;
	min-height: 12px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
}

.dtl-seg::before {
	content: "";
	position: absolute;
	top: 0;
	bottom: 0;
	left: var(--dtl-band-left);
	width: var(--dtl-band);
	background: var(--band, transparent);
	transition: width 0.12s;
}

.dtl button.dtl-seg {
	cursor: pointer;
}

.dtl button.dtl-seg:hover::before {
	width: calc(var(--dtl-band) + 3px);
}

.dtl button.dtl-seg:focus-visible {
	outline: 2px solid var(--dtl-accent);
	outline-offset: -2px;
}

.dtl-year-num {
	display: block;
	font-family: var(--dtl-font-head);
	font-size: 30px;
	line-height: 1.05;
	font-variant-numeric: lining-nums;
}

.dtl-code {
	display: block;
	margin-top: 8px;
	color: var(--dtl-ink-2);
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.08em;
	line-height: 1.2;
}

.dtl-content {
	padding-top: 1px;
}

.dtl-event + .dtl-event {
	margin-top: 10px;
}

.dtl .dtl-exh-label {
	margin-right: 8px;
	color: var(--dtl-accent);
	font-size: 11.5px;
	font-weight: 600;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	white-space: nowrap;
}

.dtl-thumbs {
	display: flex;
	flex-direction: column;
	gap: 20px;
	padding-left: 32px;
}

.dtl-thumb {
	width: var(--dtl-thumb-w);
}

.dtl .dtl-thumb > a {
	display: block;
}

.dtl-thumb img {
	display: block;
	width: auto;
	height: auto;
	max-width: var(--dtl-thumb-w);
	max-height: var(--dtl-thumb-h);
}

.dtl-thumb .dtl-ph {
	display: block;
	width: var(--dtl-thumb-w);
	height: var(--dtl-thumb-h);
	background: var(--dtl-ph);
}

/* ---- Milestone 3: controls, People view, filter ---- */

.dtl [hidden] {
	display: none !important;
}

/* Without the script: Events view only, no controls. */
.dtl:not(.dtl-js) :is(.dtl-rows-people, .dtl-count, .dtl-switch, .dtl-chips, .dtl-filter) {
	display: none;
}

.dtl-js:not([data-view="people"]) :is(.dtl-rows-people, .dtl-count, .dtl-chips) {
	display: none;
}

.dtl-js[data-view="people"] .dtl-rows-events {
	display: none;
}

.dtl .dtl-bar button {
	margin: 0;
	font-family: var(--dtl-font-body);
	letter-spacing: normal;
	text-transform: none;
	cursor: pointer;
}

.dtl .dtl-bar button:focus-visible,
.dtl .dtl-key-btn:focus-visible,
.dtl .dtl-code-item:focus-visible {
	outline: 2px solid var(--dtl-accent);
	outline-offset: 2px;
}

.dtl-bar {
	transition: transform 0.2s ease;
}

.dtl-bar.is-away {
	transform: translateY(calc(-100% - var(--dtl-sticky-top) - 2px));
}

.dtl-bar-row {
	display: flex;
	align-items: center;
	gap: 16px;
}

.dtl-nav {
	flex: 1 1 auto;
	min-width: 0;
}

/* Events / People switch */
.dtl-switch {
	display: flex;
	flex: 0 0 auto;
	padding: 4px;
	border: 1px solid var(--dtl-rule);
	border-radius: 999px;
}

.dtl .dtl-switch button {
	min-height: 40px;
	padding: 0 22px;
	border: 0;
	border-radius: 999px;
	background: transparent;
	color: var(--dtl-ink);
	font-size: 15px;
	font-weight: 500;
	line-height: 1;
}

/* Tap area 44 px tall (inside the pill's 4 px padding) without changing the look. */
.dtl .dtl-switch button {
	position: relative;
}

.dtl .dtl-switch button::before {
	content: "";
	position: absolute;
	inset: -4px 0;
}

.dtl .dtl-switch button[aria-pressed="true"] {
	background: var(--dtl-ink);
	color: var(--dtl-surface);
	font-weight: 600;
}

/* Discipline chips (People view) */
.dtl-chips {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0 calc(-1 * (var(--dtl-pad) + var(--dtl-e)));
	padding: 10px calc(var(--dtl-pad) + var(--dtl-e));
	border-top: 1px solid var(--dtl-rule);
	overflow-x: auto;
	scrollbar-width: none;
}

.dtl-chips-label {
	margin-right: 4px;
	color: var(--dtl-ink-2);
	font-size: 14px;
}

.dtl .dtl-chips button {
	flex: 0 0 auto;
	min-height: 44px;
	padding: 0 16px;
	border: 1px solid var(--dtl-rule);
	border-radius: 999px;
	background: transparent;
	color: var(--dtl-ink);
	font-size: 14px;
	font-weight: 500;
	line-height: 1;
}

.dtl .dtl-chips button:hover {
	border-color: var(--dtl-ink);
}

.dtl .dtl-chips button[aria-pressed="true"] {
	border-color: var(--dtl-ink);
	background: var(--dtl-ink);
	color: var(--dtl-surface);
	font-weight: 600;
}

/* Country filter row */
.dtl-filter {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr) auto;
	align-items: center;
	gap: 18px;
	margin: 0 calc(-1 * (var(--dtl-pad) + var(--dtl-e)));
	padding: 14px calc(var(--dtl-pad) + var(--dtl-e));
	border-bottom: 1px solid var(--dtl-rule);
	background: var(--dtl-ph);
}

.dtl-filter-band {
	width: var(--dtl-band);
	height: 60px;
	background: var(--band, transparent);
}

.dtl-filter-title {
	font-family: var(--dtl-font-head);
	font-size: 30px;
	line-height: 1.15;
}

.dtl-filter-periods {
	margin-top: 4px;
	color: var(--dtl-ink-2);
	font-size: 14px;
	line-height: 1.3;
}

.dtl .dtl-showall {
	min-height: 48px;
	padding: 0 22px;
	border: 0;
	border-radius: 999px;
	background: var(--dtl-ink);
	color: var(--dtl-surface);
	font-size: 15px;
	font-weight: 600;
	line-height: 1;
}

/* Country codes as filter buttons */
.dtl .dtl-code-item {
	display: inline;
	margin: 0;
	padding: 2px 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	letter-spacing: inherit;
	text-transform: none;
}

.dtl button.dtl-code-item {
	/* 24 × 24 px target (WCAG 2.2 AA); the negative margin keeps the line height. */
	display: inline-block;
	min-width: 24px;
	min-height: 24px;
	margin: -6px 0;
	padding: 6px 0;
	text-align: left;
	vertical-align: baseline;
	text-decoration: underline;
	text-underline-offset: 2px;
	cursor: pointer;
}

.dtl button.dtl-code-item:hover {
	color: var(--dtl-ink);
}

/* People view */
.dtl-count {
	margin-top: 20px;
	color: var(--dtl-ink-2);
	font-size: 15px;
}

.dtl-pgroup {
	display: grid;
	grid-template-columns: 100px minmax(0, 1fr);
	gap: 0 12px;
	align-items: baseline;
}

.dtl-pgroup + .dtl-pgroup {
	margin-top: 10px;
}

.dtl-group-label {
	color: var(--dtl-ink-2);
	font-size: 11.5px;
	font-weight: 600;
	letter-spacing: 0.1em;
	text-transform: uppercase;
}

.dtl-pname.is-key {
	font-weight: 600;
}

.dtl-also {
	color: var(--dtl-ink-2);
	font-size: 14px;
	font-weight: 400;
}

/* "Also" target highlight */
@keyframes dtl-flash {
	0%,
	60% {
		background-color: color-mix(in srgb, var(--dtl-accent) 22%, transparent);
	}

	100% {
		background-color: transparent;
	}
}

.dtl-flash {
	border-radius: 2px;
	animation: dtl-flash 2.5s ease-out;
}

/* Editors only: sticky bar cannot stick */
.dtl-notice {
	margin: 16px 0;
	padding: 12px 16px;
	border-left: 4px solid #b26b00;
	background: #fff4d6;
	color: #4a3300;
	font-size: 14px;
}

/* Approximate dates: small italic "c" before the year or entry */
.dtl-circa {
	margin-right: 0.12em;
	color: var(--dtl-ink-2);
	font-family: var(--dtl-font-head);
	font-size: 0.6em;
	font-style: italic;
}

/* Before a year: hang in the gap after the band so the digits stay aligned (inline on phones). */
.dtl-year-num {
	position: relative;
	white-space: nowrap;
}

.dtl-circa-long {
	display: none;
}

.dtl-year-num > .dtl-circa {
	position: absolute;
	right: 100%;
	bottom: 0.18em;
	margin-right: 2px;
	font-size: 0.62em;
	line-height: 1;
}

.dtl-event > .dtl-circa {
	margin-right: 0.35em;
	font-size: 0.9em;
}

/* ---- Milestone 4: "use theme styles" mode ----
 * Text, fonts and links come from the theme; rules and tints derive from the text colour.
 * A var() that resolves to "initial" makes the property fall back to inheriting.
 * The script supplies the page text colour (--dtl-page-ink), background (--dtl-page-bg) and heading font (--dtl-theme-head),
 * so derived colours stay right inside links and buttons (where currentColor means their own colour).
 */
.dtl.dtl--theme {
	--dtl-bg: transparent;
	--dtl-surface: var(--dtl-page-bg, Canvas);
	--dtl-ink: var(--dtl-page-ink, currentColor);
	--dtl-ink-2: color-mix(in srgb, var(--dtl-ink) 72%, transparent);
	--dtl-accent: var(--dtl-ink);
	--dtl-rule: color-mix(in srgb, var(--dtl-ink) 15%, transparent);
	--dtl-ph: color-mix(in srgb, var(--dtl-ink) 8%, transparent);
	--dtl-font-body: initial;
	--dtl-font-head: var(--dtl-theme-head, initial);
	font-size: inherit;
	line-height: inherit;
}

/* Places switched off: no colour band column */
.dtl.dtl--no-places {
	--dtl-band-area: 0px;
}

/* Phones */
@media (max-width: 700px) {
	.dtl {
		--dtl-pad: 20px;
		--dtl-band-left: 6px;
		--dtl-band-area: 20px;
		--dtl-yearcol: 64px;
		--dtl-feature-w: 200px;
		--dtl-bar-h: 52px;
		font-size: 16px;
	}

	.dtl-head {
		padding-top: 40px;
	}

	.dtl-intro {
		font-size: 17px;
	}

	.dtl .dtl-tabs a {
		padding: 14px 12px 11px;
	}

	.dtl-tab-title {
		display: none;
	}

	.dtl-bar-row {
		gap: 8px;
	}

	.dtl .dtl-switch button {
		min-height: 36px;
		padding: 0 14px;
		font-size: 14px;
	}

	.dtl-filter {
		gap: 12px;
	}

	.dtl-filter-title {
		font-size: 22px;
	}

	.dtl .dtl-showall {
		min-height: 44px;
		padding: 0 16px;
	}

	.dtl-pgroup {
		grid-template-columns: minmax(0, 1fr);
	}

	.dtl-pgroup .dtl-group-label {
		display: block;
		margin-bottom: 2px;
	}

	.dtl-section-head,
	.dtl-section-head.has-image {
		grid-template-columns: minmax(0, 1fr);
		gap: 24px;
		padding: 48px 0 28px;
	}

	.dtl-section-text {
		padding-bottom: 0;
	}

	.dtl-summary {
		font-size: 17px;
	}

	.dtl-year-num {
		font-size: 26px;
	}

	/* Phones: "circa" in full on its own line above the year, so the year keeps its full width. */
	.dtl-year-num > .dtl-circa {
		position: static;
		display: block;
		margin: 0 0 2px;
		font-size: 13px;
		line-height: 1.1;
	}

	.dtl-year-num .dtl-circa-short {
		display: none;
	}

	.dtl-year-num .dtl-circa-long {
		display: inline;
	}

	/* Thumbnails drop below the text, aligned with it (SPEC). */
	.dtl-year > .dtl-thumbs {
		grid-column: 3;
		flex-flow: row wrap;
		padding: 16px 0 0;
	}

	.dtl-year > .dtl-band {
		grid-row: span 2;
	}
}

@media (prefers-reduced-motion: reduce) {
	.dtl-bar {
		transition: none;
	}

	.dtl-flash {
		animation: none;
		outline: 2px solid var(--dtl-accent);
		outline-offset: 2px;
	}
}

@media (prefers-reduced-motion: no-preference) {
	.dtl a {
		transition: color 0.15s, text-decoration-thickness 0.15s;
	}
}
