/**
 * Zikordle - Film - Styles
 */

/* Input mobile — visible sur mobile, caché sur desktop */
.mobile-input {
    display: none;
}

@media (max-width: 768px) {
    .mobile-input {
        display: block;
        width: 100%;
        max-width: 400px;
        margin: 0 auto 12px;
        padding: 14px 20px;
        font-size: 1.1rem;
        font-weight: 600;
        text-transform: uppercase;
        text-align: center;
        letter-spacing: 8px;
        background: rgba(255,255,255,0.06);
        border: 2px solid #fbf2dd;
        border-radius: 12px;
        color: var(--text-primary, #fbf2dd);
        outline: none;
        -webkit-appearance: none;
    }
    .mobile-input:focus {
        border-color: #2b2bff;
        box-shadow: 4px 4px 0 #000;
    }
    .mobile-input::placeholder {
        letter-spacing: 2px;
        font-size: 0.85rem;
        opacity: 0.5;
    }
    /* Cacher le clavier virtuel sur mobile */
    .keyboard {
        display: none !important;
    }
}

/* Header uniforme */
.main-header {
    background-color: var(--bg-secondary);
    color: var(--text-white);
    padding: var(--spacing-md) var(--spacing-xl);
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-lg);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--text-white);
    text-decoration: none;
}

.logo:hover {
    opacity: 0.8;
}

.nav-links {
    display: flex;
    gap: var(--space-md);
    list-style: none;
    margin: 0;
    padding: 0;
    align-items: center;
}

.nav-links li {
    margin: 0;
}

.nav-links a {
    color: var(--text-white);
    text-decoration: none;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
    font-weight: 500;
}

.nav-links a:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

#user-status {
    color: var(--text-white);
    font-size: var(--font-size-sm);
    padding: var(--space-sm) var(--space-md);
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-md);
}

.btn-theme-toggle,
.btn-icon {
    background-color: transparent;
    color: var(--text-white);
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: var(--space-sm);
    border-radius: var(--radius-lg);
    font-size: var(--font-size-xl);
    cursor: pointer;
    transition: all var(--transition-normal);
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-theme-toggle:hover,
.btn-icon:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
}

/* Countdown */
.countdown-timer {
    background: rgba(43, 43, 255, 0.12);
    border-bottom: 2px solid #2b2bff;
    padding: var(--space-md);
    text-align: center;
}

.countdown-timer.hidden {
    display: none;
}

.countdown-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
}

.countdown-label {
    font-weight: 600;
    color: var(--text-primary);
}

.countdown-display {
    font-family: var(--font-mono);
    font-size: 1.25rem;
    font-weight: 700;
    color: #2b2bff;
}

/* Game Container */
.game-container {
    min-height: calc(100vh - 200px);
    padding: var(--space-xl) 0;
    background: #17151f;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 var(--space-md);
}

.game-header-section {
    text-align: center;
    margin-bottom: var(--space-2xl);
}

.game-title {
    font-family: 'Bricolage Grotesque', sans-serif;
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: var(--space-sm);
    color: #ffd23f;
    text-shadow: 3px 3px 0 #000;
}

.game-subtitle {
    color: var(--text-secondary);
    font-size: 1.125rem;
}

/* Wordle Grid */
.wordle-grid {
    /* --cols est posé par game.js selon la longueur du titre du jour (5 à 8) */
    --cols: 5;
    --cell: 72px;
    display: grid;
    grid-template-columns: repeat(var(--cols), 1fr);
    gap: var(--space-sm);
    margin-bottom: var(--space-2xl);
    max-width: min(96vw, calc(var(--cols) * var(--cell) + (var(--cols) - 1) * var(--space-sm)));
    margin-left: auto;
    margin-right: auto;
}

.wordle-row {
    display: contents;
}

