/* ===================================
   RESET ET BASE
   =================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: #0e100f;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: #fffce1;
  touch-action: pan-y;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

/* ===================================
   HEADER BRUTALISTE
   =================================== */
.site-header {
  background-color: #0e100f;
  border-bottom: 3px solid #fffce1;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  padding: 1.2rem 2rem;
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.menu-label {
  color: #fffce1;
  font-size: 1rem;
  font-weight: 700;
  padding: 0.6rem 1.5rem;
  border: 3px solid #fffce1;
  cursor: pointer;
  transition: all 0.15s;
  text-transform: uppercase;
  letter-spacing: 2px;
  background-color: transparent;
}

.menu-label:hover {
  background-color: #fffce1;
  color: #0e100f;
}

/* ===================================
   CONTAINER PRINCIPAL CENTRÉ 100%
   =================================== */
.main-container {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 3rem;
  padding: 2rem;
}

.grid-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  touch-action: none;
  user-select: none;
}

/* ===================================
   GRILLE INTERACTIVE
   =================================== */
.grid {
  --gap: 12px;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  touch-action: none;
}

.row {
  display: flex;
  gap: var(--gap);
}

.cell {
  --size: 24px;
  width: var(--size);
  height: var(--size);
  background-color: #fffce1;
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.2s;
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
  touch-action: none;
}

/* ===================================
   CONTRÔLES (COLONNE DESKTOP)
   =================================== */
.controls {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

/* Animation d'apparition des boutons */
@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.3);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Boutons de couleur ronds */
.color-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid #0e100f;
  outline: none;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--btn-color, #fffce1);
  position: relative;
  /* Animation d'entrée */
  opacity: 0;
  animation: fadeInScale 0.5s ease-out forwards;
}

/* Délais d'animation pour chaque bouton */
.color-btn:nth-child(1) {
  animation-delay: 1s;
}

.color-btn:nth-child(2) {
  animation-delay: 1.15s;
}

.color-btn:nth-child(3) {
  animation-delay: 1.3s;
}

.color-btn:nth-child(4) {
  animation-delay: 1.45s;
}

.color-btn:nth-child(5) {
  animation-delay: 1.6s;
}

.color-btn:hover,
.color-btn.active {
  border-color: #fffce1;
  transform: scale(1.15);
}

.color-btn[data-color="#fffce1"] { --btn-color: #fffce1; }
.color-btn[data-color="#74d6fa"] { --btn-color: #74d6fa; }
.color-btn[data-color="#f48084"] { --btn-color: #f48084; }
.color-btn[data-color="#48fa9c"] { --btn-color: #48fa9c; }
.color-btn[data-color="#fdc54e"] { --btn-color: #fdc54e; }

/* Bouton Chamboule rond */
.chamboule-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: #808080;
  color: #0e100f;
  font-size: 2.1rem;
  border: 3px solid #808080;
  outline: none;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.5rem;
  /* Animation d'entrée */
  opacity: 0;
  animation: fadeInScale 0.5s ease-out forwards;
  animation-delay: 1.75s;
}

.chamboule-btn:hover {
  background-color: #0e100f;
  transform: scale(1.15) rotate(15deg);
}

.chamboule-btn:active {
  transform: scale(1.05) rotate(-15deg);
}

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

/* Tablettes et mobile : contrôles en ligne */
@media (max-width: 1024px) {
  .main-container {
    flex-direction: column;
    gap: 2.5rem;
    justify-content: center;
  }
  
  .controls {
    flex-direction: row;
    gap: 1.2rem;
  }
  
  /* Ajuster les délais pour l'affichage horizontal mobile */
  .chamboule-btn {
    margin-top: 0;
    margin-left: 0.5rem;
  }
}

@media (max-width: 768px) {
  .site-header {
    padding: 1rem 1.5rem;
  }
  
  .menu-label {
    font-size: 0.9rem;
    padding: 0.5rem 1.2rem;
  }
  
  .main-container {
    padding: 1.5rem;
    gap: 2rem;
  }
  
  .grid {
    --gap: 9px;
  }
  
  .cell {
    --size: 19px;
  }
  
  .color-btn,
  .chamboule-btn {
    width: 44px;
    height: 44px;
  }
}

@media (max-width: 480px) {
  .site-header {
    padding: 0.8rem 1rem;
  }
  
  .menu-label {
    font-size: 0.8rem;
    padding: 0.4rem 1rem;
    letter-spacing: 1px;
  }
  
  .main-container {
    padding: 1rem;
    gap: 1.5rem;
  }
  
  .grid {
    --gap: 7px;
  }
  
  .cell {
    --size: 15px;
  }
  
  .controls {
    gap: 0.8rem;
  }
  
  .color-btn,
  .chamboule-btn {
    width: 38px;
    height: 38px;
    border-width: 2px;
  }
  
  .chamboule-btn {
    font-size: 1.2rem;
  }
}

/* Très petits écrans */
@media (max-width: 380px) {
  .grid {
    --gap: 6px;
  }
  
  .cell {
    --size: 13px;
  }
  
  .controls {
    gap: 0.6rem;
  }
  
  .color-btn,
  .chamboule-btn {
    width: 34px;
    height: 34px;
  }
  
  .chamboule-btn {
    font-size: 1.1rem;
  }
}

/* ===================================
   OPTIMISATIONS
   =================================== */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
