/* =========================================================
   NATALE NAPOLETANO – HOME
   Palco virtuale 1080×1920 scalato in JS (vedi js/stage.js)
   ========================================================= */

:root {
  --gold-1: #f6e3b0;
  --gold-2: #e5c17b;
  --gold-3: #b8893f;
  --night: #0e223d; /* colore del bordo superiore di back.jpg */
  --app-w: 100vw;
  --app-h: 100vh;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #050c1d;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

/* Sfondo laterale su desktop: il fondo sfocato e scurito */
body::before {
  content: "";
  position: fixed;
  inset: -40px;
  background: url("../assets/img/back.webp") center bottom / cover no-repeat;
  filter: blur(28px) brightness(0.45) saturate(1.1);
}

/* ---------- Colonna app ---------- */
#app {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--app-w);
  height: var(--app-h);
  transform: translate(-50%, -50%);
  overflow: hidden;
  background: var(--night);
  touch-action: none;
  cursor: default;
}

@media (min-aspect-ratio: 13/16) {
  #app { box-shadow: 0 0 80px rgba(0, 0, 0, 0.6); border-radius: 18px; }
}

/* ---------- Palco e livelli che condividono il sistema di coordinate ---------- */
#stage,
.stage-layer {
  position: absolute;
  left: 0;
  top: 0;
  width: 1080px;
  height: 1920px;
  transform-origin: 0 0;
  pointer-events: none;
}

#layer-back,
#layer-logo {
  position: absolute;
  inset: 0;
  width: 1080px;
  height: 1920px;
  display: block;
}

#stage-logo { opacity: 0; transition: opacity 1.2s ease; }
#stage-logo.is-visible { opacity: 1; }
#layer-logo { will-change: transform; }

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: block;
}

/* ---------- Icone ---------- */
.icon {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: auto;
  opacity: 0;
  will-change: transform, opacity;
  cursor: pointer;
}

.icon-inner {
  position: absolute;
  inset: 0;
  will-change: transform;
}

.icon-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 10px 14px rgba(2, 6, 20, 0.55));
  -webkit-user-drag: none;
  pointer-events: none;
}

/* Bagliore caldo (lanterna, cometa) animato in opacità */
.icon-glow {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 100%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 205, 120, 0.5), rgba(255, 180, 80, 0.14) 50%, rgba(255, 170, 60, 0) 100%);
  mix-blend-mode: screen;
  opacity: 0;
  pointer-events: none;
}

/* ---------- Titolo brano ---------- */
#titolo-brano {
  position: absolute;
  left: 60px;
  right: 60px;
  width: 960px;
  text-align: center;
  font-family: 'Times New Roman', Times, serif;
  font-weight: 400;
  font-size: 92px;
  line-height: 1.08;
  letter-spacing: 0.01em;
  color: var(--gold-2);
  filter: drop-shadow(0 0 18px rgba(229, 193, 123, 0.45)) drop-shadow(0 4px 6px rgba(0, 0, 0, 0.6));
  pointer-events: none;
}

#titolo-brano .riga { display: block; }
#titolo-brano .ospite {
  display: block;
  margin-top: 18px;
  font-size: 50px;
  font-style: italic;
  letter-spacing: 0.04em;
}

#titolo-brano .ch {
  display: inline-block;
  white-space: pre;
  background: linear-gradient(180deg, #fff4d2 0%, #f1d595 35%, #d9ac5c 70%, #b8893f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  opacity: 0;
  transform: translateY(26px);
  filter: blur(6px);
  transition:
    opacity 0.7s ease,
    transform 0.9s cubic-bezier(0.2, 0.8, 0.2, 1),
    filter 0.8s ease;
}

#titolo-brano.is-in .ch { opacity: 1; transform: none; filter: blur(0); }
#titolo-brano.is-out .ch {
  opacity: 0;
  transform: translateY(-14px);
  filter: blur(4px);
  transition-duration: 0.35s;
  transition-delay: 0s !important;
}

