/* Fichier : style.css */

/* --- RESET & BASE --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
    background-color: #fdfbf7; 
    color: #333;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    padding: 40px 20px;
}

/* --- TAILLE DE LA GRILLE --- */
:root {
    --cell-size: 72px;
}

/* --- TITRE --- */
h1 {
    color: #0077b5;
    font-size: 3.5rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 60px;
    letter-spacing: -1px;
}

/* --- GRILLE DES JEUX (ACCUEIL) --- */
.games-container {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
    max-width: 1000px;
    width: 100%;
}

/* --- CARTE DE JEU --- */
.game-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    width: 280px;
    height: 320px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    transition: transform 0.2s ease;
}

.game-card:hover {
    transform: translateY(-5px);
}

.game-title {
    font-size: 2rem;
    font-weight: 700;
    color: #333;
    margin-top: auto;
    margin-bottom: auto;
}

/* --- BOUTONS --- */
.btn {
    padding: 12px 30px;
    border-radius: 50px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.3s;
    border: none;
    cursor: pointer;
    width: 100%;
    text-align: center;
    margin-bottom: 10px;
}

.btn-play {
    background-color: #0077b5;
    color: white;
}

.btn-play:hover {
    background-color: #005e93;
}

.btn-soon {
    background-color: #e0e0e0;
    color: #888;
    cursor: not-allowed;
}

.game-card.disabled {
    opacity: 0.7;
    background-color: #f4f4f4;
}

.game-card.disabled .game-title {
    color: #888;
}

/* --- TOOLTIPS & ICONES --- */
.help-icon {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid #ccc;
    color: #888;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    cursor: help;
    transition: all 0.2s;
    z-index: 10;
}

.help-icon:hover {
    border-color: #0077b5;
    color: #0077b5;
    background-color: #eef3f8;
}

