/*
 * keyboard.css
 * ------------
 * Styles du composant "Clavier de piano virtuel".
 * Conçu pour être responsive : le clavier s'adapte à la largeur du conteneur.
 *
 * Variables de dimension (modifiables si besoin) :
 *   --piano-white-key-width  : largeur d'une touche blanche
 *   --piano-white-key-height : hauteur d'une touche blanche
 */

.piano-keyboard {
  --piano-white-key-width: 56px;
  --piano-white-key-height: 200px;
  --piano-black-key-width: 34px;
  --piano-black-key-height: 128px;

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: linear-gradient(180deg, #1f2430 0%, #14171f 100%);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

/* Label affichant la note en cours de lecture */
.piano-keyboard__note-label {
  min-height: 1.4em;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: #f5c94f;
  text-transform: uppercase;
  text-shadow: 0 0 8px rgba(245, 201, 79, 0.4);
}

/* Conteneur des touches : positionnement relatif pour placer les touches noires en absolu */
.piano-keyboard__keys {
  position: relative;
  display: flex;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 4px;
  /* Empêche le "scroll bounce" gênant sur mobile pendant le jeu */
  touch-action: none;
}

/* ---------------------------------------------------------------------
   Touches blanches
--------------------------------------------------------------------- */
.piano-key--white {
  position: relative;
  flex: 0 0 var(--piano-white-key-width);
  height: var(--piano-white-key-height);
  background: linear-gradient(180deg, #ffffff 0%, #f0f0f0 100%);
  border: 1px solid #ccc;
  border-radius: 0 0 6px 6px;
  box-shadow: inset 0 -4px 6px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 8px;
  cursor: pointer;
  transition: background 0.06s ease, box-shadow 0.06s ease, transform 0.06s ease;
}

.piano-key--white + .piano-key--white {
  margin-left: -1px; /* évite les doubles bordures entre touches blanches */
}

.piano-key--white .piano-key__label {
  font-size: 0.7rem;
  color: #666;
  pointer-events: none;
}

.piano-key--white:hover {
  background: linear-gradient(180deg, #fdfdfd 0%, #e9e9e9 100%);
}

.piano-key--white.piano-key--active,
.piano-key--white:active {
  background: linear-gradient(180deg, #ffe9a8 0%, #f5c94f 100%);
  box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.2);
  transform: translateY(2px);
}

.piano-key--white.piano-key--active .piano-key__label {
  color: #6b4b00;
  font-weight: 700;
}

/* ---------------------------------------------------------------------
   Touches noires
   Positionnées en absolu par-dessus les touches blanches, décalées via
   la variable --white-key-index injectée en JS (index de la touche
   blanche juste avant la touche noire).
--------------------------------------------------------------------- */
.piano-key--black {
  position: absolute;
  top: 0;
  left: calc(
    (var(--white-key-index) + 1) * var(--piano-white-key-width) -
    (var(--piano-black-key-width) / 2)
  );
  width: var(--piano-black-key-width);
  height: var(--piano-black-key-height);
  background: linear-gradient(180deg, #3a3a3a 0%, #0b0b0b 100%);
  border-radius: 0 0 4px 4px;
  box-shadow: inset 0 -3px 4px rgba(255, 255, 255, 0.08), 0 4px 6px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 6px;
  cursor: pointer;
  z-index: 2;
  transition: background 0.06s ease, transform 0.06s ease;
}

.piano-key--black .piano-key__label {
  font-size: 0.6rem;
  color: #d8d8d8;
  pointer-events: none;
}

.piano-key--black:hover {
  background: linear-gradient(180deg, #4a4a4a 0%, #161616 100%);
}

.piano-key--black.piano-key--active,
.piano-key--black:active {
  background: linear-gradient(180deg, #f5c94f 0%, #c99a2e 100%);
  transform: translateY(2px);
}

.piano-key--black.piano-key--active .piano-key__label {
  color: #3a2900;
  font-weight: 700;
}

/* ---------------------------------------------------------------------
   Responsive : on réduit la taille des touches sur petits écrans.
--------------------------------------------------------------------- */
@media (max-width: 600px) {
  .piano-keyboard {
    --piano-white-key-width: 40px;
    --piano-white-key-height: 150px;
    --piano-black-key-width: 26px;
    --piano-black-key-height: 96px;
    padding: 10px;
  }

  .piano-keyboard__note-label {
    font-size: 0.95rem;
  }
}

@media (max-width: 400px) {
  .piano-keyboard {
    --piano-white-key-width: 32px;
    --piano-white-key-height: 130px;
    --piano-black-key-width: 20px;
    --piano-black-key-height: 82px;
  }
}
