@import url("https://fonts.googleapis.com/css2?family=Cinzel:wght@400;500&family=Cormorant+Garamond:ital,wght@0,300;1,300&display=swap");

:root {
  --notte: #070A18;
  --notte-2: #0C1328;
  --pietra: #0D1226;
  --oro: #C9A04A;
  --oro-chiaro: #F0C46A;
  --crema: #F2E6CC;
  --rosso: #D4232A;
  --spento: #5E6B8E;
  --bulbo-spento: #1B2238;
  --w: min(100vw, 520px);
  --castello-h: calc(var(--w) * 0.42);
  --lago: calc(var(--w) * 0.16);
  --serif: "Cormorant Garamond", Georgia, serif;
  --incisa: "Cinzel", "Trajan Pro", Georgia, serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--notte);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100svh;
  overflow-x: hidden;
  background: var(--notte);
  color: var(--crema);
  font-family: var(--serif);
  font-weight: 300;
  -webkit-tap-highlight-color: transparent;
}

/* ───────────── Scena ───────────── */

#scena {
  position: relative;
  isolation: isolate;
  width: 100%;
  max-width: 520px;
  min-height: 100svh;
  margin: 0 auto;
  padding-bottom: calc(var(--castello-h) + var(--lago) - 6px);
  overflow: hidden;
  background:
    radial-gradient(120% 40% at 50% 0%, rgba(40, 60, 120, 0.28), transparent 70%),
    linear-gradient(180deg, #04060f 0%, var(--notte) 16%, var(--notte-2) 52%, #121d3b 84%, #1a2848 100%);
}

/* alone caldo basso, dietro al castello: le finestre del castello restano accese di luce */
#scena::before {
  content: "";
  position: absolute;
  left: -25%;
  right: -25%;
  bottom: 0;
  height: calc(var(--w) * 0.95);
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 50% 38% at 50% 50%, rgba(255, 176, 84, 0.34), transparent 70%),
    radial-gradient(ellipse 70% 55% at 50% 55%, rgba(206, 110, 52, 0.2), transparent 72%);
}

/* lago */
#scena::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--lago);
  z-index: 1;
  pointer-events: none;
  border-top: 1px solid rgba(240, 196, 106, 0.16);
  background: linear-gradient(180deg, #1c2a4a 0%, #0f1a34 45%, #080d1e 100%);
}

#cielo {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

#cielo s {
  position: absolute;
  display: block;
  width: var(--s);
  height: var(--s);
  border-radius: 50%;
  background: var(--crema);
  opacity: var(--o);
  text-decoration: none;
  animation: brilla var(--d) ease-in-out var(--r) infinite alternate;
}

#cielo i {
  position: absolute;
  top: var(--y, -4%);
  display: block;
  width: var(--s);
  height: var(--s);
  border-radius: 50%;
  background: #fff;
  opacity: var(--o);
  animation: cade var(--d) linear var(--r) infinite;
}

#cielo u {
  position: absolute;
  top: 2.2%;
  right: 7%;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  text-decoration: none;
  background:
    radial-gradient(circle at 62% 30%, rgba(160, 150, 120, 0.35) 0 5px, transparent 6px),
    radial-gradient(circle at 36% 62%, rgba(160, 150, 120, 0.3) 0 7px, transparent 8px),
    radial-gradient(circle at 34% 30%, #fffbea, #ebdfbd 55%, #b8ad8d);
  box-shadow:
    0 0 24px 4px rgba(242, 230, 204, 0.28),
    0 0 90px 36px rgba(120, 150, 225, 0.13);
}

@keyframes brilla {
  to {
    opacity: calc(var(--o) * 0.2);
    transform: scale(0.65);
  }
}

@keyframes cade {
  to {
    transform: translate3d(var(--dx, 20px), 110svh, 0);
  }
}

/* ───────────── Titolo ───────────── */

#titolo {
  position: relative;
  z-index: 3;
  padding: 56px 16px 16px;
  text-align: center;
}