/* Onda di luce al tap nello stato Anteprima */
#titolo-brano.is-wave .ch { animation: onda 0.9s cubic-bezier(0.3, 0.7, 0.3, 1) both; }
@keyframes onda {
  0%   { transform: none; }
  35%  { transform: translateY(-22px) scale(1.12); filter: brightness(1.5); }
  100% { transform: none; filter: brightness(1); }
}

/* ---------- Suggerimento ---------- */
#hint {
  position: absolute;
  left: 50%;
  bottom: calc(var(--u, 4px) * 17 + env(safe-area-inset-bottom));
  transform: translate(-50%, 8px);
  max-width: 92%;
  padding: 9px 22px;
  border-radius: 999px;
  text-align: center;
  line-height: 1.25;
  background: rgba(6, 14, 34, 0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(229, 193, 123, 0.25);
  color: rgba(246, 227, 176, 0.92);
  font-family: 'Times New Roman', Times, serif;
  font-style: italic;
  font-size: clamp(14px, calc(var(--u, 4px) * 4.4), 21px);
  letter-spacing: 0.03em;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease, transform 0.8s ease;
}
#hint.is-visible { opacity: 1; transform: translate(-50%, 0); }
#hint small {
  display: block;
  margin-top: 2px;
  font-size: 0.72em;
  opacity: 0.8;
}

/* ---------- Overlay Avvio gioco (segnaposto) ---------- */
/* ---------- Minigioco ---------- */
#gioco {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #07122a;
  opacity: 0;
  transition: opacity 0.5s ease;
  z-index: 9;               /* sotto il pulsante audio (10) e il pulsante ✕ */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
#gioco[hidden] { display: none; }
#gioco.is-visible { opacity: 1; }
.gioco-root { position: absolute; inset: 0; overflow: hidden; }

#gioco-esci {
  /* stesso stile del pulsante audio, ma a sinistra */
  position: absolute;
  top: calc(var(--u, 4px) * 3 + env(safe-area-inset-top));
  left: calc(var(--u, 4px) * 3.5);
  width: clamp(32px, calc(var(--u, 4px) * 9), 44px);
  height: clamp(32px, calc(var(--u, 4px) * 9), 44px);
  padding: 10px;
  border-radius: 50%;
  border: 1px solid rgba(229, 193, 123, 0.35);
  background: rgba(6, 14, 34, 0.35);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  cursor: pointer;
  opacity: 0.85;
  touch-action: manipulation;
  z-index: 11;
}
#gioco-esci[hidden] { display: none; }
#gioco-esci svg { width: 100%; height: 100%; display: block; }
#gioco-esci path { fill: none; stroke: var(--gold-2); stroke-width: 1.8; stroke-linecap: round; }

#overlay-gioco {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 45%, rgba(16, 32, 70, 0.94), rgba(3, 8, 22, 0.98));
  opacity: 0;
  transition: opacity 0.6s ease;
  z-index: 20;
}
#overlay-gioco[hidden] { display: none; }
#overlay-gioco.is-visible { opacity: 1; }

.overlay-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
  padding: 0 8%;
  font-family: 'Times New Roman', Times, serif;
  color: var(--gold-2);
  transform: scale(0.94);
  transition: transform 0.8s cubic-bezier(0.2, 0.9, 0.2, 1);
}
#overlay-gioco.is-visible .overlay-box { transform: none; }

