/* ============================================================
   CHALLENGES.CSS - Estils de la secció Reptes multi-pas
   ============================================================
   Conte:
   1. Capçalera i estadístiques
   2. Llegenda de dificultat
   3. Graella de targetes
   4. Targeta de repte (estats: pendent, intent, resolt)
   5. Objectius, pistes, feedback de validació
   6. Solució (mode professor)
   7. Botons d'acció
   ============================================================ */

/* ------------------------------------------------------------
   1. CAPCALERA I ESTADISTIQUES
   ------------------------------------------------------------ */
.challenges-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 1.25rem;
  background: #ffffff;
  border: 1px solid #dde3ea;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.challenges-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #1a2332;
  margin-bottom: 0.2rem;
}

.challenges-subtitle {
  font-size: 0.85rem;
  color: #6b7a8d;
}

.challenges-stats {
  display: flex;
  gap: 1.5rem;
  flex-shrink: 0;
}

.ch-stat {
  text-align: center;
}

.ch-stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: #2d7d46;
  line-height: 1.2;
}

.ch-stat-label {
  font-size: 0.72rem;
  color: #6b7a8d;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}


/* ------------------------------------------------------------
   2. LLEGENDA DE DIFICULTAT
   ------------------------------------------------------------ */
.challenges-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  padding: 0.6rem 0;
}

.legend-label {
  font-size: 0.78rem;
  color: #6b7a8d;
  font-weight: 600;
  margin-right: 0.25rem;
}

/* Badge de dificultat: reutilitzat a targetes i llegenda */
.diff-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 99px;
  white-space: nowrap;
}