.wordle-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Bricolage Grotesque', sans-serif;
    font-size: 1.5rem;
    font-weight: 800;
    border: 2px solid #fbf2dd;
    border-radius: var(--radius-md);
    background: #241f33;
    color: #fbf2dd;
    text-transform: uppercase;
    transition: all 0.3s ease;
    animation: popIn 0.3s ease;
}

.wordle-cell.filled {
    border-color: #fbf2dd;
    background: #2d2740;
}

/* Case donnée (trait d'union) : acquise dès le départ, jamais saisie ni colorée */
.wordle-cell.given {
    background: #17131f;
    border-color: rgba(251, 242, 221, .35);
    color: rgba(251, 242, 221, .55);
    animation: none;
}

.wordle-cell.correct {
    background: #16c08a;
    border-color: #000;
    color: #1a1a1a;
    animation: flip 0.6s ease;
}

.wordle-cell.present {
    background: #ffd23f;
    border-color: #000;
    color: #1a1a1a;
    animation: flip 0.6s ease;
}

.wordle-cell.absent {
    background: #3a3550;
    border-color: #000;
    color: #fbf2dd;
    animation: flip 0.6s ease;
}

.wordle-cell.current {
    border-color: #2b2bff;
    box-shadow: 4px 4px 0 #2b2bff;
}

/* Keyboard */
.keyboard {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    margin-bottom: var(--space-xl);
}

.keyboard-row {
    display: flex;
    gap: var(--space-xs);
    justify-content: center;
}

.key {
    flex: 1;
    min-width: 30px;
    padding: var(--space-md) var(--space-sm);
    background: #2d2740;
    border: 2px solid #fbf2dd;
    border-radius: var(--radius-md);
    color: #fbf2dd;
    font-weight: 700;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
}

.key:hover {
    background: #3a3550;
    transform: translateY(-2px);
}

.key:active {
    transform: translateY(0);
}

.key.correct {
    background: #16c08a;
    border-color: #000;
    color: #1a1a1a;
}

.key.present {
    background: #ffd23f;
    border-color: #000;
    color: #1a1a1a;
}

.key.absent {
    background: #3a3550;
    border-color: #000;
    color: #fbf2dd;
}

.key.wide {
    flex: 2;
    font-size: 0.75rem;
}

/* Touche ENTRÉE (à droite) — accent vert pour la repérer d'un coup d'œil */
.key.key-enter {
    border-color: #16c08a;
    color: #16c08a;
}
.key.key-enter:hover {
    background: #16c08a;
    color: #1a1a1a;
}

/* Film Hint */
.film-hint {
    text-align: center;
    padding: 12px 20px;
    margin: 12px auto;
    max-width: 400px;
    background: #ffd23f;
    border: 2px solid #000;
    box-shadow: 4px 4px 0 #000;
    border-radius: 12px;
    animation: fadeIn 0.3s ease;
}

.film-hint.hidden {
    display: none;
}

.hint-icon {
    font-size: 1.2rem;
    margin-right: 8px;
}

.hint-text {
    color: #1a1a1a;
    font-weight: 700;
    font-size: 0.9rem;
}

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

/* Stats */
.stats-section {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
    margin-top: var(--space-xl);
}

.stat-card {
    background: #241f33;
    border: 2px solid #fbf2dd;
    box-shadow: 4px 4px 0 #000;
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    text-align: center;
}

.stat-value {
    font-family: 'Bricolage Grotesque', sans-serif;
    font-size: 2rem;
    font-weight: 800;
    color: #ff5da2;
    margin-bottom: var(--space-xs);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: var(--space-md);
}

.modal-overlay.hidden {
    display: none;
}

/* ── Centrage BULLETPROOF de l'écran de fin ──────────────────────────
 * Le sélecteur d'ID (#end-game-modal) bat les règles .modal-overlay/.modal
 * partagées (components.css), quel que soit l'ordre de chargement ou le cache.
 * Corrige le modal « décalé » (non centré) sur desktop et mobile. */
