/* Variables de couleurs et typographie */
:root {
    /* Thème clair par défaut (Tableau de bord) */
    --bg-color: #F8FAFC;
    --text-color: #0F172A;
    
    /* Couleurs de marque Cortexia */
    --primary-cyan: #00D2FF;
    --success-green: #10B981;
    --premium-purple: #8B5CF6;
    
    /* Thème Focus (Nuit Profonde) */
    --focus-bg: #0F172A;
    --focus-text: #F8FAFC;
    
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
}

/* Base */
body {
    margin: 0;
    font-family: var(--font-body);
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 1.5s ease-in-out, color 1.5s ease-in-out;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

h1, h2, .logo {
    font-family: var(--font-heading);
}

/* Éléments périphériques (Header, Footer) */
.peripheral-element {
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    transition: opacity 1.5s ease-in-out, transform 1.5s ease-in-out;
}

.logo {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-cyan);
}

/* Conteneur de l'application */
#app-container {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    padding: 20px;
}

/* Écran d'accueil */
#welcome-screen {
    text-align: center;
    max-width: 600px;
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

#welcome-screen.hidden {
    opacity: 0;
    transform: translateY(-20px);
    pointer-events: none;
    position: absolute;
}

/* Bouton Principal */
.btn-primary {
    background-color: var(--primary-cyan);
    color: #000;
    border: none;
    padding: 16px 32px;
    font-size: 18px;
    font-weight: 700;
    font-family: var(--font-heading);
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 210, 255, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 20px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 210, 255, 0.5);
}

/* =========================================
   EFFET FOCUS MODE (Déclenché par JS)
   ========================================= */

body.focus-mode {
    background-color: var(--focus-bg);
    color: var(--focus-text);
}

/* Effacement des éléments périphériques */
body.focus-mode .peripheral-element {
    opacity: 0.1; /* On ne masque pas à 100% pour garder un repère visuel très léger */
    pointer-events: none;
}

/* Lueur radiale (Halo) */
#glow-effect {
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(0, 210, 255, 0.15) 0%, rgba(15, 23, 42, 0) 70%);
    border-radius: 50%;
    z-index: 0;
    opacity: 0;
    transition: opacity 2s ease-in-out;
    pointer-events: none;
}

body.focus-mode #glow-effect {
    opacity: 1;
}

/* =========================================
   CARTE DE TEST (Glassmorphism)
   ========================================= */

.glass-card {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 40px;
    width: 100%;
    max-width: 700px;
    z-index: 1;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 1s ease-in-out 0.5s, transform 1s ease-out 0.5s; /* Délai pour laisser le fond noircir d'abord */
    display: none;
}

body.focus-mode .glass-card:not(.hidden) {
    display: block; /* On l'affiche dans le flux */
    opacity: 1;
    transform: scale(1);
}

/* Zone image / SVG de la question */
#question-image {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 16px 0;
    max-width: 100%;
}

#question-image svg {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Style de la question (Grille, boutons...) */
.question-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
    font-weight: 500;
}

.category-badge {
    color: var(--primary-cyan);
    background: rgba(0, 210, 255, 0.1);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 14px;
}

.answers-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 30px;
}

.answer-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 20px;
    border-radius: 12px;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.answer-btn svg {
    display: block;
    max-width: 100%;
    height: auto;
}

.answer-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-cyan);
}

#rendered-prompt {
    font-family: 'Outfit', monospace;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--primary-cyan);
    text-align: center;
    margin: 16px 0 8px;
    word-break: break-all;
}

.answer-btn.answer-pending {
    border-color: var(--primary-cyan);
    opacity: 0.7;
}

.answer-btn.answer-correct {
    border-color: #10B981;
    background: rgba(16, 185, 129, 0.15);
    color: white;
    position: relative;
}

.answer-btn.answer-correct::after {
    content: '✓';
    position: absolute;
    top: 8px;
    right: 12px;
    font-size: 18px;
    font-weight: 700;
    color: #10B981;
}

.answer-btn.answer-wrong {
    border-color: #EF4444;
    background: rgba(239, 68, 68, 0.15);
    color: white;
    position: relative;
}

.answer-btn.answer-wrong::after {
    content: '✗';
    position: absolute;
    top: 8px;
    right: 12px;
    font-size: 18px;
    font-weight: 700;
    color: #EF4444;
}

/* =========================================
   STATISTIQUES DASHBOARD (Cartes stats)
   ========================================= */

.stat-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 140px;
}

.stat-icon {
    font-size: 32px;
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-cyan);
}

.stat-label {
    font-size: 14px;
    color: #9CA3AF;
}

/* =========================================
   CARTES DE CATÉGORIES
   ========================================= */

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin-top: 30px;
}

.category-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.category-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary-cyan);
    transform: translateY(-4px);
}

.category-card.active {
    border-color: var(--primary-cyan);
    background: rgba(0, 210, 255, 0.15);
}

.category-icon {
    display: block;
    font-size: 48px;
    margin-bottom: 12px;
}

.category-name {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--focus-text);
}

.category-count {
    display: block;
    font-size: 14px;
    color: #9CA3AF;
}

/* =========================================
   DASHBOARD HEADER
   ========================================= */

.dashboard-header {
    text-align: center;
    margin-bottom: 40px;
}

.dashboard-header h1 {
    font-size: 32px;
    margin: 0 0 12px 0;
}

.dashboard-header p {
    font-size: 16px;
    color: #9CA3AF;
    margin: 0;
}

/* =========================================
   ACTION SECTION
   ========================================= */

.action-section {
    text-align: center;
    margin: 40px 0;
}

