/**
 * ============================================================================
 * Atelier TText - Styles pour l'entraînement au Clavier (Ecole Enfant-Jésus)
 * ============================================================================
 */

:root {
  --at-primary: #2563eb;
  --at-primary-dark: #1d4ed8;
  --at-primary-light: #eff6ff;
  --at-success: #16a34a;
  --at-success-light: #dcfce7;
  --at-warning: #ea580c;
  --at-warning-light: #ffedd5;
  --at-accent: #7c3aed;
  --at-text: #1e293b;
  --at-muted: #64748b;
  --at-border: #cbd5e1;
  --at-card-bg: #ffffff;
}

/* Conteneur principal */
.atelier-wrapper {
  max-width: 1060px;
  margin: 10px auto 30px auto;
  font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  color: var(--at-text);
}

/* En-tête de l'Atelier - Format compact pour voir la phrase immédiatement */
.atelier-header {
  background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
  color: white;
  border-radius: 16px;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.2);
  margin-bottom: 14px;
  gap: 16px;
  flex-wrap: wrap;
}

.atelier-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.atelier-icon {
  font-size: 26px;
  background: rgba(255, 255, 255, 0.2);
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(5px);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.atelier-title-group h2 {
  font-family: 'Fredoka', 'Nunito', sans-serif;
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 2px 0;
  color: white;
  letter-spacing: 0.3px;
}

.atelier-title-group p {
  margin: 0;
  font-size: 13px;
  color: #dbeafe;
  font-weight: 600;
}

/* Bandeau sobre gris clair pour les actions principales */
.atelier-top-bar,
.atelier-header-actions {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  flex-wrap: wrap;
}

.btn-header-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #cbd5e1;
  text-decoration: none;
  font-weight: 700;
  font-size: 13.5px;
  padding: 8px 18px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
  cursor: pointer;
}

.btn-header-link:hover {
  transform: translateY(-1px);
  background: #ffffff;
  color: #2563eb;
  border-color: #93c5fd;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.12);
}

/* Grille de sélection des Niveaux */
.levels-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 14px;
  scrollbar-width: thin;
}

.level-tab {
  flex: 1;
  min-width: 135px;
  background: white;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  padding: 8px 12px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.level-tab:hover {
  border-color: #93c5fd;
  transform: translateY(-2px);
  background: #f8fafc;
}

.level-tab.active {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.15);
}

.level-tab-num {
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  color: #64748b;
  letter-spacing: 0.5px;
}

.level-tab.active .level-tab-num {
  color: #2563eb;
}

.level-tab-name {
  font-family: 'Fredoka', 'Nunito', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.2;
}

.level-tab-preview {
  font-size: 12px;
  color: #94a3b8;
  font-family: monospace;
  font-weight: bold;
}

.level-tab.active .level-tab-preview {
  color: #3b82f6;
}

/* Zone d'exercice active */
.exercise-card {
  background: white;
  border-radius: 18px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.05);
  padding: 16px 20px;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}

.exercise-top-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 10px;
}

.exercise-level-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #dbeafe;
  color: #1e40af;
  font-weight: 800;
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 16px;
}

.exercise-progress-pill {
  font-weight: 800;
  font-size: 12px;
  color: #64748b;
  background: #f1f5f9;
  padding: 4px 12px;
  border-radius: 16px;
}

/* Boîte de la phrase à recopier */
.sentence-display-box {
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 14px;
  min-height: 75px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: text;
}

.sentence-chars {
  font-family: 'Comic Neue', 'Fredoka', cursive, sans-serif;
  font-size: 26px;
  line-height: 1.45;
  letter-spacing: 0.5px;
  text-align: center;
  user-select: none;
  word-break: break-word;
  position: relative;
  z-index: 1;
}

.char {
  display: inline-block;
  position: relative;
  border-radius: 4px;
  transition: all 0.15s ease;
  padding: 0 1px;
}

.char.space-char {
  width: 14px;
  display: inline-block;
}

.char.correct {
  color: #16a34a;
  font-weight: 700;
  background: rgba(22, 163, 74, 0.08);
}

.char.current {
  color: #1d4ed8;
  font-weight: 700;
  background: #dbeafe;
  border-bottom: 3px solid #2563eb;
  animation: pulseCurrent 1s infinite alternate;
}

.char.current.dead-key-ready {
  color: #15803d;
  background: #dcfce7;
  border-bottom: 3px solid #16a34a;
  animation: pulseDeadKey 0.8s infinite alternate;
}

