/**
 * Новогодние эффекты.
 * На body только префиксы ny-has-* (не пересекаются с .ny-garland и т.п.).
 */

/* ——— Тема ——— */
body.ny-has-theme {
    --ny-red: #c62828;
    --ny-green: #2e7d32;
    --ny-gold: #f9a825;
}

body.ny-has-theme .main-header {
    border-bottom: 1px solid rgba(249, 168, 37, 0.35);
    box-shadow:
        0 1px 0 rgba(198, 40, 40, 0.35),
        0 8px 28px rgba(0, 0, 0, 0.35);
}

body.ny-has-theme .main-nav a:hover,
body.ny-has-theme .main-nav a.active {
    color: var(--ny-gold);
}

body.ny-has-theme .btn-primary,
body.ny-has-theme .auth-submit {
    background: linear-gradient(135deg, #b71c1c 0%, #c62828 45%, #1b5e20 100%);
    border-color: rgba(249, 168, 37, 0.45);
}

body.ny-has-theme .btn-primary:hover,
body.ny-has-theme .auth-submit:hover {
    filter: brightness(1.08);
}

body.ny-has-theme .logo-image {
    filter: drop-shadow(0 0 8px rgba(249, 168, 37, 0.35));
}

/* ——— Гирлянда (спрайт atuin: 3 кадра × 62px) ——— */
.ny-garland {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 62px;
    z-index: 10050;
    pointer-events: none;
    overflow: hidden;
    background-image: url('../images/holidays/gir.png');
    background-repeat: repeat-x;
    background-position: 0 0;
}

.ny-garland.gir_1 { background-position: 0 0; }
.ny-garland.gir_2 { background-position: 0 -62px; }
.ny-garland.gir_3 { background-position: 0 -124px; }

body.ny-has-garland .main-header {
    margin-top: 36px;
}

/* ——— Снежинки (фон) ——— */
#snowflakes-container {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: 100vw;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}

.site-snowflake {
    position: absolute;
    top: -20px;
    color: rgba(255, 255, 255, 0.75);
    text-shadow: 0 0 6px rgba(180, 220, 255, 0.35);
    animation-name: site-snowfall;
    animation-timing-function: linear;
    animation-fill-mode: forwards;
    will-change: transform, opacity;
}

@keyframes site-snowfall {
    0% { transform: translate3d(0, 0, 0) rotate(0deg); opacity: 0; }
    10% { opacity: 1; }
    100% { transform: translate3d(var(--drift, 20px), 105vh, 0) rotate(360deg); opacity: 0.15; }
}

/* ——— Снег у курсора ——— */
.ny-cursor-flake {
    position: fixed;
    z-index: 10040;
    pointer-events: none;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 0 4px rgba(180, 220, 255, 0.5);
    animation: ny-cursor-fall 0.9s ease-out forwards;
    will-change: transform, opacity;
}

@keyframes ny-cursor-fall {
    0% { transform: translate3d(0, 0, 0) scale(1); opacity: 0.95; }
    100% { transform: translate3d(var(--dx, 0px), 28px, 0) scale(0.4); opacity: 0; }
}

/* ——— Шапочка: готовый PNG поверх аватара ——— */
.ny-hat-target {
    position: relative;
    display: inline-block;
    overflow: visible;
    line-height: 0;
}

.ny-hat-target.user-menu-wrapper {
    display: inline-flex;
    align-items: center;
}

.ny-hat-target > #user-avatar,
.ny-hat-target > .user-avatar {
    display: block;
}

/* Позиции подогнаны вручную — не сбрасывать при правках гирлянды/снега */
.ny-santa-hat {
    position: absolute;
    top: -49%;
    left: -40%;
    width: 118%;
    height: auto;
    z-index: 3;
    pointer-events: none;
    user-select: none;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.45));
    transform: rotate(-4deg);
}

/* Хедер — аватар маленький */
.user-menu .ny-santa-hat {
    top: -44%;
    left: -37%;
    width: 110%;
    transform: rotate(-5deg);
}

/* Профиль — аватар крупный */
.profile-area .ny-santa-hat {
    top: -49%;
    left: -40%;
    width: 112%;
    transform: rotate(-4deg);
}

/* ——— Зимние эффекты ——— */
body.ny-has-winter .server-card,
body.ny-has-winter .auth-card,
body.ny-has-winter .profile-panel,
body.ny-has-winter .shop-item-card,
body.ny-has-winter .shop-product-card,
body.ny-has-winter .product-card,
body.ny-has-winter .news-card,
body.ny-has-winter .stat-card,
body.ny-has-winter .profile-field-box {
    box-shadow:
        inset 0 1px 0 rgba(220, 240, 255, 0.22),
        inset 0 0 24px rgba(180, 220, 255, 0.04),
        0 8px 24px rgba(0, 0, 0, 0.28);
    border-color: rgba(200, 230, 255, 0.22) !important;
}

body.ny-has-winter .btn,
body.ny-has-winter .auth-submit,
body.ny-has-winter .btn-primary {
    position: relative;
    overflow: hidden;
}

body.ny-has-winter .btn::after,
body.ny-has-winter .auth-submit::after,
body.ny-has-winter .btn-primary::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(
        115deg,
        transparent 35%,
        rgba(255, 255, 255, 0.18) 48%,
        transparent 62%
    );
    background-size: 220% 100%;
    animation: ny-frost-shine 4.5s ease-in-out infinite;
    opacity: 0.55;
}

@keyframes ny-frost-shine {
    0%, 100% { background-position: 120% 0; }
    50% { background-position: -20% 0; }
}

body.ny-has-winter .main-header {
    backdrop-filter: saturate(1.05);
}

@media (prefers-reduced-motion: reduce) {
    .site-snowflake,
    .ny-cursor-flake,
    body.ny-has-winter .btn::after,
    body.ny-has-winter .auth-submit::after,
    body.ny-has-winter .btn-primary::after {
        animation: none !important;
    }
}

@media (max-width: 720px) {
    body.ny-has-garland .main-header {
        margin-top: 28px;
    }
}