.overlay-kicker {
  font-size: clamp(11px, calc(var(--u, 4px) * 3.2), 15px);
  letter-spacing: 0.28em;
  padding-left: 0.28em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85);
  margin-bottom: 1.1em;
}
.overlay-titolo {
  font-weight: 400;
  font-size: clamp(38px, calc(var(--u, 4px) * 14), 72px);
  line-height: 1.06;
  background: linear-gradient(180deg, #fff4d2 0%, #f1d595 35%, #d9ac5c 70%, #b8893f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 18px rgba(229, 193, 123, 0.55)) drop-shadow(0 3px 4px rgba(0, 0, 0, 0.6));
  margin-bottom: 1.1em;
  animation: overlay-respiro 3.2s ease-in-out infinite;
}
.overlay-ospite {
  display: block;
  margin-top: 0.3em;
  font-size: 0.5em;
  font-style: italic;
  letter-spacing: 0.04em;
}
@keyframes overlay-respiro {
  0%, 100% { filter: drop-shadow(0 0 14px rgba(229, 193, 123, 0.45)) drop-shadow(0 3px 4px rgba(0, 0, 0, 0.6)); }
  50%      { filter: drop-shadow(0 0 26px rgba(246, 227, 176, 0.75)) drop-shadow(0 3px 4px rgba(0, 0, 0, 0.6)); }
}

.overlay-parti {
  font: 700 clamp(16px, calc(var(--u, 4px) * 5), 24px) 'Times New Roman', Times, serif;
  letter-spacing: 0.22em;
  padding: 0.85em 2.2em 0.85em 2.42em;
  text-transform: uppercase;
  color: #1a1206;
  background: linear-gradient(180deg, #fff1c9 0%, #e9c983 50%, #c39545 100%);
  border: 0;
  border-radius: 999px;
  box-shadow: 0 0 0 1px rgba(255, 241, 201, 0.6) inset, 0 6px 22px rgba(229, 193, 123, 0.45), 0 2px 6px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.15s ease, filter 0.2s ease;
  animation: overlay-pulsa 2.2s ease-in-out infinite;
}
.overlay-parti:active { transform: scale(0.96); }
.overlay-parti:disabled { filter: brightness(0.75); animation: none; }
@keyframes overlay-pulsa {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.04); }
}

.overlay-nota {
  min-height: 1.4em;
  margin: 1em 0 0;
  font-style: italic;
  font-size: clamp(13px, calc(var(--u, 4px) * 3.8), 18px);
  color: rgba(255, 255, 255, 0.85);
}

.overlay-btn {
  margin-top: clamp(28px, calc(var(--u, 4px) * 12), 64px);
  font: italic clamp(13px, calc(var(--u, 4px) * 3.6), 17px) 'Times New Roman', Times, serif;
  color: var(--gold-1);
  background: transparent;
  border: 1px solid rgba(229, 193, 123, 0.5);
  border-radius: 999px;
  padding: 0.55em 1.5em;
  cursor: pointer;
  touch-action: manipulation;
  opacity: 0.85;
}

.overlay-firma {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--u, 4px) * 4 + env(safe-area-inset-bottom));
  margin: 0;
  text-align: center;
  white-space: nowrap;
  font: clamp(8px, calc(var(--u, 4px) * 2.35), 12px) 'Times New Roman', Times, serif;
  letter-spacing: 0.08em;
  color: #fff;
  opacity: 0.85;
}

/* ---------- Sottotitolo sotto le icone (palco) ---------- */
#sottotitolo-home {
  position: absolute;
  left: 0;
  width: 1080px;
  top: 1528px;
  text-align: center;
  font-family: 'Times New Roman', Times, serif;
  font-style: italic;
  font-weight: 700;
  font-size: 54px;
  letter-spacing: 0.02em;
  color: #fff;
  text-shadow: 0 0 22px rgba(229, 193, 123, 0.75), 0 0 6px rgba(2, 6, 20, 0.9), 0 3px 6px rgba(2, 6, 20, 0.95);
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.9s ease, transform 0.9s ease;
}
#app[data-stato="home"] #sottotitolo-home { opacity: 1; transform: none; animation: sottotitolo-luce 3.4s ease-in-out 1s infinite; }
@keyframes sottotitolo-luce {
  0%, 100% { text-shadow: 0 0 22px rgba(229, 193, 123, 0.75), 0 0 6px rgba(2, 6, 20, 0.9), 0 3px 6px rgba(2, 6, 20, 0.95); }
  50%      { text-shadow: 0 0 34px rgba(246, 227, 176, 0.95), 0 0 6px rgba(2, 6, 20, 0.9), 0 3px 6px rgba(2, 6, 20, 0.95); }
}

