/* Maqueteo Línea de Historia — frontend
   Concepto: la línea de tiempo como sendero despejado.
   El riel se dibuja punteado y se rellena a medida que se avanza. */

.mlh {
	--mlh-acento: #D2402A;
	--mlh-sendero: #1F5C4C;
	--mlh-tinta: #16211D;
	--mlh-fondo: #EDEEEA;
	--mlh-destacado: #E4DCCB;

	--mlh-col-anio: 8.5rem;
	--mlh-col-riel: 2.75rem;
	--mlh-fuente-titulo: "Archivo", "Helvetica Neue", Helvetica, Arial, sans-serif;
	--mlh-fuente-texto: "Source Serif 4", Georgia, "Times New Roman", serif;
	--mlh-progreso: 0%;

	position: relative;
	box-sizing: border-box;
	color: var(--mlh-tinta);
	font-family: var(--mlh-fuente-texto);
	background: var(--mlh-fondo);
	padding: clamp(2rem, 5vw, 4.5rem) clamp(1.1rem, 4vw, 3rem);
	line-height: 1.65;
}

.mlh--sin-fuentes {
	--mlh-fuente-titulo: inherit;
	--mlh-fuente-texto: inherit;
}

.mlh *,
.mlh *::before,
.mlh *::after {
	box-sizing: border-box;
}

.mlh ol,
.mlh ul {
	margin: 0;
	padding: 0;
	list-style: none;
}

/* ---------- Encabezado ---------- */

.mlh__encabezado {
	max-width: 62ch;
	margin: 0 0 clamp(2rem, 5vw, 3.5rem);
}

.mlh__titulo {
	font-family: var(--mlh-fuente-titulo);
	font-weight: 700;
	font-size: clamp(2rem, 4.6vw, 3.4rem);
	line-height: 1.03;
	letter-spacing: -0.025em;
	color: var(--mlh-tinta);
	margin: 0 0 1rem;
}

.mlh__intro p {
	margin: 0 0 0.9rem;
	font-size: clamp(1rem, 1.15vw, 1.125rem);
	color: color-mix(in srgb, var(--mlh-tinta) 85%, transparent);
}

.mlh__intro p:last-child {
	margin-bottom: 0;
}

/* ---------- Navegación de años ---------- */

.mlh__aniosnav {
	position: sticky;
	top: 0;
	z-index: 3;
	margin: 0 0 clamp(1.5rem, 4vw, 2.75rem);
	padding: 0.6rem 0;
	background: linear-gradient(to bottom, var(--mlh-fondo) 72%, transparent);
}

.mlh__aniosnav ul {
	display: flex;
	flex-wrap: nowrap;
	gap: 0.35rem;
	overflow-x: auto;
	scrollbar-width: thin;
	padding-bottom: 0.25rem;
}

.mlh__aniosnav a {
	display: block;
	font-family: var(--mlh-fuente-titulo);
	font-weight: 600;
	font-size: 0.9rem;
	letter-spacing: 0.01em;
	text-decoration: none;
	color: color-mix(in srgb, var(--mlh-tinta) 65%, transparent);
	padding: 0.3rem 0.7rem;
	border: 1px solid color-mix(in srgb, var(--mlh-tinta) 18%, transparent);
	border-radius: 2px;
	white-space: nowrap;
	transition: color 0.2s, border-color 0.2s, background-color 0.2s;
}

.mlh__aniosnav a:hover,
.mlh__aniosnav a:focus-visible {
	color: var(--mlh-fondo);
	background: var(--mlh-tinta);
	border-color: var(--mlh-tinta);
}

.mlh__aniosnav a.is-activo {
	color: var(--mlh-acento);
	border-color: var(--mlh-acento);
	background: transparent;
}

/* ---------- Sendero ---------- */

.mlh__pista {
	position: relative;
}

.mlh__sendero {
	position: absolute;
	top: 0.35rem;
	bottom: 0.35rem;
	left: calc(var(--mlh-col-anio) + (var(--mlh-col-riel) / 2) - 1px);
	width: 2px;
	background-image: repeating-linear-gradient(
		to bottom,
		color-mix(in srgb, var(--mlh-tinta) 34%, transparent) 0 6px,
		transparent 6px 14px
	);
}

.mlh__avance {
	position: absolute;
	inset: 0 0 auto 0;
	display: block;
	height: var(--mlh-progreso);
	background: var(--mlh-sendero);
	transition: height 0.18s linear;
}

.mlh:not(.mlh--animada) .mlh__avance {
	height: 100%;
}

/* ---------- Hito ---------- */

.mlh__hito {
	position: relative;
	display: grid;
	grid-template-columns: var(--mlh-col-anio) var(--mlh-col-riel) minmax(0, 1fr);
	align-items: start;
	padding-bottom: clamp(2.25rem, 5vw, 4rem);
}

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

