/* Animation de flash rouge pour mauvaise réponse */
.erreur-reponse {
  animation: flashRed 0.5s cubic-bezier(0.23, 1, 0.32, 1);
}

@keyframes flashRed {
  0% {
    background-color: var(--accent-light);
    transform: scale(1);
  }
  10% {
    background-color: #ff5959;
    transform: scale(1.04);
  }
  50% {
    background-color: #ff5959;
    transform: scale(1.08);
  }
  80% {
    background-color: var(--accent-light);
    transform: scale(1.04);
  }
  100% {
    background-color: var(--accent-light);
    transform: scale(1);
  }
}
:root {
  --bg-light: #f5f5f5;
  --bg-dark: #1c1e21;
  --accent-light: #4f46e5;
  --accent-dark: #0a0b0c;
  --text-light: #ffffff;
  --text-dark: #1c1e21;
  --hover-light: #e8e8e8;
  --hover-dark: #4338ca;
  --border-light: #ccc;
  --border-dark: #777;
  --link-light: #64b5f6;
  --link-dark: #2196f3
}
/* Fond animé subtil sur body via gradient mouvant */
body {
  background: linear-gradient(270deg, #f5f5f5, #e0e0ff, #f5f5f5, #e0e0ff);
  background-size: 800% 800%;
  animation: gradientShift 20s ease infinite;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--text-dark);
  font-size: 16px;
  line-height: 1.5;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  transition: background-color 0.3s ease,color 0.1s ease,border-color 0.3s ease;
  margin-bottom: 10px;
}

@keyframes gradientShift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}
header {
  background-color: var(--accent-light);
  padding: 20px;
  text-align: center;
  color: var(--text-light);
  box-shadow: 0 4px 15px rgba(79, 70, 229, 0.3);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 12px;
}
#LOGO {
  max-width: 50%
}
nav {
  display: inline-block
}
.mode-label {
  font-size: 16px
}
#mode-select {
  font-size: 16px;
  background-color: var(--accent-light);
  color: var(--text-light);
  border: 1px solid var(--text-light);
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(79, 70, 229, 0.3);
  border-radius: 12px;
  appearance: auto;
  -webkit-appearance: auto;
  -moz-appearance: auto;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23ffffff' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-position: right 12px center;
  background-repeat: no-repeat;
}
#mode-select:hover {
  background-color: var(--hover-dark);
  box-shadow: 0 8px 20px rgba(67, 56, 202, 0.35);
}
main {
  padding: 30px;
  max-width: 800px;
  margin: 30px auto;
  animation: fadeIn 0.5s ease forwards;
  opacity: 0;
}
h2 {
  font-size: 24px;
  margin-bottom: 20px;
  margin-top: 20px
}
p {
  font-size: 16px;
  margin-bottom: 20px;
  line-height: 1.5
}
.reponse-container {
  position: relative
}
#reponse-indices {
  width: 100%;
  padding: 10px;
  font-size: 16px;
  border: 1px solid var(--border-light);
  border-radius: 16px;
  margin-bottom: 20px;
  background-color: var(--bg-light);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  transition: box-shadow 0.3s ease;
}
#suggestions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 20px;
  background-color: var(--bg-light);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  border-radius: 16px;
  padding: 10px;
  border: 1px solid var(--border-light);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100px;
  max-height: 200px;
  overflow-y: auto;
  overflow-x: hidden;
}
.suggestion {
  padding: 5px;
  border-bottom: 1px solid var(--border-light);
  border-radius: 16px;
  transition: background-color 0.3s ease, color 0.3s ease;
  margin-bottom: 5px;
  width: 100%;
  box-sizing: border-box;
}
.suggestion:last-child {
  border-bottom: none
}
.suggestion:hover {
  background-color: var(--accent-light);
  color: var(--text-light);
  cursor: pointer
}
/* Boutons généraux stylisés avec glow pulsé à l’hover */
button {
  font-size: 16px;
  padding: 10px 20px;
  background-color: var(--accent-light);
  color: var(--text-light);
  border: none;
  border-radius: 16px;
  cursor: pointer;
  margin-bottom: 20px;
  transition: all 0.4s ease, box-shadow 0.6s ease;
  box-shadow: 0 4px 15px rgba(79, 70, 229, 0.3);
  position: relative;
  z-index: 0;
}
button::before {
  content: "";
  position: absolute;
  top: -6px;
  left: -6px;
  right: -6px;
  bottom: -6px;
  border-radius: 22px;
  opacity: 0;
  box-shadow: 0 0 15px 5px rgba(79, 70, 229, 0.6);
  transition: opacity 0.4s ease;
  z-index: -1;
}
button:hover {
  background-color: var(--hover-dark);
  box-shadow: 0 12px 24px rgba(67, 56, 202, 0.5);
  transform: translateY(-2px);
}
button:hover::before {
  opacity: 1;
  animation: glowPulse 1.5s infinite alternate;
}

