/* ==========================================================================
   styles.css — оформление новогодней сцены.

   Слои (z-index), снизу вверх:
     0  фон страницы (ночной градиент)   — body
     1  #sky-canvas                      — звёзды, луна, Санта
     2  .ground                          — снежный сугроб во всю ширину
     3  #scene (SVG)                     — лес, дом, ёлка, снеговик
     4  .countdown                       — надпись и часы обратного отсчёта
     5  #fg-canvas                       — снег и тройка Деда Мороза
     6  .sound / noscript                — интерфейс

   Адаптивность: размеры текста через clamp(), сцена подстраивается под
   пропорции окна (viewBox меняет script.js), есть отдельные media-запросы
   для узких телефонов и для prefers-reduced-motion.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Палитра и базовые настройки
   -------------------------------------------------------------------------- */
:root
{
	--night-top: #04060d;
	--night-mid: #0a1226;
	--night-bottom: #16233d;
	--snow: #e9f2ff;
	--snow-dim: #b9cbe4;
	--warm: #ffc861;
	--text: #eaf2ff;
	--text-dim: #9fb3d4;
	--accent: #7fd0ff;
}

*
{
	box-sizing: border-box;
}

html,
body
{
	height: 100%;
	margin: 0;
	padding: 0;
}

body
{
	/* Ночь: вертикальный градиент неба + лёгкая «подсветка» от снега снизу */
	background:
		radial-gradient(120% 70% at 50% 100%, rgba(120, 160, 210, 0.18), transparent 60%),
		linear-gradient(180deg, var(--night-top) 0%, var(--night-mid) 45%, var(--night-bottom) 100%);
	background-attachment: fixed;
	color: var(--text);
	/* dvh — корректная высота на мобильных при скрывающихся панелях браузера */
	min-height: 100vh;
	min-height: 100dvh;
	overflow: hidden;
	font-family: "Segoe UI", "Ubuntu", "Helvetica Neue", Arial, sans-serif;
	-webkit-text-size-adjust: 100%;
}

/* --------------------------------------------------------------------------
   2. Канвасы и земля
   -------------------------------------------------------------------------- */
.layer
{
	position: fixed;
	inset: 0;
	width: 100%;
	height: 100%;
	display: block;
	pointer-events: none; /* снег не мешает кликам по кнопке */
}

.layer--sky
{
	z-index: 1;
}

.layer--fg
{
	z-index: 5;
}

