/* effects.css — эффекты общего фона hero/welcome и CSS-декор */

/* ═══════ ОБЩИЙ ФОН-ЛЕСС (#scene-fire-bg) ═══════ */
.fire-bg__forest {
	position: absolute;
	inset: 0;
	/* Плавный непрерывный градиент без «полки» — раньше верх был плоско
	   прозрачным до 52%, а затем резко темнел, из-за чего при масштабировании
	   фона на welcome (см. #scene-fire-bg[data-pose="welcome"]) эта граница
	   съезжала в зону луны и было видно жёсткий «шов». Теперь темнеет
	   постепенно на всём протяжении — луна и лес из #world по-прежнему
	   хорошо видны сверху, а шва нет при любом масштабе. */
	background: radial-gradient(ellipse at 50% 85%, rgba(255, 120, 30, 0.16) 0%, transparent 55%),
	linear-gradient(180deg,
			transparent 0%,
			rgba(5, 13, 5, 0.04) 34%,
			rgba(5, 13, 5, 0.14) 52%,
			rgba(5, 13, 5, 0.32) 68%,
			rgba(5, 13, 5, 0.58) 84%,
			rgba(5, 13, 5, 0.82) 100%
	);
	background-size: cover;
}

/* Оверлей-виньетка — только у костра снизу, верх остаётся прозрачным,
   чтобы луна и лес из #world не темнились по краям. Больше промежуточных
   стопов = мягче переход, без видимой границы. */
.fire-bg__overlay {
	position: absolute;
	inset: 0;
	background: radial-gradient(ellipse at 50% 92%,
	rgba(255, 90, 10, 0.14) 0%,
	rgba(0, 0, 0, 0.34) 45%,
	rgba(0, 0, 0, 0.12) 65%,
	transparent 82%
	);
	pointer-events: none;
}

/* Туман — два слоя в противофазе */
.fire-bg__fog {
	position: absolute;
	inset: 0;
	pointer-events: none;
	z-index: 1;
}

.fire-bg__fog::before,
.fire-bg__fog::after {
	content: '';
	position: absolute;
	bottom: 0;
	left: -20%;
	width: 140%;
	height: 40%;
	border-radius: 50% 50% 0 0;
	pointer-events: none;
}

.fire-bg__fog::before {
	background: radial-gradient(ellipse at 50% 100%, rgba(200, 220, 180, 0.18) 0%, transparent 70%);
	animation: fog-drift 12s ease-in-out infinite;
}

.fire-bg__fog::after {
	background: radial-gradient(ellipse at 50% 100%, rgba(180, 210, 160, 0.12) 0%, transparent 65%);
	animation: fog-drift-reverse 15s ease-in-out infinite;
	bottom: -5%;
}

/* ═══════════════════════════════════════════
   ПЕРЕДНИЙ СЛОЙ КОСТРА (#fire-front)
   Над контентом сцены (z-index выше .scene__inner=2), не перехватывает
   клики. Общий для hero и welcome — плавно переезжает из центра вправо.
═══════════════════════════════════════════ */
#fire-front {
	position: absolute;
	inset: 0;
	z-index: 5;
	overflow: hidden;
	pointer-events: none;
}

/* Мерцание слоёв света костра. КЛЮЧЕВОЕ: внутри кейфрейма сохраняем
   translateX(-50%), иначе scale() стирал центрирование и свечение
   «отъезжало» вбок (та самая кривая анимация). */
@keyframes fire-flicker {
	0%, 100% {
		opacity: 0.92;
		transform: translateX(-50%) scale(1);
	}
	30% {
		opacity: 1;
		transform: translateX(-50%) scale(1.03);
	}
	55% {
		opacity: 0.86;
		transform: translateX(-50%) scale(0.985);
	}
	78% {
		opacity: 0.97;
		transform: translateX(-50%) scale(1.015);
	}
}

/* Единое «дыхание» костра — только яркость + свечение по силуэту.
   Не анимируем transform, чтобы не конфликтовать с переездом сцены. */
@keyframes bonfire-breathe {
	0%, 100% {
		filter: brightness(0.98) drop-shadow(0 0 16px rgba(255, 140, 45, 0.26));
	}
	50% {
		filter: brightness(1.06) drop-shadow(0 0 26px rgba(255, 150, 55, 0.44));
	}
}

