/* Tema di Natale della Masterclass FC 27 (dicembre 2026).
   Attivo con html[data-xmas="on"] (predefinito), spento dal pulsante 🎄 «Natale» accanto a chiaro/scuro.
   Scelta ricordata nel browser: localStorage «jf-masterclass-xmas» = on | off. */

:root {
  --xmas-red: #ff4d5e;
  --xmas-red-deep: #c81e35;
  --xmas-gold: #ffd36b;
  --xmas-snow: #ffffff;
}
html[data-theme="light"],
html[data-jf-theme="light"] {
  --xmas-red: #d4213a;
  --xmas-red-deep: #a8142a;
  --xmas-gold: #b07a00;
  --xmas-snow: rgba(110, 140, 168, .7);
}

/* Pulsante 🎄 accanto a chiaro/scuro (stessa forma del pulsante del tema). */
.xmas-toggle .theme-icon,
.xmas-toggle .xmas-icon { font-size: 15px; line-height: 1; filter: grayscale(1) opacity(.55); transition: filter .2s ease; }
html[data-xmas="on"] .xmas-toggle .theme-icon,
html[data-xmas="on"] .xmas-toggle .xmas-icon { filter: none; }
button.xmas-toggle:not(.theme-toggle) { margin-left: 8px; }

/* Pagine WordPress: barra in alto a griglia («brand nav toggle»): il 🎄 ha una colonna sua accanto a chiaro/scuro. */
html body.jf-fc27-surface .jf-context-bar:has(> .jf-theme-toggle.xmas-toggle) { grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: "brand nav toggle xmas"; }
html body.jf-fc27-surface .jf-context-bar > .jf-theme-toggle.xmas-toggle { grid-area: xmas; position: static !important; margin: 0 !important; white-space: nowrap; }
@media (max-width: 1200px) {
  html body.jf-fc27-surface .jf-context-bar:has(> nav > a:nth-child(6)):has(> .jf-theme-toggle.xmas-toggle) { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "brand toggle xmas" "nav nav nav"; }
}
@media (max-width: 1080px) {
  html body.jf-fc27-surface .jf-context-bar:has(> .jf-theme-toggle.xmas-toggle) { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "brand toggle xmas" "nav nav nav"; }
}
/* Area Studenti: chiaro/scuro diventa un'icona in alto a destra; il 🎄 gli sta accanto, solo icona. */
@media (max-width: 991px) {
  html body .jf-student-area .jf-context-bar > .jf-theme-toggle.xmas-toggle { position: absolute !important; top: 9px; right: 55px; width: 38px; min-width: 38px; min-height: 36px; padding: 0 !important; justify-content: center; }
  html body .jf-student-area .jf-context-bar > span { max-width: calc(100% - 100px) !important; }
  html body .jf-student-area .xmas-toggle .jf-theme-label { display: none; }
}
@media (max-width: 700px) {
  html body .jf-student-area .jf-context-bar:has(> .jf-theme-toggle.xmas-toggle) { grid-template-columns: minmax(0, 1fr) 44px 44px !important; grid-template-areas: none !important; }
  html body .jf-student-area .jf-context-bar > .jf-theme-toggle.xmas-toggle { position: static !important; grid-column: 3; grid-row: 1; width: 44px !important; min-width: 44px !important; min-height: 42px !important; margin: 0 !important; }
  html body .jf-student-area .jf-context-bar > span { max-width: none !important; }
  html body.jf-fc27-surface .jf-context-bar > .jf-theme-toggle.xmas-toggle .jf-theme-label { display: none; }
  html body.jf-fc27-surface .jf-context-bar > .jf-theme-toggle.xmas-toggle { min-width: 44px; padding: 0 10px; }
}
#header { position: relative; }
html[data-xmas="on"] .xmas-toggle { border-color: color-mix(in srgb, var(--xmas-red) 55%, transparent); }

/* Tutto ciò che è natalizio si vede solo con il tema acceso. */
/* Il Natale mostra o nasconde: quando è acceso ogni elemento tiene la sua disposizione (flex, grid, inline…). */
html:not([data-xmas="on"]) .xmas-only { display: none !important; }
html[data-xmas="on"] .xmas-only-flex { display: inline-flex !important; }

/* Filo di luci sotto la barra in alto (creato da natale.js): filo a festoni, 6 colori, una lampadina ogni 18 px;
   si accendono a turno in modo veloce, con un alone forte da accese e fioche da spente. */