#titolo h1 {
  margin: 0;
  font-family: var(--incisa);
  font-weight: 500;
  font-size: clamp(1.15rem, 6vw, 1.7rem);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  line-height: 1.2;
  color: var(--oro-chiaro);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
}

#sottotitolo {
  position: relative;
  z-index: 2;
  margin: 6px 0 0;
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 300;
  font-size: clamp(0.95rem, 4.2vw, 1.15rem);
  letter-spacing: 0.04em;
  color: #9fabcc;
}

/* ───────────── Muro e griglia ───────────── */

#griglia {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px 8px;
  width: calc(100% - 24px);
  max-width: 440px;
  margin: 8px auto 0;
  padding: 16px 12px 14px;
  border-radius: 18px 18px 3px 3px;
  border: 1px solid rgba(94, 107, 142, 0.22);
  background:
    repeating-linear-gradient(0deg, transparent 0 21px, rgba(0, 0, 0, 0.32) 21px 22px),
    repeating-linear-gradient(90deg, transparent 0 43px, rgba(0, 0, 0, 0.2) 43px 44px),
    linear-gradient(180deg, #151c38 0%, var(--pietra) 55%, #090d1c 100%);
  box-shadow:
    inset 0 0 40px rgba(0, 0, 0, 0.7),
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 18px 40px rgba(0, 0, 0, 0.55);
}

/* ───────────── Finestre ───────────── */

.finestra {
  --telaio-a: #2d3659;
  --telaio-b: #121833;
  --vetro-a: #0c1329;
  --vetro-b: #05070f;
  --luce-a: #ffe6a8;
  --luce-b: #f0a93e;
  --luce-c: #7a3a10;
  --barra: rgba(70, 84, 130, 0.5);
  --alone: rgba(240, 170, 70, 0.5);
  --alone-2: rgba(240, 150, 50, 0.2);
  --num: var(--spento);

  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 6 / 7;
  padding: 3px;
  border: 0;
  border-radius: 46% 54% 3px 3px / 36% 32% 3px 3px;
  background: linear-gradient(160deg, var(--telaio-a), var(--telaio-b) 62%, var(--telaio-a));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 2px 5px rgba(0, 0, 0, 0.65);
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.finestra:focus-visible {
  outline: 2px solid var(--oro-chiaro);
  outline-offset: 3px;
}

.finestra__vetro {
  position: relative;
  display: grid;
  place-items: end center;
  width: 100%;
  height: 100%;
  padding-bottom: 17%;
  overflow: hidden;
  border-radius: 45% 55% 2px 2px / 35% 31% 2px 2px;
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(80, 100, 170, 0.12), transparent 70%),
    linear-gradient(180deg, var(--vetro-a), var(--vetro-b));
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.8);
}

/* traversa e montante sottili */
.finestra__vetro::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(var(--barra), var(--barra)) 50% 0 / 1.5px 56% no-repeat,
    linear-gradient(var(--barra), var(--barra)) 0 56% / 100% 1.5px no-repeat;
}

/* riflesso diagonale appena accennato */
.finestra__vetro::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    118deg,
    transparent 30%,
    rgba(170, 195, 255, 0.075) 38%,
    transparent 46%,
    rgba(170, 195, 255, 0.04) 58%,
    transparent 64%
  );
}

.finestra__num {
  position: relative;
  z-index: 1;
  font-family: var(--incisa);
  font-weight: 500;
  font-size: clamp(0.95rem, 4.6vw, 1.3rem);
  line-height: 1;
  color: var(--num);
  opacity: 0.85;
}

.is-futura {
  --num: #3d4768;
}

.is-oggi {
  --num: var(--crema);
  outline: 1px solid rgba(242, 230, 204, 0.85);
  outline-offset: 2px;
}
.is-oggi::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: 0 0 20px 4px rgba(242, 230, 204, 0.55);
  opacity: 0;
  animation: lumos 2.8s ease-in-out infinite;
}

