/**
 * tic-tac-toe.css — Styles dédiés au jeu Tic Tac Toe (Morpion)
 * Chargé automatiquement via $gameCssFile = 'tic-tac-toe.css' dans head.php
 * Bootstrap 5 + games.css sont chargés en priorité — ajouter ici UNIQUEMENT
 * les composants propres à ce jeu.
 */

/* ── Grille 3×3 ─────────────────────────────────────────────────────────────── */
.ttt-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .6rem;
    max-width: 340px;
    margin: 0 auto 1.25rem;
    padding: .75rem;
    background: var(--bg-soft, #f6f7fb);
    border-radius: 14px;
    border: 1px solid var(--line, #e5e7eb);
    user-select: none;
}

/* ── Cellule individuelle ───────────────────────────────────────────────────── */
.ttt-cell {
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface, #fff);
    border: 2px solid var(--line, #e5e7eb);
    border-radius: 10px;
    font-size: 2.4rem;
    font-weight: 900;
    cursor: pointer;
    transition: background .18s ease, border-color .18s ease, transform .12s ease;
    position: relative;
    overflow: hidden;
    outline: none;
    color: var(--text, #111);
    line-height: 1;
}

.ttt-cell:hover:not(.ttt-cell--x):not(.ttt-cell--o) {
    background: var(--bg-soft, #f0f2ff);
    border-color: #6366f1;
    transform: scale(1.04);
}

.ttt-cell:focus-visible {
    outline: 3px solid #6366f1;
    outline-offset: 2px;
}

/* ── Marqueurs X et O ──────────────────────────────────────────────────────── */
.ttt-cell--x {
    color: #ef4444;
    border-color: #ef4444;
    background: rgba(239, 68, 68, .06);
    cursor: default;
    animation: ttt-pop .22s ease;
}

.ttt-cell--o {
    color: #3b82f6;
    border-color: #3b82f6;
    background: rgba(59, 130, 246, .06);
    cursor: default;
    animation: ttt-pop .22s ease;
}

/* ── Cellules gagnantes (mise en évidence) ─────────────────────────────────── */
.ttt-cell--winning {
    animation: ttt-win-pulse .55s ease forwards;
    border-width: 3px;
    z-index: 1;
}

.ttt-cell--x.ttt-cell--winning {
    background: rgba(239, 68, 68, .18);
    border-color: #ef4444;
    box-shadow: 0 0 18px rgba(239, 68, 68, .35);
}

.ttt-cell--o.ttt-cell--winning {
    background: rgba(59, 130, 246, .18);
    border-color: #3b82f6;
    box-shadow: 0 0 18px rgba(59, 130, 246, .35);
}

/* ── Ligne gagnante — overlay diagonal/horizontal/vertical ─────────────────── */
.ttt-board--won .ttt-cell:not(.ttt-cell--winning) {
    opacity: .45;
    transform: scale(.97);
    transition: opacity .3s ease, transform .3s ease;
}

/* ── Badge tour actuel ─────────────────────────────────────────────────────── */
.ttt-turn-badge {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .3rem .9rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: .92rem;
    transition: background .25s ease, color .25s ease;
}

.ttt-turn-badge--x {
    background: rgba(239, 68, 68, .12);
    color: #ef4444;
    border: 1.5px solid rgba(239, 68, 68, .35);
}

.ttt-turn-badge--o {
    background: rgba(59, 130, 246, .12);
    color: #3b82f6;
    border: 1.5px solid rgba(59, 130, 246, .35);
}

/* ── Sélecteur mode IA / 2 Joueurs ─────────────────────────────────────────── */
.ttt-mode-btn {
    min-width: 130px;
}

/* ── Tableau des scores ─────────────────────────────────────────────────────── */
.ttt-scoreboard {
    display: flex;
    gap: .5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.ttt-score-item {
    flex: 1 1 90px;
    text-align: center;
    padding: .55rem .5rem;
    border-radius: 10px;
    border: 1.5px solid var(--line, #e5e7eb);
    background: var(--bg-soft, #f6f7fb);
    min-width: 80px;
    max-width: 120px;
}

.ttt-score-label {
    display: block;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 700;
    color: var(--muted, #6b7280);
    margin-bottom: .1rem;
}

.ttt-score-value {
    display: block;
    font-size: 1.7rem;
    font-weight: 900;
    line-height: 1;
}

.ttt-score-item--x .ttt-score-value { color: #ef4444; }
.ttt-score-item--draw .ttt-score-value { color: var(--muted, #6b7280); }
.ttt-score-item--o .ttt-score-value { color: #3b82f6; }

/* ── Animations ─────────────────────────────────────────────────────────────── */
@keyframes ttt-pop {
    0%   { transform: scale(.6); opacity: .5; }
    60%  { transform: scale(1.12); }
    100% { transform: scale(1);   opacity: 1; }
}

@keyframes ttt-win-pulse {
    0%   { transform: scale(1); }
    30%  { transform: scale(1.15); }
    60%  { transform: scale(1.05); }
    100% { transform: scale(1.1); }
}

/* ── IA en réflexion ────────────────────────────────────────────────────────── */
.ttt-thinking {
    font-size: .82rem;
    color: var(--muted, #6b7280);
    font-style: italic;
    min-height: 1.4rem;
    text-align: center;
    transition: opacity .2s ease;
}

.ttt-thinking::after {
    content: '…';
    animation: ttt-dots 1s steps(3, end) infinite;
}

@keyframes ttt-dots {
    0%   { clip-path: inset(0 66% 0 0); }
    33%  { clip-path: inset(0 33% 0 0); }
    66%  { clip-path: inset(0 0 0 0); }
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 400px) {
    .ttt-board {
        max-width: 280px;
        gap: .45rem;
    }
    .ttt-cell {
        font-size: 2rem;
        border-radius: 8px;
    }
}

/* ── Dark mode ──────────────────────────────────────────────────────────────── */
[data-theme="dark"] .ttt-board {
    background: #1a1d29;
    border-color: #2a2f3e;
}

[data-theme="dark"] .ttt-cell {
    background: #232735;
    border-color: #2f3445;
    color: #f1f5f9;
}

[data-theme="dark"] .ttt-cell:hover:not(.ttt-cell--x):not(.ttt-cell--o) {
    background: #2a2f45;
    border-color: #6366f1;
}

[data-theme="dark"] .ttt-cell--x { background: rgba(239, 68, 68, .12); }
[data-theme="dark"] .ttt-cell--o { background: rgba(59, 130, 246, .12); }

[data-theme="dark"] .ttt-score-item {
    background: #232735;
    border-color: #2f3445;
}

[data-theme="dark"] .ttt-turn-badge--x { background: rgba(239, 68, 68, .18); }
[data-theme="dark"] .ttt-turn-badge--o { background: rgba(59, 130, 246, .18); }
