/* ==========================================================================
   Le Défi Schémas · Glisser-Déposer & Légendes interactives (IFSI Mende)
   Moteur de jeu interactif multi-supports : drag & drop + sélection tactile.
   ========================================================================== */

.dg-page {
  background-color: var(--paper, #faf9f5);
  color: var(--ink, #253c36);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.dg-container {
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* En-tête du Défi */
.dg-hero {
  background: var(--white, #ffffff);
  border: 1px solid var(--line, #dedfd5);
  border-radius: var(--radius-lg, 12px);
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(37, 60, 54, 0.05);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.dg-hero-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.dg-hero-badges {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.dg-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: var(--line-subtle, #ecefe6);
  color: var(--ink-subtle, #3a504a);
  border: 1px solid var(--line, #dedfd5);
}

.dg-badge.primary {
  background: var(--green-light, #e6eee5);
  color: var(--green, #175848);
  border-color: rgba(23, 88, 72, 0.2);
}

.dg-badge.gold {
  background: var(--gold-light, #fbf6ec);
  color: var(--gold, #b17b31);
  border-color: var(--gold-border, #dfc699);
}

.dg-global-score {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--gold-hover, #8f6022);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--gold-light, #fbf6ec);
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-sm, 4px);
  border: 1px solid var(--gold-border, #dfc699);
}

.dg-hero h1 {
  font-family: var(--serif, Georgia, serif);
  font-size: clamp(1.4rem, 2.8vw, 2rem);
  font-weight: 700;
  color: var(--deep, #193f37);
  margin: 0;
  line-height: 1.25;
}

.dg-hero p.lead {
  font-size: 1rem;
  color: var(--ink-subtle, #3a504a);
  margin: 0;
  line-height: 1.5;
}

/* Barre de navigation des 7 défis */
.dg-nav {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.dg-nav::-webkit-scrollbar {
  height: 6px;
}

.dg-nav::-webkit-scrollbar-thumb {
  background: var(--line, #dedfd5);
  border-radius: 999px;
}

.dg-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  background: var(--white, #ffffff);
  border: 1px solid var(--line, #dedfd5);
  border-radius: var(--radius-md, 8px);
  color: var(--ink-subtle, #3a504a);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.18s ease;
  flex-shrink: 0;
}

.dg-tab-btn:hover {
  background: var(--paper, #faf9f5);
  border-color: var(--green, #175848);
  color: var(--green, #175848);
}

.dg-tab-btn.is-active {
  background: var(--green, #175848);
  border-color: var(--green, #175848);
  color: var(--white, #ffffff);
  box-shadow: 0 2px 6px rgba(23, 88, 72, 0.25);
}

.dg-tab-status {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: var(--line-subtle, #ecefe6);
  color: var(--muted, #65736c);
}

.dg-tab-btn.is-active .dg-tab-status {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.dg-tab-status.is-perfect {
  background: #2da44e;
  color: #ffffff;
}

.dg-tab-btn.is-locked {
  opacity: 0.75;
  background: var(--paper-warm, #f4f3ec);
  border-style: dashed;
}

.dg-tab-btn.is-locked.is-active {
  background: #334155;
  border-color: #334155;
  color: #ffffff;
  opacity: 1;
}

.dg-tab-status.is-locked {
  background: #f1f5f9;
  color: #64748b;
  font-weight: 500;
}

.dg-mode-toggle {
  background: none;
  border: 1px solid var(--line, #dedfd5);
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-subtle, #3a504a);
  cursor: pointer;
  transition: all 0.18s ease;
  margin-left: 0.5rem;
}

.dg-mode-toggle:hover {
  background: var(--paper, #faf9f5);
  color: var(--green, #175848);
  border-color: var(--green, #175848);
}

/* Carte de schéma verrouillé */
.dg-lock-card {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-lg, 12px);
  padding: 2.5rem 1.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
  margin-top: 1rem;
}

.dg-lock-icon {
  font-size: 2.8rem;
  line-height: 1;
}

.dg-lock-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}

.dg-lock-text {
  max-width: 600px;
  color: #475569;
  font-size: 0.95rem;
  line-height: 1.6;
  margin: 0;
}

.dg-lock-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.dg-lock-bypass {
  font-size: 0.82rem;
  color: #64748b;
  margin-top: 0.5rem;
}

/* Zone principale du Défi */
.dg-challenge-card {
  background: var(--white, #ffffff);
  border: 1px solid var(--line, #dedfd5);
  border-radius: var(--radius-lg, 12px);
  padding: 1.5rem;
  box-shadow: 0 4px 16px rgba(37, 60, 54, 0.06);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.dg-challenge-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  border-bottom: 1px solid var(--line-subtle, #ecefe6);
  padding-bottom: 0.75rem;
}

.dg-challenge-title-group h2 {
  font-family: var(--serif, Georgia, serif);
  font-size: 1.35rem;
  color: var(--deep, #193f37);
  margin: 0 0 0.25rem;
}

.dg-challenge-desc {
  font-size: 0.925rem;
  color: var(--muted, #65736c);
  margin: 0;
}

.dg-score-tag {
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm, 4px);
  background: var(--line-subtle, #ecefe6);
  color: var(--ink-subtle, #3a504a);
}

.dg-score-tag.is-validated {
  background: var(--green-light, #e6eee5);
  color: var(--green, #175848);
  border: 1px solid rgba(23, 88, 72, 0.2);
}

/* Canevas du schéma et zones de dépôt */
.dg-canvas-outer {
  position: relative;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  border: 1px solid var(--line, #dedfd5);
  border-radius: var(--radius-md, 8px);
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

.dg-canvas-img {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

.dg-caption {
  font-size: 0.825rem;
  color: var(--muted, #65736c);
  text-align: center;
  margin-top: 0.5rem;
  font-style: italic;
}

/* Zone de dépôt (Slot) */
.dg-drop-slot {
  position: absolute;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2px 4px;
  border-radius: 6px;
  font-family: var(--sans, Arial, sans-serif);
  font-size: clamp(0.68rem, 1.25vw, 0.88rem);
  font-weight: 700;
  line-height: 1.2;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  z-index: 5;
  cursor: pointer;
  background: #ffffff !important;
  opacity: 1 !important;
}

/* Slot vide */
.dg-drop-slot.is-empty {
  background: #ffffff !important;
  opacity: 1 !important;
  border: 2px dashed #0969da;
  color: #0969da;
  box-shadow: 0 2px 6px rgba(9, 105, 218, 0.15);
}

.dg-drop-slot.is-empty:hover {
  background: #f0f7ff !important;
  border-color: #0550ae;
  transform: scale(1.02);
}

.dg-slot-pin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
  background: #0969da;
  color: #ffffff;
  border-radius: 4px;
  padding: 0 4px;
  margin-right: 4px;
  height: 1.3em;
}

.dg-slot-placeholder {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Slot survolé pendant le drag */
.dg-drop-slot.is-dragover {
  background: #ebf5ff !important;
  opacity: 1 !important;
  border: 2px solid #0969da !important;
  box-shadow: 0 0 0 4px rgba(9, 105, 218, 0.35) !important;
  transform: scale(1.04);
}

/* Slot occupé par une étiquette */
.dg-drop-slot.is-occupied {
  background: #ffffff !important;
  opacity: 1 !important;
  border: 2px solid #253c36;
  color: #253c36;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
}

.dg-placed-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dg-remove-btn {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.1);
  border: none;
  border-radius: 999px;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: inherit;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s ease;
}

.dg-drop-slot:hover .dg-remove-btn {
  opacity: 1;
}

/* Slot validé avec succès */
.dg-drop-slot.is-correct {
  background: #175848 !important;
  opacity: 1 !important;
  border: 2px solid #103f33 !important;
  color: #ffffff !important;
  box-shadow: 0 2px 8px rgba(23, 88, 72, 0.3) !important;
}

.dg-drop-slot.is-correct::after {
  content: ' ✓';
  font-weight: 800;
  margin-left: 4px;
}

/* Slot erroné */
.dg-drop-slot.is-wrong {
  background: #fff0ee !important;
  opacity: 1 !important;
  border: 2px solid #cf222e !important;
  color: #904839 !important;
  box-shadow: 0 2px 8px rgba(207, 34, 46, 0.25) !important;
}

.dg-drop-slot.is-wrong::after {
  content: ' ✕';
  font-weight: 800;
  margin-left: 4px;
}

/* Slot en mode solution révélée (consultation) */
.dg-drop-slot.is-solution {
  background: #f8fafc !important;
  opacity: 1 !important;
  border: 2px solid #64748b !important;
  color: #1e293b !important;
  box-shadow: 0 2px 6px rgba(100, 116, 139, 0.2) !important;
}

.dg-drop-slot.is-solution::after {
  content: ' 👁️';
  font-size: 0.72rem;
  margin-left: 4px;
}

.dg-expected-tooltip {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  background: #253c36;
  color: #ffffff;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  white-space: nowrap;
  pointer-events: none;
  z-index: 20;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Banque d'étiquettes (Réserve en bas) */
.dg-bank-panel {
  background: var(--paper, #faf9f5);
  border: 1px solid var(--line, #dedfd5);
  border-radius: var(--radius-md, 8px);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.dg-bank-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink-subtle, #3a504a);
}

.dg-bank-hint {
  font-size: 0.8rem;
  font-weight: normal;
  color: var(--muted, #65736c);
}

.dg-bank-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  justify-content: center;
  min-height: 48px;
}

.dg-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  background: #ffffff;
  border: 2px solid var(--line, #dedfd5);
  border-radius: 999px;
  color: var(--ink, #253c36);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(37, 60, 54, 0.08);
  cursor: grab;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  touch-action: manipulation;
}

.dg-chip:hover {
  border-color: var(--green, #175848);
  color: var(--green, #175848);
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(23, 88, 72, 0.15);
}

.dg-chip:active {
  cursor: grabbing;
}

.dg-chip.is-dragging {
  opacity: 0.45;
  transform: scale(0.95);
}

/* Étiquette sélectionnée au clic (Tactile / iPad) */
.dg-chip.is-selected {
  background: var(--gold-light, #fbf6ec);
  border-color: var(--gold, #b17b31);
  color: var(--gold-hover, #8f6022);
  box-shadow: 0 0 0 3px rgba(177, 123, 49, 0.35);
  transform: translateY(-2px);
  animation: dgPulse 1.6s infinite;
}

@keyframes dgPulse {
  0% { box-shadow: 0 0 0 0 rgba(177, 123, 49, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(177, 123, 49, 0); }
  100% { box-shadow: 0 0 0 0 rgba(177, 123, 49, 0); }
}

.dg-chip.is-used {
  display: none;
}

/* Barre d'actions */
.dg-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding-top: 0.5rem;
}

.dg-actions-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.dg-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-sm, 4px);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
  border: 1px solid transparent;
}

.dg-btn.primary {
  background: var(--green, #175848);
  color: #ffffff;
  border-color: var(--green-hover, #103f33);
  box-shadow: 0 2px 6px rgba(23, 88, 72, 0.25);
}

.dg-btn.primary:hover:not(:disabled) {
  background: var(--green-hover, #103f33);
  transform: translateY(-1px);
}

.dg-btn.secondary {
  background: #ffffff;
  color: var(--ink-subtle, #3a504a);
  border-color: var(--line, #dedfd5);
}

.dg-btn.secondary:hover {
  background: var(--paper, #faf9f5);
  border-color: var(--muted, #65736c);
}

.dg-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* Bannière de score et rétroaction */
.dg-result-card {
  padding: 1.25rem;
  border-radius: var(--radius-md, 8px);
  border: 1px solid var(--line, #dedfd5);
  background: var(--white, #ffffff);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  animation: dgFadeIn 0.3s ease;
}

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

.dg-result-card.is-perfect {
  background: var(--green-light, #e6eee5);
  border-color: rgba(23, 88, 72, 0.3);
  color: var(--green, #175848);
}

.dg-result-card.is-partial {
  background: var(--gold-light, #fbf6ec);
  border-color: var(--gold-border, #dfc699);
  color: var(--gold-hover, #8f6022);
}

.dg-result-card.is-solution {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #1e293b;
}

.dg-result-card.is-solution h3 {
  color: #0f172a;
}

.dg-result-card.is-solution p {
  color: #475569;
}

.dg-result-text h3 {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
}

.dg-result-text p {
  margin: 0;
  font-size: 0.9rem;
}

/* Mode tactile & mobile */
@media (max-width: 768px) {
  .dg-container {
    padding: 1rem 0.5rem 2rem;
  }
  .dg-challenge-card {
    padding: 1rem;
  }
  .dg-actions-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .dg-actions-left {
    flex-direction: column;
  }
  .dg-btn {
    justify-content: center;
    width: 100%;
  }
}
