/* --- style.css --- */
:root {
    --primary-color: #006699;
    --bg-color: #f0f4f8;        /* Fond bleu-gris moderne */
    --panel-bg: #e9ecef;        
    --success-color: #00AA55;
    --error-color: #AA0055;
    --warning-color: #FF6600;
    --paper-bg: #ffffff;
    --text-color: #2c3e50;
    --prop-phy-color: #007a52;  /* Vert pour les propriétés physiques */
    --prop-chi-color: #d64a18;  /* Orange pour les propriétés chimiques */
}

body {
    font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-color);
    min-height: 100vh;
    box-sizing: border-box; /* Crucial pour que le padding n'ajoute pas de hauteur */
    overflow-x: hidden;     /* Empêche le scroll horizontal parasite */
}

h1, h2, h3 { color: var(--primary-color); text-align: center; }
h2 { margin: 10px 0; font-size: 1.5rem; }

/* --- LAYOUT --- */
.main-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    width: 100%;
    max-width: 1200px;
    justify-content: center;
    align-items: flex-start;
}

/* --- CARTES D'ÉLÉMENTS --- */
.element-card {
    width: 55px;  
    height: 55px; 
    flex-shrink: 0;
    background-color: white;
    border: 2px solid var(--primary-color);
    border-radius: 6px;
    display: flex; 
    align-items: center; 
    justify-content: center;
    font-size: 1.3em; 
    font-weight: bold; 
    color: var(--primary-color);
    cursor: grab; 
    user-select: none;
    line-height: 1;
    flex-direction: column;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.15);
    transition: transform 0.1s;
    position: relative !important; 
}
.element-card:hover { transform: scale(1.1); background-color: #f8f9fa; }


.element-mass {
    font-size: 0.55em;      /* Texte beaucoup plus petit pour la masse */
    font-weight: normal;
    color: #666;            /* Couleur plus discrète */
    margin-top: 2px;
}

/* États de validation */
.element-card.correct { border-color: var(--success-color); background-color: #e6fffa; color: var(--success-color); }
.element-card.incorrect { border-color: var(--error-color); background-color: #ffe6e6; color: var(--error-color); }
.element-card.locked {
    cursor: default; border-color: var(--success-color); color: #005522;
    transform: scale(0.9); width: 45px; height: 45px; font-size: 1.1em;
}

/* --- PANNEAU D'INFOS (ASIDE) --- */
.info-panel {
    flex: 0 0 280px;
    height: 400px; 
    overflow-y: auto; /* Garde 'auto' pour qu'elle n'apparaisse que si le texte déborde */
    background-color: var(--panel-bg);
    border: 2px solid #ccc;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.info-header {
    display: flex; align-items: center; gap: 15px;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 8px; margin-bottom: 10px;
}

#info-symbole {
    font-size: 2.2em; 
    font-weight: bold; 
    color: var(--primary-color);
    min-width: 60px; 
    text-align: center;
}

#info-nom { font-size: 1.1em; font-weight: bold; color: #333; }

.info-item { margin-bottom: 8px; border-bottom: 1px solid #ddd; padding-bottom: 4px; }

/* Ajoutez cette règle juste en dessous */
.info-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.info-label {
    font-weight: bold; font-size: 0.75em; color: #666;
    text-transform: uppercase; display: block; margin-bottom: 2px;
}

.info-value {
    display: block; color: var(--primary-color);
    font-weight: 500; font-size: 0.9em; line-height: 1.25;
}

/* Couleurs spécifiques demandées pour les propriétés */
#info-propPhy { color: var(--prop-phy-color); }
#info-propChi { color: var(--prop-chi-color); }

/* --- ZONES DE JEU --- */
.game-area { flex: 1; min-width: 350px; display: flex; flex-direction: column;}

.card-pool {
    display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;
    padding: 15px; border: 2px dashed #adb5bd; border-radius: 8px;
    min-height: 140px; background: rgba(255,255,255,0.4);
}

.slots-container, .periodic-grid {
    display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
    padding: 10px; background-color: rgba(255,255,255,0.5); border-radius: 8px;
}

.periodic-grid {
    display: grid; 
    grid-template-columns: repeat(8, 1fr); /* */
}

.slot {
    width: 55px; height: 55px;
    background-color: #fff; border: 2px solid #bbb; border-radius: 6px;
    display: flex; align-items: center; justify-content: center; position: relative;
}
/* --- RECHERCHE DES FAMILLES --- */
.test-zone {
    border: 3px solid var(--primary-color); background-color: #fff;
    min-height: 100px; border-radius: 10px;
    display: flex; justify-content: center; align-items: center;
    flex-wrap: wrap; gap: 10px; padding: 15px;
}

/* --- BOUTONS & FEEDBACK --- */
#message-box { margin-top: 10px; font-weight: bold; min-height: 1.5em; }

/* --- ORGANISATION DES FAMILLES TROUVÉES --- */

.found-zone {
    display: flex;
    flex-direction: row; /* <-- Change 'column' par 'row' */
    flex-wrap: wrap;     /* <-- Ajoute ceci pour que ça passe à la ligne si l'écran est trop petit */
    align-items: center; /* <-- C'est LA ligne magique pour centrer verticalement */
    background: rgba(255,255,255,0.5);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #ddd;
}

.found-group {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding-left: 10px; /* Espace pour la première carte */
    height: 48px;
}

/* Effet de superposition des cartes */
.found-group .element-card.locked {
    margin-left: -25px; /* Les cartes se chevauchent */
    position: relative;
    box-shadow: -3px 0 5px rgba(0,0,0,0.2);
    z-index: 1;
    transition: transform 0.2s, z-index 0s;
}

/* La première carte de la ligne n'a pas de décalage */
.found-group .element-card.locked:first-child {
    margin-left: 0;
}

/* Au survol d'une carte validée, elle passe devant */
.found-group .element-card.locked:hover {
    z-index: 10;
    transform: scale(1.1) translateY(-5px);
    cursor: pointer;
}

/* Scrollbar discrète */
.info-panel::-webkit-scrollbar { width: 6px; }
.info-panel::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

/* --- Ajouts pour Partie 3 (Grille et Quiz) --- */

/* Zone Question (Intégrée dans game-area mais visuellement distincte) */

.consigne {
    font-weight: normal;
    color: #666;
    font-size: 1em;
    font-style: italic;
}

.highlight-vacantes {
    color: #c92a2a;
    background-color: #fff5f5;
    padding: 0 4px;
    border-radius: 4px;
    font-weight: bold;
}

/* --- GRILLE MENDELEIEV --- */
.mendeleev-grid {
    display: grid;
    /* Définition précise des colonnes pour respecter l'alignement */
    /* Gr 1, 2 (60px) | Transition (flexible) | Gr 3, 4, 5, 6, 7 (60px) */
    grid-template-columns: repeat(2, 60px) 1fr repeat(5, 60px);
    gap: 5px;
    padding: 15px;
    background-color: rgba(255, 255, 255, 0.6);
    border: 1px solid #dee2e6;
    border-radius: 8px;
    align-items: center;
    overflow-x: auto;
}

/* Bloc Transition (Ti...Zn) */
.transition-container {
    display: flex;
    align-items: center;
    /* On retire justify-content: center car le texte va gérer l'espacement */
    gap: 4px; /* On peut augmenter légèrement l'écartement de base */
    background-color: #e9ecef;
    border-radius: 4px;
    padding: 2px 6px; /* Un peu de padding horizontal pour ne pas coller aux bords */
    height: 100%;
    white-space: nowrap; 
}

.transition-text {
    flex-grow: 1;       /* LA LIGNE MAGIQUE : Le texte prend tout l'espace restant */
    font-size: 0.7rem;
    text-align: center;
    color: #495057;
    line-height: 1.2;
    margin: 0 10px;     /* On écarte un peu le texte des cartes */
    white-space: normal; /* Permet au texte de se comporter normalement */
}

/* Pour réduire un peu la taille des cartes dans la transition si ça déborde */
.transition-container .element-card {
    transform: scale(0.9);
    margin: 0;
}

/* Case vide (Le trou) */
.hole-box {
    grid-column: span 2; 
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background-color: #fff5f5;
    border: 2px dashed #ffc9c9;
    color: #e03131;
    font-size: 0.8rem;
    font-weight: bold;
    border-radius: 4px;
    line-height: 1.1;
    padding: 2px;
}

/* Style pour afficher le numéro atomique Z (en rouge) */
.atomic-number {
    position: absolute;
    top: 2px;
    left: 5px;
    font-size: 0.85em;
    font-weight: bold;
    color: var(--error-color); 
    z-index: 10; /* S'assure qu'il est au-dessus */
}

/* Styles pour les cartes avec Input (Ga et Ge) */
.element-card.input-mode {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2px;
    background-color: #fff;
}

.input-symbol {
    font-weight: bold;
    font-size: 1.1em;
    margin-bottom: 2px;
    line-height: 1;
    color: var(--primary-color);
}

/* Le champ de saisie centré */
.z-input {
    width: 80%;
    border: 1px solid var(--primary-color);
    background-color: #f0f4f8; 
    text-align: center;
    font-weight: bold;
    font-size: 1rem;
    color: var(--text-color);
    padding: 2px 0;
    border-radius: 4px;
}

/* Ajustement du texte symbole pour ne pas chevaucher le Z */
.element-card .symbol-text {
    margin-top: 12px; 
    font-weight: bold;
    font-size: 1.2em;
}

/* --- Ajouts pour Partie 3_06 (Colonne manquante) --- */

.grid-missing-col {
    display: grid;
    /* 8 colonnes : 7 connues + 1 manquante */
    grid-template-columns: repeat(8, 60px); 
    gap: 5px;
    margin: 20px auto;
    justify-content: center;
    padding: 15px;
    background-color: rgba(255, 255, 255, 0.6);
    border: 1px solid #dee2e6;
    border-radius: 8px;
    width: fit-content;
}

/* Style spécifique pour la case "?" */
.element-card.missing {
    background-color: #e9ecef;
    border: 2px dashed #adb5bd;
    color: #868e96;
    font-size: 1.5rem;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: help;
    padding: 0; /* Annule le padding flex si nécessaire */
}

/* --- Ajout pour Partie 3_08 --- */
.spacer-row1 {
    grid-column: span 6; /* Prend la place de 6 colonnes */
}

/* --- Style pour les Inputs de Symboles (Partie 8) --- */

.card-input {
    width: 40px;          /* Largeur adaptée à la carte */
    font-size: 1.1rem;    /* Taille de police proche des symboles normaux */
    font-weight: bold;
    text-align: center;
    color: var(--primary-color);
    
    /* Esthétique de la boite */
    border: 1px solid #aaa;
    border-radius: 4px;
    background-color: #fcfcfc;
    
    /* Positionnement */
    margin-top: 14px;     /* IMPORTANT : Décale l'input pour laisser la place au Z en haut */
    padding: 2px 0;
    font-family: inherit;
}

/* Effet quand on clique dedans */
.card-input:focus {
    border-color: var(--primary-color);
    background-color: #fff;
    box-shadow: 0 0 4px rgba(0, 102, 153, 0.3);
    outline: none;
}

/* Nudge vertical pour corriger le décalage de la flèche de droite FontAwesome */
#global-btn-next .icon {
    transform: translateY(1px); /* Ajustez à -2px si elle vous semble encore trop basse */
}

/* Barre de navigation fixée en bas, mais centrée et de taille contenue */
#global-controls {
    position: fixed;
    bottom: 20px;          /* Laisse un petit espace esthétique en bas */
    left: 0;
    right: 0;
    margin: 0 auto !important; /* Centre la boîte horizontalement */
    width: calc(100% - 3rem);  /* Garde les marges latérales sur petit écran */
    max-width: 1344px;         /* Taille maximale du conteneur Bulma */
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2); /* Belle ombre pour l'effet flottant */
}