/* ---------- Anteprima: suggerimento sotto il titolo (palco) ---------- */
#hint-anteprima {
  position: absolute;
  left: 0;
  width: 1080px;
  top: 1400px;
  text-align: center;
  font-family: 'Times New Roman', Times, serif;
  font-style: italic;
  font-size: 50px;
  line-height: 1.2;
  letter-spacing: 0.02em;
  color: #fff;
  text-shadow: 0 0 18px rgba(229, 193, 123, 0.6), 0 0 6px rgba(2, 6, 20, 0.95), 0 3px 6px rgba(2, 6, 20, 0.95);
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}
#hint-anteprima.is-visible { opacity: 1; transform: none; }
#hint-anteprima small {
  display: block;
  margin-top: 10px;
  font-size: 36px;
  color: var(--gold-1);
  opacity: 0.9;
}

/* ---------- Pop-up informazioni ---------- */
#popup-info {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 0 7%;
  background: rgba(3, 8, 22, 0.72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.4s ease;
  z-index: 25;
}
#popup-info[hidden] { display: none; }
#popup-info.is-visible { opacity: 1; }

.popup-box {
  position: relative;
  width: 100%;
  max-width: 420px;
  padding: 3.4em 1.6em 2.6em;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(20, 40, 84, 0.96), rgba(8, 18, 42, 0.98));
  border: 1px solid rgba(229, 193, 123, 0.5);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(229, 193, 123, 0.15);
  text-align: center;
  font-family: 'Times New Roman', Times, serif;
  transform: translateY(16px) scale(0.96);
  transition: transform 0.45s cubic-bezier(0.2, 0.9, 0.2, 1);
}
#popup-info.is-visible .popup-box { transform: none; }

.popup-testo {
  font-size: clamp(16px, calc(var(--u, 4px) * 4.6), 22px);
  letter-spacing: 0.12em;
  line-height: 1.4;
  color: var(--gold-1);
}

.popup-chiudi {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 40px;
  height: 40px;
  padding: 10px;
  border-radius: 50%;
  border: 1px solid rgba(229, 193, 123, 0.4);
  background: rgba(6, 14, 34, 0.4);
  cursor: pointer;
  touch-action: manipulation;
}
.popup-chiudi svg { width: 100%; height: 100%; display: block; }
.popup-chiudi path { fill: none; stroke: var(--gold-2); stroke-width: 1.8; stroke-linecap: round; }

/* ---------- Schermata "Tocca per entrare" ---------- */
#splash {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: calc(var(--app-h) * 0.42);
  border: 0;
  background: radial-gradient(ellipse at 50% 55%, rgba(6, 14, 34, 0) 0%, rgba(6, 14, 34, 0.35) 100%);
  cursor: pointer;
  touch-action: manipulation;
  opacity: 0;
  transition: opacity 0.7s ease;
  z-index: 15;
}
#splash[hidden] { display: none; }
#splash.is-visible { opacity: 1; }

.splash-testo {
  font: italic clamp(18px, calc(var(--u, 4px) * 6), 30px) 'Times New Roman', Times, serif;
  letter-spacing: 0.06em;
  color: var(--gold-1);
  padding: 0.6em 1.6em;
  border: 1px solid rgba(229, 193, 123, 0.55);
  border-radius: 999px;
  background: rgba(6, 14, 34, 0.45);
  text-shadow: 0 0 14px rgba(229, 193, 123, 0.6);
  box-shadow: 0 0 24px rgba(229, 193, 123, 0.2);
  animation: splash-pulsa 2.4s ease-in-out infinite;
}
@keyframes splash-pulsa {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50%      { transform: scale(1.05); opacity: 1; }
}

