/*
 * IMMGO — Charte : glisser-déposer (poignée, élément saisi, fantôme, zones cibles, colonnes) et zone de dépôt de
 * fichiers
 * Auteur : Jacks Ngalangala
 */

/* ─── Liste réordonnable ─── */
.gd-racine {
  display: flex;
  flex-direction: column;
  gap: var(--e-3);
}
.gd-consigne {
  font-size: var(--taille-legende);
  color: var(--texte-faible);
}
.gd-zone {
  margin: 0;
  padding: 0;
  list-style: none;
}
.gd-liste {
  display: flex;
  flex-direction: column;
}
.gd-liste > .gd-element {
  display: flex;
  align-items: center;
  gap: var(--e-2);
  border-bottom: 1px solid var(--trait);
}
.gd-liste > .gd-element:last-child {
  border-bottom: 0;
}
.gd-element > .gd-contenu {
  flex: 1;
  min-width: 0;
}
.gd-outils {
  display: flex;
  align-items: center;
  gap: var(--e-1);
  flex: none;
}
.gd-ordonnable .gd-liste .gd-outils {
  padding-left: var(--e-2);
}

/* Poignée : six points ; le doigt saisit ici (le reste de l'élément laisse défiler la page). */
.gd-poignee {
  display: grid;
  place-items: center;
  width: var(--hauteur-controle-petit);
  height: var(--hauteur-controle-petit);
  border: 0;
  border-radius: var(--r-petit);
  background: transparent;
  color: var(--texte-faible);
  cursor: grab;
  touch-action: none;
}
.gd-poignee:hover {
  background: var(--surface-douce);
  color: var(--texte);
}
.gd-poignee svg {
  width: 20px;
  height: 20px;
}

/* Boutons de repli ↑/↓ : la souris glisse ; ils apparaissent au clavier (focus) et sur écran tactile, et restent
   toujours lus par les lecteurs d'écran (masquage visuel seulement, aucune place prise sinon). */
