@import url("https://fonts.googleapis.com/css2?family=Quicksand:wght@300..700&display=swap");

/* --- CONFIGURATION GLOBALE --- */
:root {
  --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
  --glass-bg: rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-accent: rgba(99, 102, 241, 0.2);

  --primary-color: #6366f1;
  --primary-hover: #4f46e5;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --nature-color: #38bdf8;
  --fonction-color: #f43f5e;
  --success-color: #10b981;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Quicksand", sans-serif;
}

body {
  background: var(--bg-gradient);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: var(--text-main);
  overflow-x: hidden;
  position: relative;
}

/* --- ANIMATIONS DE FOND (LIQUID GLASS OPTIMISÉ) --- */

/* 1. Le conteneur parent qui applique le flou UNE SEULE FOIS pour tout le monde */
.bg-blur-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  filter: blur(80px); /* Le flou est appliqué ici, plus sur les cercles ! */
  transform: translateZ(0); /* Rendu matériel activé sur le conteneur */
  backface-visibility: hidden;
}

/* 2. Les cercles simplifiés au maximum (sans filter, sans box-shadow) */
.bg-blur-circle {
  position: absolute;
  border-radius: 50%;
  opacity: 0.35; /* Légèrement réduit pour compenser la netteté sous le flou */
  will-change: transform;
  backface-visibility: hidden;
}

.circle-1 {
  width: 40vw;
  height: 40vw;
  max-width: 400px;
  max-height: 400px;
  background: #4f46e5;
  top: -10%;
  left: -10%;
  animation: floatCircle1 22s infinite alternate ease-in-out;
}

.circle-2 {
  width: 50vw;
  height: 50vw;
  max-width: 500px;
  max-height: 500px;
  background: #db2777;
  bottom: -15%;
  right: -10%;
  animation: floatCircle2 26s infinite alternate ease-in-out;
}

.circle-3 {
  width: 30vw;
  height: 30vw;
  max-width: 300px;
  max-height: 300px;
  background: #06b6d4;
  top: 40%;
  right: 15%;
  animation: floatCircle3 20s infinite alternate ease-in-out;
}

/* 3. Des animations distinctes avec des trajectoires en % pour éviter les saccades */
@keyframes floatCircle1 {
  0% {
    transform: translate(0, 0) scale(1);
  }
  100% {
    transform: translate(8%, 12%) scale(1.05);
  }
}

@keyframes floatCircle2 {
  0% {
    transform: translate(0, 0) scale(1);
  }
  100% {
    transform: translate(-10%, -8%) scale(1.08);
  }
}

@keyframes floatCircle3 {
  0% {
    transform: translate(0, 0) scale(1);
  }
  100% {
    transform: translate(-5%, 10%) scale(1.05);
  }
}

/* --- CONTENEUR PRINCIPAL --- */
.container {
  width: min(100%, 980px);
  max-width: 980px;
  padding: 24px;
  margin: 0 auto;
  z-index: 10;
}

/* --- CARTES GLASSMORPHISM --- */
.card {
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: 32px;
  padding: 36px;
  box-shadow: 0 28px 50px rgba(0, 0, 0, 0.35);
  text-align: center;
  transition:
    transform 0.4s ease,
    box-shadow 0.4s ease;
  opacity: 0;
  transform: translateY(30px);
  animation: fadeInUp 0.6s forwards;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 32px 60px rgba(0, 0, 0, 0.4);
}

@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hidden {
  display: none !important;
}

/* --- ÉCRAN D'ACCUEIL --- */
#logo:hover {
  filter: brightness(1.2);
  transform: scale(1.1);
  transition:
    filter 0.3s ease,
    transform 0.3s ease;
}

.logo-icon {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 96px;
  height: 96px;
  margin: 0 auto 10px;
  animation: pulse 2s infinite;
}

.logo-icon img {
  width: 100%;
  height: auto;
  display: block;
}

