/*
 * Línea de tiempo "Nuestra historia" (ancla #historia).
 *
 *   Contenedor                  → history-line
 *     Contenedor                → history-line__head
 *       Texto corto             → eyebrow eyebrow--plain
 *       Título                  → history-line__heading
 *       Texto                   → history-line__intro
 *     Contenedor VACÍO          → history-line__rail   (history-line.js lo llena con los años)
 *     Contenedor                → history-line__stage
 *       Contenedor (un hito)    → history-line__item   (se repite: duplicar para agregar un hito)
 *         Contenedor            → history-line__media
 *           Imagen              → history-line__photo
 *           Título (el año)     → history-line__year
 *         Contenedor            → history-line__body
 *           Título              → history-line__title
 *           Texto               → history-line__text
 *
 * history-line.js muestra un hito a la vez, crea los años, los botones y avanza solo.
 * En el editor de Elementor (o sin JS) todos los hitos se ven uno bajo otro.
 * Los modificadores --stacked, --on y --done los pone el JS; no se usan en Elementor.
 */

.history-line {
	display: block;
	width: 100%;
	padding: clamp(48px, 6vw, 88px) var(--wrap-gutter);
	overflow: hidden;
	background: var(--color-soft);
}

.history-line__head {
	--row-gap: 0;

	display: flex;
	flex-direction: column;
	align-items: center;
	margin-bottom: clamp(22px, 2.6vw, 36px);
	text-align: center;
}
.history-line__heading { padding-top: 14px; }
.history-line__heading .elementor-heading-title {
	max-width: 15em;
	margin-inline: auto;
	font-family: var(--font-display);
	font-size: clamp(32px, 4.4vw, 64px);
	font-weight: 800;
	letter-spacing: -.04em;
	line-height: 1.04;
	color: var(--color-ink);
}
.history-line__intro { padding-top: 14px; font-weight: 500; color: var(--color-muted); }
.history-line__intro p { margin: 0; }

/* ---- Años (los crea el JS) ---- */
.history-line__rail {
	--row-gap: 0;
	--column-gap: 0;

	position: relative;
	display: flex;
	flex-direction: row !important; /* Elementor fija la dirección con más especificidad */
	flex-wrap: nowrap;
	margin-bottom: clamp(14px, 1.8vw, 24px);
	padding: 6px 4px 0;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
}
.history-line__rail::-webkit-scrollbar { display: none; }
.history-line__rail:empty { display: none; }

.history-line__dot {
	position: relative;
	flex: 0 0 70px;
	margin: 0;
	padding: 24px 2px 0;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
	color: var(--color-muted);
	font: inherit;
	text-align: center;
	text-transform: none;
	cursor: pointer;
	scroll-snap-align: center;
	-webkit-appearance: none;
	appearance: none;
}
.history-line__dot:hover,
.history-line__dot:focus { background: none; color: var(--color-ink); }
.history-line__dot--on,
.history-line__dot--on:hover { color: var(--color-ink); }
/* Tramos de la línea a cada lado del punto. */
.history-line__dot::before,
.history-line__dot::after {
	content: "";
	position: absolute;
	top: 7px;
	height: 2px;
	background: var(--color-line);
	transition: background-color .3s;
}
.history-line__dot::before { left: 0; right: 50%; }
.history-line__dot::after { left: 50%; right: 0; }
.history-line__dot:first-child::before,
.history-line__dot:last-child::after { display: none; }
.history-line__dot--done::before,
.history-line__dot--done::after { background: var(--color-brand-red); }
.history-line__dot--on::after { background: var(--color-line); }

.history-line__marker {
	position: absolute;
	left: 50%;
	top: 0;
	z-index: 1;
	width: 16px;
	height: 16px;
	margin-left: -8px;
	border: 2px solid #d9d0cc;
	border-radius: 50%;
	background: #fff;
	transition: transform .3s var(--ease-out), background-color .3s, border-color .3s;
}
.history-line__marker--done { border-color: var(--color-brand-red); background: var(--color-brand-red); }
.history-line__marker--on { transform: scale(1.45); box-shadow: 0 0 0 6px rgba(215, 38, 30, .18); }

.history-line__dot-label {
	font-size: 14px;
	font-weight: 700;
	letter-spacing: -.01em;
	color: inherit;
	transition: color .3s;
}

/* ---- Escenario ---- */
.history-line__stage {
	--row-gap: 0;
	--column-gap: 0;

	position: relative;
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	overflow: hidden;
	border-radius: clamp(26px, 3vw, 40px);
	background: #fff;
	box-shadow: 0 24px 60px rgba(41, 33, 31, .10);
	outline: none;
}
.history-line__stage:focus-visible { outline: 3px solid var(--color-brand-red); outline-offset: 3px; }

.history-line__item {
	--row-gap: 0;
	--column-gap: 0;

	display: grid;
	grid-template-columns: minmax(0, 1fr);
}
.history-line__item + .history-line__item { border-top: 1px solid var(--color-line); }