/* ─── Детальный CSS-костёр ─── */
.fire-bg__bonfire {
	position: absolute;
	bottom: 10%;
	left: 60%;
	width: 260px;
	height: 300px;
	transform: translateX(-50%) scale(1.15);
	transform-origin: bottom center;
	pointer-events: none;
	/* Плавный «переезд» костра между сценами hero → welcome */
	transition: left 0.95s var(--ease-cinematic),
	bottom 0.95s var(--ease-cinematic),
	transform 0.95s var(--ease-cinematic);
	will-change: left, bottom, transform, filter;
	/* Единое «дыхание» света привязано к самому костру (только filter —
	   не трогает transform, чтобы не спорить с переездом между сценами).
	   drop-shadow повторяет силуэт пламени → свечение не отделяется от огня. */
	animation: bonfire-breathe 3.4s ease-in-out infinite;
}

/* Позы: где стоит костёр на каждой сцене */
#fire-front[data-pose="hero"] .fire-bg__bonfire {
	left: 60%;
	bottom: 10%;
	transform: translateX(-50%) scale(1.15);
}

#fire-front[data-pose="zooming"] .fire-bg__bonfire {
	left: 66%;
	bottom: 11%;
	transform: translateX(-50%) scale(1.28);
}

#fire-front[data-pose="welcome"] .fire-bg__bonfire {
	left: 82%;
	bottom: 8%;
	transform: translateX(-50%) scale(0.9);
}

/* На welcome зарево меньше и перепад резче — не дотягивается до
   логотипов в верхней части. */
#fire-front[data-pose="welcome"] .bonfire__halo {
	width: 300px;
	height: 200px;
	background: radial-gradient(ellipse at 50% 72%,
	rgba(255, 175, 80, 0.34) 0%,
	rgba(255, 120, 35, 0.18) 22%,
	rgba(255, 70, 15, 0.06) 42%,
	transparent 58%);
	filter: blur(5px);
}

/* Большое мягкое зарево — движется вместе с костром */
.bonfire__halo {
	position: absolute;
	left: 50%;
	bottom: 4px;
	width: 440px;
	height: 360px;
	transform: translateX(-50%);
	background: radial-gradient(ellipse at 50% 72%,
	rgba(255, 175, 80, 0.42) 0%,
	rgba(255, 120, 35, 0.26) 28%,
	rgba(255, 70, 15, 0.12) 52%,
	transparent 74%);
	filter: blur(6px);
	pointer-events: none;
	z-index: 0;
	/* Синхронно с заревом углей (одинаковая длительность/фаза) — свет читается
	   как единый источник, а translateX(-50%) сохраняется внутри кейфрейма. */
	animation: fire-flicker 2.8s ease-in-out infinite;
}

/* Нижнее зарево углей */
.bonfire__glow {
	position: absolute;
	left: 50%;
	bottom: -6px;
	width: 170px;
	height: 48px;
	transform: translateX(-50%);
	background: radial-gradient(ellipse, rgba(255, 120, 30, 0.6) 0%, transparent 70%);
	border-radius: 50%;
	z-index: 1;
	animation: fire-flicker 2.8s ease-in-out infinite;
}

/* Брёвна — три полена крест-накрест, с текстурой и подсветкой снизу */
.bonfire__logs {
	position: absolute;
	left: 50%;
	bottom: 8px;
	width: 160px;
	height: 34px;
	transform: translateX(-50%);
	z-index: 3;
}