.is-oggi .finestra__vetro {
  background:
    radial-gradient(90% 60% at 50% 100%, rgba(240, 196, 106, 0.28), transparent 70%),
    linear-gradient(180deg, #131c3a, #0a0f22);
}

@keyframes lumos {
  0%,
  100% { opacity: 0.15; }
  50% { opacity: 1; }
}

.is-aperta {
  --telaio-a: #7a5528;
  --telaio-b: #2c1a0a;
  --barra: rgba(44, 22, 6, 0.75);
  --num: #4a2606;
  box-shadow:
    0 0 10px 1px var(--alone),
    0 0 34px 8px var(--alone-2),
    inset 0 1px 0 rgba(255, 230, 170, 0.35);
}

.is-aperta .finestra__vetro {
  background:
    radial-gradient(75% 65% at 50% 62%, var(--luce-a) 0%, var(--luce-b) 48%, var(--luce-c) 100%);
  box-shadow: inset 0 0 14px rgba(70, 28, 4, 0.75);
  animation: fiamma 5s ease-in-out infinite alternate;
}

.is-aperta .finestra__vetro::after {
  background: linear-gradient(
    118deg,
    transparent 30%,
    rgba(255, 255, 255, 0.2) 38%,
    transparent 47%
  );
}

.is-aperta .finestra__num {
  opacity: 0.9;
  text-shadow: 0 1px 0 rgba(255, 232, 170, 0.55);
}

@keyframes fiamma {
  from {
    filter: brightness(0.96);
  }
  to {
    filter: brightness(1.06);
  }
}

/* il 24: oro e rosso, corona di luce, un poco più grande */
.finestra[data-n="24"] {
  --telaio-a: #f0c46a;
  --telaio-b: #8a5a16;
  --vetro-a: #2a0c14;
  --vetro-b: #12060a;
  --luce-a: #ffd9a0;
  --luce-b: #e0452e;
  --luce-c: #6e0f14;
  --alone: rgba(212, 35, 42, 0.6);
  --alone-2: rgba(240, 196, 106, 0.35);
  --num: var(--oro-chiaro);
  margin: -3px -4px;
  box-shadow:
    0 0 0 1px rgba(240, 196, 106, 0.5),
    0 0 18px 3px rgba(240, 196, 106, 0.3),
    0 0 44px 10px rgba(212, 35, 42, 0.2),
    0 2px 5px rgba(0, 0, 0, 0.65);
}

.finestra[data-n="24"].is-aperta {
  --num: #3d0a0c;
  box-shadow:
    0 0 0 1px rgba(240, 196, 106, 0.7),
    0 0 14px 2px var(--alone),
    0 0 50px 14px var(--alone-2);
}

.is-shake {
  animation: scuoti 0.52s ease-in-out;
}

@keyframes scuoti {
  15% { transform: translateX(-7px) rotate(-1.5deg); }
  32% { transform: translateX(7px) rotate(1.5deg); }
  50% { transform: translateX(-5px) rotate(-1deg); }
  68% { transform: translateX(4px) rotate(0.6deg); }
  84% { transform: translateX(-2px); }
}

/* ───────────── Orizzonte ───────────── */

#castello,
#riflesso {
  position: absolute;
  left: 0;
  right: 0;
  height: var(--castello-h);
  pointer-events: none;
}

#castello {
  bottom: var(--lago);
  z-index: 2;
}

#riflesso {
  bottom: calc(var(--castello-h) * -1 + var(--lago));
  z-index: 2;
  transform: scaleY(-1);
  opacity: 0.6;
  filter: blur(1.2px);
  -webkit-mask-image: linear-gradient(to top, rgba(0, 0, 0, 0.75), transparent 62%);
  mask-image: linear-gradient(to top, rgba(0, 0, 0, 0.75), transparent 62%);
}

#castello img,
#riflesso img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 51%;
}

/* ───────────── Gufo e boccino ───────────── */

#gufo {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3;
  width: clamp(70px, 24vw, 120px);
  opacity: 0;
  pointer-events: none;
}

#gufo img {
  will-change: transform;
  display: block;
  width: 100%;
  height: auto;
  opacity: 0.92;
}

