/* Importation de la police Google Fonts Outfit */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&display=swap');

/* Variables de configuration */
:root {
  /* Marges de la zone de texte par rapport aux bords de l'image (à ajuster selon les lignes rouges) */
  --text-top: 15%;
  --text-bottom: 15%;
  --text-left: 10%;
  --text-right: 10%;
  
  /* Aspect ratio par défaut (sera mis à jour dynamiquement par le JS) */
  --aspect-ratio: 0.65;
  
  /* Palette de couleurs premium */
  --bg-dark: #0f1015;
  --bg-card: #181922;
  --color-text: #ffffff;
  --color-muted: #a0aec0;
  
  --gradient-vrai: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --gradient-faux: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  --shadow-color: rgba(0, 0, 0, 0.6);
}

/* Reset de base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-dark);
  background-image: radial-gradient(circle at 50% 50%, #1e202c 0%, #0d0e12 100%);
  color: var(--color-text);
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 16px;
}

/* Conteneur principal */
.app-container {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  perspective: 1000px; /* Pour de futures animations 3D */
}

/* Spinner de chargement */
.loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  animation: fadeIn 0.3s ease-out;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-left-color: #3b82f6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loader-text {
  font-size: 1rem;
  color: var(--color-muted);
  font-weight: 400;
  letter-spacing: 0.5px;
}

/* Message d'erreur */
.error-card {
  background-color: var(--bg-card);
  padding: 32px;
  border-radius: 20px;
  text-align: center;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 10px 30px var(--shadow-color);
  border: 1px solid rgba(255, 255, 255, 0.08);
  animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.error-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.error-title {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 12px;
  color: #ef4444;
}

.error-desc {
  color: var(--color-muted);
  line-height: 1.5;
  margin-bottom: 24px;
}

.btn-retry {
  display: inline-block;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 10px 24px;
  border-radius: 30px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-retry:hover {
  background: #fff;
  color: var(--bg-dark);
  transform: translateY(-2px);
}

/* La carte de jeu */
.card {
  position: relative;
  /* Calcul dynamique de la largeur en fonction de la hauteur max de l'écran pour éviter tout dépassement */
  width: min(90vw, calc(85dvh * var(--aspect-ratio)));
  aspect-ratio: var(--aspect-ratio);
  
  background-image: url('images/fond_carte_jeu.png');
  background-size: 100% 100%;
  background-position: center;
  background-repeat: no-repeat;
  
  border-radius: 24px; /* Arrondi léger pour épouser la forme de la carte */
  box-shadow: 
    0 30px 60px rgba(0, 0, 0, 0.6),
    0 0 100px rgba(0, 0, 0, 0.2),
    inset 0 0 2px rgba(255, 255, 255, 0.2);
    
  opacity: 0;
  transform: translateY(30px) rotateX(10deg);
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.card.loaded {
  opacity: 1;
  transform: translateY(0) rotateX(0);
}

/* Zone globale de la carte qui englobe tous les éléments */
.card-content {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  box-sizing: border-box;
}

/* Zone de contenu flexible et scrollable calée exactement par rapport aux lignes rouges */
.text-scroll-container {
  position: absolute;
  top: var(--text-top);
  bottom: var(--text-bottom);
  left: var(--text-left);
  right: var(--text-right);
  overflow-y: auto;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  
  /* Stylisation de la scrollbar pour qu'elle soit visible si nécessaire (fond clair de carte) */
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.25) transparent;
}

.text-scroll-container::-webkit-scrollbar {
  width: 5px;
}

.text-scroll-container::-webkit-scrollbar-track {
  background: transparent;
}

.text-scroll-container::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.25);
  border-radius: 3px;
}

/* Wrapper interne permettant le centrage vertical dynamique si la hauteur le permet,
   et le défilement normal depuis le haut si le texte dépasse. */
.scroll-content {
  width: 100%;
  margin: auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* En-tête de la carte positionné à exactement 50 pixels du haut */
.card-header {
  position: absolute;
  top: 50px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
}

/* Étoiles dorées */
.stars {
  color: #d97706; /* Ambre foncé pour être visible sur fond clair */
  font-size: 1.1rem;
  letter-spacing: 2px;
}

/* Question en rouge (Taille adaptée au smartphone pour laisser place à l'explication) */
.question-title {
  font-size: clamp(1.15rem, 5.2vw, 1.45rem);
  font-weight: 800;
  line-height: 1.3;
  color: #dc2626; /* Rouge vif élégant */
  margin-bottom: 12px;
  text-transform: none;
  letter-spacing: -0.3px;
  width: 100%;
  text-align: center;
}

/* Container du badge */
.badge-container {
  margin-bottom: 12px;
}

/* Badge Réponse (VRAI/FAUX sur fond vert) */
.badge-reponse {
  display: inline-block;
  padding: 6px 22px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  background: var(--gradient-vrai); /* Fond vert par défaut */
  color: #ffffff;
  border: 1px solid rgba(16, 185, 129, 0.3);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
  animation: zoomIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.2s both;
}

/* Explication principale (en Noir, priorité haute, lisibilité accrue) */
.explication-text {
  font-size: clamp(0.85rem, 3.8vw, 1.02rem);
  font-weight: 400;
  line-height: 1.45;
  color: #000000; /* Texte noir */
  animation: fadeIn 0.6s ease-out 0.3s both;
  text-align: center;
}

/* Footer de la carte positionné à exactement 50 pixels du bas */
.card-footer {
  position: absolute;
  bottom: 50px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
}

/* Points en lettres dorées */
.points-gold {
  font-size: clamp(1.2rem, 5vw, 1.4rem);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  background: linear-gradient(135deg, #a67c1e 0%, #f1c40f 50%, #9a6b0c 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.15));
  animation: zoomIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.4s both;
}

/* Animations */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