#end-game-modal.modal-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-md);
    z-index: 10000;
}
#end-game-modal.modal-overlay.hidden { display: none; }
#end-game-modal .modal {
    margin: auto;            /* filet de centrage même hors flex */
    max-height: 90vh;
    overflow-y: auto;
    /* anime depuis le centre : pas de décalage résiduel */
    transform-origin: center center;
}

.modal {
    background: #241f33;
    border: 2px solid #fbf2dd;
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 8px 8px 0 #000;
}

.modal-close {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    background: transparent;
    border: none;
    font-size: 2rem;
    color: var(--text-primary);
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.modal-content h2 {
    margin-bottom: var(--space-lg);
    color: var(--text-primary);
}

.help-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.help-item h3 {
    font-family: 'Bricolage Grotesque', sans-serif;
    font-weight: 700;
    margin-bottom: var(--space-sm);
    color: #ff5da2;
}

.color-legend {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-top: var(--space-md);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.legend-box {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #000;
    border-radius: var(--radius-md);
    font-weight: 800;
    color: #1a1a1a;
}

.legend-box.correct {
    background: #16c08a;
}

.legend-box.present {
    background: #ffd23f;
}

.legend-box.absent {
    background: #3a3550;
    color: #fbf2dd;
}

/* Animations */
@keyframes popIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes flip {
    0% { transform: rotateX(0); }
    50% { transform: rotateX(90deg); }
    100% { transform: rotateX(0); }
}

.cell-flip {
    animation: flip 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

.row-shake {
    animation: shake 0.4s ease;
}

@keyframes confetti-fall {
    0% { transform: translateY(-100vh) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

.confetti-piece {
    position: fixed;
    top: 0;
    width: 10px;
    height: 10px;
    z-index: 99999;
    pointer-events: none;
    animation: confetti-fall 3s ease-in forwards;
}

/* Responsive */
@media (max-width: 768px) {
    .main-header { display: none !important; } /* Replaced by game-header */

    .game-container { padding: 8px 0 4px; min-height: auto; }
    .game-header-section { margin-bottom: 8px; }

    .game-title {
        font-size: 1.4rem;
        margin-bottom: 2px;
    }
    .game-subtitle {
        font-size: 0.78rem;
        margin-bottom: 0;
    }

    /* Grid compact : cells qui se réduisent pour tenir au-dessus du clavier */
    .wordle-grid {
        --cell: 60px;
        max-width: min(92vw, calc(var(--cols) * var(--cell) + (var(--cols) - 1) * 4px));
        gap: 4px;
        margin-bottom: 10px;
    }

    .wordle-cell {
        font-size: 1.05rem;
        border-width: 1.5px;
        border-radius: 6px;
    }

    /* Clavier : plus compact en bas */
    .keyboard {
        gap: 3px;
        margin-bottom: 8px;
    }
    .keyboard-row { gap: 3px; }

    .key {
        padding: 8px 4px;
        font-size: 0.78rem;
        min-height: 36px;
        border-radius: 5px;
    }
    .key.wide { font-size: 0.7rem; }

    /* Stats/footer collapsed */
    .stat-card { padding: 6px; }
    .stat-value { font-size: 1.1rem; }
    .stat-label { font-size: 0.68rem; }
}

@media (max-width: 480px) {
    .main-header { display: none !important; }

    .game-title { font-size: 1.2rem; }
    .game-subtitle { font-size: 0.7rem; }

    .wordle-grid {
        --cell: 56px;
        max-width: min(94vw, calc(var(--cols) * var(--cell) + (var(--cols) - 1) * 3px));
        gap: 3px;
    }

    .wordle-cell {
        font-size: 0.92rem;
        border-width: 1.5px;
    }

    /* Titres longs (7-8 lettres) : cases plus étroites → lettre un cran plus petite */
    .wordle-grid[data-long="1"] .wordle-cell { font-size: 0.8rem; }

    button, .btn-theme-toggle, .btn-icon, .modal-close { min-height: 44px; }
}
