/* =========================================================
   ACTIA — THÈME DE NOËL v3 « Nuit d'hiver »
   Actif uniquement quand <body> a la classe .noel
   (menu Thème → Ambiance → Noël). Chargé après refonte.css.
   ========================================================= */

/* Icônes utilisées par le menu et le compte à rebours (toujours dispo) */
.ci-snow { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 2v20M4.9 7l14.2 10M4.9 17 19.1 7'/%3E%3Cpath d='m9 4 3 2 3-2M9 20l3-2 3 2M3.5 10.5l3.1-.4L5.4 7.3M20.5 13.5l-3.1.4 1.2 2.8M3.5 13.5l3.1.4-1.2 2.8M20.5 10.5l-3.1-.4 1.2-2.8'/%3E%3C/svg%3E"); }
.ci-gift { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='8' width='18' height='4' rx='1'/%3E%3Cpath d='M12 8v13M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7'/%3E%3Cpath d='M7.5 8a2.5 2.5 0 0 1 0-5C10 3 12 8 12 8s2-5 4.5-5a2.5 2.5 0 0 1 0 5'/%3E%3C/svg%3E"); }

/* Flocon du menu Thème (image) */
.theme-menu-panel .theme-fest-icon {
  flex: none;
  width: 20px;
  height: 20px;
  margin: -2px;
  object-fit: contain;
}

#noelFx { display: none; }

/* ---------- 1. Couleurs : nuit bleue, rouge & or ---------- */
body.noel,
body.noel.light {
  --accent: #d93a48;
  --accent2: #f2c14e;
  --gold: #f2c14e;

  --bg: #0a1424;
  --bg2: #0e1b2f;
  --surface: #11223a;
  --surface-2: #172c49;
  --input: #0c1a2d;
  --card: #11223a;
  --border: #22395a;
  --border-strong: #31507a;
  --text: #eef3fa;
  --muted: #93a7c3;
  --tag-text: #ffd9de;

  --green: #3ccf7a;
  --orange: #f2b544;
  --red: #ff5a66;
  --blue: #7cc4ff;
  --icon-green: #3ccf7a;

  --bar: #08111f;
  --bar-text: #b6c4d8;
  --bar-border: #1d2f4c;

  --shadow-sm: 0 1px 0 rgba(0, 0, 0, .3);
  --shadow: 0 6px 22px rgba(0, 0, 0, .4);

  color: var(--text);
  background:
    radial-gradient(ellipse 90% 60% at 80% -10%, rgba(64, 110, 170, .35), transparent 60%),
    linear-gradient(180deg, #060e1b 0%, #0a1628 55%, #10223b 100%) fixed;
}
body.noel .bg-glow { display: none; }
body.noel ::selection { background: #d93a48; color: #fff; }

/* Le fond du décor doit rester visible derrière la page */
body.noel .app,
body.noel .main { background: transparent; }

/* ---------- 2. Décor du fond ---------- */
#noelBack {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
#noelBack .nb-star {
  position: absolute;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 6px rgba(255, 255, 255, .8);
  animation: nbTwinkle 3.5s ease-in-out infinite;
}
@keyframes nbTwinkle { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }

#noelBack .nb-moon {
  position: absolute;
  top: 96px;
  right: 6%;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 62% 38%, rgba(190, 170, 120, .35) 0 7px, transparent 8px),
    radial-gradient(circle at 38% 64%, rgba(190, 170, 120, .3) 0 5px, transparent 6px),
    radial-gradient(circle at 70% 70%, rgba(190, 170, 120, .25) 0 4px, transparent 5px),
    radial-gradient(circle at 35% 35%, #fffdf2, #f4e8c1 62%, #dccb93);
  box-shadow:
    0 0 30px 6px rgba(255, 238, 190, .35),
    0 0 120px 40px rgba(255, 238, 190, .08);
}

#noelBack .nb-land {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 210px;
}
#noelBack .nb-hills { position: absolute; inset: 0; width: 100%; height: 100%; }
#noelBack .nb-pine { position: absolute; bottom: 14px; transform: translateX(-50%); }
#noelBack .nb-pine svg { display: block; height: 100%; width: auto; }
#noelBack .nb-cabin {
  position: absolute;
  left: 23%;
  bottom: 22px;
  width: 128px;
}
#noelBack .nb-cabin svg { display: block; width: 100%; height: auto; }
#noelBack .nb-win {
  filter: drop-shadow(0 0 6px #ffb84d);
  animation: nbFire 2.6s ease-in-out infinite alternate;
}
@keyframes nbFire { from { opacity: .82; } to { opacity: 1; } }
#noelBack .nb-smoke {
  position: absolute;
  left: 71%;
  top: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(220, 230, 245, .3);
  filter: blur(2px);
  animation: nbSmoke 5s ease-out infinite;
}
#noelBack .nb-smoke.s2 { animation-delay: 1.7s; }
#noelBack .nb-smoke.s3 { animation-delay: 3.4s; }
@keyframes nbSmoke {
  0% { transform: translate(0, 0) scale(.6); opacity: 0; }
  15% { opacity: .8; }
  100% { transform: translate(26px, -70px) scale(2.6); opacity: 0; }
}

