/* Thème d'hiver : actif quand hiver.js pose la classe `hiver` sur <html>.
   Il ne fait que surcharger style.css. Les animations ne touchent qu'à
   `opacity` et `transform`, que le navigateur compose sans repeindre. */

html.hiver .sidebar { background: #00695c; }
html.hiver .sidebar-brand,
html.hiver .sidebar-footer { border-color: #00574d; }
html.hiver .sidebar-link:hover { background: #00574d; }

/* ── Guirlande : ampoules fixes + halo qui clignote par-dessus ── */

html.hiver .sidebar-brand,
html.hiver .mobile-topbar,
html.hiver .login-header { position: relative; }

html.hiver .sidebar-brand::after,
html.hiver .sidebar-brand::before,
html.hiver .mobile-topbar::after,
html.hiver .mobile-topbar::before,
html.hiver .login-header::after,
html.hiver .login-header::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -10px;
    height: 16px;
    pointer-events: none;
    z-index: 2;
}

/* Le fil, puis trois ampoules par motif de 54 px, un peu allongées. */
html.hiver .sidebar-brand::after,
html.hiver .mobile-topbar::after,
html.hiver .login-header::after {
    background:
        radial-gradient(3px 4.5px at 9px 10px, #d63b2f 92%, transparent) 0 0 / 54px 16px repeat-x,
        radial-gradient(3px 4.5px at 27px 11px, #f2c14e 92%, transparent) 0 0 / 54px 16px repeat-x,
        radial-gradient(3px 4.5px at 45px 10px, #3aa86b 92%, transparent) 0 0 / 54px 16px repeat-x,
        radial-gradient(14px 6px at 9px 0, transparent 82%, #2b2b2b 86% 96%, transparent) 0 0 / 18px 16px repeat-x;
}

/* Halo d'une ampoule sur deux, qui s'allume et s'éteint. */
html.hiver .sidebar-brand::before,
html.hiver .mobile-topbar::before,
html.hiver .login-header::before {
    z-index: 3;
    background:
        radial-gradient(7px 8px at 9px 10px, rgba(255, 120, 100, 0.75), transparent) 0 0 / 108px 16px repeat-x,
        radial-gradient(7px 8px at 81px 10px, rgba(255, 220, 120, 0.8), transparent) 0 0 / 108px 16px repeat-x,
        radial-gradient(7px 8px at 45px 10px, rgba(110, 230, 160, 0.7), transparent) 0 0 / 108px 16px repeat-x;
    opacity: 0;
    will-change: opacity;
    animation: hiver-blink 3.2s ease-in-out infinite alternate;
}

@keyframes hiver-blink {
    0%, 35% { opacity: 0; }
    65%, 100% { opacity: 1; }
}

/* ── Neige posée sur le haut des cartes ──
   Un seul motif de 120 px répété, décalé d'une carte à l'autre pour ne pas
   voir la répétition. Sous le texte (z-index -1 dans le contexte isolé de la
   carte), aucune animation : peint une fois. */

html.hiver :where(.dash-card, .summary-card, .std-gpa-card, .ue-card, .stat-card,
                  .chart-box, .fact-card, .teacher-card, .review-card) {
    position: relative;
}
html.hiver :where(.event, .dash-card, .summary-card, .std-gpa-card, .ue-card, .stat-card,
                  .chart-box, .fact-card, .teacher-card, .review-card) {
    isolation: isolate;
}
html.hiver :where(.event, .dash-card, .summary-card, .std-gpa-card, .ue-card, .stat-card,
                  .chart-box, .fact-card, .teacher-card, .review-card)::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 10px;
    z-index: -1;
    pointer-events: none;
    border-radius: inherit;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 10'%3E%3Cpath d='M0 0H120V3C112 3 110 6 104 6C98 6 97 3.5 90 4C84 4.5 83 8 78 8C74 8 73 4 66 4C58 4 57 5.5 50 5.5C44 5.5 43 3 36 3.5C30 4 29 7 24 7C19 7 18 3.5 11 3.5C5 3.5 4 3 0 3Z' transform='translate(0 1)' fill='%23587089' opacity='.3'/%3E%3Cpath d='M0 0H120V3C112 3 110 6 104 6C98 6 97 3.5 90 4C84 4.5 83 8 78 8C74 8 73 4 66 4C58 4 57 5.5 50 5.5C44 5.5 43 3 36 3.5C30 4 29 7 24 7C19 7 18 3.5 11 3.5C5 3.5 4 3 0 3Z' fill='%23f7fafc'/%3E%3C/svg%3E") 0 0 / 120px 10px repeat-x;
}
/* Les cours du planning sont petits et parfois en texte blanc : neige plus
   fine, texte décalé de 2 px pour ne pas passer dessus. */
html.hiver .event { padding-top: 5px; }
html.hiver .event::before { height: 6px; }
html.hiver :where(.event, .dash-card, .summary-card, .ue-card, .stat-card, .fact-card,
                  .teacher-card, .review-card):nth-child(2n)::before {
    background-position-x: -47px;
}
html.hiver :where(.event, .dash-card, .summary-card, .ue-card, .stat-card, .fact-card,
                  .teacher-card, .review-card):nth-child(3n)::before {
    background-position-x: -83px;
}

/* ── Neige (canvas posé par hiver.js) ── */

#hiver-snow {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 80;
}

/* ── Interrupteur dans le pied de la barre ── */

.hiver-toggle {
    width: calc(100% - 1rem);
    background: none;
    border: none;
    cursor: pointer;
    font: inherit;
    font-size: 0.82rem;
    text-align: left;
}
html:not(.hiver) .hiver-toggle { opacity: 0.75; }

@media (prefers-reduced-motion: reduce) {
    html.hiver .sidebar-brand::before,
    html.hiver .mobile-topbar::before,
    html.hiver .login-header::before { animation: none; }
}
