/* ========================================
   QUIZ MASTER PRO - Système de Thème
   Variables CSS Personnalisables
   ======================================== */
@font-face {
  font-family: "RacersDelight";
  src: url("/assets/fonts/RacersDelight.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-title: "RacersDelight", system-ui, sans-serif;
  --font-countdown: "RacersDelight", system-ui, sans-serif;

  /* === COULEURS PRIMAIRES === */
  --color-primary: #8b5cf6;
  --color-primary-light: #a78bfa;
  --color-primary-dark: #7c3aed;

  --color-secondary: #ec4899;
  --color-secondary-light: #f472b6;
  --color-secondary-dark: #db2777;

  /* === COULEURS ÉTAT === */
  --color-success: #10b981;
  --color-success-light: #34d399;
  --color-success-dark: #059669;

  --color-error: #ef4444;
  --color-error-light: #f87171;
  --color-error-dark: #dc2626;

  --color-warning: #f59e0b;
  --color-warning-light: #fbbf24;
  --color-warning-dark: #d97706;

  --color-info: #3b82f6;
  --color-info-light: #60a5fa;
  --color-info-dark: #2563eb;

  /* === COULEURS NEUTRES === */
  --color-gray-50: #f9fafb;
  --color-gray-100: #f3f4f6;
  --color-gray-200: #e5e7eb;
  --color-gray-300: #d1d5db;
  --color-gray-400: #9ca3af;
  --color-gray-500: #6b7280;
  --color-gray-600: #4b5563;
  --color-gray-700: #374151;
  --color-gray-800: #1f2937;
  --color-gray-900: #111827;

  /* === TEXTE === */
  --color-text-primary: #111827;
  --color-text-secondary: #6b7280;
  --color-text-light: #ffffff;

  /* === BACKGROUNDS === */
  --color-bg-primary: #ffffff;
  --color-bg-secondary: #f9fafb;
  --color-bg-dark: #1f2937;

  /* === BORDURES === */
  --border-width: 2px;
  --border-width-thick: 4px;
  --border-radius: 0.75rem; /* 12px */
  --border-radius-large: 1.5rem; /* 24px */
  --border-radius-full: 9999px;

  --border-color: var(--color-gray-300);
  --border-color-hover: var(--color-primary-light);
  --border-color-active: var(--color-primary);

  /* === OMBRES === */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
    0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1),
    0 8px 10px -6px rgba(0, 0, 0, 0.1);
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* ========================================
   CLASSES UTILITAIRES AVEC VARIABLES
   ======================================== */
.title-font {
  font-family: var(--font-title);
}

/* Boutons */
.btn-primary {
  background: linear-gradient(
    135deg,
    var(--color-primary) 0%,
    var(--color-secondary) 100%
  );
  color: var(--color-text-light);
  border: none;
  padding: 1rem 1.5rem;
  border-radius: var(--border-radius-large);
  font-weight: bold;
  transition: transform 0.2s, box-shadow 0.2s;
}
.btn-primary:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-lg);
}

.btn-success {
  background: linear-gradient(
    135deg,
    var(--color-success) 0%,
    var(--color-success-light) 100%
  );
  color: var(--color-text-light);
  border: none;
  padding: 1rem 1.5rem;
  border-radius: var(--border-radius-large);
  font-weight: bold;
  transition: transform 0.2s;
}
.btn-success:hover {
  transform: scale(1.05);
}

.btn-error {
  background: linear-gradient(
    135deg,
    var(--color-error) 0%,
    var(--color-error-light) 100%
  );
  color: var(--color-text-light);
  border: none;
  padding: 1rem 1.5rem;
  border-radius: var(--border-radius-large);
  font-weight: bold;
  transition: transform 0.2s;
}

.btn-secondary {
  background: var(--color-gray-200);
  color: var(--color-text-primary);
  border: none;
  padding: 1rem 1.5rem;
  border-radius: var(--border-radius-large);
  font-weight: bold;
  transition: background 0.2s;
}
.btn-secondary:hover {
  background: var(--color-gray-300);
}

/* Cards */
.card {
  background: var(--color-bg-primary);
  border-radius: var(--border-radius-large);
  box-shadow: var(--shadow-xl);
  padding: 2rem;
}

/* Avatar */
.avatar-circle {
  border-radius: var(--border-radius-full);
  border-width: var(--border-width-thick);
  border-style: solid;
  border-color: var(--border-color);
  transition: border-color 0.2s, transform 0.2s;
}
.avatar-circle:hover {
  border-color: var(--border-color-hover);
  transform: scale(1.1);
}
.avatar-circle.selected {
  border-color: var(--color-primary);
  transform: scale(1.1);
}