/* Boutons .recommencer-container button harmonisés avec glow pulsé */
.recommencer-container button {
  font-size: 24px;
  padding: 15px 30px;
  background-color: var(--accent-light);
  color: var(--text-light);
  border: none;
  border-radius: 16px;
  cursor: pointer;
  margin-top: 20px;
  transition: all 0.4s ease, box-shadow 0.6s ease;
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.5);
  max-width: 90%;
  text-shadow: 0 0 5px rgba(0,0,0,0.15);
  position: relative;
  z-index: 0;
}
.recommencer-container button::before {
  content: "";
  position: absolute;
  top: -8px;
  left: -8px;
  right: -8px;
  bottom: -8px;
  border-radius: 24px;
  opacity: 0;
  box-shadow: 0 0 20px 7px rgba(79, 70, 229, 0.7);
  transition: opacity 0.4s ease;
  z-index: -1;
}
.recommencer-container button:hover {
  background-color: var(--hover-dark);
  box-shadow: 0 16px 36px rgba(67, 56, 202, 0.7);
  transform: translateY(-3px);
}
.recommencer-container button:hover::before {
  opacity: 1;
  animation: glowPulse 1.5s infinite alternate;
}

@keyframes glowPulse {
  from {
    box-shadow: 0 0 15px 5px rgba(79, 70, 229, 0.6);
  }
  to {
    box-shadow: 0 0 25px 15px rgba(79, 70, 229, 0.9);
  }
}

#resultat-indices {
  font-size: 18px;
  font-weight: bold;
  animation: fadeInResultat 0.6s ease forwards, underlineAppear 1s ease forwards;
  opacity: 0;
  transition: color 0.3s ease, background-color 0.3s ease, box-shadow 0.3s ease;
  padding: 8px 12px;
  border-radius: 12px;
  position: relative;
  color: var(--text-dark);
}
#resultat-indices.highlight-message {
  background-color: var(--accent-light);
  color: var(--text-light);
  box-shadow: 0 0 15px rgba(79, 70, 229, 0.6);
}

@keyframes underlineAppear {
  0% {
    box-shadow: inset 0 -4px 0 0 transparent;
  }
  50% {
    box-shadow: inset 0 -4px 0 0 var(--accent-light);
  }
  100% {
    box-shadow: inset 0 -4px 0 0 var(--accent-light);
  }
}

@keyframes fadeInResultat {
  to {
    opacity: 1;
  }
}
.recommencer-container {
  position: absolute;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center
}
#ecran-fin {
  background-color: rgba(245, 245, 245, 0.6);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  text-align: center;
  z-index: 10;
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-radius: 12px;
  animation: fadeInSmooth 0.8s ease forwards;
  opacity: 0;
  box-shadow: inset 0 0 30px rgba(79, 70, 229, 0.25), 0 8px 32px rgba(79, 70, 229, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  position: relative;
  overflow: hidden;
}

#ecran-fin::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(270deg, rgba(79,70,229,0.15), rgba(79,70,229,0.05), rgba(79,70,229,0.15));
  animation: slowRotate 10s linear infinite;
  z-index: 0;
  border-radius: 12px;
}

#ecran-fin > * {
  position: relative;
  z-index: 1;
}

@keyframes slowRotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