.logo-icon-text {
  font-size: 3rem;
  font-weight: 800;
  background: linear-gradient(to right, #fff, #94a3b8);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.glow {
  position: relative;
  display: flex; /* Aligne le texte et le curseur sur la même ligne */
  align-items: center;
  justify-content: center;
  cursor: default;
  width: 100%; /* Force le titre à prendre toute la ligne pour que le logo reste au-dessus */
  margin-top: 15px; /* Optionnel : rajoute un petit espace sous le logo */
}

/* Léger effet de survol au besoin */
.glow:hover {
  filter: drop-shadow(0 0 12px rgba(99, 102, 241, 0.4));
  transition: filter 0.3s ease;
}

/* Style du curseur vertical */
.typewriter-cursor {
  color: var(--primary-color);
  font-weight: 300;
  margin-left: 4px;
  animation: blinkCursor 0.7s infinite alternate;
}

@keyframes blinkCursor {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

h1 {
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(to right, #fff, #94a3b8);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 5px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 1.1rem;
  margin-bottom: 35px;
}

/* --- SÉLECTEUR DE MODE INTERACTIF --- */
.mode-selector {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 35px;
}

.mode-option {
  cursor: pointer;
  position: relative;
}

.mode-option input {
  display: none;
}

.mode-box {
  position: relative;
  overflow: hidden;
  display: block;
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  font-weight: 600;
  color: var(--text-main);
}

.mode-option input:checked + .mode-box::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%; /* Départ hors du champ à gauche */
  width: 50%;
  height: 100%;
  background: linear-gradient(
    to right,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.2) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  transform: skewX(-25deg);
  animation: shine 1s forwards;
  pointer-events: none;
  z-index: 2;
}

@keyframes shine {
  100% {
    left: 200%;
  }
}

.mode-option input:checked + .mode-box {
  background: var(--glass-accent);
  border-color: var(--primary-color);
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.3);
  transform: scale(1.02);
  transition: all 0.5s ease;
}

.mode-option input:not(:checked) + .mode-box:hover {
  color: #4f46e5;
  border-color: var(--primary-color);
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.3);
  transform: scale(1.02);
  transition: all 0.3s ease;
}

/* --- BOUTONS --- */
.btn-primary,
.btn-next {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 14px;
  font-size: 1.1rem;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #6365f1b1 0%, #4e46e5b8 100%);
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 24px rgba(99, 102, 241, 0.4);
}

.btn-primary:active {
  transform: translateY(-3px);
}

.btn-secondary {
  padding: 16px 25px;
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-secondary:hover {
  transform: scale(1.05);
  background: rgba(255, 255, 255, 0.2);
  border-color: var(--text-muted);
  transition: all 0.4s ease;
}

.btn-secondary:active {
  transform: translateX(-1px);
}

.btn-tertiary {
  padding: 16px 25px;
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
  background-color: rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: all 0.3s ease;
}

.stats-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.stats-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
  align-items: center;
}

