/* Variables globales */
:root {
  --primary-color: #1ddb53;
  --secondary-color: #ff3e3e;
  --tertiary-color: #2563eb;
  --quaternary-color: #b346ff;
  --bg-dark: #0a0e17;
  --bg-darker: #050709;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --navbar-height: 70px;
  --mobile-navbar-height: 60px;
  --vh: 1vh; /* Variable pour la hauteur du viewport sur mobile */

  font-family: 'Space Grotesk', system-ui, Avenir, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  font-weight: 400;

  color-scheme: light dark;
  color: var(--text-primary);
  background-color: var(--bg-darker);

  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Styles de base */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  height: 100%;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch; /* Scrolling plus fluide sur iOS */
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 100vh;
  min-height: calc(var(--vh, 1vh) * 100); /* Utilisation de la variable pour une hauteur correcte sur mobile */
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  position: relative;
}

#root {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  min-height: calc(var(--vh, 1vh) * 100); /* Application aussi au root element */
}

/* Liens */
a {
  font-weight: 500;
  color: var(--primary-color);
  text-decoration: inherit;
  transition: color 0.3s ease;
  touch-action: manipulation; /* Améliore la réactivité tactile */
  display: inline-block; /* Améliore la zone de tap sur mobile */
}

a:hover {
  color: white;
  text-shadow: 0 0 8px rgba(29, 219, 83, 0.7);
}

/* Titres */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Chakra Petch', sans-serif;
  line-height: 1.1;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

h1 {
  font-size: 3.2em;
}

h2 {
  font-size: 2.4em;
}

h3 {
  font-size: 1.8em;
}

h4 {
  font-size: 1.4em;
}

/* Boutons */
button {
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0.6em 1.2em;
  font-size: 1em;
  font-weight: 500;
  font-family: inherit;
  background-color: #1a1a1a;
  cursor: pointer;
  transition: all 0.25s ease;
  min-height: 44px; /* Améliore la taille des cibles tactiles */
  min-width: 44px; /* Dimension minimale pour cibles tactiles selon WCAG */
  touch-action: manipulation; /* Améliore la réactivité tactile */
}

button:hover {
  border-color: var(--primary-color);
  transform: translateY(-2px);
}

button:focus,
button:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Images */
img, svg {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Scrollbar personnalisée */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-darker);
}

::-webkit-scrollbar-thumb {
  background: rgba(29, 219, 83, 0.3);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(29, 219, 83, 0.5);
}

/* Optimisations tactiles */
* {
  -webkit-tap-highlight-color: transparent;
}

input, button, select, textarea, a {
  touch-action: manipulation;
}

/* Classes utilitaires */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
}

/* Mode clair (si nécessaire) */
@media (prefers-color-scheme: light) {
  :root {
    color: #213547;
    background-color: #ffffff;
  }
  
  a:hover {
    color: var(--primary-color);
  }
  
  button {
    background-color: #f9f9f9;
  }
}

/* Responsive */
@media (max-width: 768px) {
  html {
    font-size: 14px;
  }
  
  h1 {
    font-size: 2rem !important; /* Forçage pour s'assurer de la taille sur mobile */
  }
  
  h2 {
    font-size: 1.6rem !important;
  }
  
  h3 {
    font-size: 1.4rem !important;
  }
  
  h4 {
    font-size: 1.2rem !important;
  }
  
  .container {
    padding: 0 1rem;
  }
  
  button {
    padding: 0.5em 1em;
  }
  
  .desktop-only {
    display: none !important;
  }
  
  ::-webkit-scrollbar {
    width: 4px;
  }
}

@media (max-width: 480px) {
  html {
    font-size: 13px;
  }
  
  h1 {
    font-size: 1.75rem !important;
  }
  
  h2 {
    font-size: 1.35rem !important;
  }
  
  h3 {
    font-size: 1.15rem !important;
  }
  
  .container {
    padding: 0 0.75rem;
  }
}

