/**
 * Agro History Timeline
 * Plně customizovatelná a responzivní timeline.
 * Vše je řízeno CSS proměnnými (custom properties) => snadný theming.
 */

.agro-timeline {
	/* ---- Barvy (přepsatelné přes atributy shortcode nebo CSS) ---- */
	--agro-accent: #c2a15c;                 /* hlavní zlatá (kolečko + čára) */
	--agro-line: var(--agro-accent);        /* barva spojovací čáry */
	--agro-icon: #7d7f45;                    /* barva ikon (olivově zlatá) */
	--agro-circle-bg: #ffffff;               /* pozadí kolečka */
	--agro-circle-border: var(--agro-accent);/* okraj kolečka */
	--agro-year-color: #1f2530;              /* rok (velký nadpis) */
	--agro-title-color: #1f2530;             /* titulek milníku */
	--agro-desc-color: #6b7280;              /* popis */
	--agro-bg: transparent;                  /* pozadí celé komponenty */

	/* ---- Typografie ---- */
	--agro-font: inherit;                    /* výchozí = font webu */
	--agro-year-size: 1.9rem;
	--agro-title-size: 1.05rem;
	--agro-desc-size: 0.9rem;

	/* ---- Rozměry ---- */
	--agro-circle-size: 92px;
	--agro-icon-size: 46px;
	--agro-circle-border-width: 1.5px;
	--agro-line-thickness: 2px;
	--agro-gap: 22px;                        /* mezera mezi textovými sloupci */
	--agro-vgap: 34px;                       /* svislá mezera (vertikální/mobil) */
	--agro-marker-gap: 20px;                 /* mezera kolečko -> text */
	--agro-max-width: 1080px;
	--agro-badge-bg: var(--agro-circle-bg);  /* pozadí "výřezu" s rokem */
	--agro-badge-year-size: 1.2rem;          /* velikost roku v kolečku */

	/* ---- Zarovnání (nastavuje modifier třída) ---- */
	--agro-align: left;
	--agro-line-origin: calc(var(--agro-circle-size) / 2);

	box-sizing: border-box;
	width: 100%;
	max-width: var(--agro-max-width);
	margin-inline: auto;
	padding: 8px 0;
	background: var(--agro-bg);
	font-family: var(--agro-font);
	color: var(--agro-desc-color);
}

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

/* Zarovnání textu / kolečka */
.agro-timeline--align-left   { --agro-align: left;   --agro-line-origin: calc(var(--agro-circle-size) / 2); }
.agro-timeline--align-center { --agro-align: center; --agro-line-origin: 50%; }
.agro-timeline--align-right  { --agro-align: right;  --agro-line-origin: calc(100% - var(--agro-circle-size) / 2); }

/* ---------- TRACK ---------- */
.agro-timeline__track {
	display: flex;
	flex-wrap: nowrap;
	align-items: stretch;
	width: 100%;
}

.agro-timeline__item {
	flex: 1 1 0;
	min-width: 0;
	position: relative;
	display: flex;
	flex-direction: column;
}

/* ---------- KOLEČKO + IKONA ---------- */
.agro-timeline__marker {
	position: relative;
	height: var(--agro-circle-size);
	margin-bottom: var(--agro-marker-gap);
	text-align: var(--agro-align);
	line-height: 0;
}

.agro-timeline__circle {
	position: relative;
	z-index: 2;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var(--agro-circle-size);
	height: var(--agro-circle-size);
	border: var(--agro-circle-border-width) solid var(--agro-circle-border);
	border-radius: 50%;
	background: var(--agro-circle-bg);
}

.agro-timeline__icon {
	display: inline-flex;
	width: var(--agro-icon-size);
	height: var(--agro-icon-size);
	color: var(--agro-icon);
}

.agro-timeline__icon svg {
	width: 100%;
	height: 100%;
	display: block;
}

/* ---------- SPOJOVACÍ ČÁRA (horizontálně) ---------- */
.agro-timeline__connector {
	position: absolute;
	z-index: 1;
	top: 50%;
	left: var(--agro-line-origin);
	width: 100%;
	height: var(--agro-line-thickness);
	transform: translateY(-50%);
	background: var(--agro-line);
}

.agro-timeline__item:last-child .agro-timeline__connector {
	display: none;
}

/* varianty spojnice */
.agro-timeline--connector-none .agro-timeline__connector {
	display: none;
}

.agro-timeline--connector-dots .agro-timeline__connector {
	height: 0;
	background: none;
	border-top: var(--agro-line-thickness) dotted var(--agro-line);
}

/* ---------- TEXTOVÝ OBSAH ---------- */
.agro-timeline__content {
	text-align: var(--agro-align);
	padding-inline-end: var(--agro-gap);
}

.agro-timeline__year {
	display: block;
	font-size: var(--agro-year-size);
	font-weight: 700;
	line-height: 1.1;
	color: var(--agro-year-color);
	letter-spacing: -0.01em;
}

.agro-timeline__title {
	margin: 10px 0 6px;
	font-size: var(--agro-title-size);
	font-weight: 700;
	line-height: 1.25;
	color: var(--agro-title-color);
}

.agro-timeline__desc {
	margin: 0;
	font-size: var(--agro-desc-size);
	line-height: 1.55;
	color: var(--agro-desc-color);
}

/* ---------- ROK VE VÝŘEZU KOLEČKA (year_in_circle) ---------- */
.agro-timeline__year--badge {
	display: none;
}

/* v badge režimu skryj velký rok pod kolečkem (horizontálně) */
.agro-timeline--year-badge.agro-timeline--horizontal .agro-timeline__content .agro-timeline__year {
	display: none;
}

/* více místa pod kolečkem, protože badge zasahuje pod okraj */
.agro-timeline--year-badge.agro-timeline--horizontal .agro-timeline__marker {
	margin-bottom: calc(var(--agro-marker-gap) + 8px);
}