/* Inputs */
.input-text {
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 0.75rem 1rem;
  font-size: 1rem;
  transition: border-color 0.2s;
}
.input-text:focus {
  outline: none;
  border-color: var(--color-primary);
}

/* Badges */
.badge-success,
.badge-error,
.badge-info {
  color: var(--color-text-light);
  padding: 0.25rem 0.75rem;
  border-radius: var(--border-radius);
  font-weight: bold;
  font-size: 0.875rem;
}
.badge-success {
  background: var(--color-success);
}
.badge-error {
  background: var(--color-error);
}
.badge-info {
  background: var(--color-info);
}

/* Cartes animées */
.card-hover {
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
.card-hover:hover {
  transform: translateY(-5px) scale(1.02);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

/* ========================================
   THÈMES PRÉDÉFINIS (Optionnels)
   ======================================== */

[data-theme="dark"] {
  --color-primary: #a78bfa;
  --color-secondary: #f472b6;
  --color-text-primary: #f9fafb;
  --color-text-secondary: #d1d5db;
  --color-bg-primary: #1f2937;
  --color-bg-secondary: #111827;
  --border-color: #4b5563;
}

[data-theme="ocean"] {
  --color-primary: #0ea5e9;
  --color-primary-light: #38bdf8;
  --color-primary-dark: #0284c7;
  --color-secondary: #06b6d4;
  --color-secondary-light: #22d3ee;
  --color-secondary-dark: #0891b2;
}

[data-theme="forest"] {
  --color-primary: #10b981;
  --color-primary-light: #34d399;
  --color-primary-dark: #059669;
  --color-secondary: #14b8a6;
  --color-secondary-light: #2dd4bf;
  --color-secondary-dark: #0d9488;
}

[data-theme="fire"] {
  --color-primary: #f59e0b;
  --color-primary-light: #fbbf24;
  --color-primary-dark: #d97706;
  --color-secondary: #ef4444;
  --color-secondary-light: #f87171;
  --color-secondary-dark: #dc2626;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
  :root {
    --border-radius: 0.5rem;
    --border-radius-large: 1rem;
  }
}

/* ========================================
   ANIMATIONS
   ======================================== */

@keyframes bounce-in {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes bounce-click {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(0.95);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes slide-in-bottom {
  from {
    transform: translateY(100px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slide-in-top {
  from {
    transform: translateY(-100px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes wiggle {
  0%,
  100% {
    transform: rotate(-3deg);
  }
  50% {
    transform: rotate(3deg);
  }
}

@keyframes pulse-big {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-10px);
  }
  75% {
    transform: translateX(10px);
  }
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

@keyframes slide-down {
  from {
    transform: translate(-50%, -100%);
    opacity: 0;
  }
  to {
    transform: translate(-50%, 0);
    opacity: 1;
  }
}

@keyframes bounce-subtle {
  0%,
  100% {
    transform: translate(-50%, 0);
  }
  50% {
    transform: translate(-50%, -10px);
  }
}

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

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

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

/* ⚠️ pop: on conserve la DERNIÈRE version (scale 1.05) */
@keyframes pop {
  0% {
    transform: scale(0.8);
    opacity: 0;
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-30px);
  }
}

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

/* Classes d’animation */
.animate-bounce-in {
  animation: bounce-in 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
.animate-slideInBottom {
  animation: slide-in-bottom 0.6s ease-out;
}
.animate-slideInTop {
  animation: slide-in-top 0.6s ease-out;
}
.animate-wiggle {
  animation: wiggle 0.5s ease-in-out;
}
.animate-pulse-big {
  animation: pulse-big 0.8s ease-in-out infinite;
}
.animate-pop {
  animation: pop 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
.animate-slide-down {
  animation: slide-down 0.5s ease-out;
}
.animate-bounce-subtle {
  animation: bounce-subtle 2s ease-in-out infinite;
}

/* (Garde la classe, mais pas de keyframes slide-up dans ton CSS) */
.animate-slide-up {
  animation: slide-up 0.5s ease-out;
}

/* (Garde la classe, mais pas de keyframes pop-in dans ton CSS) */
.animate-pop-in {
  animation: pop-in 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.pulse-animation {
  animation: pulse 1s infinite;
}

/* Réponses qui apparaissent */
.answer-appear {
  animation: bounce-in 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* ========================================
   INTERACTIONS / UX
   ======================================== */

* {
  scroll-behavior: smooth;
}

* {
  -webkit-tap-highlight-color: transparent;
}
body {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button {
  transition: all 0.2s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  transform-origin: center;
}

button:hover:not(:disabled) {
  transform: scale(1.05);
}

button:active:not(:disabled) {
  transform: scale(0.95);
  animation: bounce-click 0.3s ease;
}

button:disabled {
  opacity: 1; /* on ne cache pas */
  cursor: not-allowed;
  pointer-events: none; /* on bloque le clic */
}

/* Boutons réponse */
.answer-btn {
  transition: all 0.2s;
}
.answer-btn:not(:disabled):hover {
  transform: scale(1.05);
}
.answer-btn:active {
  transform: scale(0.95);
}

/* ========================================
   VISIBILITÉ RÉPONSES
   ======================================== */

.player-answer-hidden {
  opacity: 0.2;
  filter: blur(17px);
  transform: scale(0.95);
}

.player-answer-visible {
  opacity: 1;
  filter: blur(0);
  transform: scale(1);
}

.answer-hidden {
  opacity: 0.2;
  filter: blur(17px);
  transform: scale(0.95);
  pointer-events: none;
}

.answer-visible {
  opacity: 1;
  filter: blur(0);
  transform: scale(1);
}

/* ========================================
   LOADING / SPINNER
   ======================================== */

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  z-index: 9999;
}

.spinner {
  border: 4px solid #f3f3f3;
  border-top: 4px solid #3498db;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
}

/* ========================================
   SCROLLBAR
   ======================================== */

.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Fade helpers */
@keyframes fadeOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(20px);
  }
}

.animate-fade-in {
  animation: fadeIn 0.5s ease-out both;
}

.animate-fade-out {
  animation: fadeOut 0.5s ease-in both;
}

.animate-fade-in-only {
  animation: fadeInOnly 0.7s ease-out both;
}

.animate-fade-out-only {
  animation: fadeOutOnly 0.7s ease-in both;
}

/* Scroll super fluide pour les rows de quiz */
[id^="row-"] {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch; /* iOS smooth scroll */
  scroll-padding: 0 16px; /* Espace aux bords */
}

/* Cache scrollbar mais garde fonctionnalité */
[id^="row-"]::-webkit-scrollbar {
  height: 6px;
}

[id^="row-"]::-webkit-scrollbar-track {
  background: transparent;
}

[id^="row-"]::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

[id^="row-"]::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* Empêcher drag des images dans les sliders */
[id^="row-"] img {
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

[id^="row-"] button {
  pointer-events: auto;
}

[id^="row-"] {
  cursor: grab;
  user-select: none;
}

[id^="row-"]:active {
  cursor: grabbing;
}

/* Animation montée (vert) */
@keyframes slide-up {
  from {
    transform: translateY(50px);
    background-color: rgba(16, 185, 129, 0.2);
  }
  to {
    transform: translateY(0);
    background-color: transparent;
  }
}

/* Animation descente (rouge) */
@keyframes slide-down {
  from {
    transform: translateY(-50px);
    background-color: rgba(239, 68, 68, 0.2);
  }
  to {
    transform: translateY(0);
    background-color: transparent;
  }
}

.player-slide-up {
  animation: slide-up 0.8s ease-out;
  border-left: 4px solid #10b981 !important;
}

.player-slide-down {
  animation: slide-down 0.8s ease-out;
  border-left: 4px solid #ef4444 !important;
}

.player-no-change {
  animation: fadeIn 0.6s ease-out;
}

@keyframes bounce-in {
  0% {
    opacity: 0;
    transform: scale(0.3) translateY(-20px);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    transform: scale(1);
  }
}

.animate-bounce-in {
  animation: bounce-in 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) both;
}

@keyframes pop-countdown {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes pop {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.animate-pop {
  animation: pop 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) both;
}

/* Animation countdown 3,2,1 */
@keyframes pop-countdown {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Fade in/out */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

.animate-fade-in {
  animation: fadeIn 0.3s ease-out;
}

.animate-fade-out {
  animation: fadeOut 0.3s ease-out;
}

/* Masquer scrollbar classement */
#leaderboard-scroll-container {
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
}

#leaderboard-scroll-container::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

/* couche background (customization.background) */
#quizBaseBg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* couche cover flou (quiz cover) */
#quizCoverBg {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;

  background-size: cover;
  background-position: center;

  filter: blur(6px);
  opacity: 0.25;
  transform: scale(1.08);
}

/* IMPORTANT: tes pages ne doivent plus peindre un background par-dessus */
.qz-screen {
  background: transparent !important; /* override inline background */
}