.mlh__marca {
	grid-column: 2;
	grid-row: 1;
	position: relative;
	justify-self: center;
	width: 0.9rem;
	height: 0.9rem;
	margin-top: 0.55rem;
	background: var(--mlh-fondo);
	border: 2px solid color-mix(in srgb, var(--mlh-tinta) 38%, transparent);
	transition: border-color 0.35s ease, background-color 0.35s ease, transform 0.35s ease;
}

/* Filete que conecta el marcador con el texto */
.mlh__marca::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 100%;
	width: calc(var(--mlh-col-riel) / 2 - 0.45rem);
	height: 1px;
	background: color-mix(in srgb, var(--mlh-tinta) 25%, transparent);
	transform: scaleX(0);
	transform-origin: left center;
	transition: transform 0.45s ease 0.1s, background-color 0.35s ease;
}

.mlh__hito.is-visible .mlh__marca {
	background: var(--mlh-acento);
	border-color: var(--mlh-acento);
}

.mlh__hito.is-visible .mlh__marca::after {
	transform: scaleX(1);
	background: var(--mlh-acento);
}

.mlh:not(.mlh--animada) .mlh__marca {
	background: var(--mlh-acento);
	border-color: var(--mlh-acento);
}

.mlh:not(.mlh--animada) .mlh__marca::after {
	transform: scaleX(1);
}

.mlh__hito.is-destacado .mlh__marca {
	width: 1.15rem;
	height: 1.15rem;
	margin-top: 0.4rem;
}

.mlh__anio {
	grid-column: 1;
	grid-row: 1;
	margin: 0;
	padding-right: 1.25rem;
	text-align: right;
	font-family: var(--mlh-fuente-titulo);
	font-weight: 700;
	font-size: clamp(1.5rem, 2.6vw, 2.15rem);
	line-height: 1;
	letter-spacing: -0.02em;
	color: color-mix(in srgb, var(--mlh-tinta) 45%, transparent);
	transition: color 0.4s ease;
	font-variant-numeric: tabular-nums;
}

.mlh__hito.is-visible .mlh__anio,
.mlh:not(.mlh--animada) .mlh__anio {
	color: var(--mlh-tinta);
}

.mlh__cuerpo {
	grid-column: 3;
	grid-row: 1;
	max-width: 62ch;
	padding-left: 0.35rem;
}

.mlh__etiqueta {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin: 0 0 0.5rem;
	font-family: var(--mlh-fuente-titulo);
	font-weight: 600;
	font-size: 0.82rem;
	letter-spacing: 0.02em;
	color: var(--mlh-acento);
}

.mlh__etiqueta::before {
	content: "";
	width: 1.1rem;
	height: 2px;
	background: currentColor;
	flex: none;
}

.mlh__hito-titulo {
	font-family: var(--mlh-fuente-titulo);
	font-weight: 600;
	font-size: clamp(1.2rem, 1.8vw, 1.5rem);
	line-height: 1.22;
	letter-spacing: -0.015em;
	margin: 0 0 0.85rem;
	color: var(--mlh-tinta);
}

.mlh__texto p {
	margin: 0 0 0.85rem;
	font-size: 1.02rem;
	color: color-mix(in srgb, var(--mlh-tinta) 88%, transparent);
	hyphens: auto;
}

.mlh__texto p:last-child {
	margin-bottom: 0;
}

/* Las fotos se montan sobre un paspartú, como copias de archivo.
   Así una foto vieja de baja resolución no se ve estirada. */
.mlh__figura {
	margin: 0 0 1.25rem;
	max-width: 27rem;
	padding: 0.55rem;
	background: var(--mlh-destacado);
}

.mlh__figura img {
	display: block;
	width: 100%;
	height: auto;
	filter: saturate(0.9);
}

.mlh__figura figcaption {
	margin-top: 0.5rem;
	padding: 0 0.1rem;
	font-family: var(--mlh-fuente-titulo);
	font-size: 0.78rem;
	line-height: 1.4;
	color: color-mix(in srgb, var(--mlh-tinta) 62%, transparent);
}

.mlh__hito.is-destacado .mlh__figura {
	background: color-mix(in srgb, var(--mlh-tinta) 8%, var(--mlh-fondo));
}

.mlh--alterno .es-par .mlh__figura {
	margin-left: auto;
}

@media (max-width: 782px) {
	.mlh .mlh__figura {
		max-width: 100%;
	}

	.mlh .es-par .mlh__figura {
		margin-left: 0;
	}
}

.mlh__accion {
	margin: 1rem 0 0;
}