#boccino {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 4;
  width: 26px;
  height: 26px;
  pointer-events: none;
  will-change: transform;
}
#boccino img {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 0 6px rgba(240, 196, 106, 0.75));
  animation: frulla 0.9s ease-in-out infinite alternate;
}
@keyframes frulla {
  from { transform: scale(1) rotate(-4deg); }
  to { transform: scale(1.06) rotate(4deg); }
}





@keyframes batte {
  from { transform: rotate(0deg) scaleY(1); }
  to { transform: rotate(-24deg) scaleY(0.55); }
}


@keyframes battedx {
  from { transform: rotate(0deg) scaleY(1); }
  to { transform: rotate(24deg) scaleY(0.55); }
}

/* ───────────── Avviso ───────────── */

#avviso {
  position: fixed;
  inset: 0;
  z-index: 13;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 300;
  font-size: clamp(2rem, 11vw, 3.2rem);
  line-height: 1.12;
  letter-spacing: -0.01em;
  color: #fff0d2;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.9), 0 0 42px rgba(212, 35, 42, 0.45);
  background: radial-gradient(70% 50% at 50% 50%, rgba(10, 4, 8, 0.86), rgba(6, 4, 8, 0.72));
  opacity: 0;
  pointer-events: none;
}
#avviso.urla {
  animation: urla 1.6s cubic-bezier(0.22, 1.12, 0.36, 1) forwards;
}
@keyframes urla {
  0% { opacity: 0; transform: scale(0.86) rotate(-1.6deg); }
  18% { opacity: 1; transform: scale(1.05) rotate(1deg); }
  34% { transform: scale(0.99) rotate(-0.4deg); }
  50% { transform: scale(1) rotate(0deg); }
  82% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.03); }
}
#scena.scossa {
  animation: scossa 0.62s cubic-bezier(0.33, 0, 0.2, 1) both;
}
@keyframes scossa {
  0% { transform: translate(0, 0); }
  14% { transform: translate(-5px, 2px); }
  30% { transform: translate(5px, -3px); }
  48% { transform: translate(-4px, 2px); }
  66% { transform: translate(3px, -1px); }
  82% { transform: translate(-1.5px, 0.5px); }
  100% { transform: translate(0, 0); }
}
#lampo.rosso {
  background: radial-gradient(circle at var(--x, 50%) var(--y, 50%), rgba(255, 90, 90, 0.75) 0%, rgba(212, 35, 42, 0.45) 30%, rgba(212, 35, 42, 0) 64%);
  animation: lampoRosso 620ms ease-out forwards;
}
@keyframes lampoRosso {
  0% { opacity: 0; clip-path: circle(6% at var(--x, 50%) var(--y, 50%)); }
  22% { opacity: 0.75; clip-path: circle(70% at var(--x, 50%) var(--y, 50%)); }
  100% { opacity: 0; clip-path: circle(150% at var(--x, 50%) var(--y, 50%)); }
}
@media (prefers-reduced-motion: reduce) {
  #avviso.urla,
  #scena.scossa,
  #lampo.rosso {
    animation: none;
  }
  #avviso.urla { opacity: 1; }
}

#avviso[hidden] {
  display: none;
}

/* ───────────── Modale ───────────── */

#modale {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 64px 20px 32px;
  overflow-y: auto;
  padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px));
  background:
    radial-gradient(70% 50% at 50% 38%, rgba(40, 30, 14, 0.35), transparent 75%),
    rgba(3, 4, 10, 0.995);
}

#modale[hidden] {
  display: none;
}

#modale-chiudi {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 11;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0 0 3px;
  border: 1px solid rgba(201, 160, 74, 0.55);
  border-radius: 50%;
  background: rgba(7, 10, 24, 0.7);
  color: var(--crema);
  font-family: var(--serif);
  font-size: 1.7rem;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
}

#modale-chiudi:focus-visible {
  outline: 2px solid var(--oro-chiaro);
  outline-offset: 3px;
}