/* Снежный покров: тянется на всю ширину, поэтому лес можно обрезать по бокам */
.ground
{
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	height: 24vh;
	z-index: 2;
	background: linear-gradient(180deg, #f2f8ff 0%, #cfdff2 55%, #a9c0dd 100%);
	border-radius: 46% 54% 0 0 / 9vh 11vh 0 0;
	box-shadow: 0 -14px 40px rgba(180, 215, 255, 0.22);
}

/* Вторая «волна» сугроба, чтобы край не выглядел плоским */
.ground::after
{
	content: "";
	position: absolute;
	left: -6%;
	right: -6%;
	bottom: 0;
	height: 60%;
	background: linear-gradient(180deg, #ffffff, #d7e5f6);
	border-radius: 60% 40% 0 0 / 12vh 8vh 0 0;
	opacity: 0.75;
}

/* SVG-сцена: прижата к низу, целиком видна (meet), по центру по горизонтали */
.scene
{
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	width: 100%;
	height: min(58vh, 560px);
	z-index: 3;
	pointer-events: none;
	overflow: visible;
}

/* --------------------------------------------------------------------------
   3. Дом: свет в окнах, дым из трубы, фонарь над дверью
   -------------------------------------------------------------------------- */

/* Тёплый свет окон: лёгкое «дыхание» лампы */
.window__light
{
	animation: windowFlicker 5s ease-in-out infinite;
}

.window--b .window__light
{
	animation-delay: -2.2s;
}

@keyframes windowFlicker
{
	0%, 100%
	{
		opacity: 0.92;
	}
	35%
	{
		opacity: 1;
	}
	60%
	{
		opacity: 0.82;
	}
}

/* Фонарь над дверью мигает быстрее и заметнее */
.lamp
{
	animation: lampPulse 2.6s ease-in-out infinite;
}

@keyframes lampPulse
{
	0%, 100%
	{
		opacity: 0.7;
	}
	50%
	{
		opacity: 1;
	}
}

/*
	Дым из трубы: четыре клуба по очереди поднимаются, растут и растворяются.
	transform-box: fill-box нужен, чтобы масштаб считался от самого кружка,
	а не от всей сцены.
*/
.smoke circle
{
	fill: #cfd9e8;
	transform-box: fill-box;
	transform-origin: 50% 100%;
	opacity: 0;
	animation: smokeRise 7s linear infinite;
}

.smoke circle:nth-child(1)
{
	animation-delay: 0s;
}

.smoke circle:nth-child(2)
{
	animation-delay: -1.75s;
}

.smoke circle:nth-child(3)
{
	animation-delay: -3.5s;
}

.smoke circle:nth-child(4)
{
	animation-delay: -5.25s;
}

@keyframes smokeRise
{
	0%
	{
		opacity: 0;
		transform: translate(0, 0) scale(0.4);
	}
	15%
	{
		opacity: 0.34;
	}
	60%
	{
		opacity: 0.18;
		transform: translate(26px, -110px) scale(1.5);
	}
	100%
	{
		opacity: 0;
		transform: translate(52px, -190px) scale(2.2);
	}
}

/* --------------------------------------------------------------------------
   4. Ёлка: звезда и переливающаяся гирлянда
   -------------------------------------------------------------------------- */
.tree__star
{
	animation: starPulse 3.2s ease-in-out infinite;
}

@keyframes starPulse
{
	0%, 100%
	{
		opacity: 0.75;
	}
	50%
	{
		opacity: 1;
	}
}

/*
	Огоньки гирлянды. Цвет задаётся через CSS-свойство color, а fill: currentColor
	позволяет одному ключевому кадру менять и заливку, и свечение (drop-shadow
	берёт currentColor). Классы bulb--1..6 дают разные цвета и задержки —
	получается «переливание» вдоль всей ветки.
*/
.bulb
{
	fill: currentColor;
	animation: bulbShift 7.5s linear infinite;
}

.bulb--1
{
	color: #ff5d5d;
	animation-delay: 0s;
}

.bulb--2
{
	color: #ffd45c;
	animation-delay: -1.2s;
}

.bulb--3
{
	color: #66e0a3;
	animation-delay: -2.4s;
}

.bulb--4
{
	color: #62b8ff;
	animation-delay: -3.6s;
}

.bulb--5
{
	color: #d78bff;
	animation-delay: -4.8s;
}

.bulb--6
{
	color: #fff2b8;
	animation-delay: -6s;
}

@keyframes bulbShift
{
	0%
	{
		opacity: 1;
		filter: drop-shadow(0 0 6px currentColor);
	}
	25%
	{
		opacity: 0.35;
		filter: drop-shadow(0 0 2px currentColor);
	}
	50%
	{
		opacity: 1;
		filter: drop-shadow(0 0 9px currentColor);
	}
	75%
	{
		opacity: 0.45;
		filter: drop-shadow(0 0 3px currentColor);
	}
	100%
	{
		opacity: 1;
		filter: drop-shadow(0 0 6px currentColor);
	}
}

/*
	Мишура: волнистые ленты без заливки, только толстая золотая линия.
	Лёгкое «поблёскивание» — медленная смена прозрачности.
*/
.tinsel path
{
	fill: none;
	stroke: #e3c46b;
	stroke-width: 3.2;
	stroke-linecap: round;
	animation: tinselShine 5.5s ease-in-out infinite;
}

.tinsel path:nth-child(2)
{
	stroke: #d3ad55;
	animation-delay: -1.4s;
}

.tinsel path:nth-child(3)
{
	stroke: #ecd493;
	animation-delay: -2.8s;
}

.tinsel path:nth-child(4)
{
	stroke: #d3ad55;
	animation-delay: -4.2s;
}

@keyframes tinselShine
{
	0%, 100%
	{
		opacity: 0.72;
	}
	50%
	{
		opacity: 1;
	}
}

/*
	Гирлянда на доме: провод, перевитый лапником, и маленькие огоньки
	вдоль края крыши и вокруг двери (как на references/house.jpg).
*/
.house-garland path
{
	fill: none;
	stroke: #24402c;
	stroke-width: 2.4;
	stroke-linecap: round;
}

.hbulb
{
	fill: currentColor;
	animation: hbulbShift 4.5s linear infinite;
}

.hbulb--1
{
	color: #ff6b6b;
	animation-delay: 0s;
}

.hbulb--2
{
	color: #ffd45c;
	animation-delay: -1.1s;
}

.hbulb--3
{
	color: #6fe0a0;
	animation-delay: -2.2s;
}

.hbulb--4
{
	color: #6fb8ff;
	animation-delay: -3.3s;
}

@keyframes hbulbShift
{
	0%, 100%
	{
		opacity: 1;
		filter: drop-shadow(0 0 5px currentColor);
	}
	50%
	{
		opacity: 0.4;
		filter: drop-shadow(0 0 1px currentColor);
	}
}

/*
	Бусы: тот же приём, что и у огоньков гирлянды — цвет лежит в color,
	fill: currentColor берёт его, а drop-shadow светит тем же цветом.
*/
.bead
{
	fill: currentColor;
	animation: beadShift 6.5s linear infinite;
}

.bead--1
{
	color: #ff8fa3;
	animation-delay: 0s;
}

.bead--2
{
	color: #8fd7ff;
	animation-delay: -1.6s;
}

.bead--3
{
	color: #ffe08a;
	animation-delay: -3.2s;
}

.bead--4
{
	color: #b6f0c8;
	animation-delay: -4.8s;
}

@keyframes beadShift
{
	0%, 100%
	{
		opacity: 0.95;
		filter: drop-shadow(0 0 4px currentColor);
	}
	50%
	{
		opacity: 0.55;
		filter: drop-shadow(0 0 1px currentColor);
	}
}

/* Блики на снегу то появляются, то гаснут */
.glints circle
{
	animation: glint 4s ease-in-out infinite;
}

.glints circle:nth-child(2)
{
	animation-delay: -0.7s;
}

.glints circle:nth-child(3)
{
	animation-delay: -1.4s;
}

.glints circle:nth-child(4)
{
	animation-delay: -2.1s;
}

.glints circle:nth-child(5)
{
	animation-delay: -2.8s;
}

.glints circle:nth-child(6)
{
	animation-delay: -3.5s;
}

@keyframes glint
{
	0%, 100%
	{
		opacity: 0.15;
	}
	50%
	{
		opacity: 0.8;
	}
}

/* --------------------------------------------------------------------------
   5. Заголовок и часы обратного отсчёта
   -------------------------------------------------------------------------- */
.countdown
{
	position: fixed;
	top: max(6vh, 24px);
	left: 50%;
	transform: translateX(-50%);
	z-index: 4;
	width: min(94vw, 900px);
	text-align: center;
	pointer-events: none; /* чтобы снег «падал» поверх, но клики не перехватывались */
}

/* «Праздничный» вид: антиквенный шрифт, разрядка, градиент и свечение.
   Внешние веб-шрифты не подключаются (CSP + отсутствие зависимостей). */
.countdown__title
{
	margin: 0 0 clamp(14px, 3vh, 30px);
	font-family: "Georgia", "Palatino Linotype", "Book Antiqua", "Times New Roman", serif;
	font-weight: 700;
	font-style: italic;
	font-size: clamp(1.25rem, 4.6vw, 2.9rem);
	letter-spacing: 0.04em;
	text-transform: none;
	background: linear-gradient(180deg, #ffffff 0%, #cfe6ff 45%, #8fc4ff 100%);
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
	text-shadow: 0 0 26px rgba(120, 180, 255, 0.28);
}

.countdown__ornament
{
	display: inline-block;
	margin: 0 0.5em;
	color: var(--accent);
	-webkit-text-fill-color: var(--accent);
	animation: ornamentSpin 9s linear infinite;
}

.countdown__ornament:last-child
{
	animation-direction: reverse;
}

@keyframes ornamentSpin
{
	from
	{
		transform: rotate(0deg);
	}
	to
	{
		transform: rotate(360deg);
	}
}

.countdown__clock
{
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	align-items: flex-start;
	gap: clamp(6px, 2.4vw, 26px);
}

.unit
{
	display: flex;
	flex-direction: column;
	align-items: center;
	min-width: clamp(64px, 17vw, 150px);
	padding: clamp(6px, 1.4vw, 14px) clamp(4px, 1.2vw, 12px);
	border-radius: 14px;
	background: rgba(10, 20, 40, 0.42);
	border: 1px solid rgba(140, 190, 255, 0.18);
	backdrop-filter: blur(3px);
}

.unit__value
{
	font-family: "Georgia", "Palatino Linotype", "Times New Roman", serif;
	font-weight: 700;
	font-size: clamp(2rem, 8.5vw, 4.6rem);
	line-height: 1;
	font-variant-numeric: tabular-nums; /* цифры не «прыгают» по ширине */
	color: #f4f9ff;
	text-shadow:
		0 0 12px rgba(140, 200, 255, 0.55),
		0 0 34px rgba(90, 150, 255, 0.35);
}

.unit__label
{
	margin-top: 6px;
	font-size: clamp(0.6rem, 2.2vw, 0.9rem);
	letter-spacing: 0.16em;
	text-transform: uppercase;
	color: var(--text-dim);
}

.unit__sep
{
	align-self: center;
	font-size: clamp(1rem, 3vw, 1.6rem);
	color: rgba(160, 200, 255, 0.45);
}

.countdown__year
{
	margin: clamp(12px, 2.6vh, 26px) 0 0;
	font-size: clamp(0.8rem, 2.6vw, 1.1rem);
	letter-spacing: 0.3em;
	text-transform: uppercase;
	color: var(--accent);
	opacity: 0.85;
}

/* --------------------------------------------------------------------------
   6. Кнопка звука и noscript
   -------------------------------------------------------------------------- */
.sound
{
	position: fixed;
	left: 50%;
	bottom: max(14px, calc(env(safe-area-inset-bottom, 0px) + 12px));
	transform: translateX(-50%);
	z-index: 6;
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 11px 20px; /* не меньше 44px по высоте — удобно попадать пальцем */
	font: inherit;
	font-size: clamp(0.8rem, 2.6vw, 0.95rem);
	color: var(--text);
	background: rgba(12, 24, 46, 0.72);
	border: 1px solid rgba(140, 190, 255, 0.28);
	border-radius: 999px;
	cursor: pointer;
	transition: background 0.25s, border-color 0.25s, transform 0.15s;
}

.sound:hover
{
	background: rgba(24, 44, 78, 0.85);
	border-color: rgba(160, 210, 255, 0.5);
}

.sound:active
{
	transform: translateX(-50%) scale(0.97);
}

.sound:focus-visible
{
	outline: 2px solid var(--accent);
	outline-offset: 3px;
}

.sound__icon
{
	display: inline-block;
	color: var(--accent);
}

/* Когда звук включён — иконка «звенит» */
.sound[aria-pressed="true"] .sound__icon
{
	animation: ring 1.6s ease-in-out infinite;
}

@keyframes ring
{
	0%, 100%
	{
		transform: rotate(0deg);
	}
	20%
	{
		transform: rotate(-14deg);
	}
	40%
	{
		transform: rotate(12deg);
	}
	60%
	{
		transform: rotate(-7deg);
	}
}

.noscript
{
	position: fixed;
	left: 50%;
	bottom: 70px;
	transform: translateX(-50%);
	z-index: 6;
	padding: 10px 16px;
	background: rgba(12, 24, 46, 0.8);
	border-radius: 10px;
}

/* --------------------------------------------------------------------------
   7. Адаптация под мобильные устройства
   -------------------------------------------------------------------------- */

/* Планшеты и узкие телефоны: сцена ниже, чтобы не перекрывать часы */
@media (max-width: 820px)
{
	.countdown
	{
		top: max(4vh, 18px);
	}

	.scene
	{
		height: min(46vh, 420px);
	}

	.ground
	{
		height: 20vh;
	}
}

/* Портретные телефоны: отсчёт в две строки, сцена занимает нижнюю треть */
@media (max-width: 560px)
{
	.countdown__clock
	{
		gap: 8px;
	}

	.unit
	{
		min-width: 74px;
		border-radius: 11px;
	}

	.unit__sep
	{
		display: none; /* разделители на узком экране только мешают */
	}

	/* Снежинки-украшения у заголовка переносились на вторую строку — прячем их */
	.countdown__ornament
	{
		display: none;
	}

	.scene
	{
		height: 40vh;
	}

	.ground
	{
		height: 17vh;
	}
}

/* Альбомная ориентация телефона: по вертикали мало места — уплотняем блок */
@media (max-height: 460px)
{
	.countdown
	{
		top: 10px;
	}

	.countdown__title
	{
		margin-bottom: 8px;
	}

	.unit__label
	{
		display: none;
	}

	.scene
	{
		height: 52vh;
	}
}

/* Отключаем декоративные анимации для тех, кто просит меньше движения */
@media (prefers-reduced-motion: reduce)
{
	.smoke circle,
	.glints circle,
	.tinsel path,
	.bead,
	.hbulb,
	.countdown__ornament,
	.tree__star,
	.lamp,
	.window__light,
	.sound[aria-pressed="true"] .sound__icon
	{
		animation: none;
	}

	.smoke circle
	{
		opacity: 0.16;
	}
}