/* samotný "výřez" s rokem sedící na spodním okraji kolečka */
.agro-timeline--year-badge.agro-timeline--horizontal .agro-timeline__year--badge {
	display: inline-block;
	position: absolute;
	left: 50%;
	bottom: 0;
	transform: translate(-50%, 50%);
	margin: 0;
	padding: 0 12px;
	background: var(--agro-badge-bg);
	font-size: var(--agro-badge-year-size);
	font-weight: 700;
	line-height: 1;
	letter-spacing: -0.01em;
	color: var(--agro-year-color);
	white-space: nowrap;
}

/* ================================================================
 * VERTIKÁLNÍ ROZLOŽENÍ (layout=vertical) – platí ve všech šířkách
 * ================================================================ */
.agro-timeline--vertical .agro-timeline__track {
	flex-direction: column;
}

.agro-timeline--vertical .agro-timeline__item {
	flex-direction: row;
	align-items: stretch;
}

.agro-timeline--vertical .agro-timeline__marker {
	flex: 0 0 var(--agro-circle-size);
	width: var(--agro-circle-size);
	height: auto;
	margin-bottom: 0;
	display: flex;
	justify-content: center;
	align-items: flex-start;
}

.agro-timeline--vertical .agro-timeline__connector {
	top: var(--agro-circle-size);
	bottom: 0;
	left: 50%;
	width: var(--agro-line-thickness);
	height: auto;
	transform: translateX(-50%);
}

.agro-timeline--vertical.agro-timeline--connector-dots .agro-timeline__connector {
	width: 0;
	height: auto;
	border-top: 0;
	border-left: var(--agro-line-thickness) dotted var(--agro-line);
}

.agro-timeline--vertical .agro-timeline__content {
	padding-inline-end: 0;
	padding-inline-start: var(--agro-gap);
	padding-bottom: var(--agro-vgap);
	text-align: left;
}

.agro-timeline--vertical .agro-timeline__item:last-child .agro-timeline__content {
	padding-bottom: 0;
}

/* ================================================================
 * ANIMACE (aktivní jen když JS přidá .is-ready => progresivní vylepšení)
 * ================================================================ */
.agro-timeline--animate.is-ready .agro-timeline__item {
	opacity: 0;
	transform: translateY(18px);
	transition: opacity 0.6s ease, transform 0.6s ease;
	transition-delay: var(--agro-delay, 0ms);
}

.agro-timeline--animate.is-ready .agro-timeline__item.is-visible {
	opacity: 1;
	transform: none;
}

/* ================================================================
 * RESPONZIVITA – mobil (max 768px)
 * ================================================================ */
@media (max-width: 768px) {

	/* mobile=vertical: horizontální timeline se skládá pod sebe */
	.agro-timeline--horizontal.agro-timeline--mobile-vertical .agro-timeline__track {
		flex-direction: column;
	}

	.agro-timeline--horizontal.agro-timeline--mobile-vertical .agro-timeline__item {
		flex-direction: row;
		align-items: stretch;
	}

	.agro-timeline--horizontal.agro-timeline--mobile-vertical .agro-timeline__marker {
		flex: 0 0 var(--agro-circle-size);
		width: var(--agro-circle-size);
		height: auto;
		margin-bottom: 0;
		display: flex;
		justify-content: center;
		align-items: flex-start;
	}

	.agro-timeline--horizontal.agro-timeline--mobile-vertical .agro-timeline__connector {
		top: var(--agro-circle-size);
		bottom: 0;
		left: 50%;
		width: var(--agro-line-thickness);
		height: auto;
		transform: translateX(-50%);
		background: var(--agro-line);
	}

	.agro-timeline--horizontal.agro-timeline--mobile-vertical.agro-timeline--connector-dots .agro-timeline__connector {
		width: 0;
		border-top: 0;
		border-left: var(--agro-line-thickness) dotted var(--agro-line);
		background: none;
	}

	.agro-timeline--horizontal.agro-timeline--mobile-vertical .agro-timeline__content {
		padding-inline-end: 0;
		padding-inline-start: var(--agro-gap);
		padding-bottom: var(--agro-vgap);
		text-align: left;
	}

	.agro-timeline--horizontal.agro-timeline--mobile-vertical .agro-timeline__item:last-child .agro-timeline__content {
		padding-bottom: 0;
	}

	/* badge režim: na mobilu (skládání) vrať rok pod kolečko */
	.agro-timeline--year-badge.agro-timeline--horizontal.agro-timeline--mobile-vertical .agro-timeline__year--badge {
		display: none;
	}

	.agro-timeline--year-badge.agro-timeline--horizontal.agro-timeline--mobile-vertical .agro-timeline__content .agro-timeline__year {
		display: block;
	}

	/* mobile=scroll: zachová horizontální podobu, přidá vodorovný posun */
	.agro-timeline--horizontal.agro-timeline--mobile-scroll .agro-timeline__track {
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
		scroll-snap-type: x mandatory;
		padding-bottom: 8px;
	}

	.agro-timeline--horizontal.agro-timeline--mobile-scroll .agro-timeline__item {
		flex: 0 0 72%;
		scroll-snap-align: start;
	}

	/* zmenšení kolečka na malých displejích */
	.agro-timeline {
		--agro-circle-size: 76px;
		--agro-icon-size: 38px;
		--agro-year-size: 1.6rem;
	}
}

/* ================================================================
 * Přístupnost – respektuj sníženou míru pohybu
 * ================================================================ */
@media (prefers-reduced-motion: reduce) {
	.agro-timeline--animate.is-ready .agro-timeline__item {
		opacity: 1;
		transform: none;
		transition: none;
	}
}