.tooltip {
    visibility: hidden;
    opacity: 0;
    width: 220px;
    background-color: #333;
    color: #fff;
    text-align: left;
    border-radius: 8px;
    padding: 10px 15px;
    position: absolute;
    top: 50px;
    right: 10px;
    z-index: 20;
    font-size: 0.85rem;
    line-height: 1.4;
 /* transition: opacity 0.3s; */
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.tooltip::after {
    content: "";
    position: absolute;
    bottom: 100%;
    right: 12px;
    border-width: 6px;
    border-style: solid;
    border-color: transparent transparent #333 transparent;
}

.help-icon:hover + .tooltip {
    visibility: visible;
    opacity: 1;
}

/* --- SWITCH LANGUE --- */
.lang-switch-container {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: bold;
    color: #555;
    font-size: 0.9rem;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #0077b5;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

/* --- STYLE SPÉCIFIQUE TANGO --- */

.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 500px;
    margin: 0 auto 20px auto;
    padding: 0 10px;
}

.back-link {
    text-decoration: none;
    color: #666;
    font-weight: bold;
    font-size: 0.9rem;
    transition: color 0.2s;
}
.back-link:hover { color: #0077b5; }

.timer-container {
    background: white;
    padding: 5px 12px;
    border-radius: 20px;
    border: 1px solid #ccc;
    font-family: monospace;
    font-size: 1.1rem;
    color: #0077b5;
    font-weight: bold;
}

.game-header .lang-switch-container {
    position: static;
    margin: 0;
}

.game-page-title {
    font-size: 2.5rem;
    color: #0077b5;
    margin-bottom: 10px;
}

.game-subtitle {
    margin-bottom: 30px;
    color: #666;
    font-size: 0.9rem;
}

/* --- LA GRILLE AGRANDIE --- */
.tango-grid {
    display: grid;
    /* On utilise la variable --cell-size (72px) au lieu de 60px */
    grid-template-columns: repeat(6, var(--cell-size) 0);
    grid-template-rows: repeat(6, var(--cell-size) 0);
    
    gap: 0;
    margin: 20px auto 30px auto;
    width: fit-content;
    
    border: 2px solid #ccc;
    background-color: #ccc; 
    box-shadow: none; 
    border-radius: 0;
}

.cell {
    width: var(--cell-size);
    height: var(--cell-size);
    background-color: white;   /* Fond blanc par défaut */
    border: 1px solid #e0e0e0;
    border-radius: 0;
    
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem; /* Taille Emoji */
    cursor: pointer;
    user-select: none;
    position: relative;
    z-index: 1;
}

/* SOLEIL et LUNE */
.cell.sun { 
    background-color: white;
    color: inherit;
} 
.cell.moon { 
    background-color: white; /* Plus de bleu pâle */
    color: inherit;
}

/* On garde le gris SEULEMENT pour les cases verrouillées (indices) */
.cell.locked { 
    background-color: #eee; 
    cursor: not-allowed; 
    color: #888; 
    opacity: 0.6; /* Légèrement transparent pour différencier */
}


/* --- TANGO : CONTRAINTES (= et x) --- */
.constraint {
    width: 0;
    height: 0;
    position: relative;
    z-index: 20; 
    overflow: visible; 
    place-self: center; 
}

.constraint::after {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    background-color: white;
    border-radius: 50%;
    border: 1px solid #e0e0e0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-family: sans-serif;
}

.constraint.equal::after { content: "="; color: #0077b5; font-size: 16px; padding-bottom: 2px; }
.constraint.cross::after { content: "×"; color: #d9534f; font-size: 12px; }


/* --- RESPONSIVE MOBILE --- */
@media (max-width: 500px) {
    :root {
        /* Sur mobile, on calcule pour que ça prenne toute la largeur moins les marges */
        /* Ecrase le 72px automatiquement si l'écran est petit */
        --cell-size: calc((100vw - 30px) / 6); 
    }
    .tango-grid {
        grid-template-columns: repeat(6, var(--cell-size) 0);
        grid-template-rows: repeat(6, var(--cell-size) 0);
    }
    .cell { width: var(--cell-size); height: var(--cell-size); font-size: 1.5rem; }
    
    .zip-checkpoint { width: 24px; height: 24px; font-size: 12px; border-width: 1.5px; }
    .constraint::after { width: 16px; height: 16px; font-size: 10px; }
    .constraint.equal::after { font-size: 14px; }
}

/* POPUP VICTOIRE */
.victory-modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.victory-modal.hidden { display: none; }

.victory-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}
.victory-content h2 { color: #0077b5; margin-bottom: 10px; }
.victory-content button { margin-top: 20px; }

.controls {
    display: flex;
    flex-direction: row;
    gap: 15px;
    justify-content: center;
    width: 100%;
    max-width: 500px;
    margin-top: 20px;
}

.controls .btn {
    flex: 1;
    margin: 0;
}

.btn-reset {
    background-color: transparent;
    border: 2px solid #d9534f;
    color: #d9534f;
    font-weight: bold;
}

.btn-reset:hover {
    background-color: #fff5f5;
    border-color: #c9302c;
    color: #c9302c;
}

/* --- AJOUTS POUR UI MOBILE --- */

/* Classe pour forcer l'affichage via JS (Mobile) */
.tooltip.visible {
    visibility: visible;
    opacity: 1;
    z-index: 100; /* S'assurer qu'il passe au-dessus */
}

/* Style de la petite croix de fermeture */
.tooltip-close-btn {
    display: none; /* Caché par défaut sur PC */
    position: absolute;
    top: 5px;
    right: 8px;
    color: #fff;
    font-weight: bold;
    font-size: 16px;
    cursor: pointer;
    line-height: 1;
    opacity: 0.8;
}

/* Sur mobile (ou écrans tactiles), on affiche la croix et on ajuste un peu */
@media (hover: none), (max-width: 768px) {
    .tooltip-close-btn {
        display: block; /* Afficher la croix sur mobile */
    }
    
    .tooltip {
        padding-right: 25px; /* Faire de la place pour la croix */
        width: 260px; /* Un peu plus large sur mobile */
    }

    /* Désactiver l'effet hover natif CSS qui peut être "collant" sur mobile */
    .help-icon:hover + .tooltip {
        visibility: hidden;
        opacity: 0;
    }
    /* Seule la classe .visible (ajoutée par JS) doit l'afficher */
    .help-icon:hover + .tooltip.visible {
        visibility: visible;
        opacity: 1;
    }
}

/* --- LE CANVAS --- */
#canvas-container {
    width: 100%;
    max-width: 450px; /* Ou la taille max souhaitée */
    margin: 0 auto;
    /* Ratio carré pour le conteneur */
    aspect-ratio: 1 / 1; 
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 10px; /* Optionnel : coins arrondis globaux */
    touch-action: none; /* CRUCIAL : Empêche le scroll sur mobile */
}

@media (max-width: 600px) {
    /* 1. On change le comportement du conteneur de langue */
    .lang-switch-container {
        position: relative; /* On enlève le 'absolute' */
        top: auto;
        right: auto;
        
        /* On le centre */
        justify-content: center;
        margin: 0 auto 40px auto; /* 40px de marge en bas pour séparer des jeux */
        width: 100%;
    }

    /* 2. On réduit la marge sous le titre (h1) pour rapprocher le bouton */
    h1 {
        margin-bottom: 20px; /* Au lieu de 60px */
        margin-top: 10px;
    }
}