/* On garde le padding sur le body pour que les dernières cartes ne soient pas cachées */
body {
    padding-bottom: 100px; 
}

/* =========================================
   BOX DE CONSIGNE (Actions de l'utilisateur)
   ========================================= */
.consigne-box {
    background-color: #eef6fc !important; /* Correspond au info-light de Bulma */
    border-left: 4px solid #3298dc !important; /* Bordure bleue de mise en évidence */
}

/* =========================================
   MODIFICATIONS : CHEVAUCHEMENT ET HAUTEUR COMPACTE
   ========================================= */

/* 1. Chevauchement horizontal des familles identifiées */
.found-group {
    display: inline-flex;
    align-items: center;
    overflow: visible; /* Évite de couper les cartes au survol */
}
.found-group .element-card {
    margin: 0 0 0 -25px !important; /* Marge négative pour le chevauchement */
    position: relative;
    box-shadow: -4px 0 6px rgba(0,0,0,0.15) !important; /* Ombre portée sur la gauche */
    transition: transform 0.2s, z-index 0s;
    z-index: 1;
}
.found-group .element-card:first-child {
    margin-left: 0 !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
}
.found-group .element-card:hover {
    transform: translateY(-8px); /* Soulève la carte au survol */
    z-index: 10; /* Passe au premier plan */
}

