/* ==========================================================================
   NEW YEAR DECOR — UASerials
   Ретро-гірлянда на «провисаючому» дроті + ялинкові кульки, шапка на лого,
   відлік до Нового року і салют. Підключається разом з js/newyear.js.
   Щоб вимкнути все після свят — приберіть два рядки підключення з main.tpl
   (або змініть дати в CONFIG на початку js/newyear.js).
   ========================================================================== */

/* ---------- Гірлянда ---------- */
.ny-on .header {z-index: 40;}
.ny-garland {position: absolute; left: 0; right: 0; top: 100%; height: 1px;
	pointer-events: none; z-index: 40; user-select: none; -webkit-user-select: none;}
.ny-garland svg {position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none;}
.ny-garland .ny-wire {fill: none; stroke: #16301f; stroke-width: 2.4; stroke-linecap: round;}
.ny-garland .ny-wire--2 {stroke: #24492f; stroke-width: 1.6;}
.ny-garland .ny-wire--hl {stroke: rgba(255,255,255,.12); stroke-width: .8;}
.ny-off .ny-garland {display: none;}

/* Лампочка: .ny-b — точка кріплення (статичний кут), .ny-s — гойдання на вітрі */
.ny-b {position: absolute; width: 14px; height: 30px; margin-left: -7px; margin-top: -2px;
	transform-origin: 50% 0; transform: rotate(var(--r)); pointer-events: auto; cursor: pointer;}
.ny-s {position: absolute; inset: 0; transform-origin: 50% 0;
	animation: ny-sway var(--sw, 4s) ease-in-out infinite alternate; animation-delay: var(--swd, 0s);}
.ny-sock {position: absolute; left: 3px; top: 0; width: 8px; height: 8px; border-radius: 2px 2px 1px 1px;
	background: linear-gradient(90deg, #0d2014, #2f5b3b 45%, #0d2014);
	box-shadow: inset 0 -1px 0 rgba(0,0,0,.5);}
.ny-glass {position: absolute; left: 1px; top: 7px; width: 12px; height: 19px; overflow: hidden;
	border-radius: 50% 50% 50% 50% / 32% 32% 68% 68%;
	background: radial-gradient(circle at 38% 28%, rgba(255,255,255,.35), transparent 38%), var(--cd);
	box-shadow: inset 0 -2px 3px rgba(0,0,0,.35);}
.ny-lit {position: absolute; inset: 0; border-radius: inherit; opacity: 1;
	background: radial-gradient(circle at 42% 34%, #fff 0, var(--c) 42%, var(--cd) 115%);}
.ny-glass::after {content: ""; position: absolute; left: 3px; top: 4px; width: 3px; height: 7px;
	border-radius: 50%; background: rgba(255,255,255,.75); transform: rotate(14deg);}
.ny-halo {position: absolute; left: 50%; top: 16px; width: 54px; height: 54px; margin: -27px 0 0 -27px;
	border-radius: 50%; pointer-events: none; opacity: 1;
	background: radial-gradient(circle, var(--c) 0, transparent 62%);}
.ny-halo::after {content: ""; position: absolute; inset: 18px; border-radius: 50%;
	background: radial-gradient(circle, rgba(255,255,255,.55), transparent 70%);}
.ny-halo {mix-blend-mode: screen; filter: saturate(1.2);}
.ny-halo-wrap {position: absolute; inset: 0; opacity: .55; pointer-events: none;}

/* «Чіпнули» мишкою — лампа розгойдується */
.ny-b.ny-poke {animation: ny-poke 1.1s cubic-bezier(.3,.7,.4,1);}
.ny-b.ny-pop .ny-lit {animation: ny-pop .6s ease-out !important;}
.ny-b.ny-pop .ny-halo {animation: ny-pop .6s ease-out !important;}

/* Режими миготіння (перемикаються скриптом) */
.ny-garland[data-mode="wave"] .ny-lit,
.ny-garland[data-mode="wave"] .ny-halo {animation: ny-wave 2.8s ease-in-out infinite; animation-delay: calc(var(--i) * -0.09s);}

.ny-garland[data-mode="twinkle"] .ny-lit,
.ny-garland[data-mode="twinkle"] .ny-halo {animation: ny-twinkle var(--d) ease-in-out infinite; animation-delay: var(--dl);}

.ny-garland[data-mode="chase"] .ny-lit,
.ny-garland[data-mode="chase"] .ny-halo {animation: ny-chase 2.1s steps(1, end) infinite; animation-delay: calc(var(--k) * -0.7s);}

.ny-garland[data-mode="glow"] .ny-lit,
.ny-garland[data-mode="glow"] .ny-halo {animation: ny-glow 3.2s ease-in-out infinite; animation-delay: var(--dl);}

.ny-garland[data-mode="sparkle"] .ny-lit,
.ny-garland[data-mode="sparkle"] .ny-halo {animation: ny-sparkle 1.3s linear infinite; animation-delay: var(--dl);}

@keyframes ny-wave {0%,100% {opacity: .08;} 50% {opacity: 1;}}
@keyframes ny-twinkle {0%,100% {opacity: 1;} 40% {opacity: .9;} 50% {opacity: .06;} 62% {opacity: 1;}}
@keyframes ny-chase {0% {opacity: 1;} 33.3% {opacity: .07;} 100% {opacity: .07;}}
@keyframes ny-glow {0%,100% {opacity: .7;} 50% {opacity: 1;}}
@keyframes ny-sparkle {0%,8% {opacity: 1;} 10%,100% {opacity: .35;}}
@keyframes ny-pop {0% {opacity: 1; filter: brightness(2.2);} 100% {opacity: 1; filter: none;}}
@keyframes ny-sway {from {transform: rotate(-4deg);} to {transform: rotate(4deg);}}
@keyframes ny-poke {
	0% {transform: rotate(var(--r));}
	18% {transform: rotate(calc(var(--r) + 32deg));}
	40% {transform: rotate(calc(var(--r) - 20deg));}
	62% {transform: rotate(calc(var(--r) + 10deg));}
	82% {transform: rotate(calc(var(--r) - 4deg));}
	100% {transform: rotate(var(--r));}
}

/* ---------- Хвоя + ягоди в точках кріплення ---------- */
.ny-garland .ny-needle {stroke-linecap: round; fill: none;}
.ny-garland .ny-berry {fill: #c8102e;}
.ny-garland .ny-berry-hl {fill: rgba(255,255,255,.7);}

/* ---------- Ялинкові кульки на нитках ---------- */
.ny-ball {position: absolute; width: 0; height: var(--len); transform-origin: 50% 0;
	animation: ny-pend var(--pd, 5s) ease-in-out infinite alternate; animation-delay: var(--pdl, 0s);}
.ny-ball::before {content: ""; position: absolute; left: -.5px; top: 0; width: 1px; height: 100%;
	background: linear-gradient(#d9b45a, rgba(217,180,90,.55));}
.ny-ball__in {position: absolute; left: 0; top: 100%; transform-origin: 50% calc(var(--len) * -1);}
.ny-ball__in.ny-poke {animation: ny-ball-poke 1.6s cubic-bezier(.3,.7,.4,1);}
.ny-ball__cap {position: absolute; left: -4px; top: -3px; width: 8px; height: 6px; border-radius: 2px;
	background: linear-gradient(90deg, #8a6a1f, #f3d27a 45%, #8a6a1f);}
.ny-ball__orb {position: absolute; left: calc(var(--s) / -2); top: 2px; width: var(--s); height: var(--s);
	border-radius: 50%; pointer-events: auto; cursor: pointer;
	background:
		radial-gradient(circle at 32% 28%, rgba(255,255,255,.95) 0, rgba(255,255,255,.35) 12%, transparent 30%),
		radial-gradient(circle at 70% 78%, rgba(255,255,255,.18), transparent 35%),
		radial-gradient(circle at 45% 40%, var(--c1), var(--c2) 75%);
	box-shadow: 0 4px 10px rgba(0,0,0,.45), inset 0 -3px 6px rgba(0,0,0,.35);}
.ny-ball__orb::after {content: ""; position: absolute; left: 10%; right: 10%; top: 46%; height: 2px;
	border-radius: 2px; background: rgba(255,255,255,.28); box-shadow: 0 4px 0 rgba(255,255,255,.12);}
.ny-ball--star .ny-ball__orb::after {content: "✦"; left: 0; right: 0; top: 50%; height: auto; background: none;
	box-shadow: none; transform: translateY(-50%); text-align: center; color: rgba(255,240,200,.85);
	font-size: calc(var(--s) * .42); line-height: 1;}
@keyframes ny-pend {from {transform: rotate(-3deg);} to {transform: rotate(3deg);}}
@keyframes ny-ball-poke {
	0% {transform: rotate(0);} 15% {transform: rotate(-14deg);} 38% {transform: rotate(10deg);}
	60% {transform: rotate(-5deg);} 80% {transform: rotate(2deg);} 100% {transform: rotate(0);}
}

/* Іскорки при кліку */
.ny-spark {position: fixed; width: 5px; height: 5px; margin: -2.5px 0 0 -2.5px; border-radius: 50%;
	pointer-events: none; z-index: 9999; background: var(--c);
	box-shadow: 0 0 6px 1px var(--c);
	animation: ny-spark .8s cubic-bezier(.2,.7,.3,1) forwards;}
@keyframes ny-spark {
	from {transform: translate(0,0) scale(1); opacity: 1;}
	to {transform: translate(var(--dx), var(--dy)) scale(.2); opacity: 0;}
}

/* ---------- Шапка Санти на зірці логотипу ---------- */
.ny-on .header__logo {position: relative;}
.ny-on .header__logo::before {content: ""; position: absolute; left: 4px; top: -1px; width: 34px; height: 28px;
	transform: rotate(-16deg); pointer-events: none;
	background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 68 56'%3E%3Cdefs%3E%3ClinearGradient id='a' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop offset='0' stop-color='%23ff4b4b'/%3E%3Cstop offset='1' stop-color='%23a8141f'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath d='M9 40 C12 20 24 6 42 5 C55 4 61 14 60 30 L55 31 C53 22 49 17 42 19 C35 22 34 31 36 40 Z' fill='url(%23a)'/%3E%3Crect x='4' y='36' width='38' height='13' rx='6.5' fill='%23f4f4f4'/%3E%3Crect x='6' y='38' width='34' height='4' rx='2' fill='%23fff'/%3E%3Ccircle cx='58' cy='34' r='7' fill='%23fafafa'/%3E%3Ccircle cx='56' cy='32' r='2.5' fill='%23fff'/%3E%3C/svg%3E") center / contain no-repeat;
	filter: drop-shadow(0 2px 2px rgba(0,0,0,.5));}
.ny-on .header__logo {filter: drop-shadow(0 0 6px rgba(248,210,104,.35));}

/* ---------- Кнопка вкл/викл гірлянди ---------- */
.ny-toggle {display: none; width: 40px; height: 40px; padding: 0; margin-right: 12px; border-radius: 50%;
	background: var(--bg-darker); color: var(--accent-2); font-size: 16px; box-shadow: none; border: 0;
	align-items: center; justify-content: center; cursor: pointer;}
.ny-on .ny-toggle {display: inline-flex;}
.ny-toggle:hover {background: var(--accent); color: #fff;}
.ny-off .ny-toggle {color: var(--tt); opacity: .7;}

/* ---------- Відлік до Нового року ---------- */
.carou__menu .ny-cd {display: none;}
.ny-on .carou__menu .ny-cd {display: flex; align-items: center; margin-right: auto; padding: 0 16px 0 4px;
	gap: 9px; cursor: pointer; white-space: nowrap; color: var(--tt-lighter); font-size: 13px;
	text-shadow: 0 1px 3px rgba(0,0,0,.8);}
.ny-cd__ico {color: #4fc26b; font-size: 18px; filter: drop-shadow(0 0 6px rgba(79,194,107,.55));}
.ny-cd__label {opacity: .85;}
.ny-cd__time {font-weight: 700; color: var(--accent-2); font-variant-numeric: tabular-nums; letter-spacing: .5px;}
.ny-cd__time i {font-style: normal; font-weight: 500; opacity: .75; margin: 0 1px 0 1px;}
.ny-cd:hover .ny-cd__ico {animation: ny-tree .6s ease-in-out;}
@keyframes ny-tree {0%,100% {transform: rotate(0);} 30% {transform: rotate(-12deg) scale(1.15);} 65% {transform: rotate(9deg) scale(1.1);}}

/* ---------- Салют ---------- */
.ny-fireworks {position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 9998;}

/* ---------- Адаптив ---------- */
@media screen and (max-width: 1220px) {
	.ny-on .carou__menu .ny-cd {flex: 0 0 100%; order: -1; justify-content: center; margin: 0;
		padding: 10px; background: rgba(0,0,0,.35); text-shadow: none;}
}
@media screen and (max-width: 950px) {
	.ny-toggle {order: 10; margin-right: 10px;}
}
@media screen and (max-width: 590px) {
	.ny-on .header {margin-bottom: 44px;}
	.ny-on .carou__menu .ny-cd {background: var(--bg-darker); font-size: 12px;}
}
@media screen and (max-width: 470px) {
	.ny-cd__label {display: none;}
	.ny-cd__time::before {content: "До НР: "; font-weight: 500; color: var(--tt-lighter); opacity: .8;}
}

/* Для тих, хто вимкнув анімації в системі */
@media (prefers-reduced-motion: reduce) {
	.ny-s, .ny-ball {animation: none !important;}
	.ny-garland .ny-lit, .ny-garland .ny-halo {animation-duration: 8s !important;}
}
@media screen and (max-width: 470px) {
	.ny-cd--done .ny-cd__label {display: inline;}
	.ny-cd--done .ny-cd__time::before {content: none;}
}