@keyframes pulseCurrent {
  from { background: #dbeafe; }
  to { background: #bfdbfe; }
}

@keyframes pulseDeadKey {
  from { background: #dcfce7; }
  to { background: #bbf7d0; }
}

@keyframes pulseKey {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}

.char.pending {
  color: #64748b;
}

.char.wrong-shake {
  animation: shakeChar 0.3s ease;
  background: #fee2e2;
  color: #dc2626;
  border-bottom: 3px solid #dc2626;
}

@keyframes shakeChar {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* Zone de saisie superposée sur la phrase pour ne JAMAIS faire sauter la page au focus */
.hidden-typing-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: text;
  z-index: 2;
  pointer-events: auto;
}

/* Fiche d'aide interactive pour le Clavier AZERTY Belge */
.keyboard-helper-card {
  background: linear-gradient(135deg, #f0fdf4 0%, #e0f2fe 100%);
  border: 1.5px solid #bae6fd;
  border-radius: 14px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
  flex-wrap: wrap;
}

.helper-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.helper-icon {
  font-size: 32px;
}

.helper-text h4 {
  margin: 0 0 2px 0;
  font-size: 14px;
  font-weight: 800;
  color: #0369a1;
}

.helper-text p {
  margin: 0;
  font-size: 13px;
  color: #334155;
  font-weight: 600;
}

.helper-keys-visual {
  display: flex;
  align-items: center;
  gap: 8px;
}

.key-cap {
  background: white;
  border: 1px solid #cbd5e1;
  border-bottom: 3px solid #94a3b8;
  border-radius: 8px;
  padding: 6px 12px;
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 800;
  color: #1e293b;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
}

.key-cap.accent-key {
  border-color: #3b82f6;
  border-bottom-color: #1d4ed8;
  color: #1d4ed8;
  background: #eff6ff;
}

.key-plus {
  font-weight: 900;
  color: #64748b;
  font-size: 14px;
}

/* Barre de progression & Statistiques */
.progress-stats-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 15px;
  flex-wrap: wrap;
}

.progress-bar-outer {
  flex: 1;
  height: 12px;
  background: #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  min-width: 200px;
}

.progress-bar-inner {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #10b981);
  border-radius: 10px;
  width: 0%;
  transition: width 0.25s ease;
}

.stats-badges-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #475569;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 4px 10px;
  border-radius: 10px;
}

/* Modale / Écran de Félicitations de fin de phrase ou niveau */
.success-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.success-overlay.show {
  display: flex;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.success-modal {
  background: white;
  border-radius: 24px;
  max-width: 480px;
  width: 100%;
  padding: 32px 28px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  animation: popUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popUp {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.success-icon-trophy {
  font-size: 56px;
  margin-bottom: 12px;
  display: inline-block;
  animation: bounce 0.8s infinite alternate;
}

@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-8px); }
}

.success-modal h3 {
  font-family: 'Fredoka', sans-serif;
  font-size: 24px;
  color: #1e3a8a;
  margin: 0 0 8px 0;
}

.success-modal p {
  color: #475569;
  font-size: 15px;
  margin: 0 0 24px 0;
  line-height: 1.5;
}

.success-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-primary-action {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  border: none;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 16px;
  padding: 12px 24px;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.3);
  transition: all 0.2s ease;
}

.btn-primary-action:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(37, 99, 235, 0.4);
}

.btn-secondary-link {
  background: #f1f5f9;
  color: #1e293b;
  border: 1px solid #cbd5e1;
  text-decoration: none;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 14px;
  padding: 10px 20px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s ease;
}

.btn-secondary-link:hover {
  background: #e2e8f0;
}

.belgian-keyboard-guide {
  background: white;
  border-radius: 18px;
  border: 1px solid #e2e8f0;
  padding: 20px 24px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
}

.guide-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Fredoka', sans-serif;
  font-size: 18px;
  color: #1e3a8a;
  margin: 0 0 14px 0;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}

.guide-card-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px;
  box-sizing: border-box;
  overflow: hidden;
}

