/* APEXLANE — schermata d'ingresso con audio (anteprima).
   Schermata blu con la sola X del logo: al clic la X vola al suo posto nella scritta APEXLANE,
   la scritta si apre da lì e partono i suoni. Senza JS la schermata non compare. */

.gate { display: none; }
.gate-mode .gate { display: block; position: fixed; inset: 0; z-index: 200; }
.gate[hidden] { display: none; }

.gate__bg {
  position: absolute; inset: 0;
  background: radial-gradient(60% 55% at 50% 50%, #303750 0%, #242937 55%, #1A1E29 100%);
}

/* La X è il pulsante: nient'altro sullo schermo */
.gate__x {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: clamp(170px, 28vw, 360px); padding: 0; border: 0; background: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.gate__x img { display: block; width: 100%; height: auto; transform-origin: 50% 50%; will-change: transform; }
.gate__x:focus { outline: none; }
.gate__x:focus-visible { outline: 2px solid #fff; outline-offset: 18px; border-radius: 4px; }

@media (prefers-reduced-motion: no-preference) {
  .js .gate__x img { animation: x-in 1100ms cubic-bezier(0.16, 1, 0.3, 1) 120ms both, x-beat 1.4s ease-in-out 1300ms infinite; }
  .js .gate__hint { animation: hint-in 700ms ease-out 1300ms both, hint-breathe 1.4s ease-in-out 2000ms infinite; }
}
@keyframes x-in { from { opacity: 0; transform: scale(1.5); filter: blur(14px); } }
/* Battito: due colpi ravvicinati (lub-dub), poi pausa */
@keyframes x-beat {
  0%, 55%, 100% { transform: scale(1); filter: drop-shadow(0 0 10px rgba(228, 104, 48, 0.3)); }
  12% { transform: scale(1.1); filter: drop-shadow(0 0 36px rgba(228, 104, 48, 0.9)); }
  24% { transform: scale(0.98); filter: drop-shadow(0 0 16px rgba(228, 104, 48, 0.45)); }
  36% { transform: scale(1.06); filter: drop-shadow(0 0 28px rgba(228, 104, 48, 0.75)); }
}
@keyframes hint-in { from { opacity: 0; transform: translate(-50%, 8px); } }
@keyframes hint-breathe { 0%, 55%, 100% { color: rgba(255, 255, 255, 0.7); } 12% { color: #fff; } }

/* Invito al clic sotto la X: fa parte del pulsante, sparisce al clic */
.gate__hint {
  position: absolute; left: 50%; top: calc(100% + clamp(28px, 5vh, 48px)); transform: translateX(-50%);
  white-space: nowrap; font: 600 clamp(0.8rem, 1vw, 0.95rem)/1 var(--f-label); letter-spacing: 0.36em; padding-left: 0.36em;
  color: rgba(255, 255, 255, 0.7); pointer-events: none;
}
.gate.is-open .gate__hint { opacity: 0 !important; transition: opacity 120ms ease; animation: none; }

/* Finché si è sulla schermata l'entrata del logo resta ferma al primo fotogramma */
.gate-wait, .gate-wait body { overflow: hidden; }
.gate-wait .hero *, .gate-wait .hero *::before, .gate-wait .hero *::after, .gate-wait .lang {
  animation-play-state: paused !important;
}

/* Entrata del logo quando si arriva dalla schermata: tutto parte dall'impatto della X.
   La scritta si apre dalla posizione della X (33,7%–51,6% della larghezza del logo). */
.gate-mode .hero__flash, .gate-mode .hero__shock { left: var(--impact-x, 50%); top: var(--impact-y, 50%); }
@media (prefers-reduced-motion: no-preference) {
  .js.gate-mode .page-landing .hero__logo {
    animation:
      logo-burst 900ms cubic-bezier(0.16, 1, 0.3, 1) both,
      logo-glow 3.6s ease-in-out 1.8s infinite alternate;
  }
  .js.gate-mode .page-landing .hero__brand { animation: impact-shake 420ms linear 20ms both; }
  .js.gate-mode .hero__slash { animation: slash 520ms cubic-bezier(0.7, 0, 0.3, 1) -60ms both; }
  .js.gate-mode .hero__flash { animation: flash 950ms ease-out both; }
  .js.gate-mode .hero__shock { animation: shock 1100ms cubic-bezier(0.16, 1, 0.3, 1) both; }
  .js.gate-mode .page-landing .hero__brand::after { animation: lane-in 900ms var(--ease-out) 180ms both; }
  .js.gate-mode .page-landing .hero .logo-shine::after { animation: shine 1100ms var(--ease-out) 520ms both; }
  .js.gate-mode .page-landing .hero__cue { animation: fade-in 800ms ease-out 1300ms both; }
  .js.gate-mode .lang { animation: fade-in 800ms ease-out 900ms both; }
}
@keyframes logo-burst {
  0%   { clip-path: inset(-50% 48.4% -50% 33.7%); filter: brightness(3) blur(3px); }
  35%  { filter: brightness(1.8) blur(0); }
  100% { clip-path: inset(-50% -12% -50% -12%); filter: none; }   /* margine per il bagliore del logo */
}

/* Interruttore audio dopo l'ingresso (per chi vuole spegnere i suoni) */
.sound-toggle {
  position: fixed; right: var(--gutter); bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 60;
  display: none; align-items: center; justify-content: center; gap: 3px;
  width: 44px; height: 44px; border: 1px solid rgba(255, 255, 255, 0.22); border-radius: 50%;
  background: rgba(16, 19, 25, 0.72); backdrop-filter: blur(6px); cursor: pointer;
}
.js .sound-toggle { display: inline-flex; }
.gate-wait .sound-toggle { visibility: hidden; }
.sound-toggle span { width: 3px; height: 6px; background: rgba(255, 255, 255, 0.7); border-radius: 1px; }
.sound-toggle[aria-pressed="true"] { border-color: var(--orange); }
.sound-toggle[aria-pressed="true"] span { background: var(--orange); }
@media (prefers-reduced-motion: no-preference) {
  .sound-toggle[aria-pressed="true"] span { animation: eq 900ms ease-in-out infinite; }
  .sound-toggle[aria-pressed="true"] span:nth-child(2) { animation-delay: -300ms; }
  .sound-toggle[aria-pressed="true"] span:nth-child(3) { animation-delay: -600ms; }
  .sound-toggle[aria-pressed="true"] span:nth-child(4) { animation-delay: -150ms; }
}
@keyframes eq { 0%, 100% { height: 5px; } 50% { height: 16px; } }

main:focus { outline: none; }

/* Prima dell'impatto la scritta resta nascosta: la X che vola è l'unica cosa in scena */
.gate-wait.gate-mode .hero__logo { opacity: 0; }