#ecran-fin.show ~ footer {
  display: none
}
@keyframes fadeInSmooth {
  from {
    opacity: 0;
    transform: scale(1.03);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
#resultat-final h2 {
  font-size: 28px;
  margin-bottom: 20px;
  color: var(--text-dark);
  margin-top: 10px
}
#resultat-final img {
  max-width: 70%;
  margin-bottom: 10px
}
.by-mat {
  font-family: 'Roboto','Lato',sans-serif;
  font-weight: 100;
  /* Pour Roboto Thin */
  /* font-weight: 300; */
  /* Pour Lato Light */
  font-size: 14px;
  opacity: 0.7
}
a {
  color: var(--link-light);
  text-decoration: none;
  transition: color 0.3s ease
}
a:hover {
  text-decoration: underline;
  color: var(--link-dark)
}
.toggle-theme {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100
}
.toggle-theme input[type="checkbox"] {
  display: none
}
.toggle-theme label {
  cursor: pointer;
  display: inline-block;
  width: 30px;
  height: 30px;
  position: relative
}
.toggle-theme .fas {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 20px;
  transition: all 0.3s
}
.toggle-theme .fas.fa-moon {
  opacity: 1
}
.toggle-theme .fas.fa-sun {
  opacity: 0
}
.toggle-theme input[type="checkbox"]:checked ~ label .fas.fa-moon {
  opacity: 0
}
.toggle-theme input[type="checkbox"]:checked ~ label .fas.fa-sun {
  opacity: 1
}
body.dark-mode {
  --bg-light: #1c1e21;
  --bg-dark: #0a0b0c;
  --accent-light: #0a0b0c;
  --accent-dark: #ffffff;
  --text-light: #ffffff;
  --text-dark: #ffffff;
  --hover-light: #2c2e33;
  --hover-dark: #232323;
  --border-light: #777;
  --border-dark: #777;
  --link-light: #64b5f6;
  --link-dark: #2196f3
}
@media only screen and (max-width: 768px) {
  body {
    font-size: 14px
  }
  header {
    padding: 10px
  }
  #LOGO {
    max-width: 70%
  }
  main {
    padding: 20px;
    max-width: 90%;
    margin: 20px auto;
    animation: fadeIn 0.5s ease forwards;
    opacity: 0;
  }
  h2 {
    font-size: 20px;
    margin-bottom: 15px;
    margin-top: 15px
  }
  p {
    font-size: 14px;
    margin-bottom: 15px
  }
  .mode-label,
  #mode-select,
  #reponse-indices {
    font-size: 14px
  }
  #reponse-indices,
  #suggestions {
    padding: 5px;
    margin-bottom: 15px
  }
  .suggestion {
    padding: 3px
  }
  button {
    font-size: 14px;
    padding: 5px 10px;
    margin-bottom: 15px
  }
  #resultat-indices {
    font-size: 16px;
  }
  .recommencer-container {
    top: 50%
  }
  #resultat-final h2 {
    font-size: 24px;
    margin-bottom: 15px
  }
  .recommencer-container button {
    font-size: 20px;
    padding: 10px 20px;
    margin-top: 15px;
    display: block;
    margin: 0 auto;
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.3);
    transition: all 0.3s ease, box-shadow 0.4s ease;
    position: relative;
    z-index: 0;
  }
  .recommencer-container button::before {
    content: "";
    position: absolute;
    top: -6px;
    left: -6px;
    right: -6px;
    bottom: -6px;
    border-radius: 22px;
    opacity: 0;
    box-shadow: 0 0 15px 5px rgba(79, 70, 229, 0.6);
    transition: opacity 0.3s ease;
    z-index: -1;
  }
  .recommencer-container button:hover {
    background-color: var(--hover-dark);
    box-shadow: 0 12px 24px rgba(67, 56, 202, 0.5);
    transform: translateY(-2px);
  }
  .recommencer-container button:hover::before {
    opacity: 1;
    animation: glowPulse 1.5s infinite alternate;
  }
  .toggle-theme {
    top: 5px;
    left: 5px
  }
  .toggle-theme label {
    width: 20px;
    height: 20px
  }
  .toggle-theme .fas {
    font-size: 16px
  }
}
@keyframes fadeIn {
  to {
    opacity: 1;
  }
}
/* Animation fade-in pour les indices */
.fade-in {
  animation: fadeInIndices 0.6s cubic-bezier(0.23, 1, 0.32, 1) forwards;
  opacity: 0;
}

@keyframes fadeInIndices {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
/* Bouton #reessayer avec animation de clic et spinner intégré */
#reessayer {
  position: relative;
  overflow: hidden;
  min-width: 120px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Style pour l'état de chargement du bouton */
#reessayer.loading {
  color: transparent !important;
  pointer-events: none;
}
#reessayer.loading::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 24px;
  height: 24px;
  margin-left: -12px;
  margin-top: -12px;
  border: 3px solid var(--text-light);
  border-top: 3px solid var(--accent-light);
  border-radius: 50%;
  animation: spinner-rotate 0.8s linear infinite;
  z-index: 1;
}

@keyframes spinner-rotate {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
/* Animation pour mettre en avant un nouvel indice */
.nouvel-indice {
  animation: pulseHighlight 0.5s cubic-bezier(0.23, 1, 0.32, 1);
}

@keyframes pulseHighlight {
  0% {
    background-color: #fff8e1;
    color: var(--accent-light);
    transform: scale(1);
  }
  30% {
    background-color: #ffe082;
    color: var(--accent-light);
    transform: scale(1.07);
  }
  70% {
    background-color: #fff8e1;
    color: var(--accent-light);
    transform: scale(1.03);
  }
  100% {
    background-color: transparent;
    color: inherit;
    transform: scale(1);
  }
}

/* Animation pour renforcer l'interaction sur le bouton actif */
.bouton-active {
  animation: pulseButton 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

@keyframes pulseButton {
  0% {
    box-shadow: 0 0 0 0 rgba(79,70,229,0.3);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(79,70,229,0.15);
    transform: scale(1.06);
  }
  100% {
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.3);
    transform: scale(1);
  }
}