.bonfire__log {
	position: absolute;
	bottom: 0;
	left: 18px;
	width: 124px;
	height: 17px;
	border-radius: 9px;
	background: linear-gradient(180deg, #6b3f18 0%, #4a2a0d 55%, #2c1705 100%);
	box-shadow: inset 0 2px 3px rgba(255, 160, 80, 0.35),
	inset 0 -2px 4px rgba(0, 0, 0, 0.55),
	0 3px 7px rgba(0, 0, 0, 0.5);
}

.bonfire__log:nth-child(1) {
	transform: rotate(-15deg);
}

.bonfire__log:nth-child(2) {
	transform: rotate(15deg);
}

.bonfire__log--3 {
	width: 104px;
	left: 28px;
	bottom: -3px;
	transform: rotate(3deg);
	filter: brightness(0.82);
}

/* Раскалённые угли между брёвнами */
.bonfire__embers-bed {
	position: absolute;
	left: 50%;
	bottom: 9px;
	width: 104px;
	height: 22px;
	transform: translateX(-50%);
	background: radial-gradient(ellipse at 50% 55%,
	rgba(255, 225, 150, 0.95) 0%,
	rgba(255, 130, 35, 0.7) 45%,
	transparent 76%);
	border-radius: 50%;
	z-index: 4;
	animation: fire-flicker 2.8s ease-in-out infinite;
}

/* Пламя — языки складываются аддитивно (screen) в яркое ядро */
.bonfire__flames {
	position: absolute;
	left: 50%;
	bottom: 16px;
	width: 130px;
	height: 170px;
	transform: translateX(-50%);
	z-index: 5;
}

.flame {
	position: absolute;
	bottom: 0;
	border-radius: 50% 50% 30% 30% / 62% 62% 40% 40%;
	transform-origin: bottom center;
	mix-blend-mode: screen;
}

/* Широкое мягкое основание пламени */
.flame--back {
	left: 50%;
	margin-left: -62px;
	width: 124px;
	height: 118px;
	background: radial-gradient(ellipse at 50% 82%, rgba(255, 95, 25, 0.6) 0%, transparent 70%);
	filter: blur(5px);
	animation: flame-flicker 2.6s ease-in-out infinite;
}

/* Боковые языки */
.flame--1 {
	left: 50%;
	margin-left: -44px;
	width: 44px;
	height: 104px;
	background: linear-gradient(180deg, #ffdf72 0%, #ff8f1e 46%, #ff3a10 100%);
	animation: flame-flicker 1.9s ease-in-out infinite 0.1s;
}

.flame--3 {
	left: 50%;
	margin-left: 2px;
	width: 44px;
	height: 96px;
	background: linear-gradient(180deg, #ffdf72 0%, #ff8f1e 46%, #ff3a10 100%);
	animation: flame-flicker 2.1s ease-in-out infinite 0.35s;
}

/* Главный высокий язык */
.flame--2 {
	left: 50%;
	margin-left: -26px;
	width: 52px;
	height: 150px;
	background: linear-gradient(180deg, #fff7d6 0%, #ffd84a 26%, #ff7c1e 62%, #e8320a 100%);
	animation: flame-flicker 1.5s ease-in-out infinite 0.2s;
}

/* Бело-горячее ядро */
.flame--core {
	left: 50%;
	margin-left: -14px;
	width: 28px;
	height: 92px;
	background: linear-gradient(180deg, #ffffff 0%, #fff3b4 40%, #ffb733 100%);
	filter: blur(0.5px);
	animation: flame-flicker 1.2s ease-in-out infinite 0.15s;
}

/* Искры */
.bonfire__sparks {
	position: absolute;
	left: 50%;
	bottom: 92px;
	width: 100px;
	height: 1px;
	transform: translateX(-50%);
	z-index: 6;
	pointer-events: none;
}

.spark {
	position: absolute;
	width: 4px;
	height: 4px;
	border-radius: 50%;
	background: var(--color-gold);
	box-shadow: 0 0 6px 1px rgba(255, 150, 50, 0.8);
	bottom: 0;
	animation: spark-fly 1.5s ease-out infinite;
}

.spark:nth-child(1) {
	left: 10%;
	animation-delay: 0s;
	animation-duration: 1.3s;
	--spark-x: -15px;
}

.spark:nth-child(2) {
	left: 26%;
	animation-delay: 0.3s;
	animation-duration: 1.7s;
	--spark-x: 8px;
}

.spark:nth-child(3) {
	left: 40%;
	animation-delay: 0.6s;
	animation-duration: 1.5s;
	--spark-x: -5px;
}

.spark:nth-child(4) {
	left: 56%;
	animation-delay: 0.9s;
	animation-duration: 1.9s;
	--spark-x: 18px;
}

.spark:nth-child(5) {
	left: 72%;
	animation-delay: 0.15s;
	animation-duration: 1.4s;
	--spark-x: -10px;
}

.spark:nth-child(6) {
	left: 46%;
	animation-delay: 1.1s;
	animation-duration: 1.6s;
	--spark-x: 12px;
}

.spark:nth-child(7) {
	left: 20%;
	animation-delay: 0.75s;
	animation-duration: 2s;
	--spark-x: -20px;
}

.spark:nth-child(8) {
	left: 84%;
	animation-delay: 0.5s;
	animation-duration: 1.8s;
	--spark-x: 16px;
}

.spark:nth-child(9) {
	left: 62%;
	animation-delay: 1.3s;
	animation-duration: 1.5s;
	--spark-x: -12px;
}

/* Адаптив: на телефоне костёр компактнее и ниже, чтобы не спорить с текстом */
@media (max-width: 600px) {
	#fire-front[data-pose="hero"] .fire-bg__bonfire {
		left: 50%;
		bottom: 3%;
		transform: translateX(-50%) scale(0.62);
	}

	#fire-front[data-pose="zooming"] .fire-bg__bonfire {
		left: 60%;
		bottom: 6%;
		transform: translateX(-50%) scale(0.7);
	}

	#fire-front[data-pose="welcome"] .fire-bg__bonfire {
		left: 82%;
		bottom: 6%;
		transform: translateX(-50%) scale(0.56);
	}

	/* Зарево компактнее и быстрее затухает — на мобилке не дотягивается
	   до логотипов в верхней части экрана. */
	.bonfire__halo {
		width: 240px;
		height: 150px;
		background: radial-gradient(ellipse at 50% 72%,
		rgba(255, 175, 80, 0.30) 0%,
		rgba(255, 120, 35, 0.16) 20%,
		rgba(255, 70, 15, 0.05) 38%,
		transparent 56%);
		filter: blur(4px);
	}
}

/* Уважаем prefers-reduced-motion: гасим мерцание/языки */
@media (prefers-reduced-motion: reduce) {
	.bonfire__halo,
	.bonfire__glow,
	.bonfire__embers-bed,
	.flame,
	.spark {
		animation: none !important;
	}

	.fire-bg__bonfire {
		transition: none !important;
	}
}

/* ─── CSS-вензели (псевдографика) ─── */
.ornament-css {
	width: 100%;
	height: 100%;
	position: relative;
	overflow: hidden;
}

.ornament-css::before,
.ornament-css::after {
	content: '';
	position: absolute;
	border: 2px solid var(--color-gold);
	border-radius: 50%;
	opacity: 0.35;
}

/* Нижний-левый вензель */
.hero__ornament--bl .ornament-css::before {
	width: 200px;
	height: 200px;
	bottom: 0;
	left: 0;
	border-right-color: transparent;
	border-top-color: transparent;
}

.hero__ornament--bl .ornament-css::after {
	width: 120px;
	height: 120px;
	bottom: 40px;
	left: 40px;
	border-right-color: transparent;
	border-top-color: transparent;
}

/* Верхний-правый вензель */
.hero__ornament--tr .ornament-css::before {
	width: 120px;
	height: 120px;
	top: 0;
	right: 0;
	border-left-color: transparent;
	border-bottom-color: transparent;
}

.hero__ornament--tr .ornament-css::after {
	width: 70px;
	height: 70px;
	top: 25px;
	right: 25px;
	border-left-color: transparent;
	border-bottom-color: transparent;
}

/* ─── Светлячки (декор разделов) ─── */
.firefly-layer {
	position: absolute;
	inset: 0;
	pointer-events: none;
	z-index: 1;
	overflow: hidden;
}

.firefly {
	position: absolute;
	width: 5px;
	height: 5px;
	border-radius: 50%;
	background: var(--color-gold);
	box-shadow: 0 0 8px 2px var(--color-gold-glow);
	animation: float-bob var(--ff-dur, 4s) ease-in-out infinite var(--ff-delay, 0s);
	opacity: 0.7;
}

/* Туман на сценах разделов */
.fog-layer {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	height: 200px;
	background: linear-gradient(to top, rgba(180, 210, 160, 0.15) 0%, transparent 100%);
	pointer-events: none;
	animation: fog-drift 18s ease-in-out infinite;
	z-index: 1;
}
