/*
 * Дорога из Бишкека: абстрактная карта-путь с остановками.
 *
 * Узлы кривой и позиции меток считает PHP, поэтому здесь только оформление
 * и состояния. Линия прочерчивается через pathLength, а не через длину в
 * пикселях — размер сцены зависит от ширины экрана.
 */

.st-route {
	position: relative;
	z-index: 10;
	overflow: hidden;
	padding: calc(var(--index) * 4) var(--pad) calc(var(--index) * 6);
}

.st-route__veil {
	position: absolute; inset: 0;
	background:
		radial-gradient(ellipse 44% 36% at 18% 22%, rgba(255, 255, 255, .88) 0%, rgba(255, 255, 255, .5) 40%, rgba(255, 255, 255, .18) 66%, transparent 84%),
		radial-gradient(ellipse 38% 30% at 76% 16%, rgba(255, 255, 255, .74) 0%, rgba(255, 255, 255, .4) 44%, rgba(255, 255, 255, .14) 70%, transparent 86%),
		linear-gradient(180deg,
			rgba(230, 241, 250, 0) 0%,
			rgba(222, 236, 248, .12) 28%,
			rgba(210, 229, 245, .26) 52%,
			rgba(200, 222, 241, .38) 76%,
			rgba(196, 219, 239, .45) 100%);
	pointer-events: none;
}

.st-route__inner { position: relative; max-width: var(--max); margin: 0 auto; }

.st-route__head {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
	gap: calc(var(--index) * 3);
	align-items: end;
	padding-bottom: calc(var(--index) * 2);
	border-bottom: 1px solid var(--line);
}
.st-route__head .st-lead { margin: 0; }

/* ============================================================
   1. Сцена
   ============================================================ */

.st-route__stage {
	position: relative;
	margin-top: calc(var(--index) * 2.6);
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 360px);
	gap: calc(var(--index) * 2.4);
	align-items: center;
}

/* Метки лежат в процентах от поля, поэтому поле обязано повторять пропорции
   svg — иначе точки уедут с дороги. */
.st-route__viewport { position: relative; }
.st-route__plot { position: relative; aspect-ratio: 1200 / 560; }
.st-route__svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }

/* Вертикальная дорога живёт только на узких экранах. */
.st-route__svg--v { display: none; }

/* ---- фон: гребни и озеро ---- */