/* lucine */

#modale-lucine {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  row-gap: 8px;
  width: min(94vw, 440px);
  margin-top: auto;
}

.lucina {
  --calore: #f0c46a;
  position: relative;
  flex: 0 0 22px;
  height: 52px;
  text-align: center;
}

.lucina:nth-child(3n + 1) { --calore: #ffd68a; }
.lucina:nth-child(3n + 2) { --calore: #f08a3c; }
.lucina:nth-child(7n + 4) { --calore: #e0452e; }

.lucina::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: #2b3250;
}

.filo {
  display: block;
  width: 1px;
  height: 11px;
  margin: 0 auto;
  background: #39415f;
}

.lucina:nth-child(even) .filo {
  height: 19px;
}

.bulbo {
  position: relative;
  display: block;
  width: 11px;
  height: 16px;
  margin: 0 auto;
  text-decoration: none;
  border-radius: 38% 38% 50% 50% / 28% 28% 72% 72%;
  background: radial-gradient(circle at 35% 35%, #2c3658, var(--bulbo-spento) 70%);
  box-shadow: inset 0 -2px 3px rgba(0, 0, 0, 0.4);
  transition: background 0.25s ease, box-shadow 0.25s ease;
}

.lettera {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: block;
  font-family: var(--incisa);
  font-style: normal;
  font-weight: 400;
  font-size: 0.78rem;
  line-height: 1;
  color: #2d3552;
  transition: color 0.3s ease, text-shadow 0.3s ease;
}

.is-on .bulbo {
  background: radial-gradient(circle at 38% 38%, #fff8e0, var(--calore) 55%, color-mix(in srgb, var(--calore) 55%, #1a0c02));
  box-shadow:
    0 0 8px 2px var(--calore),
    0 0 22px 6px color-mix(in srgb, var(--calore) 45%, transparent);
  animation: accendi 0.55s steps(1, end);
}

.is-on .lettera {
  color: var(--crema);
  text-shadow: 0 0 8px var(--calore);
}

@keyframes accendi {
  0% { opacity: 0.25; }
  25% { opacity: 1; }
  40% { opacity: 0.35; }
  60% { opacity: 1; }
  75% { opacity: 0.6; }
  100% { opacity: 1; }
}

/* cornice dorata */

#modale-cornice {
  position: relative;
  width: fit-content;
  max-width: min(84vw, 360px);
  padding: 12px;
  background:
    linear-gradient(135deg, #f7de9e 0%, #c9a04a 22%, #7b5a1f 48%, #d9b25e 72%, #8a6522 100%);
  box-shadow:
    0 0 0 1px #3a280b,
    inset 0 0 0 1px #fbe9b4,
    inset 0 0 0 4px #8d6a28,
    inset 0 0 0 5px #3a2a0e,
    inset 0 0 0 9px #b98f3e,
    0 22px 50px rgba(0, 0, 0, 0.75),
    0 0 70px rgba(201, 160, 74, 0.14);
}

#modale-foto {
  display: block;
  width: auto;
  max-width: min(78vw, 336px);
  max-height: 44svh;
  object-fit: contain;
  background: #0a0c16;
  outline: 1px solid #3a2a0e;
  border: 3px solid #1a1306;
  filter: sepia(0.32) contrast(1.05) saturate(0.88);
}

#modale-data {
  font-family: var(--incisa);
  font-weight: 400;
  font-size: 0.8rem;
  letter-spacing: 0.18em;
  padding-left: 0.18em;
  text-align: center;
  color: var(--oro);
}

#modale-frase {
  max-width: 32ch;
  margin-bottom: auto;
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 300;
  font-size: clamp(1.25rem, 5.6vw, 1.6rem);
  line-height: 1.45;
  color: var(--crema);
}

.parola {
  display: inline-block;
  white-space: pre;
}

/* entrata della griglia: CSS puro, non dipende dal CDN */
.finestra {
  animation: entraFinestra 540ms cubic-bezier(0.22, 1.2, 0.4, 1) both;
  animation-delay: calc(var(--i, 0) * 26ms);
}
@keyframes entraFinestra {
  from { opacity: 0; transform: translateY(22px) scale(0.86); }
  to { opacity: 1; transform: none; }
}

/* ───────────── Schermi alti / larghi ───────────── */

@media (min-width: 521px) {
  #scena {
    box-shadow: 0 0 0 1px rgba(94, 107, 142, 0.12), 0 0 80px rgba(0, 0, 0, 0.6);
  }
}

