/* ═══════════════════════════════════════════════════════════
   TUTORIAL · Spotlight che illumina davvero
   Versione 4 · Fix definitivo (buco nel nero)
   ═══════════════════════════════════════════════════════════ */

/* ===== OVERLAY ===== */
#tutorialOverlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  pointer-events: none;
}

#tutorialOverlay.active {
  display: block;
}

body.tutorial-active {
  overflow: hidden;
}

/* ⚠️ RIMOSSO ::before che copriva tutto di nero */

/* ===== SPOTLIGHT (il "buco" che illumina) ===== */
#tutorialSpotlight {
  position: fixed;
  border-radius: 16px;
  /* * Il box-shadow crea il nero INTORNO allo spotlight.
     * Il centro resta trasparente → si vede il gioco sotto! */
  box-shadow:
    0 0 0 9999px rgba(0, 0, 0, 0.85),
    0 0 30px 8px rgba(251, 191, 36, 0.7);
  background: transparent;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 2; /* * Sotto al tooltip */
  pointer-events: none;
  border: 3px solid #fbbf24;
  animation: spotlightPulse 1.5s ease-in-out infinite;
}

/* * Pulse animato */
@keyframes spotlightPulse {
  0%, 100% {
    box-shadow:
      0 0 0 9999px rgba(0, 0, 0, 0.85),
      0 0 30px 8px rgba(251, 191, 36, 0.7);
  }
  50% {
    box-shadow:
      0 0 0 9999px rgba(0, 0, 0, 0.85),
      0 0 45px 12px rgba(251, 191, 36, 1);
  }
}

/* * Quando è cliccabile (step "toccami"): lo spotlight SALE sopra il tooltip
      così il click arriva a lui e non al tooltip */
body.tutorial-waiting-click #tutorialSpotlight {
  pointer-events: auto !important;
  cursor: pointer;
  z-index: 6;
}

/* ===== TOOLTIP ===== */
#tutorialTooltip {
  position: fixed;
  max-width: 340px;
  width: calc(100% - 40px);
  background: linear-gradient(160deg, #1e1b4b 0%, #0f0f1e 100%);
  border: 2px solid rgba(251, 191, 36, 0.4);
  border-radius: 20px;
  padding: 22px 20px 18px;
  z-index: 5;
  pointer-events: auto;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.6),
    0 0 40px rgba(251, 191, 36, 0.2);
  animation: tutorialPop 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes tutorialPop {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

#tutorialTooltip.tooltip-center {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: tutorialPopCenter 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes tutorialPopCenter {
  from { opacity: 0; transform: translate(-50%, -40%) scale(0.9); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* * In modalità wait-click: tooltip in basso, semitrasparente, non blocca i click */
body.tutorial-waiting-click #tutorialTooltip {
  top: auto !important;
  bottom: 12px !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  max-width: calc(100% - 24px);
  padding: 14px 16px 12px;
  background: rgba(15, 15, 30, 0.95);
  pointer-events: none;
}

body.tutorial-waiting-click #tutorialTooltip button {
  pointer-events: auto;
}

/* ===== FRECCE TOOLTIP ===== */
#tutorialTooltip.tooltip-top::after {
  content: '';
  position: absolute;
  bottom: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-top: 12px solid rgba(251, 191, 36, 0.4);
}

#tutorialTooltip.tooltip-bottom::before {
  content: '';
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-bottom: 12px solid rgba(251, 191, 36, 0.4);
}

/* ===== HEADER TOOLTIP ===== */
.tutorial-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 10px;
}

.tutorial-device-icon {
  font-size: 32px;
  line-height: 1;
  display: none;
  flex-shrink: 0;
}

.tutorial-progress {
  font-size: 11px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 10px;
  border-radius: 12px;
  flex-shrink: 0;
  margin-left: auto;
}

/* ===== TITOLO E TESTO ===== */
.tutorial-title {
  font-size: 19px;
  font-weight: 800;
  margin-bottom: 10px;
  color: #fff;
  line-height: 1.3;
}

.tutorial-text {
  font-size: 14px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.85);
  margin-bottom: 18px;
}

.tutorial-text b {
  color: #fbbf24;
  font-weight: 700;
}

/* ===== AZIONI ===== */
.tutorial-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tutorial-btn-primary {
  background: linear-gradient(90deg, #fbbf24, #f59e0b);
  border: none;
  color: #1a1a2e;
  padding: 13px 20px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s;
  box-shadow: 0 4px 15px rgba(251, 191, 36, 0.3);
}

.tutorial-btn-primary:active {
  transform: scale(0.96);
}

.tutorial-btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.75);
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.tutorial-btn-secondary:active {
  transform: scale(0.96);
  background: rgba(255, 255, 255, 0.12);
}

.tutorial-btn-skip {
  border-style: dashed;
  opacity: 0.7;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 380px) {
  #tutorialTooltip {
    padding: 18px 16px 14px;
    max-width: calc(100% - 24px);
    width: calc(100% - 24px);
  }

  .tutorial-title { font-size: 17px; }
  .tutorial-text { font-size: 13px; }

  .tutorial-btn-primary {
    font-size: 13px;
    padding: 12px 16px;
  }
}

/* ═══════════════════════════════════════════════
   FIX · Il tooltip non deve essere oscurato
   ═══════════════════════════════════════════════ */

/* * Il tooltip deve essere SOPRA a tutto il nero,
      quindi gli diamo z-index molto alto */
#tutorialTooltip {
  z-index: 100 !important;
}

/* * Anche i bottoni dentro devono essere cliccabili */
#tutorialTooltip * {
  pointer-events: auto;
}

/* Forza lo spotlight ad essere cliccabile e sopra a tutto quando serve */
body.tutorial-waiting-click #tutorialSpotlight {
  pointer-events: auto !important;
  z-index: 9999 !important; /* Molto in alto per superare il tooltip */
}