.period-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.period-btn {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  border-radius: 14px;
  padding: 12px 16px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.period-btn:hover,
.period-btn.active {
  background: rgba(99, 102, 241, 0.2);
  border-color: rgba(99, 102, 241, 0.5);
}

.stats-summary {
  margin-top: 22px;
  padding: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.stats-summary div {
  color: var(--text-main);
  font-size: 0.95rem;
}

.chart-box {
  margin-top: 20px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.chart-box canvas {
  width: 100%;
  height: auto;
  display: block;
}

.btn-tertiary:hover {
  filter: brightness(1.2);
  transform: scale(1.02);
  transition: all 0.3s ease;
}

.btn-tertiary:active {
  transform: translateX(-1px);
}

.btn-text {
  background: none;
  border: none;
  color: var(--text-muted);
  font-weight: 600;
  cursor: pointer;
  transition: color 0.3s;
}

.btn-text:hover {
  color: var(--text-main);
}

/* --- ZONE DE JEU --- */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}

.score-badge {
  background: var(--glass-accent);
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: 600;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.sentence-box {
  background: rgba(0, 0, 0, 0.2);
  padding: 25px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  margin-bottom: 30px;
}

.sentence {
  font-size: 1.3rem;
  line-height: 1.6;
  font-weight: 600;
}

/* Mises en valeur fluides des mots cibles */
.highlight-nature {
  color: var(--nature-color);
  background: rgba(56, 189, 248, 0.15);
  padding: 2px 8px;
  border-radius: 6px;
  border-bottom: 2px solid var(--nature-color);
  font-weight: 800;
}

.highlight-fonction {
  color: var(--fonction-color);
  background: rgba(244, 63, 94, 0.15);
  padding: 2px 8px;
  border-radius: 6px;
  border-bottom: 2px solid var(--fonction-color);
  font-weight: 800;
}

/* --- CHAMPS DE SAISIE --- */
.input-group {
  text-align: left;
  margin-bottom: 25px;
  animation: fadeIn 0.4s ease;
}

.input-group label {
  display: block;
  margin-bottom: 10px;
  font-weight: 600;
  color: var(--text-muted);
}

.enhance-word {
  color: var(--primary-color);
  text-decoration: underline;
}

.input-wrapper {
  position: relative;
}

input[type="text"] {
  width: 100%;
  padding: 16px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  color: #fff;
  font-size: 1rem;
  transition: all 0.3s ease;
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
  background: rgba(0, 0, 0, 0.4);
}

/* --- ACTIONS CONTENEUR --- */
.actions {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 15px;
}

/* --- BOUTON PASSER ULTRA-DISCRET À CÔTÉ DE LA QUESTION --- */
.btn-skip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.35);
  padding: 3px 8px;
  font-size: 0.75rem; /* Très petit */
  border-radius: 6px;
  margin-left: 10px; /* Espace après le point d'interrogation */
  cursor: pointer;
  vertical-align: middle;
  transition: all 0.2s ease;
  font-weight: normal;
}

.btn-skip:hover {
  background: rgba(244, 63, 94, 0.1);
  border-color: rgba(244, 63, 94, 0.3);
  color: #fb7185;
}

/* Réajustement de la zone du bas puisqu'il n'y a plus qu'un bouton */
.secondary-actions {
  display: block;
  width: 100%;
}

.sentence-box {
  background: rgba(15, 23, 42, 0.9);
  border-left: 4px solid rgba(99, 102, 241, 0.85);
  padding: 24px;
  border-radius: 22px;
  margin-bottom: 30px;
  /* ASTUCE : On place la transition ici pour qu'elle s'exécute au survol ET quand la souris sort de l'élément */
  transition:
    border-color 0.3s ease,
    box-shadow 0.3s ease;
}

.sentence-box:hover {
  border-left-color: rgba(99, 102, 241, 1);
  /* Ombre localisée uniquement à gauche */
  box-shadow: -12px 0 15px -8px rgba(99, 102, 241, 0.6);
}

/* --- BOX DE FEEDBACK ET INDICES --- */
.hint-box,
.feedback-box {
  margin-top: 20px;
  padding: 20px;
  border-radius: 14px;
  text-align: left;
  font-size: 1rem;
  line-height: 1.5;
  animation: slideDown 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.hint-box {
  background: rgba(234, 179, 8, 0.1);
  border: 1px solid rgba(234, 179, 8, 0.3);
  color: #fde047;
}

.feedback-box.correct {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #34d399;
}

.feedback-box.wrong {
  background: rgba(244, 63, 94, 0.15);
  border: 1px solid rgba(244, 63, 94, 0.4);
  color: #fb7185;
}

/* --- EFFET FLASH OMBRE POUR CHAMP VIDE --- */
.feedback-box.flash-error {
  box-shadow: 0 0 25px rgba(244, 63, 94, 0.85);
  animation:
    slideDown 0.4s ease,
    pulse-shadow 0.8s ease-in-out forwards;
}

@keyframes pulse-shadow {
  0% {
    box-shadow: 0 0 25px rgba(244, 63, 94, 0.85);
  }
  20% {
    box-shadow: 0 0 35px rgba(244, 63, 94, 1);
  }
  100% {
    box-shadow: 0 0 0px rgba(244, 63, 94, 0);
  }
}

/* Bouton suivant stylisé en mode validation */
.btn-next {
  margin-top: 25px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.3);
}

/* --- KEYFRAMES SUPPLEMENTAIRES --- */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

/* --- COMPLÉMENT STYLES MENUS & COURS --- */

.main-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 10px;
}