@media (max-height: 700px) {
  #modale-foto {
    max-height: 32svh;
  }
}

/* ───────────── Movimento ridotto ───────────── */

@media (prefers-reduced-motion: reduce) {
  #cielo s,
  #cielo i,
  .is-oggi,
  .is-aperta .finestra__vetro,
  .is-shake,
  .is-on .bulbo,
  #boccino img,
  .is-oggi::after {
    animation: none;
  }

  .bulbo,
  .lettera {
    transition: none;
  }
}

/* ── Apertura: la luce esce dalla finestra e invade lo schermo ───────────── */
#lampo {
  position: fixed;
  inset: 0;
  z-index: 9;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(circle at var(--x, 50%) var(--y, 50%), rgba(255, 244, 214, 0.9) 0%, rgba(230, 186, 110, 0.5) 24%, rgba(201, 160, 74, 0) 58%);
}
#lampo.acceso {
  animation: lampo 640ms cubic-bezier(0.25, 0.7, 0.3, 1) forwards;
}
@keyframes lampo {
  0% { opacity: 0; clip-path: circle(2% at var(--x, 50%) var(--y, 50%)); }
  34% { opacity: 0.4; clip-path: circle(80% at var(--x, 50%) var(--y, 50%)); }
  100% { opacity: 0; clip-path: circle(160% at var(--x, 50%) var(--y, 50%)); }
}

/* la cornice scende come un quadro appeso e si assesta */
#modale-cornice.entra {
  animation: appendi 900ms cubic-bezier(0.22, 1.35, 0.4, 1) both;
  transform-origin: 50% -28px;
}
@keyframes appendi {
  0% { opacity: 0; transform: translateY(-46px) rotate(5.5deg); }
  55% { opacity: 1; transform: translateY(0) rotate(-2.4deg); }
  78% { transform: rotate(1.2deg); }
  100% { opacity: 1; transform: rotate(-0.6deg); }
}

/* la foto arriva sovraesposta e mette a fuoco */
#modale-foto.entra {
  animation: fuoco 760ms cubic-bezier(0.25, 0.75, 0.3, 1) both;
}
@keyframes fuoco {
  0% { transform: scale(1.03); filter: sepia(0.32) contrast(1.05) saturate(0.7) blur(9px); }
  100% { transform: scale(1); filter: sepia(0.32) contrast(1.05) saturate(0.88) blur(0); }
}

/* ── 24 dicembre ─────────────────────────────────────────────────────────── */
#scintille {
  position: fixed;
  inset: 0;
  z-index: 11;
  pointer-events: none;
}
.scintilla {
  position: absolute;
  bottom: -12px;
  width: var(--s, 3px);
  height: var(--s, 3px);
  border-radius: 50%;
  background: #fff2cd;
  box-shadow: 0 0 10px 3px rgba(247, 206, 130, 0.8);
  animation: sale var(--d, 5s) var(--r, 0s) ease-out infinite;
}
@keyframes sale {
  0% { opacity: 0; transform: translate(0, 0) scale(0.6); }
  12% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx, 20px), -102svh) scale(1.1); }
}
.festa #modale-cornice {
  box-shadow:
    0 0 0 1px #3a280b,
    inset 0 0 0 1px #fbe9b4,
    inset 0 0 0 4px #8d6a28,
    inset 0 0 0 5px #3a2a0e,
    inset 0 0 0 9px #b98f3e,
    0 22px 50px rgba(0, 0, 0, 0.75),
    0 0 90px rgba(240, 196, 106, 0.3);
}
.festa #modale-data {
  color: var(--oro-chiaro);
}
@media (prefers-reduced-motion: reduce) {
  #lampo.acceso,
  #modale-cornice.entra,
  #modale-foto.entra,
  .scintilla {
    animation: none;
  }
  #modale-foto.entra { filter: sepia(0.32) contrast(1.05) saturate(0.88); }
}

