/**
 * STROOP TEST CSS
 * Styles de l'arène, du mot cible, des boutons de couleur et de la réactivité plein écran.
 */

:root {
    --stroop-red: #ef4444;
    --stroop-red-glow: rgba(239, 68, 68, 0.35);
    --stroop-blue: #3b82f6;
    --stroop-blue-glow: rgba(59, 130, 246, 0.35);
    --stroop-green: #22c55e;
    --stroop-green-glow: rgba(34, 197, 94, 0.35);
    --stroop-yellow: #eab308;
    --stroop-yellow-glow: rgba(234, 179, 8, 0.35);
    --stroop-purple: #a855f7;
    --stroop-purple-glow: rgba(168, 85, 247, 0.35);
    --stroop-orange: #f97316;
    --stroop-orange-glow: rgba(249, 115, 22, 0.35);
}

/* Optimisation du contraste en mode clair */
.theme-lvl-1,
.theme-lvl-2 {
    --stroop-yellow: #b45309;
    --stroop-blue: #2563eb;
    --stroop-green: #15803d;
}

/* Conteneur principal centré */
.stroop-arena {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 640px;
    margin: auto;
    padding: 10px;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
}

/* Consigne épurée sans contour (style Chromatic Memory) */
.time-instruction {
    font-family: var(--font-heading);
    font-size: clamp(1.15rem, 2.2vw, 1.45rem);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: clamp(1rem, 2.5vh, 1.8rem);
    text-align: center;
}

.time-instruction .prompt-focus {
    color: var(--text-primary);
    font-weight: 700;
}

/* Carte centrale contenant le mot affiché */
.stroop-card {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: clamp(120px, 20vh, 180px);
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg, 18px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
    margin-bottom: clamp(1.5rem, 3.5vh, 2.8rem);
    padding: clamp(1rem, 3vw, 2.5rem);
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
    transition: transform 0.15s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Texte du mot */
.stroop-word {
    font-family: var(--font-heading);
    font-size: clamp(3.2rem, 8vw, 5.8rem);
    font-weight: 800;
    line-height: 1;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    animation: stroopPopIn 0.12s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes stroopPopIn {
    0% {
        transform: scale(0.92);
        opacity: 0.7;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Grille des boutons de réponse */
.stroop-buttons-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: clamp(10px, 2vw, 16px);
    width: 100%;
    box-sizing: border-box;
}

@media (min-width: 580px) {
    .stroop-buttons-grid.cols-4 {
        grid-template-columns: repeat(4, 1fr);
    }
    .stroop-buttons-grid.cols-6 {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Bouton individuel de couleur */
.stroop-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: clamp(12px, 2.2vh, 20px) 10px;
    min-height: clamp(64px, 9vh, 88px);
    border-radius: var(--radius-md, 12px);
    background: var(--card-bg);
    border: 2px solid var(--btn-color);
    color: var(--text-primary);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: transform 0.1s ease, box-shadow 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    touch-action: manipulation;
}

.stroop-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px var(--btn-glow);
}

.stroop-btn:active,
.stroop-btn.is-active {
    transform: translateY(2px) scale(0.98);
    box-shadow: 0 2px 6px var(--btn-glow);
}

/* Pastille et libellé */
.stroop-btn-indicator {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background-color: var(--btn-color);
    box-shadow: 0 0 8px var(--btn-glow);
    flex-shrink: 0;
}

.stroop-btn-label {
    font-family: var(--font-heading);
    font-size: clamp(0.95rem, 1.6vw, 1.15rem);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-primary);
}

/* Raccourci clavier discret */
.stroop-key-badge {
    font-family: var(--font-heading), monospace;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-secondary);
    background: rgba(125, 125, 125, 0.12);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1px 6px;
    line-height: 1.2;
}

/* Couleurs spécifiques injectées via variables CSS */
.stroop-btn[data-color="red"] {
    --btn-color: var(--stroop-red);
    --btn-glow: var(--stroop-red-glow);
}
.stroop-btn[data-color="blue"] {
    --btn-color: var(--stroop-blue);
    --btn-glow: var(--stroop-blue-glow);
}
.stroop-btn[data-color="green"] {
    --btn-color: var(--stroop-green);
    --btn-glow: var(--stroop-green-glow);
}
.stroop-btn[data-color="yellow"] {
    --btn-color: var(--stroop-yellow);
    --btn-glow: var(--stroop-yellow-glow);
}
.stroop-btn[data-color="purple"] {
    --btn-color: var(--stroop-purple);
    --btn-glow: var(--stroop-purple-glow);
}
.stroop-btn[data-color="orange"] {
    --btn-color: var(--stroop-orange);
    --btn-glow: var(--stroop-orange-glow);
}

/* Retours visuels & Révélation d'erreur conforme à la règle 4.2 */
.stroop-btn.highlight-correct {
    background-color: var(--btn-color) !important;
    border-color: var(--btn-color) !important;
    box-shadow: 0 0 24px var(--btn-glow), inset 0 0 10px rgba(255, 255, 255, 0.4) !important;
    transform: scale(1.04) !important;
}

.stroop-btn.highlight-correct .stroop-btn-label {
    color: #ffffff !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.stroop-btn.highlight-correct .stroop-key-badge {
    background: rgba(255, 255, 255, 0.3) !important;
    color: #ffffff !important;
    border-color: rgba(255, 255, 255, 0.5) !important;
}

.stroop-btn.shake-error {
    animation: stroopShake 0.35s ease-in-out;
    border-color: var(--accent-color-secondary, #ef4444) !important;
}

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

/* Flash de validation unifié (Règle 4.1) */
.flash-success-shadow {
    animation: flashSuccessShadow 0.5s ease-out;
}
.flash-failure-shadow {
    animation: flashRedShadow 0.5s ease-out;
}

@keyframes flashSuccessShadow {
    0% {
        box-shadow: inset 0 0 0 4px var(--accent-color), 0 0 30px var(--accent-glow);
    }
    100% {
        box-shadow: inset 0 0 0 0 transparent, 0 0 0 transparent;
    }
}

@keyframes flashRedShadow {
    0% {
        box-shadow: inset 0 0 0 4px var(--accent-color-secondary, #ef4444), 0 0 30px color-mix(in srgb, var(--accent-color-secondary, #ef4444) 45%, transparent);
    }
    100% {
        box-shadow: inset 0 0 0 0 transparent, 0 0 0 transparent;
    }
}

/* Plein Écran & Agrandissement Proportionnel (Règle 3.2) */
.game-board:fullscreen .stroop-arena,
.ios-fullscreen .stroop-arena {
    max-width: 860px;
    padding: 20px;
}

.game-board:fullscreen .stroop-card,
.ios-fullscreen .stroop-card {
    min-height: clamp(180px, 26vh, 260px);
    border-radius: 24px;
    margin-bottom: clamp(2rem, 4.5vh, 3.5rem);
}

.game-board:fullscreen .stroop-word,
.ios-fullscreen .stroop-word {
    font-size: clamp(4.8rem, 11vw, 8.2rem);
}

.game-board:fullscreen .stroop-btn,
.ios-fullscreen .stroop-btn {
    min-height: clamp(80px, 12vh, 110px);
    padding: clamp(16px, 3vh, 26px) 14px;
    border-radius: var(--radius-lg, 16px);
}

.game-board:fullscreen .stroop-btn-label,
.ios-fullscreen .stroop-btn-label {
    font-size: clamp(1.2rem, 2.2vw, 1.6rem);
}

.game-board:fullscreen .stroop-btn-indicator,
.ios-fullscreen .stroop-btn-indicator {
    width: 18px;
    height: 18px;
}

.game-board:fullscreen .stroop-key-badge,
.ios-fullscreen .stroop-key-badge {
    font-size: 0.9rem;
    padding: 2px 8px;
}

/* Boîte de score ajustée à la case 72x72 */
.score-box {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
}

.score-box #header-score-label {
    display: none !important;
}

.score-box #current-score {
    font-family: var(--font-heading);
    font-size: 1.15rem !important;
    font-weight: 700;
    line-height: 1;
    color: var(--text-primary);
    text-align: center;
    letter-spacing: 0.5px;
}

@media (max-width: 768px) {
    .score-box #current-score {
        font-size: 0.95rem !important;
    }
}

