/* Новогоднее оформление шапки (themes/BTPro_v24/head_nav.php, включается $ICE в include/config.php, декабрь–февраль).
   Снег — canvas (js/newyear.js), гирлянда — CSS. Анимируются только opacity/transform: шапку не перерисовывает каждый кадр. */

/* содержимое шапки над снегом */
.ny-on .nb-container { position: relative; z-index: 1; }

/* 1. Снег внутри шапки ------------------------------------------------------ */
.ny-snow {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

/* 2. Гирлянда под нижним краем шапки ---------------------------------------- */
.ny-garland {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    height: 22px;
    margin-top: -3px;
    display: flex;
    overflow: hidden;
    pointer-events: none;
    z-index: 2;
}
.ny-garland i {
    position: relative;
    flex: 0 0 64px;
    height: 22px;
    /* провод: провисающая дуга между крючками */
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='12' viewBox='0 0 64 12'%3E%3Cpath d='M0 1 Q32 15 64 1' fill='none' stroke='%23233150' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat 0 0 / 64px 12px;
}
/* лампочка в нижней точке дуги */
.ny-garland i::before {
    content: "";
    position: absolute;
    left: 28px;
    top: 7px;
    width: 8px;
    height: 12px;
    border-radius: 50% 50% 45% 45%;
    background: var(--ny-c);
    box-shadow: inset -1px -2px 2px rgba(0, 0, 0, .25), inset 1px 1px 1px rgba(255, 255, 255, .45);
    border-top: 3px solid #3a4560; /* цоколь */
    background-clip: padding-box;
}
/* свечение — отдельный слой, мигает через opacity */
.ny-garland i::after {
    content: "";
    position: absolute;
    left: 20px;
    top: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--ny-c) 0%, transparent 65%);
    opacity: .75;
    animation: ny-glow 2.4s ease-in-out infinite;
    animation-delay: var(--ny-d, 0s);
}
.ny-garland i:nth-child(5n+1) { --ny-c: #ff4d5e; --ny-d: 0s; }
.ny-garland i:nth-child(5n+2) { --ny-c: #ffd23f; --ny-d: .48s; }
.ny-garland i:nth-child(5n+3) { --ny-c: #3ddc84; --ny-d: .96s; }
.ny-garland i:nth-child(5n+4) { --ny-c: #4fb3ff; --ny-d: 1.44s; }
.ny-garland i:nth-child(5n)   { --ny-c: #d28bff; --ny-d: 1.92s; }

@keyframes ny-glow {
    0%, 100% { opacity: .85; }
    50%      { opacity: .12; }
}

/* лампочка тоже чуть гаснет вместе со свечением */
.ny-garland i::before { animation: ny-bulb 2.4s ease-in-out infinite; animation-delay: var(--ny-d, 0s); }
@keyframes ny-bulb {
    0%, 100% { opacity: 1; }
    50%      { opacity: .55; }
}

/* 3. Логотип: ёлочка и колпак ---------------------------------------------- */
.ny-on .nb-brand { position: relative; display: inline-flex; align-items: center; gap: 6px; }
.ny-tree { width: 24px; height: 28px; flex: 0 0 auto; margin-top: -4px; }
.ny-tree .ny-star { transform-origin: 12px 4px; animation: ny-star 3s ease-in-out infinite; }
.ny-tree .ny-l { animation: ny-bulb 1.6s ease-in-out infinite; }
.ny-tree .ny-l:nth-of-type(2n) { animation-delay: .8s; }
.ny-tree .ny-l:nth-of-type(3n) { animation-delay: .4s; }
@keyframes ny-star {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50%      { transform: scale(1.18) rotate(18deg); }
}
.ny-logo { position: relative; }
.ny-hat {
    position: absolute;
    left: -9px;
    top: -12px;
    width: 22px;
    height: 18px;
    transform: rotate(-22deg);
    pointer-events: none;
}

/* 4. Отсчёт до Нового года / поздравление ---------------------------------- */
/* только на широких экранах: в узкой шапке ему нет места */
.ny-count { display: none; }
@media (min-width: 1400px) {
    .ny-count:not([hidden]) { display: inline-flex; }
}
.ny-count {
    align-items: center;
    gap: 6px;
    margin-left: 6px;
    padding: 3px 10px 3px 8px;
    border-radius: 999px;
    border: 1px solid rgba(255, 210, 63, .35);
    background: linear-gradient(90deg, rgba(255, 77, 94, .16), rgba(255, 210, 63, .12));
    color: #ffe9a8;
    font: 500 .74rem/1.2 Inter, system-ui, sans-serif;
    letter-spacing: .01em;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.ny-count b { color: #fff; font-weight: 700; }
.ny-count i { font-style: normal; }

/* 4a. Анимации ------------------------------------------------------------- */
/* гирлянда слегка раскачивается, лампочки бегут волной */
.ny-garland i { transform-origin: 50% 0; animation: ny-sway 4s ease-in-out infinite; animation-delay: calc(var(--ny-d, 0s) * -1); }
@keyframes ny-sway {
    0%, 100% { transform: rotate(1.2deg); }
    50%      { transform: rotate(-1.2deg); }
}
/* колпак покачивается, помпон слегка подпрыгивает */
.ny-hat { transform-origin: 30% 85%; animation: ny-hat 3.2s ease-in-out infinite; }
@keyframes ny-hat {
    0%, 100% { transform: rotate(-22deg); }
    50%      { transform: rotate(-12deg) translateY(-1px); }
}
/* ёлочка качается, при наведении на логотип — подпрыгивает */
.ny-tree { transform-origin: 50% 100%; animation: ny-tree 5s ease-in-out infinite; }
@keyframes ny-tree {
    0%, 100% { transform: rotate(-3deg); }
    50%      { transform: rotate(3deg); }
}
.nb-brand:hover .ny-tree { animation: ny-jump .6s ease-out; }
@keyframes ny-jump {
    0%   { transform: translateY(0) scale(1); }
    40%  { transform: translateY(-6px) scale(1.12); }
    70%  { transform: translateY(1px) scale(.97); }
    100% { transform: translateY(0) scale(1); }
}
/* отсчёт: мягкое мерцание рамки */
.ny-count { animation: ny-pill 3s ease-in-out infinite; }
@keyframes ny-pill {
    0%, 100% { border-color: rgba(255, 210, 63, .25); }
    50%      { border-color: rgba(255, 210, 63, .6); }
}

/* небо шапки обрезает всё, что вылетает за край: иначе сани после пролёта (translateX(100vw)) давали
   горизонтальную прокрутку, и страница уезжала вбок */
.ny-sky {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}
/* сани: пролетают слева направо за 12 с, потом ~30 с пауза */
.ny-sleigh {
    position: absolute;
    left: 0;
    top: 50%;
    margin-top: -18px;
    width: 120px;
    height: 30px;
    pointer-events: none;
    z-index: 0;
    opacity: 0;
    transform: translateX(-140px);
    animation: ny-fly 42s linear 3s infinite;
    filter: drop-shadow(0 0 4px rgba(180, 210, 255, .55));
}
/* искристый след за санями */
.ny-sleigh::before {
    content: "";
    position: absolute;
    right: 100%;
    top: 12px;
    width: 140px;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(90deg, transparent, rgba(255, 233, 168, .55));
    -webkit-mask: radial-gradient(circle, #000 0 1px, transparent 1.5px) 0 0 / 7px 6px;
            mask: radial-gradient(circle, #000 0 1px, transparent 1.5px) 0 0 / 7px 6px;
}
@keyframes ny-fly {
    0%   { transform: translateX(-160px); opacity: 0; }
    2%   { opacity: .9; }
    27%  { opacity: .9; }
    29%  { transform: translateX(calc(100vw + 40px)); opacity: 0; }
    100% { transform: translateX(calc(100vw + 40px)); opacity: 0; }
}
.ny-sleigh-bob { animation: ny-bob 1.6s ease-in-out infinite; }
@keyframes ny-bob {
    0%, 100% { transform: translateY(-4px); }
    50%      { transform: translateY(4px); }
}
.ny-sleigh .ny-leg { animation: ny-gallop .35s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: 50% 0; }
@keyframes ny-gallop {
    from { transform: rotate(-12deg); }
    to   { transform: rotate(12deg); }
}

/* 4b. Снег на блоках (.tp-block — шаблоны themes/BTPro_v24/html/block-*.html) ------------------
   Сугроб лежит на верхнем крае карточки и свисает каплями-сосульками. Файл подключается только в сезон,
   поэтому правила без отдельного флага. ::before/::after у .tp-block больше нигде не используются. */
.tp-block { position: relative; }
.tp-block::before {
    content: "";
    position: absolute;
    /* не до самых углов карточки (радиус 16px), а с отступом — сугроб лежит на ровной части */
    left: 26px;
    right: 26px;
    top: -7px;
    height: 16px;
    z-index: 1;
    pointer-events: none;
    /* закруглённые концы: середина целиком, края — по половинке эллипса */
    -webkit-mask:
        linear-gradient(#000, #000) center / calc(100% - 28px) 100% no-repeat,
        radial-gradient(14px 8px at 14px 9px, #000 97%, transparent) left / 28px 100% no-repeat,
        radial-gradient(14px 8px at 14px 9px, #000 97%, transparent) right / 28px 100% no-repeat;
            mask:
        linear-gradient(#000, #000) center / calc(100% - 28px) 100% no-repeat,
        radial-gradient(14px 8px at 14px 9px, #000 97%, transparent) left / 28px 100% no-repeat,
        radial-gradient(14px 8px at 14px 9px, #000 97%, transparent) right / 28px 100% no-repeat;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='18' viewBox='0 0 120 18'%3E%3Cpath d='M0 8C8 2 18 3 26 6C34 1 48 1 56 6C64 2 78 1 86 5C96 0 110 3 120 8V11C114 12 110 11 106 12C104 16 100 16 99 12C90 13 80 11 70 12C68 17 63 17 62 12C52 13 40 11 30 12C28 15 24 15 23 12C14 13 6 11 0 11Z' fill='%23fff'/%3E%3Cpath d='M0 10.4C6 11 14 12.6 23 11.6M30 11.6C40 10.6 52 12.6 62 11.6M70 11.6C80 10.6 90 12.6 99 11.6M106 11.6C110 10.8 114 11.6 120 10.4' fill='none' stroke='%23cfe0f5' stroke-width='1.2'/%3E%3C/svg%3E") repeat-x 0 0 / 107px 16px;
    filter: drop-shadow(0 1px 1px rgba(15, 40, 90, .22));
}
/* разный рисунок сугроба у соседних блоков */
.tp-block:nth-of-type(3n+2)::before { background-position-x: -44px; }
.tp-block:nth-of-type(3n)::before   { background-position-x: -83px; }
/* искорки на снегу */
.tp-block::after {
    content: "";
    position: absolute;
    left: 36px;
    right: 36px;
    top: -5px;
    height: 8px;
    z-index: 1;
    pointer-events: none;
    background:
        radial-gradient(circle, #fff 0 1px, rgba(170, 205, 255, .9) 1.5px, transparent 2.5px) 0 0 / 53px 8px repeat-x,
        radial-gradient(circle, #fff 0 .8px, rgba(255, 233, 168, .9) 1.3px, transparent 2.2px) 27px 2px / 71px 8px repeat-x;
    animation: ny-glint 3.6s ease-in-out infinite;
}
.tp-block:nth-of-type(2n)::after { animation-delay: -1.8s; }
@keyframes ny-glint {
    0%, 100% { opacity: .15; }
    50%      { opacity: 1; }
}

/* 5. Узкие экраны: меньше лампочек, без колпака у мелкого логотипа ---------- */
@media (max-width: 575.98px) {
    .ny-garland i { flex-basis: 48px; background-size: 48px 12px; }
    .ny-garland i::before { left: 20px; }
    .ny-garland i::after  { left: 12px; }
    .ny-tree { width: 20px; height: 24px; }
    .ny-hat { left: -7px; top: -10px; width: 18px; height: 15px; }
}

/* 6. Анимации идут всегда, даже при системном «уменьшить движение» (так решил владелец сайта) */
@media (max-width: 575.98px) {
    .ny-sleigh { width: 90px; height: 23px; margin-top: -14px; }
    .ny-sleigh svg { width: 90px; height: 23px; }
}

@media print {
    .ny-snow, .ny-garland, .ny-count, .ny-hat, .ny-tree, .ny-sky, .tp-block::before, .tp-block::after { display: none !important; }
}
