/* ==========================================================================
   CSS DÉDIÉ : LECTURE.PHP - Atelier de Lecture & Compréhension
   Fichier : css/lecture.css
   École de l'Enfant-Jésus - Morlanwelz
   ========================================================================== */

/* Style spécifique au Jeu de Lecture - Adapte à 100% de la largeur sans contour bleu */
  .lecture-container {
    width: 100%;
    box-sizing: border-box;
    margin: 0 0 20px 0;
    background: #ffffff;
    border-radius: 20px;
    padding: 15px 18px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.05);
    border: none;
    font-family: 'Nunito', sans-serif;
  }

  .lecture-header {
    background: linear-gradient(135deg, #62d0ff 0%, #3a86ff 100%);
    border-radius: 14px;
    padding: 10px 15px;
    color: white;
    text-align: center;
    margin-bottom: 12px;
    box-shadow: 0 4px 12px rgba(58, 134, 255, 0.25);
  }

  .lecture-header h2 {
    color: white !important;
    font-family: 'Fredoka', sans-serif;
    font-size: 20px;
    margin: 0 0 4px 0;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.2);
  }

  .lecture-header p {
    font-size: 13px;
    margin: 0;
    opacity: 0.95;
  }

  /* Onglets de sélection du sous-exercice */
  .mode-tabs-container {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
  }

  .mode-tab {
    background: #ffffff;
    border: 2px solid #cbd5e1;
    color: #475569;
    padding: 10px 20px;
    border-radius: 16px;
    font-weight: 800;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Fredoka', sans-serif;
  }

  .mode-tab:hover {
    border-color: #3a86ff;
    color: #3a86ff;
    background: #f0f7ff;
  }

  .mode-tab.active {
    background: linear-gradient(135deg, #ff9ee5 0%, #d946ef 100%);
    color: white;
    border-color: #c084fc;
    box-shadow: 0 4px 12px rgba(217, 70, 239, 0.35);
  }

  /* Barre d'options compacte */
  .options-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    padding: 8px 12px;
    margin-bottom: 12px;
  }

  .option-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
  }

  .option-label {
    font-weight: 800;
    color: #334155;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 4px;
  }

  .opt-btn {
    background: white;
    border: 2px solid #cbd5e1;
    color: #475569;
    padding: 7px 12px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
  }

  .opt-btn:hover {
    border-color: #3a86ff;
    color: #3a86ff;
    background: #f0f7ff;
  }

  .opt-btn.active {
    background: #3a86ff;
    color: white;
    border-color: #2563eb;
    box-shadow: 0 3px 8px rgba(58, 134, 255, 0.3);
  }

  .opt-btn-theme.active {
    background: #10b981;
    color: white;
    border-color: #059669;
    box-shadow: 0 3px 8px rgba(16, 185, 129, 0.3);
  }

  .opt-btn-font.active {
    background: #8b5cf6;
    color: white;
    border-color: #7c3aed;
    box-shadow: 0 3px 8px rgba(139, 92, 246, 0.3);
  }

  /* Zone des étiquettes (Réserve pour exercice 1) */
  .labels-section {
    background: #fffbeb;
    border: 2px dashed #fde047;
    border-radius: 14px;
    padding: 10px 12px;
    margin-bottom: 12px;
    text-align: center;
    position: relative;
  }

  .labels-section-title {
    font-weight: 800;
    color: #b45309;
    font-size: 14px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
  }

  .labels-pool {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    min-height: 44px;
    align-items: center;
  }

  /* Cartes Étiquettes (Mode 1) */
  .word-label {
    background: #ffffff;
    border: 2px solid #ff9ee5;
    color: #1e293b;
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 22px;
    font-weight: 800;
    cursor: grab;
    user-select: none;
    touch-action: manipulation;
    box-shadow: 0 3px 8px rgba(255, 158, 229, 0.2);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    position: relative;
  }

  .word-label:active {
    cursor: grabbing;
  }

  .word-label:hover {
    transform: translateY(-2px) scale(1.02);
    border-color: #ec4899;
  }

  .word-label.selected {
    border-color: #3a86ff !important;
    background: #eff6ff !important;
    box-shadow: 0 0 0 3px rgba(58, 134, 255, 0.4) !important;
    transform: scale(1.04);
  }

  .word-label.placed-hidden {
    opacity: 0.2;
    pointer-events: none;
    filter: grayscale(0.8);
  }

  .btn-audio-word {
    background: #f1f5f9;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
    margin-left: 2px;
  }

  .btn-audio-word:hover {
    background: #e2e8f0;
  }

  /* Styles d'écritures */
  .font-minuscule, .font-minuscule .label-text, .font-minuscule .letter-tile, .font-minuscule .letter-slot, .font-minuscule .memory-card-back {
    text-transform: lowercase;
    font-family: 'Fredoka', 'Nunito', sans-serif;
  }

  .font-majuscule, .font-majuscule .label-text, .font-majuscule .letter-tile, .font-majuscule .letter-slot, .font-majuscule .memory-card-back {
    text-transform: uppercase;
    font-family: 'Fredoka', 'Nunito', sans-serif;
  }

  /* Grille des images / photos (Mode 1 et 2) */
  .images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
  }

  .image-card {
    background: #ffffff;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    padding: 10px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.04);
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    position: relative;
  }

  .image-card:hover {
    border-color: #93c5fd;
  }

  .photo-frame {
    width: 100%;
    height: 95px;
    background: linear-gradient(180deg, #f0fdf4 0%, #e0f2fe 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    overflow: hidden;
    position: relative;
    border: 1px solid #bae6fd;
  }

  .photo-frame img {
    max-width: 92%;
    max-height: 92%;
    object-fit: contain;
    border-radius: 8px;
  }

  .photo-frame .emoji-display {
    font-size: 52px;
    line-height: 1;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.12));
    user-select: none;
  }

  .photo-frame .btn-audio-word {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  }

  /* Zone d'accueil de l'étiquette (Mode 1) */
  .drop-slot {
    width: 100%;
    min-height: 46px;
    background: #f8fafc;
    border: 2px dashed #cbd5e1;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: relative;
    cursor: pointer;
    padding: 3px;
    box-sizing: border-box;
  }

  .drop-slot.drag-over {
    background: #e0f2fe;
    border-color: #3a86ff;
  }

  .drop-slot.selected-target {
    border-color: #3a86ff;
    background: #eff6ff;
  }

  .drop-slot-placeholder {
    color: #94a3b8;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 4px;
    pointer-events: none;
  }

  .drop-slot .word-label {
    width: auto;
    margin: 0;
    padding: 5px 12px;
    font-size: 20px;
    box-shadow: none;
  }

  .btn-remove-slot {
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 11px;
    font-weight: 900;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 4px;
  }

  /* === STYLES MODE 2 : ÉCRITURE DES LETTRES === */
  .spelling-box {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
  }

  .letter-slots-row {
    display: flex;
    gap: 5px;
    justify-content: center;
    min-height: 44px;
    align-items: center;
    flex-wrap: wrap;
    width: 100%;
  }

  .letter-slot {
    width: 38px;
    height: 44px;
    background: #f8fafc;
    border: 2px dashed #cbd5e1;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 24px;
    color: #1e293b;
    cursor: pointer;
    transition: all 0.2s ease;
    box-sizing: border-box;
    position: relative;
  }

  .letter-slot.filled {
    background: #eff6ff;
    border-style: solid;
    border-color: #3a86ff;
    color: #1d4ed8;
    box-shadow: 0 2px 5px rgba(58, 134, 255, 0.2);
  }

  .letter-bank-row {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
    background: #fffbeb;
    border: 1.5px dashed #fde047;
    border-radius: 10px;
    padding: 6px;
    width: 100%;
    box-sizing: border-box;
  }

  .letter-tile {
    width: 36px;
    height: 42px;
    background: #ffffff;
    border: 2px solid #ff9ee5;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 22px;
    color: #1e293b;
    cursor: grab;
    user-select: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.06);
    transition: all 0.2s ease;
  }

  .letter-tile:active {
    cursor: grabbing;
  }

  .letter-tile:hover {
    transform: translateY(-2px);
    border-color: #ec4899;
  }

  .letter-tile.used {
    opacity: 0.2;
    pointer-events: none;
    filter: grayscale(0.8);
  }

  /* === STYLES MODE 3 : JEU DE MÉMORY (CARTES COMPACTES DE LA MOITIÉ DE LA TAILLE) === */
  .memory-grid {
    display: grid;
    gap: 8px;
    margin-bottom: 12px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
  }

  /* Niveau 1 : 3 colonnes (Max 360px) */
  .memory-grid.memory-lvl-1 {
    grid-template-columns: repeat(3, 1fr);
    max-width: 360px;
  }

  /* Niveau 2 : 4 colonnes (Max 480px) */
  .memory-grid.memory-lvl-2 {
    grid-template-columns: repeat(4, 1fr);
    max-width: 480px;
  }

  /* Niveau 3 : 6 colonnes (Max 600px) */
  .memory-grid.memory-lvl-3 {
    grid-template-columns: repeat(6, 1fr);
    max-width: 600px;
  }

  .memory-card {
    width: 100%;
    aspect-ratio: 1 / 1;
    perspective: 1000px;
    cursor: pointer;
    user-select: none;
  }

  .memory-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-style: preserve-3d;
    border-radius: 10px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.06);
  }

  .memory-card.flipped .memory-card-inner {
    transform: rotateY(180deg);
  }

  .memory-card-front, .memory-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
  }

  .memory-card-front {
    background: linear-gradient(135deg, #ffde59 0%, #ffc825 100%);
    border: 2px solid #f59e0b;
    color: #b45309;
  }

  .memory-card-front::after {
    content: "❓";
    font-size: clamp(16px, 3.5vw, 26px);
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.12));
  }

  .memory-card-back {
    background: #ffffff;
    border: 2px solid #3a86ff;
    transform: rotateY(180deg);
    padding: 4px;
  }

  .memory-card-back.card-image {
    background: linear-gradient(180deg, #f0fdf4 0%, #e0f2fe 100%);
  }

  .memory-card-back.card-word {
    background: #fffbeb;
    border-color: #ff9ee5;
    font-size: clamp(11px, 2.4vw, 17px);
    font-weight: 800;
    color: #1e293b;
    word-break: break-word;
  }

  .memory-card-back img {
    max-width: 85%;
    max-height: 85%;
    object-fit: contain;
  }

  .memory-card-back .emoji-display {
    font-size: clamp(26px, 4.5vw, 50px);
    line-height: 1;
  }

  .memory-card.matched .memory-card-inner {
    transform: rotateY(180deg);
  }

  .memory-card.matched .memory-card-back {
    border-color: #22c55e !important;
    background: #f0fdf4 !important;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.3);
  }

  .memory-card.wrong-match .memory-card-back {
    border-color: #ef4444 !important;
    background: #fef2f2 !important;
    animation: shakeCard 0.4s ease;
  }

  /* Feedback de validation */
  .image-card.correct {
    border-color: #22c55e !important;
    background: #f0fdf4 !important;
  }

  .image-card.wrong {
    border-color: #ef4444 !important;
    background: #fef2f2 !important;
  }

  .status-badge {
    position: absolute;
    top: -8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: white;
    font-weight: bold;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    z-index: 5;
  }

  .status-badge.badge-correct { background: #22c55e; }
  .status-badge.badge-wrong { background: #ef4444; }

  /* Actions bas de page */
  .actions-container {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 12px;
  }

  .btn-action {
    padding: 9px 20px;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
    border: none;
    font-family: 'Fredoka', sans-serif;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
  }

  .btn-verify {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
  }

  .btn-restart {
    background: linear-gradient(135deg, #3a86ff 0%, #2563eb 100%);
    color: white;
  }

  /* Modal de victoire */
  .modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }

  .modal-overlay.visible {
    opacity: 1;
    pointer-events: auto;
  }

  .modal-content {
    background: white;
    border-radius: 24px;
    padding: 25px 20px;
    max-width: 440px;
    width: 90%;
    text-align: center;
    border: 4px solid #ffde59;
  }

  .modal-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 26px;
    color: #16a34a;
    margin: 0 0 8px 0;
  }

  .stars-row {
    font-size: 34px;
    margin: 10px 0;
    color: #fbbf24;
  }

  .modal-message {
    font-size: 15px;
    color: #475569;
    margin-bottom: 20px;
  }

  @media screen and (max-width: 640px) {
    .lecture-container { padding: 10px; }
    .word-label { font-size: 16px; padding: 5px 10px; }
    .photo-frame { height: 85px; }
    .photo-frame .emoji-display { font-size: 42px; }
    .options-bar { flex-direction: column; align-items: stretch; }
    .option-group { justify-content: center; }
  }