/* ---------- 3. Calque de devant : neige, guirlande, traîneau ---------- */
body.noel #noelFx {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  overflow: hidden;
}
#noelFx .noel-snow {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transition: opacity .3s;
}
/* Pas de neige par-dessus les fenêtres de saisie */
body.noel:has(.modal.open) #noelFx .noel-snow,
body.noel:has(.supplier-confirm-overlay) #noelFx .noel-snow { opacity: 0; }

#noelFx .noel-garland {
  position: absolute;
  left: 0;
  right: 0;
  height: 48px;
  overflow: hidden;
  margin-top: -2px;
}
#noelFx .noel-garland svg { display: block; }
#noelFx .nb-bulb .glow { filter: url(#nbGlow); opacity: .55; }
#noelFx .nb-bulb { animation: nbBulb 2.4s ease-in-out infinite; }
#noelFx .nb-bulb.g1 { animation-delay: .8s; }
#noelFx .nb-bulb.g2 { animation-delay: 1.6s; }
@keyframes nbBulb {
  0%, 100% { opacity: 1; }
  50% { opacity: .38; }
}

/* Traîneau du père Noël (passe au clic sur le compte à rebours) */
#noelFx .noel-sleigh {
  position: absolute;
  left: 0;
  top: 0;
  width: 270px;
  color: #ffe6a6;
  filter: drop-shadow(0 0 6px rgba(255, 214, 120, .85));
  animation: nbFly 8s cubic-bezier(.35, .1, .65, .9) forwards;
}
#noelFx .noel-sleigh svg { display: block; width: 100%; height: auto; animation: nbBob 1.1s ease-in-out infinite alternate; }
@keyframes nbFly {
  0%   { transform: translate(-300px, 42vh) rotate(-7deg); }
  50%  { transform: translate(calc(50vw - 135px), 16vh) rotate(-3deg); }
  100% { transform: translate(calc(100vw + 40px), 4vh) rotate(-9deg); }
}
@keyframes nbBob { from { transform: translateY(-3px); } to { transform: translateY(3px); } }