.diff-1 { background: #e8f5ed; color: #2d7d46; }   /* verd - bàsic */
.diff-2 { background: #e8f4fd; color: #2980b9; }   /* blau - intermedi */
.diff-3 { background: #fef9e7; color: #d68910; }   /* groc - avançat */
.diff-4 { background: #fdf2e9; color: #ca6f1e; }   /* taronja - expert */
.diff-5 { background: #f9ebea; color: #c0392b; }   /* vermell - final */


/* ------------------------------------------------------------
   3. GRAELLA DE TARGETES
   ------------------------------------------------------------ */
.challenges-grid {
  display: grid;
  /* Columna única en projector, dues en pantalla gran */
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 900px) {
  .challenges-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}


/* ------------------------------------------------------------
   4. TARGETA DE REPTE
   ------------------------------------------------------------ */
.challenge-card {
  background: #ffffff;
  border: 2px solid #dde3ea;
  border-radius: 10px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

.challenge-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

/* Estat: resolt */
.challenge-card.ch-solved {
  border-color: #2d7d46;
  background: linear-gradient(to bottom right, #f0faf4, #ffffff);
}

/* Estat: intentat però no resolt */
.challenge-card.ch-attempted {
  border-color: #e67e22;
  background: linear-gradient(to bottom right, #fef9f0, #ffffff);
}


/* Capçalera interna de la targeta */
.ch-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ch-card-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ch-number {
  font-size: 0.72rem;
  font-weight: 700;
  color: #6b7a8d;
  font-family: 'Cascadia Code', 'Consolas', monospace;
}

.ch-status-icon {
  font-size: 1.3rem;
}

/* Títol del repte */
.ch-title {
  font-size: 1rem;
  font-weight: 700;
  color: #1a2332;
  line-height: 1.3;
}

/* Escenari narratiu */
.ch-scenario {
  font-size: 0.88rem;
  color: #4a5568;
  line-height: 1.6;
  padding: 0.6rem 0.8rem;
  background: #f8fafc;
  border-left: 3px solid #dde3ea;
  border-radius: 0 6px 6px 0;
}


/* ------------------------------------------------------------
   5a. OBJECTIUS
   ------------------------------------------------------------ */
.ch-section-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b7a8d;
  margin-bottom: 0.4rem;
}

.ch-objectives {
  /* contenidor */
}

.ch-obj-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  counter-reset: obj-counter;
}

.ch-obj-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: #1a2332;
  line-height: 1.5;
  counter-increment: obj-counter;
}

.ch-obj-item::before {
  content: counter(obj-counter);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4rem;
  height: 1.4rem;
  background: #e8f5ed;
  color: #2d7d46;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 0.05em;
}


/* ------------------------------------------------------------
   5b. FEEDBACK DE VALIDACIO
   ------------------------------------------------------------ */
.ch-feedback {
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
}

.ch-fb-ok {
  background: #e8f5ed;
  border: 1px solid #2d7d46;
}

.ch-fb-error {
  background: #fdf5f5;
  border: 1px solid #e67e22;
}

.ch-fb-summary {
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: #1a2332;
}

.ch-fb-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.ch-fb-item {
  font-size: 0.82rem;
  padding: 0.1rem 0;
}

.ch-fb-pass { color: #1e5c32; }
.ch-fb-fail { color: #922b21; }


/* ------------------------------------------------------------
   5c. PISTES
   ------------------------------------------------------------ */
.ch-hints-section {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.ch-hints-container {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.ch-hint-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: 0.45rem 0.7rem;
  font-size: 0.83rem;
  color: #78350f;
  animation: hint-appear 300ms ease;
}

@keyframes hint-appear {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ch-hint-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.3rem;
  height: 1.3rem;
  background: #f59e0b;
  color: white;
  border-radius: 50%;
  font-size: 0.68rem;
  font-weight: 700;
  flex-shrink: 0;
}

.ch-hint-text {
  font-family: 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.82rem;
  line-height: 1.5;
}


/* ------------------------------------------------------------
   6. SOLUCIO (mode professor)
   ------------------------------------------------------------ */
.ch-solution {
  padding: 0.75rem;
  background: #fff8e1;
  border: 1px dashed #f39c12;
  border-radius: 8px;
}

.ch-solution-label {
  color: #d68910;
}

.ch-solution-cmds {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-top: 0.4rem;
}

.ch-solution-line {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 0.82rem;
  padding: 0.25rem 0.5rem;
  background: #1a2332;
  border-radius: 4px;
  color: #a8d8a8;
}

.ch-sol-prompt {
  color: #4ecdc4;
  font-weight: 700;
  flex-shrink: 0;
}

.ch-sol-cmd {
  color: #a8d8a8;
}

.ch-autorun-btn {
  margin-top: 0.5rem;
  padding: 0.4rem 0.8rem;
  background: #f39c12;
  color: #1a2332;
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 200ms ease;
}

.ch-autorun-btn:hover {
  background: #e67e22;
}


/* ------------------------------------------------------------
   7. BOTONS D'ACCIO
   ------------------------------------------------------------ */
.ch-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.25rem;
}

/* Botó "Obre terminal" */
.ch-terminal-btn {
  padding: 0.45rem 0.85rem;
  background: #1a2332;
  color: #4ecdc4;
  border: 1px solid #4ecdc4;
  border-radius: 6px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 200ms ease;
  font-family: 'Cascadia Code', 'Consolas', monospace;
}

.ch-terminal-btn:hover {
  background: #4ecdc4;
  color: #1a2332;
}

/* Botó "Pista" */
.ch-hint-btn {
  padding: 0.45rem 0.85rem;
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: 6px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 200ms ease;
}

.ch-hint-btn:hover:not(:disabled) {
  background: #fde68a;
  color: #78350f;
}

.ch-hint-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Botó "Comprova" */
.ch-check-btn {
  padding: 0.45rem 0.9rem;
  background: #2d7d46;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 200ms ease;
}

.ch-check-btn:hover {
  background: #1e5c32;
}

/* Botó "Reinicia simulador" */
.ch-reset-btn {
  padding: 0.45rem 0.85rem;
  background: #f8fafc;
  color: #6b7a8d;
  border: 1px solid #dde3ea;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 200ms ease;
  margin-left: auto;
}

.ch-reset-btn:hover {
  background: #fdf5f5;
  color: #c0392b;
  border-color: #c0392b;
}