.gd-outils .btn-icone {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.gd-element:focus-within .gd-outils .btn-icone {
  position: static;
  width: var(--hauteur-controle-petit);
  height: var(--hauteur-controle-petit);
  clip: auto;
}
@media (hover: none) {
  .gd-outils .btn-icone {
    position: static;
    width: var(--hauteur-controle-petit);
    height: var(--hauteur-controle-petit);
    clip: auto;
  }
}
.carte-corps-plein > .gd-racine > .gd-consigne {
  padding: 0 var(--e-6);
}

/* ─── Grille (photos) : les outils se posent sur la vignette ─── */
.gd-grille {
  display: grid;
  gap: var(--e-3);
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
.gd-grille > .gd-element {
  position: relative;
}
.gd-grille .gd-outils {
  position: absolute;
  top: var(--e-2);
  left: var(--e-2);
  z-index: 1;
  padding: 2px;
  border-radius: var(--r-moyen);
  background: var(--surface);
  box-shadow: var(--ombre-2);
}
.gd-grille .gd-outils .btn-icone[aria-label] svg {
  transform: rotate(-90deg); /* en grille, l'ordre se lit de gauche à droite */
}

/* ─── États pendant le déplacement ─── */
.gd-en-cours,
.gd-en-cours * {
  cursor: grabbing !important;
  user-select: none;
}
.gd-element.gd-source {
  opacity: 0.35;
}
.gd-element.gd-saisi {
  opacity: 1;
  border-radius: var(--r-moyen);
  box-shadow: var(--anneau);
  background: var(--or-pale);
}
.gd-element[aria-busy='true'] {
  opacity: 0.6;
  pointer-events: none;
}
body > .gd-fantome {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  width: var(--gd-largeur);
  height: var(--gd-hauteur);
  transform: translate(var(--gd-x), var(--gd-y)) rotate(1.5deg);
  pointer-events: none;
  list-style: none;
  border-radius: var(--r-moyen);
  background: var(--surface);
  box-shadow: var(--ombre-3);
  opacity: 0.96;
}
.gd-zone.gd-cible {
  background: var(--or-pale);
  outline: 2px dashed var(--or-trait);
  outline-offset: 2px;
  border-radius: var(--r-moyen);
}
.gd-zone.gd-refus {
  outline: 2px dashed var(--trait-fort);
  outline-offset: 2px;
  border-radius: var(--r-moyen);
  cursor: not-allowed;
}

/* ─── Colonnes (pipeline) ─── */
.gd-colonnes .gd-zone {
  display: flex;
  flex-direction: column;
  gap: var(--e-2);
  min-height: 96px;
  padding: var(--e-1);
  transition: background var(--duree) var(--courbe);
}
.gd-colonnes .gd-zone:empty::after {
  content: attr(data-vide);
  display: grid;
  place-items: center;
  min-height: 80px;
  padding: var(--e-3);
  text-align: center;
  border: 1px dashed var(--trait-fort);
  border-radius: var(--r-moyen);
  color: var(--texte-faible);
  font-size: var(--taille-petit);
}
.gd-carte {
  position: relative;
}
.gd-carte > .gd-outils {
  position: absolute;
  top: var(--e-1);
  right: var(--e-1);
}
.gd-carte > .gd-outils .gd-poignee {
  width: 28px;
  height: 28px;
}
/* Bouton de repli « étape suivante » : visible au clavier et au toucher, en pastille flottante. */
.gd-carte > .gd-outils .btn-icone {
  background: var(--surface);
  box-shadow: var(--ombre-2);
}
.gd-carte:focus-within > .gd-outils .btn-icone {
  width: 28px;
  height: 28px;
}

/* ─── Zone de dépôt de fichiers ─── */
.gd-depot-cadre {
  display: block;
}
.gd-depot {
  display: flex;
  align-items: center;
  gap: var(--e-4);
  width: 100%;
  padding: var(--e-6);
  border: 1.5px dashed var(--trait-fort);
  border-radius: var(--r-grand);
  background: var(--surface-douce);
  color: var(--texte);
  text-align: left;
  transition:
    border-color var(--duree) var(--courbe),
    background var(--duree) var(--courbe);
}
.gd-depot:hover,
.gd-depot.gd-depot-survol,
.fichier-zone.gd-depot-survol {
  border-color: var(--or);
  background: var(--or-pale);
}
.gd-depot[aria-busy='true'] {
  opacity: 0.6;
  pointer-events: none;
}
.gd-depot-icone {
  display: grid;
  place-items: center;
  flex: none;
  width: var(--hauteur-controle);
  height: var(--hauteur-controle);
  border-radius: var(--r-pilule);
  background: var(--or-pale);
  color: var(--or-texte);
}
.gd-depot-texte {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.gd-depot-titre {
  font-weight: var(--graisse-moyenne);
}
.gd-depot-aide {
  color: var(--texte-second);
  font-size: var(--taille-petit);
}
.gd-depot-refus {
  color: var(--danger);
  font-size: var(--taille-petit);
}
.gd-depot-compacte {
  padding: var(--e-3) var(--e-4);
  border-radius: var(--r-moyen);
}
.gd-depot-compacte .gd-depot-icone {
  width: var(--hauteur-controle-petit);
  height: var(--hauteur-controle-petit);
}

/* ─── Composeur (deux colonnes : catalogue → sélection) ─── */
.gd-composeur-colonnes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--e-4);
}
.gd-composeur-colonne {
  padding: var(--e-3);
  background: var(--surface-douce);
  border: 1px dashed var(--trait-fort);
  border-radius: var(--r-grand);
}
.gd-composeur-colonne:last-child {
  background: var(--or-pale);
  border: 1px solid var(--or-trait);
}
.gd-composeur-tete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--e-1) var(--e-2) var(--e-3);
  font-size: var(--taille-petit);
  font-weight: var(--graisse-forte);
  color: var(--texte-second);
}
.gd-composeur-zone {
  max-height: 46vh;
  overflow-y: auto;
  min-height: 220px;
}
.gd-composeur .gd-carte > .gd-outils {
  top: 50%;
  right: auto;
  left: var(--e-1);
  transform: translateY(-50%);
}
.gd-module {
  display: flex;
  align-items: center;
  gap: var(--e-3);
  padding: var(--e-2) var(--e-2) var(--e-2) 40px;
  background: var(--surface);
  border: 1px solid var(--trait);
  border-radius: var(--r-moyen);
  box-shadow: var(--ombre-1);
}
.gd-module-texte {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  font-weight: var(--graisse-moyenne);
}
.gd-module-detail {
  font-size: var(--taille-legende);
  font-weight: var(--graisse-normale);
  color: var(--texte-second);
}
@media (max-width: 599px) {
  .gd-grille {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  }
  .gd-composeur-colonnes {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  body > .gd-fantome {
    transform: translate(var(--gd-x), var(--gd-y));
  }
}
