/* RESET DI BASE */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* FONT PRINCIPALE */
html, body {
  height: 100%;
  font-family: 'Poppins', sans-serif;
}

/* SFONDO GENERALE */
body {
  background-color: #001f3f; /* Blu scuro */
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: -webkit-fill-available;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 20px;
}

/* CANVAS PER CORIANDOLI */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* i click passano al di sotto */
}

/* CONTENITORE PRINCIPALE */
.quiz-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 90%;
  max-width: 420px;
}

/* SWITCH LINGUA - sopra il box */
.lang-switcher {
  margin-bottom: 20px;
  z-index: 1000;
}

.lang-switcher select {
  padding: 10px 15px;
  font-size: 0.95rem;
  font-family: 'Poppins', sans-serif;
  background-color: #022347;
  color: #fff;
  border: 2px solid #ff8c00;
  border-radius: 25px;
  cursor: pointer;
  outline: none;
  transition: all 0.3s ease;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23ff8c00' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 35px;
}

.lang-switcher select:hover {
  background-color: #033170;
  border-color: #e67e00;
}

.lang-switcher select:focus {
  box-shadow: 0 0 10px rgba(255, 140, 0, 0.5);
}

.lang-switcher select option {
  background-color: #022347;
  color: #fff;
  padding: 10px;
}

/* WRAPPER (attiva la prospettiva 3D per flip) */
.quiz-wrapper {
  width: 100%;
  padding: 1rem;
  perspective: 1000px; /* Necessario per l'effetto 3D flip */
}

/* CARD PRINCIPALE */
.quiz-card {
  background: #011830; /* Card scura */
  border-radius: 20px;
  padding: 2rem;
  text-align: center;
  color: #fff;
  position: relative;
  box-shadow: 0 0px 55px rgba(233, 232, 231, 0.1);

  opacity: 1;
  transition: opacity 0.4s ease-in-out, transform 0.4s ease-in-out;
}

/* TITOLO DOMANDA */
.quiz-question {
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  line-height: 1.3;
}

/* AREA INPUT (campi di testo, checkbox, ecc.) */
.quiz-inputs {
  margin-bottom: 1.5rem;
}

.quiz-inputs input[type="text"],
.quiz-inputs input[type="number"] {
  width: 100%;
  padding: 0.8rem;
  margin-top: 0.5rem;
  border: none;
  border-radius: 8px;
  outline: none;
  font-size: 16px; /* Previene lo zoom su iOS */
  color: #fff;
  background-color: #022347;
  transition: background-color 0.3s;
  -webkit-appearance: none;
}

.quiz-inputs input::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

.quiz-inputs input:focus {
  background-color: #033170;
}

/* CHECKBOX */
.quiz-inputs label {
  display: flex;
  align-items: center;
  margin: 0.5rem 0;
  cursor: pointer;
  font-weight: 300;
  padding: 8px 0;
}
.quiz-inputs label input[type="checkbox"] {
  margin-right: 10px;
  transform: scale(1.2);
  min-width: 20px;
  min-height: 20px;
}

/* PULSANTE AVANTI/CONCLUDI */
.quiz-btn {
  background: #ff8c00;
  color: #fff;
  font-size: 1rem;
  padding: 0.8rem 1.5rem;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  transition: background-color 0.3s, transform 0.3s;
  width: 100%;
  max-width: 200px;
  margin: 0 auto;
  display: block;
  -webkit-tap-highlight-color: transparent;
}

.quiz-btn:hover {
  background: #e67e00;
  transform: translateY(-2px);
}

.quiz-btn:active {
  transform: scale(0.98);
}

/* FLIP 3D: animazioni di entrata/uscita */
.flip-in {
  animation: flipIn 0.6s forwards cubic-bezier(0.65, 0, 0.35, 1);
}
@keyframes flipIn {
  0% {
    transform: rotateY(90deg);
    opacity: 0;
  }
  100% {
    transform: rotateY(0deg);
    opacity: 1;
  }
}

.flip-out {
  animation: flipOut 0.6s forwards cubic-bezier(0.65, 0, 0.35, 1);
}
@keyframes flipOut {
  0% {
    transform: rotateY(0);
    opacity: 1;
  }
  100% {
    transform: rotateY(-90deg);
    opacity: 0;
  }
}

/* ========================================
   RESPONSIVE - iPhone e dispositivi mobili
   ======================================== */

/* iPhone SE, iPhone 5/5S (320px) */
@media (max-width: 320px) {
  body {
    padding: 15px 10px;
  }
  
  .quiz-card {
    padding: 1.2rem;
    border-radius: 15px;
  }
  
  .quiz-question {
    font-size: 1rem;
    margin-bottom: 1rem;
  }
  
  .quiz-inputs input[type="text"],
  .quiz-inputs input[type="number"] {
    padding: 0.7rem;
    font-size: 16px;
  }
  
  .quiz-btn {
    padding: 0.7rem 1.2rem;
    font-size: 0.9rem;
  }
  
  .lang-switcher select {
    padding: 8px 10px;
    font-size: 0.8rem;
    padding-right: 28px;
  }
}

/* iPhone 6/7/8, iPhone X/XS/11 Pro (375px - 414px) */
@media (min-width: 321px) and (max-width: 480px) {
  body {
    padding: 20px 15px;
  }
  
  .quiz-card {
    padding: 1.5rem;
  }
  
  .quiz-question {
    font-size: 1.15rem;
    margin-bottom: 1.2rem;
  }
  
  .quiz-inputs input[type="text"],
  .quiz-inputs input[type="number"] {
    padding: 0.75rem;
    font-size: 16px;
  }
  
  .lang-switcher {
    margin-bottom: 15px;
  }
  
  .lang-switcher select {
    padding: 9px 12px;
    font-size: 0.85rem;
    padding-right: 30px;
  }
}

/* iPhone 12/13/14 Pro Max e dispositivi più grandi (428px+) */
@media (min-width: 481px) and (max-width: 768px) {
  .quiz-card {
    padding: 1.8rem;
  }
  
  .quiz-question {
    font-size: 1.3rem;
  }
}

/* Landscape mode su mobile */
@media (max-height: 500px) and (orientation: landscape) {
  body {
    padding: 10px;
    align-items: flex-start;
  }
  
  .quiz-container {
    flex-direction: row;
    align-items: flex-start;
    gap: 15px;
  }
  
  .lang-switcher {
    margin-bottom: 0;
    margin-top: 10px;
  }
  
  .quiz-card {
    padding: 1rem 1.5rem;
  }
  
  .quiz-question {
    font-size: 1rem;
    margin-bottom: 0.8rem;
  }
  
  .quiz-inputs {
    margin-bottom: 0.8rem;
  }
}

/* Safe area per iPhone X e successivi (notch) */
@supports (padding: max(0px)) {
  body {
    padding-left: max(15px, env(safe-area-inset-left));
    padding-right: max(15px, env(safe-area-inset-right));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    padding-top: max(20px, env(safe-area-inset-top));
  }
}

/* Previene problemi con la tastiera su iOS */
@media (max-width: 480px) {
  .quiz-inputs input:focus {
    position: relative;
    z-index: 100;
  }
}