/* ── 24 dicembre: alone, lucine che sfarfallano, boccino, stelle filanti ─── */
.festa #modale-cornice::before {
  content: "";
  position: absolute;
  inset: -26px;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(240, 196, 106, 0.3), rgba(240, 196, 106, 0) 68%);
  animation: respiro 3.6s ease-in-out infinite;
}
@keyframes respiro {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}
.festa .is-on .bulbo {
  animation: sfarfalla 2.8s ease-in-out infinite;
}
@keyframes sfarfalla {
  0%, 100% { opacity: 1; }
  42% { opacity: 0.72; }
  47% { opacity: 1; }
  58% { opacity: 0.85; }
}
#boccino-festa {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 12;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  pointer-events: none;
  animation: orbita 9s linear infinite;
}
#boccino-festa img {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 9px rgba(240, 196, 106, 0.9));
  animation: frulla 0.8s ease-in-out infinite alternate;
}
@keyframes orbita {
  0% { transform: translate(120px, -150px) scale(0.85); }
  25% { transform: translate(-130px, -40px) scale(1.1); }
  50% { transform: translate(100px, 160px) scale(0.9); }
  75% { transform: translate(-110px, 90px) scale(1.05); }
  100% { transform: translate(120px, -150px) scale(0.85); }
}
.filante {
  position: fixed;
  z-index: 11;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: #fff6dd;
  box-shadow: 0 0 10px 3px rgba(255, 240, 200, 0.9);
  opacity: 0;
  animation: filante 7s var(--r, 0s) ease-out infinite;
}
@keyframes filante {
  0% { opacity: 0; transform: translate(0, 0); }
  4% { opacity: 1; }
  16% { opacity: 0; transform: translate(260px, 190px); }
  100% { opacity: 0; transform: translate(260px, 190px); }
}
@media (prefers-reduced-motion: reduce) {
  .festa #modale-cornice::before,
  .festa .is-on .bulbo,
  #boccino-festa,
  #boccino-festa img,
  .filante {
    animation: none;
  }
  .filante { opacity: 0; }
}

/* Con la modale aperta la scena è coperta: ferma le sue animazioni */
body.modale-aperta #cielo s,
body.modale-aperta #cielo i,
body.modale-aperta #boccino,
body.modale-aperta #boccino img,
body.modale-aperta #gufo,
body.modale-aperta .is-oggi::after,
body.modale-aperta .is-aperta .finestra__vetro {
  animation-play-state: paused;
}
#boccino-festa img {
  filter: none;
}
#boccino-festa::before {
  content: "";
  position: absolute;
  inset: -40%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(240, 196, 106, 0.45), rgba(240, 196, 106, 0) 68%);
}

/* entrata e uscita della modale: CSS, indipendenti dal CDN */
#modale {
  opacity: 0;
  transition: opacity 260ms ease;
}
#modale.visibile {
  opacity: 1;
}
@media (prefers-reduced-motion: reduce) {
  #modale { transition: none; }
}

/* tasto dei suoni */
#audio {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top, 0px));
  left: 12px;
  z-index: 8;
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 15px;
  line-height: 1;
  color: var(--oro);
  background: rgba(10, 14, 28, 0.55);
  border: 1px solid rgba(201, 160, 74, 0.3);
  border-radius: 50%;
  cursor: pointer;
}
#audio.is-muto {
  color: #5e6b8e;
  border-color: rgba(94, 107, 142, 0.35);
}
#audio.is-muto::after {
  content: "";
  position: absolute;
  left: 7px;
  right: 7px;
  top: 50%;
  height: 1px;
  background: currentColor;
  transform: rotate(-35deg);
}