.guide-card-item h5 {
  font-size: 14px;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 6px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.guide-card-item p {
  font-size: 12px;
  color: #64748b;
  margin: 0 0 8px 0;
  line-height: 1.4;
}

.guide-card-keys {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}

.guide-card-keys .key-cap {
  padding: 3px 7px;
  font-size: 12px;
  min-width: 24px;
  line-height: 1.2;
}

.guide-card-keys .key-plus {
  font-size: 11px;
}

.key-break,
.guide-card-keys br {
  flex-basis: 100%;
  width: 100%;
  height: 4px;
  display: block;
}

.key-separator {
  display: none;
}

/* ==========================================================================
   Styles du Diplôme Officiel du Champion TText
   ========================================================================== */

/* Bouton Diplôme dans l'en-tête */
.btn-header-diploma {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white !important;
  border: 1px solid #b45309;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.25);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-header-diploma:hover {
  background: linear-gradient(135deg, #fbbf24, #d97706);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(217, 119, 6, 0.35);
}

.btn-header-diploma.unlocked {
  animation: pulseGoldBadge 2s infinite alternate;
}

@keyframes pulseGoldBadge {
  from { box-shadow: 0 4px 12px rgba(217, 119, 6, 0.25); }
  to { box-shadow: 0 4px 20px rgba(245, 158, 11, 0.6); }
}

/* Modale du Diplôme */
.diploma-overlay {
  z-index: 10005;
}

.diploma-modal-card {
  max-width: 960px;
  width: 95%;
  max-height: 94vh;
  overflow-y: auto;
  padding: 28px 32px;
  border-radius: 24px;
  position: relative;
  box-sizing: border-box;
}

.diploma-close-btn {
  position: absolute;
  top: 18px;
  right: 18px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  font-size: 18px;
  font-weight: 800;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  transition: all 0.15s ease;
}

.diploma-close-btn:hover {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fca5a5;
}

.diploma-modal-header {
  text-align: center;
  margin-bottom: 20px;
}

.diploma-modal-header h3 {
  font-family: 'Fredoka', 'Nunito', sans-serif;
  font-size: 26px;
  color: #1e3a8a;
  margin: 10px 0 8px 0;
}

.diploma-modal-header p {
  color: #475569;
  font-size: 15px;
  line-height: 1.5;
  margin: 0;
}

/* Saisie prénom / pseudo */
.diploma-input-box {
  background: linear-gradient(135deg, #f0fdf4 0%, #eff6ff 100%);
  border: 2px dashed #93c5fd;
  border-radius: 16px;
  padding: 16px 20px;
  margin-bottom: 20px;
}

.diploma-input-box label {
  display: block;
  font-family: 'Nunito', sans-serif;
  font-size: 15px;
  color: #1e3a8a;
  margin-bottom: 8px;
}

.diploma-input-group {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.diploma-student-input {
  flex: 1;
  min-width: 240px;
  padding: 12px 18px;
  font-family: 'Fredoka', 'Nunito', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: #1e3a8a;
  border: 2px solid #cbd5e1;
  border-radius: 12px;
  background: white;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.diploma-student-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.btn-apply-name {
  padding: 12px 20px;
  font-size: 15px;
  border-radius: 12px;
}

/* Prévisualisation Canvas du diplôme */
.diploma-preview-container {
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  margin-bottom: 22px;
  background: #fffbeb;
  border: 3px solid #fde68a;
  display: flex;
  justify-content: center;
  align-items: center;
}

.diploma-canvas-preview {
  width: 100%;
  height: auto;
  display: block;
  max-height: 480px;
  object-fit: contain;
}

/* Actions diplôme */
.diploma-actions-group {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

.btn-download-diploma {
  background: linear-gradient(135deg, #16a34a, #15803d);
  color: white;
  font-size: 16px;
  padding: 12px 24px;
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(22, 163, 74, 0.35);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-download-diploma:hover {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(22, 163, 74, 0.45);
}

.btn-print-diploma {
  background: #2563eb;
  color: white;
  border-color: #1d4ed8;
}

.btn-print-diploma:hover {
  background: #1d4ed8;
  color: white;
}

.btn-gold-diploma {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  box-shadow: 0 6px 18px rgba(217, 119, 6, 0.4);
}

.btn-gold-diploma:hover {
  background: linear-gradient(135deg, #fbbf24, #d97706);
}

/* Onglets de niveaux verrouillés et validés */
.level-tab.locked {
  opacity: 0.65;
  background: #f8fafc;
  border-color: #e2e8f0;
  cursor: not-allowed;
}

.level-tab.locked:hover {
  transform: none;
  box-shadow: none;
  border-color: #e2e8f0;
}

.level-tab.locked .level-tab-num {
  color: #94a3b8;
}

.level-tab.locked .level-tab-name {
  color: #64748b;
}

.level-tab.validated {
  border-color: #86efac;
  background: #f0fdf4;
}

.level-tab.validated .level-tab-num {
  color: #16a34a;
}

.level-tab.validated .level-tab-preview {
  color: #16a34a;
  font-weight: 800;
}

/* Pilule d'objectif de phrases par niveau */
.exercise-goal-pill {
  font-weight: 800;
  font-size: 12px;
  color: #15803d;
  background: #dcfce7;
  padding: 4px 12px;
  border-radius: 16px;
  border: 1px solid #bbf7d0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.exercise-goal-pill.pending {
  color: #b45309;
  background: #fef3c7;
  border-color: #fde68a;
}

/* Modale de progression du diplôme */
.diploma-progress-card {
  max-width: 580px;
  width: 92%;
  padding: 26px 28px;
  position: relative;
  text-align: center;
}

.diploma-progress-summary {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  margin-bottom: 14px;
  text-align: center;
}

.diploma-progress-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 14px 0;
  text-align: left;
}

.diploma-progress-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
}

.diploma-progress-item.done {
  background: #f0fdf4;
  border-color: #86efac;
  color: #15803d;
}

.diploma-progress-item.current {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}

.diploma-progress-item.locked {
  color: #94a3b8;
}

.diploma-badge-status {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 8px;
  font-weight: 800;
}

.diploma-badge-status.done {
  background: #dcfce7;
  color: #16a34a;
}

.diploma-badge-status.pending {
  background: #fef3c7;
  color: #d97706;
}

.diploma-badge-status.locked {
  background: #e2e8f0;
  color: #64748b;
}

/* Responsive */
@media (max-width: 768px) {
  .atelier-header {
    flex-direction: column;
    align-items: flex-start;
    padding: 18px 20px;
  }

  .sentence-chars {
    font-size: 22px;
  }

  .keyboard-helper-card {
    flex-direction: column;
    align-items: flex-start;
  }
}