/* Con JS: los hitos se apilan en la misma celda y solo se ve el activo. */
.history-line__item--stacked {
	grid-area: 1 / 1;
	border-top: 0 !important; /* anula el separador de la lista estática (.item + .item) */
	opacity: 0;
	visibility: hidden;
	transition: opacity .6s ease, visibility .6s;
}
.history-line__item--on { opacity: 1; visibility: visible; }

.history-line__media {
	position: relative;
	display: block;
	aspect-ratio: 16 / 11;
	overflow: hidden;
	background: #1d1513;
	touch-action: pan-y;
}
.history-line__media::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
	background: linear-gradient(0deg, rgba(24, 15, 12, .78) 0%, rgba(24, 15, 12, .15) 45%, rgba(24, 15, 12, 0) 70%);
	pointer-events: none;
}

/* La foto llena la caja; se recorta el <img> interno (excepción documentada). */
.history-line__photo {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
}
.history-line__photo img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
}
.history-line__photo--stacked img { transform: scale(1.08); transition: transform 6s ease-out; }
.history-line__photo--on img { transform: scale(1); }

.history-line__year {
	position: absolute;
	left: clamp(20px, 3vw, 40px);
	bottom: clamp(10px, 1.6vw, 22px);
	z-index: 2;
	width: auto;
	margin: 0;
}
.history-line__year .elementor-heading-title {
	font-family: var(--font-display);
	font-size: clamp(64px, 22vw, 96px);
	font-weight: 800;
	letter-spacing: -.06em;
	line-height: .9;
	font-variant-numeric: tabular-nums;
	text-shadow: 0 6px 30px rgba(0, 0, 0, .25);
	color: #fff;
}

.history-line__body {
	--row-gap: 14px;

	display: flex;
	flex-direction: column;
	justify-content: center;
	padding: 24px 22px 26px;
}
.history-line__body--stacked { padding-bottom: 100px; transform: translateY(10px); transition: transform .5s var(--ease-out); }
.history-line__body--on { transform: none; }
.history-line__title .elementor-heading-title {
	font-family: var(--font-display);
	font-size: clamp(26px, 2.8vw, 40px);
	font-weight: 800;
	letter-spacing: -.035em;
	line-height: 1.05;
	color: var(--color-ink);
}
.history-line__text { font-size: clamp(16px, 1.25vw, 18px); color: var(--color-muted); }
.history-line__text p { margin: 0; }

/* ---- Controles (los crea el JS) ---- */
.history-line__nav {
	position: absolute;
	left: 22px;
	right: 22px;
	bottom: 26px;
	z-index: 3;
	display: flex;
	align-items: center;
	gap: 10px;
}
.history-line__btn {
	display: grid;
	place-items: center;
	flex: none;
	width: 48px;
	height: 48px;
	margin: 0;
	padding: 0;
	border: 1.5px solid var(--color-line);
	border-radius: 50%;
	background: #fff;
	box-shadow: none;
	color: var(--color-ink);
	cursor: pointer;
	transition: background-color .25s, color .25s, border-color .25s;
	-webkit-appearance: none;
	appearance: none;
}
.history-line__btn:hover,
.history-line__btn:focus { border-color: var(--color-brand-red); background: var(--color-brand-red); color: #fff; }
.history-line__btn--play { border-color: var(--color-brand-red); background: var(--color-brand-red); color: #fff; }
.history-line__btn svg { width: 18px; height: 18px; }

.history-line__progress {
	flex: 1;
	height: 3px;
	margin-left: 8px;
	overflow: hidden;
	border-radius: 3px;
	background: var(--color-line);
}
.history-line__bar { display: block; width: 0; height: 100%; background: var(--color-brand-red); }

.history-line__count {
	flex: none;
	font-size: 13px;
	font-weight: 700;
	letter-spacing: .12em;
	white-space: nowrap;
	color: var(--color-muted);
}
.history-line__current { font-size: 15px; color: var(--color-brand-red); }

@media (min-width: 768px) {
	.history-line__year .elementor-heading-title { font-size: clamp(72px, 10vw, 150px); }
	.history-line__dot { flex: 1 0 64px; }
}

@media (min-width: 1025px) {
	.history-line__item { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
	.history-line__media { aspect-ratio: auto; min-height: clamp(300px, 30vw, 440px); }
	.history-line__body { padding: clamp(26px, 3.4vw, 52px); }
	.history-line__body--stacked { padding-bottom: calc(clamp(26px, 3.4vw, 52px) + 72px); }
	/* Los controles ocupan la columna derecha, abajo. */
	.history-line__nav {
		left: calc(58.3333% + clamp(26px, 3.4vw, 52px));
		right: clamp(26px, 3.4vw, 52px);
		bottom: clamp(26px, 3.4vw, 52px);
	}
}

@media (prefers-reduced-motion: reduce) {
	.history-line__item--stacked,
	.history-line__photo--stacked img,
	.history-line__body--stacked { transition: none; transform: none; }
}