.menu-hub-btn {
  padding: 22px 18px !important;
  font-size: 1.15rem !important;
  border-radius: 18px !important;
}

/* Boutons retour */
.back-btn {
  position: absolute;
  top: 20px;
  left: 25px;
  font-size: 0.9rem;
  opacity: 0.8;
}
.back-btn:hover {
  opacity: 1;
}

@media (max-width: 860px) {
  .container {
    padding: 18px;
  }

  .card {
    padding: 28px;
  }

  h1 {
    font-size: 2rem;
  }

  .subtitle,
  .subtitle-sheet {
    font-size: 1rem;
  }

  .sentence {
    font-size: 1.15rem;
  }

  .game-header {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }

  .actions {
    grid-template-columns: 1fr;
  }

  .main-options {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  body {
    padding: 12px;
  }

  .logo-icon {
    width: 80px;
    height: 80px;
  }

  .logo-icon-text {
    font-size: 2.5rem;
  }

  .card {
    padding: 22px;
    border-radius: 24px;
  }

  .back-btn {
    position: relative;
    top: 0;
    left: 0;
    display: inline-block;
    margin-bottom: 14px;
  }

  h1 {
    font-size: 1.8rem;
  }

  .subtitle,
  .subtitle-sheet {
    font-size: 0.92rem;
  }

  .sentence {
    font-size: 1.05rem;
  }

  .btn-primary,
  .btn-secondary,
  .btn-next {
    font-size: 0.92rem;
  }

  input[type="text"] {
    padding: 14px;
    font-size: 0.95rem;
  }

  .sheet-item {
    font-size: 0.88rem;
  }

  .item-example {
    font-size: 0.8rem;
    color: rgba(203, 213, 225, 0.9);
    display: block;
    margin-top: 8px;
    font-style: italic;
  }

  .period-btn,
  .stats-summary div,
  .btn-text {
    font-size: 0.88rem;
  }
}

/* Styles spécifiques aux fiches de cours */
.lesson-sheet {
  text-align: left !important;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.lesson-sheet h2 {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 5px;
  background: linear-gradient(to right, #fff, #cbd5e1);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle-sheet {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 10px;
}

/* Zone scrollable pour conserver la carte propre */
.scroll-box {
  overflow-y: auto;
  padding-right: 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Barre de défilement customisée moderne */
.scroll-box::-webkit-scrollbar {
  width: 6px;
}
.scroll-box::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 10px;
}
.scroll-box::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}
.scroll-box::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

.sheet-item {
  background: rgba(255, 255, 255, 0.04);
  padding: 14px 18px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.95rem;
  line-height: 1.5;
}

.sheet-item strong {
  color: #fff;
  display: block;
  margin-bottom: 0.5rem;
}

.item-example {
  font-size: 0.92rem;
  color: rgba(203, 213, 225, 0.9);
  display: block;
  margin-top: 8px;
  font-style: italic;
}

.sub-list {
  margin-left: 20px;
  margin-top: 8px;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sub-list li {
  font-size: 0.9rem;
  color: #cbd5e1;
}