/* ---------- Loader ---------- */
#loader {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  gap: 10px;
  transition: opacity 0.6s ease;
  z-index: 30;
}
#loader span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold-2);
  box-shadow: 0 0 10px var(--gold-2);
  animation: puntino 1.2s ease-in-out infinite;
}
#loader span:nth-child(2) { animation-delay: 0.2s; }
#loader span:nth-child(3) { animation-delay: 0.4s; }
#loader.is-hidden { opacity: 0; pointer-events: none; }
@keyframes puntino {
  0%, 100% { opacity: 0.25; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

/* ---------- Data di uscita ⇄ "Scopri di più" (in basso sul Golfo) ---------- */
#data-uscita {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--u, 4px) * 3 + env(safe-area-inset-bottom));
  height: clamp(40px, calc(var(--u, 4px) * 12), 60px);
  font-family: 'Times New Roman', Times, serif;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.4s ease 0.6s;
  z-index: 5;
}
#data-uscita.is-visible { opacity: 1; }

.data-testo,
.data-scopri {
  position: absolute;
  left: 50%;
  top: 50%;
  white-space: nowrap;
  text-transform: uppercase;
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.data-testo {
  transform: translate(-50%, -50%);
  font-size: clamp(14px, calc(var(--u, 4px) * 4.4), 23px);
  font-weight: 700;
  letter-spacing: 0.2em;
  padding: 0.45em 1.1em 0.45em 1.3em; /* compensa lo spazio dell'ultima lettera */
  border-radius: 999px;
  background: rgba(6, 14, 34, 0.6);
  border: 1px solid rgba(229, 193, 123, 0.55);
  box-shadow: 0 0 18px rgba(229, 193, 123, 0.3);
  color: #fff;
  text-shadow: 0 1px 3px rgba(2, 6, 20, 0.95), 0 0 14px rgba(229, 193, 123, 0.7);
}

.data-scopri {
  transform: translate(-50%, -50%) scale(0.92);
  opacity: 0;
  font: 700 clamp(14px, calc(var(--u, 4px) * 4.4), 23px) 'Times New Roman', Times, serif;
  letter-spacing: 0.22em;
  padding: 0.6em 1.6em 0.6em 1.82em;
  color: #1a1206;
  background: linear-gradient(180deg, #fff1c9 0%, #e9c983 50%, #c39545 100%);
  border: 0;
  border-radius: 999px;
  box-shadow: 0 0 26px rgba(246, 227, 176, 0.7), 0 2px 5px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  touch-action: manipulation;
}

#data-uscita.mostra-scopri .data-testo { opacity: 0; transform: translate(-50%, -50%) translateY(-8px); }
#data-uscita.mostra-scopri .data-scopri { opacity: 1; transform: translate(-50%, -50%); }
#data-uscita.is-visible.mostra-scopri .data-scopri { pointer-events: auto; }

/* ---------- Pulsante audio ---------- */
#audio-toggle {
  position: absolute;
  top: calc(var(--u, 4px) * 3 + env(safe-area-inset-top));
  right: calc(var(--u, 4px) * 3.5);
  width: clamp(32px, calc(var(--u, 4px) * 9), 44px);
  height: clamp(32px, calc(var(--u, 4px) * 9), 44px);
  padding: 8px;
  border-radius: 50%;
  border: 1px solid rgba(229, 193, 123, 0.35);
  background: rgba(6, 14, 34, 0.35);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  cursor: pointer;
  opacity: 0;
  transition: opacity 1s ease, border-color 0.3s ease;
  touch-action: manipulation;
  z-index: 10;
}
#audio-toggle.is-visible { opacity: 0.85; }
#audio-toggle svg { width: 100%; height: 100%; display: block; overflow: visible; }
#audio-toggle path { fill: none; stroke: var(--gold-2); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#audio-toggle .spk { fill: var(--gold-2); }
#audio-toggle .off { display: none; }
#audio-toggle[aria-pressed="true"] .on { display: none; }
#audio-toggle[aria-pressed="true"] .off { display: inline; }
#audio-toggle[aria-pressed="true"] { border-color: rgba(229, 193, 123, 0.2); }

/* "Scopri di più": bagliore che pulsa per farsi notare */
#data-uscita.mostra-scopri .data-scopri { animation: scopri-luce 1.6s ease-in-out infinite; }
@keyframes scopri-luce {
  0%, 100% { box-shadow: 0 0 22px rgba(246, 227, 176, 0.6), 0 2px 5px rgba(0, 0, 0, 0.5); }
  50%      { box-shadow: 0 0 40px rgba(255, 241, 201, 0.95), 0 2px 5px rgba(0, 0, 0, 0.5); }
}