.subtext {
    color: #9CA3AF;
    font-size: 14px;
    margin-top: 12px;
}

/* =========================================
   SCORE PAGE
   ========================================= */

.score-header {
    text-align: center;
    margin-bottom: 30px;
}

.score-main {
    text-align: center;
    padding: 40px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 16px;
    margin-bottom: 30px;
}

.score-value {
    font-family: var(--font-heading);
    font-size: 64px;
    font-weight: 700;
    color: var(--primary-cyan);
    margin-bottom: 12px;
}

.score-label {
    font-size: 18px;
    color: #9CA3AF;
}

.score-percentile {
    font-size: 24px;
    color: var(--premium-purple);
    margin-bottom: 8px;
}

.score-sublabel {
    font-size: 14px;
    color: #6B7280;
}

.category-scores {
    margin-bottom: 40px;
}

.category-scores h3 {
    color: var(--focus-text);
    font-size: 20px;
    margin-bottom: 20px;
}

/* =========================================
   CATEGORY SCORES (données JSON)
   ========================================= */

#score-value {
    color: var(--primary-cyan) !important;
}

#score-percentile {
    color: var(--premium-purple) !important;
}

/* =========================================
   SIGNUP PROMPT
   ========================================= */

.signup-prompt {
    margin-top: 40px;
    padding: 24px;
    background: rgba(139, 92, 246, 0.1);
    border-radius: 12px;
    text-align: center;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.signup-content h3 {
    color: var(--premium-purple);
    margin: 0 0 12px 0;
}

.signup-content p {
    color: #9CA3AF;
    font-size: 14px;
    margin-bottom: 16px;
}

/* =========================================
   CATEGORY BADGE
   ========================================= */

.category-badge {
    color: var(--primary-cyan);
    background: rgba(0, 210, 255, 0.1);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
}

/* =========================================
   PROGRESS SECTION
   ========================================= */

.progress-section {
    margin-top: 20px;
    text-align: center;
}

.progress-section span {
    font-size: 14px;
    color: #9CA3AF;
}

/* =========================================
   CATEGORIES SECTION
   ========================================= */

.categories-section {
    margin-top: 40px;
}

.categories-section h3 {
    color: var(--focus-text);
    font-size: 18px;
    margin-bottom: 20px;
}

/* =========================================
   CHRONOMÈTRE PAR QUESTION
   ========================================= */

.question-timer-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 0 16px;
}

.question-timer-label {
    font-size: 13px;
    font-weight: 600;
    color: #00D2FF;
    min-width: 32px;
    text-align: right;
    transition: color 0.3s;
}

.question-timer-label.timer-warning {
    color: #EF4444;
    animation: pulse-warning 1s ease-in-out infinite;
}

@keyframes pulse-warning {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.5; }
}

.question-timer-track {
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.question-timer-bar {
    height: 100%;
    width: 100%;
    background: #00D2FF;
    border-radius: 2px;
    transition: width 1s linear, background 0.3s;
}

/* =========================================
   RESPONSIVE MOBILE (≤ 480px)
   ========================================= */

@media (max-width: 480px) {
    /* Réduction des marges globales */
    .peripheral-element {
        padding: 12px 16px;
    }

    #app-container {
        padding: 12px;
        align-items: flex-start;
        padding-top: 16px;
    }

    /* Carte principale */
    .glass-card {
        padding: 20px 16px;
        border-radius: 16px;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* En-tête de question */
    .question-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        margin-bottom: 12px;
    }

    /* Texte de la question */
    #question-text {
        font-size: 18px;
        line-height: 1.4;
        margin: 0 0 12px;
        text-align: center;
    }

    /* Prompt rendu (séquences) */
    #rendered-prompt {
        font-size: 18px;
        letter-spacing: 0.05em;
        word-break: break-word;
    }

    /* Image / SVG */
    #question-image {
        max-width: 100%;
        overflow-x: auto;
        text-align: center;
        display: flex;
        justify-content: center;
    }

    #question-image svg {
        max-width: 100%;
        height: auto;
        display: block;
    }

    /* Grille de réponses : 1 colonne sur petit écran */
    .answers-grid {
        grid-template-columns: 1fr;
        gap: 10px;
        margin-top: 16px;
    }

    .answer-btn {
        padding: 16px 12px;
        font-size: 16px;
        text-align: center;
        justify-content: center;
    }

    .answer-btn svg {
        max-width: 80%;
        height: auto;
    }

    /* Compteur de questions */
    #question-counter {
        font-size: 13px;
    }

    /* Écran de fin */
    #end-screen h1 {
        font-size: 22px;
    }

    #end-screen p {
        font-size: 14px;
        margin-bottom: 20px;
    }

    #end-screen .btn-primary {
        width: 100%;
        font-size: 16px;
        padding: 14px 20px;
    }

    /* Score page */
    .score-value {
        font-size: 48px;
    }

    .score-main {
        padding: 24px 16px;
    }

    /* Dashboard */
    .dashboard-header h1 {
        font-size: 24px;
    }

    .categories-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .category-card {
        padding: 14px 10px;
    }

    .category-icon {
        font-size: 32px;
        margin-bottom: 6px;
    }

    /* Mémoire — affichage phase 1 */
    #memory-display {
        font-size: 36px;
        padding: 16px 8px;
    }
}

/* =========================================
   RESPONSIVE TABLETTE (481px – 768px)
   ========================================= */

@media (min-width: 481px) and (max-width: 768px) {
    .glass-card {
        padding: 28px 24px;
        max-width: 100%;
        box-sizing: border-box;
    }

    .answers-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    #app-container {
        padding: 16px;
    }
}