/* Края поля растворяем, иначе горы обрываются прямоугольником. */
.st-route__land {
	-webkit-mask-image: linear-gradient(90deg, transparent 0, #000 7%, #000 93%, transparent 100%);
	mask-image: linear-gradient(90deg, transparent 0, #000 7%, #000 93%, transparent 100%);
}
.st-route__cloud { fill: rgba(255, 255, 255, .7); }
.st-route__ridge { stroke: none; }
.st-route__ridge--far { fill: rgba(27, 110, 156, .07); }
.st-route__ridge--near { fill: rgba(27, 110, 156, .11); }
.st-route__lake { fill: rgba(27, 110, 156, .16); }

/* ---- сама дорога ---- */

.st-route__dash {
	fill: none;
	stroke: rgba(15, 44, 63, .2);
	stroke-width: 2;
	stroke-dasharray: 5 7;
	stroke-linecap: round;
}
.st-route__line {
	fill: none;
	stroke: var(--sun);
	stroke-width: 3.5;
	stroke-linecap: round;
}
.js .st-route__line { stroke-dasharray: 1; stroke-dashoffset: 1; }
.js .st-route__stage.is-in .st-route__line { animation: st-road-draw 2.1s var(--ease) forwards; }
@keyframes st-road-draw { to { stroke-dashoffset: 0; } }

/* ---- солнце, которое едет по дороге ---- */

/* Позицию солнца ведёт скрипт (см. main.js), плавность — здесь. */
.st-route__sun { transition: none; }
.st-route__sun circle { fill: var(--sun); }
.st-route__sun-halo {
	fill: rgba(232, 145, 47, .22);
	animation: st-sun-beat 2.4s ease-in-out infinite;
	transform-box: fill-box;
	transform-origin: center;
}
@keyframes st-sun-beat {
	0%, 100% { transform: scale(.8); opacity: .8; }
	50% { transform: scale(1.15); opacity: .35; }
}

/* ============================================================
   2. Остановки
   ============================================================ */

.st-route__stop {
	position: absolute;
	left: var(--st-x); top: var(--st-y);
	width: 0; height: 0;
	z-index: 3;
}
.js .st-route__stop { opacity: 0; }
.js .st-route__stage.is-in .st-route__stop {
	animation: st-stop-in .5s var(--ease) forwards;
	animation-delay: var(--st-stop-delay, 0ms);
}
@keyframes st-stop-in {
	from { opacity: 0; }
	to { opacity: 1; }
}

.st-route__stop i {
	position: absolute; left: -9px; top: -9px;
	width: 18px; height: 18px; border-radius: 999px;
	background: #FFF;
	border: 2px solid var(--sun);
	box-shadow: 0 3px 10px rgba(15, 44, 63, .2);
	transition: transform .4s var(--ease), background .4s ease, box-shadow .4s ease;
}
.st-route__stop i::after {
	content: '';
	position: absolute; inset: 3px;
	border-radius: 999px;
	background: var(--sun);
	opacity: 0;
	transition: opacity .4s ease;
}

.st-route__stop b,
.st-route__stop em {
	position: absolute; left: 50%;
	transform: translateX(-50%);
	white-space: nowrap;
	transition: opacity .35s ease, background .4s ease, box-shadow .4s ease, color .4s ease;
}
.st-route__stop b {
	bottom: 22px;
	font-size: 10px; letter-spacing: .16em; text-transform: uppercase; font-weight: 500;
	color: var(--deep);
	background: rgba(255, 255, 255, .9);
	box-shadow: var(--shade-1);
	padding: 5px 10px;
	opacity: 0;
}
.st-route__stop em {
	top: 16px;
	font-style: normal;
	font-size: 9.5px; letter-spacing: .18em;
	color: var(--sun-ink);
}

.st-route__stop:hover i,
.st-route__stop:focus-visible i,
.st-route__stop.is-on i {
	transform: scale(1.35);
	box-shadow: 0 5px 18px rgba(232, 145, 47, .5);
}
.st-route__stop:hover i::after,
.st-route__stop:focus-visible i::after,
.st-route__stop.is-on i::after { opacity: 1; }
.st-route__stop:hover b,
.st-route__stop:focus-visible b,
.st-route__stop.is-on b { opacity: 1; }
.st-route__stop.is-on { z-index: 5; }

.st-route__city {
	position: absolute;
	left: var(--st-x); top: var(--st-y);
	transform: translate(-50%, -46px);
	font-size: 9.5px; letter-spacing: .28em; text-transform: uppercase;
	color: var(--deep);
	background: rgba(255, 255, 255, .85);
	padding: 4px 9px;
	white-space: nowrap;
}

/* ============================================================
   3. Окно с описанием
   ============================================================ */

.st-route__card {
	position: relative;
	z-index: 6;
	background: #FFF;
	border: 1px solid var(--line);
	border-top: 2px solid var(--sun);
	box-shadow: var(--shade-2);
	display: grid;
}
.st-route__shot { display: block; aspect-ratio: 16 / 9; overflow: hidden; }
.st-route__shot img { transition: opacity .35s ease; }
.st-route__card.is-swapping .st-route__shot img { opacity: 0; }

.st-route__text { padding: calc(var(--index) * 1.4); }

/* Высота фиксирована: иначе окно прыгало при каждом наведении на остановку. */
.st-route__name {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	min-height: 2.4em;
}
.st-route__teaser {
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
	min-height: 4.9em;
}

.st-route__where {
	display: block;
	font-size: 10px; letter-spacing: .28em; text-transform: uppercase; color: var(--azure);
	white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.st-route__name {
	margin-top: calc(var(--index) * .7);
	font-size: calc(var(--index) * 1);
	font-weight: 200; line-height: 1.2;
	letter-spacing: calc(var(--index) / 20);
	text-transform: uppercase;
}
.st-route__teaser {
	margin-top: calc(var(--index) * .8);
	font-size: 13.5px; line-height: 1.7; font-weight: 300; color: var(--muted);
}
.st-route__facts {
	display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: calc(var(--index) * .9);
	margin: calc(var(--index) * 1.2) 0 0;
	padding-top: calc(var(--index) * 1.1);
	border-top: 1px solid var(--line);
}
.st-route__facts dt { font-size: 9px; letter-spacing: .24em; text-transform: uppercase; color: var(--muted-2); }
.st-route__facts dd {
	margin: 5px 0 0; font-size: 13px; font-weight: 300;
	display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
	min-height: 2.6em;
}

.st-route__buy {
	display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
	gap: calc(var(--index) * .9);
	margin-top: calc(var(--index) * 1.2);
	padding-top: calc(var(--index) * 1.1);
	border-top: 1px solid var(--line);
}
.st-route__buy span { font-size: calc(var(--index) * .82); font-weight: 200; color: var(--sun-ink); white-space: nowrap; }
.st-route__buy .st-btn { padding: 14px 22px; }

/* ============================================================
   4. Экраны поменьше
   ============================================================ */

@media (max-width: 1100px) {
	.st-route__stage { grid-template-columns: 1fr; gap: calc(var(--index) * 2); }
}

@media (max-width: 900px) {
	.st-route__head { grid-template-columns: 1fr; gap: calc(var(--index) * 1.4); align-items: start; }

	/*
	 * На телефоне дорога во всю ширину экрана превращалась в полоску высотой
	 * в палец, и её приходилось листать вбок. Здесь она разворачивается
	 * сверху вниз — весь маршрут виден целиком, без прокрутки.
	 */
	.st-route__svg { display: none; }
	.st-route__svg--v { display: block; }
	.st-route__plot { aspect-ratio: 560 / 1720; }

	.st-route__stop { left: var(--st-xv); top: var(--st-yv); }
	.st-route__city { left: var(--st-xv); top: var(--st-yv); transform: translate(-50%, -74px); font-size: 9px; }

	/* Место есть — значит, названия остановок можно показать все сразу. */
	.st-route__stop b {
		display: block;
		opacity: 1;
		bottom: auto; top: -20px;
		left: 24px; transform: none;
		/* Метка — блок нулевой ширины, и подпись без max-content ужимается
		   до самого длинного слова, разваливая название на четыре строки. */
		width: max-content;
		max-width: min(46vw, 178px);
		white-space: normal;
		font-size: 9.5px; line-height: 1.4; letter-spacing: .1em;
		padding: 5px 8px;
		background: rgba(255, 255, 255, .94);
	}
	.st-route__stop em { top: 18px; left: 24px; transform: none; font-size: 9px; }
	.st-route__stop.is-right b,
	.st-route__stop.is-right em { left: auto; right: 26px; text-align: right; }
	.st-route__stop.is-on b { color: var(--sun-ink); }

	.st-route__card { margin-top: calc(var(--index) * 2); }
}

@media (prefers-reduced-motion: reduce) {
	.js .st-route__line { stroke-dashoffset: 0; }
	.js .st-route__stop { opacity: 1; }
	.st-route__sun-halo { animation: none; }
}