/* 2. Compactage de l'interface pour les écrans < 750px de haut */
@media screen and (max-height: 780px) {
    /* On force la réduction des paddings et margins imposés par Bulma */
    .section { padding-top: 0rem !important; padding-bottom: 0.5rem !important; }
    header.mb-5 { margin-bottom: 0.5rem !important; }
    .title.is-2 { font-size: 1.5rem !important; margin-bottom: 0.5rem !important; }
    .subtitle.is-4 { font-size: 1.1rem !important; }
    
    /* On compacte les boites et les textes */
    .box { padding: 0.75rem !important; margin-bottom: 0.75rem !important; }
    .content p, .content ul { margin-bottom: 0.5em !important; }
    .game-area { padding: 0.75rem !important; }
    
    /* Footer et info-panel */
    #global-controls { margin-top: 0.75rem !important; padding: 0.5rem !important; }
    .info-panel { padding: 0.75rem !important; top: 10px !important; }
    .info-header { margin-bottom: 0.5rem !important; padding-bottom: 0.25rem !important; }
    .info-item { margin-bottom: 0.25rem !important; }
    
    /* Zones de drag & drop plus fines */
    .card-pool { margin-bottom: 0.5rem !important; min-height: 70px; }
    .test-zone { min-height: 80px !important; }

    .found-group { margin-bottom: 0rem !important; }

}