@media (min-width: 769px) {
  .mobile-only {
    display: none !important;
  }
}

/* Utilitaires d'espacement */
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mt-5 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mb-5 { margin-bottom: 2rem; }

.mx-auto { margin-left: auto; margin-right: auto; }
.my-1 { margin-top: 0.25rem; margin-bottom: 0.25rem; }
.my-2 { margin-top: 0.5rem; margin-bottom: 0.5rem; }
.my-3 { margin-top: 1rem; margin-bottom: 1rem; }

.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 1rem; }
.p-4 { padding: 1.5rem; }
.p-5 { padding: 2rem; }

/* Animations globales */
@keyframes glitch {
  0% {
    transform: translate(0);
  }
  20% {
    transform: translate(-2px, 2px);
  }
  40% {
    transform: translate(-2px, -2px);
  }
  60% {
    transform: translate(2px, 2px);
  }
  80% {
    transform: translate(2px, -2px);
  }
  100% {
    transform: translate(0);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

@keyframes float {
  0% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
  100% {
    transform: translateY(0px);
  }
}

@keyframes scanLines {
  0% {
    background-position: 0 0;
  }
  100% {
    background-position: 0 100%;
  }
}

/* Empêche les débordements de texte */
* {
  overflow-wrap: break-word;
  word-wrap: break-word;
  hyphens: auto;
}

/* Amélioration de l'accessibilité */
*:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Pour contenir les contenus offscreen */
.offscreen {
  position: absolute;
  left: -9999px;
  top: -9999px;
}

/* Styles pour le contenu centré */
.text-center {
  text-align: center;
}

/* Utilitaires de flex */
.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.flex-wrap {
  flex-wrap: wrap;
}

.justify-center {
  justify-content: center;
}

.justify-between {
  justify-content: space-between;
}

.align-center {
  align-items: center;
}

.gap-1 {
  gap: 0.25rem;
}

.gap-2 {
  gap: 0.5rem;
}

.gap-3 {
  gap: 1rem;
}

/* Utilitaires pour les grilles responsives */
.grid {
  display: grid;
}

.grid-cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-cols-4 {
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1024px) {
  .lg-grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .lg-grid-cols-1 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .md-grid-cols-1 {
    grid-template-columns: 1fr;
  }
  
  .md-grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .grid-cols-2, 
  .grid-cols-3, 
  .grid-cols-4 {
    grid-template-columns: 1fr;
  }
  
  .grid {
    gap: 1rem;
  }
}

@media (max-width: 480px) {
  .sm-grid-cols-1 {
    grid-template-columns: 1fr;
  }
  
  .grid {
    gap: 0.75rem;
  }
}

/* Utilitaires de largeur */
.w-full {
  width: 100%;
}

.w-1\/2 {
  width: 50%;
}

.w-1\/3 {
  width: 33.333333%;
}

.w-1\/4 {
  width: 25%;
}

/* Espace pour la navbar fixe */
.pt-navbar {
  padding-top: var(--navbar-height);
}

@media (max-width: 768px) {
  .pt-navbar {
    padding-top: var(--mobile-navbar-height);
  }
}

/* Classe pour hauteur complète qui respecte les variables */
.full-height {
  height: 100vh;
  height: calc(var(--vh, 1vh) * 100);
}

/* Optimisations pour les appareils mobiles */
@media (max-width: 768px) {
  /* Accessibilité augmentée pour les cibles tactiles */
  a, button, input[type="button"], input[type="submit"], input[type="reset"] {
    min-height: 44px;
    min-width: 44px;
    padding: 0.5rem 1rem;
  }
  
  /* Meilleure gestion pour zones tactiles intéractives */
  a:active, button:active, input:active, [role="button"]:active {
    transform: scale(0.97);
  }
  
  /* Optimisations pour texte lisible sur mobile */
  p, li, td, th {
    font-size: 1rem !important; /* Taille minimale pour lisibilité sur mobile */
  }
  
  /* Classes d'utilité spécifiques à mobile */
  .hide-on-mobile {
    display: none !important;
  }
  
  .show-on-mobile {
    display: block !important;
  }
  
  .text-center-mobile {
    text-align: center !important;
  }
  
  .full-width-mobile {
    width: 100% !important;
    max-width: 100% !important;
  }
  
  .p-mobile-sm {
    padding: 0.75rem !important;
  }
  
  .m-mobile-sm {
    margin: 0.75rem !important;
  }
  
  /* Gestion adaptée aux zones avec safe-area notch et arrondis d'écran */
  .safe-area-padding {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* Styles pour lorsque le clavier virtuel est visible sur mobile */
body.keyboard-visible {
  /* Ajustements pour éviter les problèmes de mise en page avec le clavier virtuel */
  height: auto;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

/* Optimisations pour la mise en page mobile */
.scrollable {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

/* Styles pour animations réduites (préférence utilisateur) */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Styles pour la navigation mobile */
.mobile-nav {
  position: fixed;
  top: var(--mobile-navbar-height);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 998;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background-color: rgba(5, 7, 9, 0.95);
  backdrop-filter: blur(10px);
  transform: translateX(100%);
  transition: transform 0.3s ease-in-out;
}

.mobile-nav.open {
  transform: translateX(0);
}

/* Styles pour le bouton mobile hamburger */
.hamburger {
  width: 24px;
  height: 24px;
  position: relative;
  transition: 0.3s;
}

.hamburger span {
  display: block;
  position: absolute;
  height: 2px;
  width: 100%;
  background: var(--primary-color);
  border-radius: 2px;
  opacity: 1;
  left: 0;
  transform: rotate(0deg);
  transition: 0.3s ease-in-out;
}

.hamburger span:nth-child(1) {
  top: 6px;
}

.hamburger span:nth-child(2),
.hamburger span:nth-child(3) {
  top: 12px;
}

.hamburger span:nth-child(4) {
  top: 18px;
}

.hamburger.open span:nth-child(1) {
  top: 12px;
  width: 0%;
  left: 50%;
}

.hamburger.open span:nth-child(2) {
  transform: rotate(45deg);
}

.hamburger.open span:nth-child(3) {
  transform: rotate(-45deg);
}

.hamburger.open span:nth-child(4) {
  top: 12px;
  width: 0%;
  left: 50%;
}

/* Navigation fixée au bas pour mobile */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: rgba(5, 7, 9, 0.9);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(29, 219, 83, 0.2);
  display: none;
  align-items: center;
  justify-content: space-around;
  z-index: 999;
  padding-bottom: env(safe-area-inset-bottom);
}

@media (max-width: 768px) {
  .bottom-nav {
    display: flex;
  }
  
  /* Ajouter un padding pour le contenu afin d'éviter qu'il ne soit caché par la navbar du bas */
  .has-bottom-nav {
    padding-bottom: 70px; /* 60px height + 10px de marge */
  }
}

/* Meilleure tronquage de texte pour mobile */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.truncate-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Gestion améliorée des cards sur mobile */
.card {
  border-radius: 0.75rem;
  background: rgba(10, 14, 23, 0.7);
  border: 1px solid rgba(29, 219, 83, 0.1);
  padding: 1.5rem;
}

@media (max-width: 768px) {
  .card {
    padding: 1rem;
    border-radius: 0.5rem;
  }
}

@media (max-width: 480px) {
  .card {
    padding: 0.75rem;
  }
}

/* Styles pour "retour en haut" */
.back-to-top {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background-color: var(--primary-color);
  color: var(--bg-darker);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  z-index: 999;
  opacity: 0.8;
  transform: translateY(100px);
  transition: transform 0.3s ease;
}

.back-to-top.visible {
  transform: translateY(0);
}

@media (max-width: 768px) {
  .back-to-top {
    bottom: 70px; /* Au-dessus de la navigation inférieure */
  }
}