.mlh__accion a {
	font-family: var(--mlh-fuente-titulo);
	font-weight: 600;
	font-size: 0.92rem;
	color: var(--mlh-tinta);
	text-decoration: none;
	border-bottom: 2px solid var(--mlh-acento);
	padding-bottom: 2px;
	transition: color 0.2s;
}

.mlh__accion a:hover,
.mlh__accion a:focus-visible {
	color: var(--mlh-acento);
}

/* Hito destacado */

.mlh__hito.is-destacado .mlh__cuerpo {
	background: var(--mlh-destacado);
	padding: clamp(1.1rem, 2.4vw, 1.75rem);
	margin-left: -0.35rem;
}

.mlh__hito.is-destacado .mlh__hito-titulo {
	font-size: clamp(1.35rem, 2.2vw, 1.8rem);
}

/* ---------- Estilo alterno ---------- */

.mlh--alterno .mlh__sendero {
	left: calc(50% - 1px);
}

.mlh--alterno .mlh__hito {
	grid-template-columns: minmax(0, 1fr) var(--mlh-col-riel) minmax(0, 1fr);
	grid-template-rows: auto auto;
	column-gap: 0;
}

.mlh--alterno .mlh__marca {
	grid-row: 1;
}

.mlh--alterno .mlh__marca::after {
	display: none;
}

.mlh--alterno .mlh__anio {
	grid-row: 1;
}

.mlh--alterno .mlh__cuerpo {
	grid-row: 2;
	max-width: none;
}

.mlh--alterno .es-par .mlh__anio,
.mlh--alterno .es-par .mlh__cuerpo {
	grid-column: 1;
	text-align: right;
	padding-right: 1.5rem;
	padding-left: 0;
}

.mlh--alterno .es-par .mlh__etiqueta {
	flex-direction: row-reverse;
}

.mlh--alterno .es-impar .mlh__anio,
.mlh--alterno .es-impar .mlh__cuerpo {
	grid-column: 3;
	text-align: left;
	padding-left: 1.5rem;
	padding-right: 0;
}

.mlh--alterno .es-impar .mlh__anio {
	text-align: left;
}

/* ---------- Estilo compacto ---------- */

.mlh--compacto .mlh__sendero {
	left: calc(var(--mlh-col-riel) / 2 - 1px);
}

.mlh--compacto .mlh__hito {
	grid-template-columns: var(--mlh-col-riel) minmax(0, 1fr);
	grid-template-rows: auto auto;
}

.mlh--compacto .mlh__marca {
	grid-column: 1;
	grid-row: 1;
}

.mlh--compacto .mlh__marca::after {
	display: none;
}

.mlh--compacto .mlh__anio {
	grid-column: 2;
	grid-row: 1;
	text-align: left;
	padding: 0 0 0.5rem;
	font-size: clamp(1.35rem, 2.2vw, 1.75rem);
}

.mlh--compacto .mlh__cuerpo {
	grid-column: 2;
	grid-row: 2;
	padding-left: 0;
}

/* ---------- Móvil: todo pasa a una columna ---------- */

@media (max-width: 782px) {
	.mlh {
		--mlh-col-riel: 1.9rem;
	}

	.mlh .mlh__sendero {
		left: calc(var(--mlh-col-riel) / 2 - 1px);
	}

	.mlh .mlh__hito {
		grid-template-columns: var(--mlh-col-riel) minmax(0, 1fr);
		grid-template-rows: auto auto;
	}

	.mlh .mlh__marca {
		grid-column: 1;
		grid-row: 1;
		margin-top: 0.35rem;
	}

	.mlh .mlh__marca::after {
		display: none;
	}

	.mlh .mlh__anio,
	.mlh .es-par .mlh__anio,
	.mlh .es-impar .mlh__anio {
		grid-column: 2;
		grid-row: 1;
		text-align: left;
		padding: 0 0 0.45rem;
		font-size: 1.6rem;
	}

	.mlh .mlh__cuerpo,
	.mlh .es-par .mlh__cuerpo,
	.mlh .es-impar .mlh__cuerpo {
		grid-column: 2;
		grid-row: 2;
		text-align: left;
		padding-left: 0;
		padding-right: 0;
	}

	.mlh .es-par .mlh__etiqueta {
		flex-direction: row;
	}

	.mlh__hito.is-destacado .mlh__cuerpo {
		margin-left: 0;
	}
}

/* ---------- Accesibilidad ---------- */

.mlh a:focus-visible {
	outline: 2px solid var(--mlh-acento);
	outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
	.mlh__marca,
	.mlh__marca::after,
	.mlh__anio,
	.mlh__avance {
		transition: none !important;
	}
}

/* Aviso del editor cuando no hay hitos */
.mlh-aviso {
	padding: 1rem 1.25rem;
	border: 1px dashed #999;
	color: #555;
	font-size: 0.95rem;
}