/* Statistiques Sandbox personnalisées */
#stat-best-cat,
#stat-worst-cat {
    font-size: clamp(0.95rem, 1.4vw, 1.25rem);
    white-space: nowrap;
    font-weight: 700;
}

/* Manches ratées affichées en rouge sur le diagramme de barres */
#history-chart .history-bar.bar-failed {
    background-color: var(--accent-color-secondary, #ef4444) !important;
    box-shadow: 0 0 10px color-mix(in srgb, var(--accent-color-secondary, #ef4444) 45%, transparent) !important;
}

#history-chart .history-bar-wrapper.has-error .bar-label {
    color: var(--accent-color-secondary, #ef4444) !important;
    font-weight: 700;
}

/* Header live timer (Style speedrun / Schulte Grid) */
.timer-display {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 100%;
    font-size: 2.5rem;
    min-width: 110px;
    justify-content: center;
    padding: 0px 15px;
    font-family: var(--font-heading);
    font-weight: 400;
    color: var(--accent-color);
    font-variant-numeric: tabular-nums;
    justify-self: center;
}

.timer-display svg {
    width: 48px;
    height: 48px;
    stroke: none;
    overflow: visible;
    flex-shrink: 0;
}

.timer-text {
    padding-top: 8px;
    white-space: nowrap;
}

.game-board:fullscreen .timer-display,
.ios-fullscreen .timer-display {
    font-size: 3.5rem;
    gap: 16px;
}

.game-board:fullscreen .timer-display svg,
.ios-fullscreen .timer-display svg {
    width: 60px;
    height: 60px;
}

@media (max-width: 700px) {
    .timer-display {
        font-size: 1.85rem;
        gap: 8px;
        padding: 0 4px;
        min-width: auto;
    }

    .timer-display svg {
        width: 32px;
        height: 32px;
    }
}