/* Étincelles (clic + traînée du traîneau) */
#noelFx .noel-pop {
  position: absolute;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  background: var(--c, #ffd166);
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  filter: drop-shadow(0 0 4px var(--c, #ffd166));
  animation: nbPop .9s ease-out forwards;
}
#noelFx .noel-pop.is-small { width: 6px; height: 6px; margin: -3px 0 0 -3px; animation-duration: 1.1s; }
@keyframes nbPop {
  0% { transform: translate(0, 0) scale(1) rotate(0); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(.2) rotate(180deg); opacity: 0; }
}

/* ---------- 4. Interface ---------- */

/* Barre du haut : liseré or sous le rouge */
body.noel .sidebar { box-shadow: 0 1px 0 #f2c14e; }

/* Bonnet sur le logo */
body.noel .brand-logo { position: relative; overflow: visible; }
.noel-hat {
  position: absolute;
  top: -30%;
  left: -22%;
  width: 74%;
  pointer-events: none;
  transform: rotate(-24deg);
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .35));
  z-index: 2;
}
.noel-hat svg { display: block; width: 100%; height: auto; }
body:not(.noel) .noel-hat { display: none; }

/* Boutons principaux : sucre d'orge */
body.noel .btn.primary {
  background: repeating-linear-gradient(-45deg, #d93a48 0 10px, #c22d3b 10px 20px);
  border-color: #b8293a;
  color: #fff;
}
body.noel .btn.primary:hover { filter: brightness(1.08); }

/* Petite étoile dorée après les titres de page */
body.noel .view-head h2::after {
  content: '';
  display: inline-block;
  width: .62em;
  height: .62em;
  margin-left: .4em;
  vertical-align: .05em;
  background: #f2c14e;
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  filter: drop-shadow(0 0 4px rgba(242, 193, 78, .7));
  animation: nbStar 2.8s ease-in-out infinite;
}
@keyframes nbStar { 0%, 100% { transform: scale(1) rotate(0); } 50% { transform: scale(1.15) rotate(12deg); } }

/* Neige posée sur le haut des cartes */
body.noel .stat-card,
body.noel .card,
body.noel .nc-card,
body.noel .note-card {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 140 14'%3E%3Cpath d='M0 0H140V4Q133 10 125 6Q117 2 109 7Q103 12 96 7Q87 1 77 6Q71 10 66 6Q57 0 47 7Q41 13 34 7Q26 1 18 6Q9 11 0 4Z' fill='%23eef5fd'/%3E%3Ccircle cx='103' cy='11' r='1.6' fill='%23eef5fd'/%3E%3Ccircle cx='40' cy='12.5' r='1.4' fill='%23eef5fd'/%3E%3C/svg%3E");
  background-repeat: repeat-x;
  background-size: 140px 14px;
  background-position: top left;
}

/* Compte à rebours dans la barre de recherche */
.noel-count {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid rgba(242, 193, 78, .45);
  border-radius: var(--radius-sm, 8px);
  background: linear-gradient(135deg, rgba(217, 58, 72, .22), rgba(242, 193, 78, .12));
  color: #fff3d1;
  font: inherit;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
  flex: none;
  transition: border-color .15s, transform .15s;
}
.noel-count:hover { border-color: #f2c14e; }
.noel-count:active { transform: scale(.97); }
.noel-count .ci { width: 16px; height: 16px; color: #f2c14e; }
.noel-count strong { font-weight: 700; }
.noel-count-long { color: #d8c7a0; }
body:not(.noel) .noel-count { display: none; }

/* ---------- 5. Petits écrans ---------- */
@media (max-width: 860px) {
  #noelBack .nb-land { height: 130px; }
  #noelBack .nb-cabin { display: none; }
  #noelBack .nb-pine:nth-child(n+6) { display: none; }
  #noelBack .nb-moon { width: 48px; height: 48px; top: 80px; }
  #noelFx .noel-sleigh { width: 190px; }
  .noel-count { padding: 0 10px; }
  .noel-count-long { display: none; }
}
@media (max-width: 480px) {
  .noel-count { padding: 0 8px; gap: 0; }
  .noel-count .ci { display: none; }
}

/* ---------- 6. Accessibilité : pas d'animation ---------- */
@media (prefers-reduced-motion: reduce) {
  #noelBack *,
  #noelFx *,
  body.noel .view-head h2::after { animation: none !important; }
}