.xmas-lights { position: absolute; left: 0; right: 0; bottom: -14px; height: 20px; pointer-events: none; z-index: 3; }
.xmas-lights::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 9px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='9'%3E%3Cpath d='M0 1.5 Q9 9 18 1.5' fill='none' stroke='%23293a33' stroke-width='1.5'/%3E%3C/svg%3E") 9px 0 / 18px 9px repeat-x;
}
html[data-theme="light"] .xmas-lights::before,
html[data-jf-theme="light"] .xmas-lights::before { opacity: .7; }
.xmas-lights i {
  --c: #e3122b;
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--x) 11px, #fffbe8 0 1.4px, var(--c) 2.1px 4.1px, transparent 4.9px) 0 0 / 108px 20px repeat-x;
  filter: drop-shadow(0 0 3px var(--c)) drop-shadow(0 0 9px var(--c));
  animation: var(--anim) var(--dur) ease-in-out var(--del) infinite;
}
/* Colori del Natale: rosso, verde abete, oro, bianco caldo; ogni filo ha il suo ritmo, irregolare come le luci vere. */
.xmas-lights .l1 { --x: 9px;  --c: #ff1f3a; --anim: xmas-luci-a; --dur: 2.7s; --del: -.3s; }
.xmas-lights .l2 { --x: 27px; --c: #19c94a; --anim: xmas-luci-b; --dur: 3.4s; --del: -1.1s; }
.xmas-lights .l3 { --x: 45px; --c: #ffc22e; --anim: xmas-luci-c; --dur: 2.1s; --del: -.7s; }
.xmas-lights .l4 { --x: 63px; --c: #fff1c9; --anim: xmas-luci-d; --dur: 4.3s; --del: -2.2s; }
.xmas-lights .l5 { --x: 81px; --c: #ff1f3a; --anim: xmas-luci-b; --dur: 3.1s; --del: -1.9s; }
.xmas-lights .l6 { --x: 99px; --c: #19c94a; --anim: xmas-luci-a; --dur: 2.4s; --del: -1.4s; }
html[data-theme="light"] .xmas-lights .l4, html[data-jf-theme="light"] .xmas-lights .l4 { --c: #e0a400; }
/* Ritmi diversi: accensioni lunghe, tremolii, spegnimenti brevi e doppi lampi. */
@keyframes xmas-luci-a {
  0%, 18% { opacity: 1; } 22% { opacity: .15; } 26% { opacity: 1; } 30% { opacity: .2; } 34%, 58% { opacity: 1; }
  64%, 74% { opacity: .12; } 80%, 100% { opacity: 1; }
}
@keyframes xmas-luci-b {
  0% { opacity: .15; } 10%, 44% { opacity: 1; } 48% { opacity: .35; } 52%, 66% { opacity: 1; }
  70%, 88% { opacity: .12; } 94%, 100% { opacity: .15; }
}
@keyframes xmas-luci-c {
  0%, 30% { opacity: 1; } 33% { opacity: .2; } 36% { opacity: 1; } 39% { opacity: .2; } 42% { opacity: 1; }
  45%, 62% { opacity: .1; } 68%, 100% { opacity: 1; }
}
@keyframes xmas-luci-d {
  0% { opacity: .35; } 25% { opacity: 1; } 50% { opacity: .55; } 62% { opacity: 1; } 70% { opacity: .2; } 78%, 100% { opacity: .9; }
}



/* Neve: un canvas leggero sopra lo sfondo, mai sopra i contenuti cliccabili. */
.xmas-snow { position: fixed; inset: 0; z-index: 5; pointer-events: none; display: none; } /* sopra le sezioni (anche la barra della lezione extra), mai cliccabile */
html[data-xmas="on"] .xmas-snow { display: block; }

/* Etichetta «Edizione di Natale» nell'hero. */
.xmas-ribbon {
  display: none;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  padding: 7px 13px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(90deg, var(--xmas-red-deep), var(--xmas-red));
  box-shadow: 0 10px 28px rgba(200, 30, 53, .32);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}
html[data-xmas="on"] .xmas-ribbon { display: inline-flex; }

/* Cappello di Natale sulla testa di John (posizionato da natale.js sulla foto vera). */
.xmas-hat { position: absolute !important; z-index: 2; display: none; pointer-events: none; transform-origin: 30% 90%; transform: rotate(-9deg); height: auto !important; max-width: none !important; min-width: 0 !important; margin: 0 !important; right: auto !important; bottom: auto !important; transition: none !important; }
html[data-xmas="on"] .xmas-hat.is-placed { display: block; }

/* Neve sulle schede che fluttuano accanto a John. */
html[data-xmas="on"] .float-card::before {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  top: -7px;
  height: 9px;
  border-radius: 9px;
  background: linear-gradient(#ffffff, #e9f1f6);
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .25));
}
html[data-xmas="on"][data-theme="light"] .float-card::before { filter: drop-shadow(0 2px 3px rgba(20, 40, 60, .22)); }

/* Riquadro del prezzo: nastro rosso del regalo. */
html[data-xmas="on"] .xmas-gift { position: relative; }
html[data-xmas="on"] .xmas-gift::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  right: 34px;
  width: 14px;
  background: linear-gradient(90deg, var(--xmas-red-deep), var(--xmas-red), var(--xmas-red-deep));
  opacity: .9;
  pointer-events: none;
  border-radius: 2px;
}
html[data-xmas="on"] .xmas-gift > * { position: relative; z-index: 1; }

@media (prefers-reduced-motion: reduce) {
  .xmas-lights i { animation: none; }
}
