/* === Variables CSS === */
/* Louise, tu peux changer les couleurs ici pour personnaliser ton site ! */
:root {
    --rouge-empire: #8b0000;
    --rouge-clair: #a01010;
    --or: #ffd700;
    --or-doux: #e6c200;
    --fond-sombre: #1a0a00;
    --fond-carte: rgba(20, 10, 5, 0.75);
    --texte-clair: #f5f0e8;
    --texte-dore: #ffe066;
    --vert-correct: #2e7d32;
    --rouge-incorrect: #c62828;
    --rayon-carte: 16px;
    --ombre-carte: 0 8px 32px rgba(0, 0, 0, 0.4);
    --flou-carte: blur(12px);
}

/* === Reset de base === */
*, *::before, *::after {
    box-sizing: border-box;
}

body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    overscroll-behavior: none;
    background-color: var(--fond-sombre);
    color: var(--texte-clair);
    -webkit-text-size-adjust: 100%;
}

/* Supprimer le delai au tap et le flash gris sur mobile */
button {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* === Animations === */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}

@keyframes progressGlow {
    0%, 100% { box-shadow: 0 0 6px rgba(255, 215, 0, 0.4); }
    50% { box-shadow: 0 0 14px rgba(255, 215, 0, 0.7); }
}

/* Classe pour l'animation d'entree */
.animate-in {
    animation: fadeIn 0.4s ease-out;
}

/* Classe pour la transition entre questions */
.fade-out {
    opacity: 0;
    transition: opacity 0.3s ease-out;
}

.fade-in {
    opacity: 1;
    transition: opacity 0.3s ease-in;
}

/* === Page d'accueil === */
#landing-page {
    text-align: center;
    position: relative;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    padding-bottom: 60px;
    background-color: var(--fond-sombre);
}

#background-video {
    width: 50%;
    height: auto;
    z-index: 0;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

#playGameButton {
    z-index: 1;
    position: relative;
    padding: 16px 36px;
    font-size: 20px;
    cursor: pointer;
    background: linear-gradient(135deg, var(--rouge-empire), var(--rouge-clair));
    color: var(--or);
    border: 2px solid var(--or);
    border-radius: var(--rayon-carte);
    transition: all 0.3s ease;
    font-family: Georgia, 'Times New Roman', serif;
    font-weight: 700;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 15px rgba(139, 0, 0, 0.4);
}

#playGameButton:focus,
#playGameButton:active {
    background: linear-gradient(135deg, var(--rouge-clair), #b01515);
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.4);
    transform: scale(1.03);
}

@media (hover: hover) {
    #playGameButton:hover {
        background: linear-gradient(135deg, var(--rouge-clair), #b01515);
        box-shadow: 0 6px 20px rgba(139, 0, 0, 0.5);
        transform: scale(1.03);
    }
}

/* === Section du jeu === */
#game {
    display: none;
}

/* === Zone de jeu principale === */
#roman-emperor {
    text-align: center;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    /* Le fond est mis dans ::before pour que ca marche sur iPhone */
    position: relative;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
    padding-top: calc(60px + env(safe-area-inset-top));
}

/* Image de fond fixe qui marche aussi sur Safari iOS */
#roman-emperor::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('images/roman_emperor_game.webp');
    background-size: cover;
    background-position: center;
    z-index: -1;
}

/* === Boite de texte (style glassmorphism) === */
.text-box {
    background: var(--fond-carte);
    backdrop-filter: var(--flou-carte);
    -webkit-backdrop-filter: var(--flou-carte);
    border-radius: var(--rayon-carte);
    padding: 20px 24px;
    margin: 12px auto;
    width: 90%;
    max-width: 560px;
    box-shadow: var(--ombre-carte);
    border: 1px solid rgba(255, 215, 0, 0.15);
    text-align: center;
    font-size: 18px;
    color: var(--texte-clair);
    line-height: 1.5;
}

/* === En-tete du jeu (titre + progression + score) === */
#game-header {
    background: var(--fond-carte);
    backdrop-filter: var(--flou-carte);
    -webkit-backdrop-filter: var(--flou-carte);
    border-radius: var(--rayon-carte);
    padding: 16px 20px 12px;
    margin: 8px auto 12px;
    width: 90%;
    max-width: 560px;
    border: 1px solid rgba(255, 215, 0, 0.15);
    box-shadow: var(--ombre-carte);
}

/* === Titre du jeu === */
#roman-emperor h1 {
    color: var(--or);
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    font-size: 26px;
    font-family: Georgia, 'Times New Roman', serif;
    margin: 0 0 8px;
    letter-spacing: 0.5px;
}

/* === Barre de progression === */
#progress-container {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    margin: 4px 0;
    overflow: hidden;
}

#progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--or), var(--or-doux));
    border-radius: 4px;
    transition: width 0.5s ease;
    animation: progressGlow 2s ease-in-out infinite;
}

/* === Score compact === */
#score {
    background: transparent;
    box-shadow: none;
    border: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding: 4px 0 0;
    margin: 0;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
}

#progression {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: var(--or);
    margin-bottom: 4px;
}

#score-counts {
    display: flex;
    justify-content: center;
    gap: 16px;
}

.score-correct {
    color: #66bb6a;
}

.score-incorrect {
    color: #ef5350;
}

/* === Question === */
#question .text-box {
    font-size: 18px;
    font-weight: 600;
    line-height: 1.5;
}

/* === Image de l'empereur === */
#image {
    width: 160px;
    height: 160px;
    object-fit: cover;
    margin: 14px 0;
    border-radius: 50%;
    border: 3px solid var(--or);
    box-shadow: 0 4px 20px rgba(255, 215, 0, 0.2), 0 6px 12px rgba(0, 0, 0, 0.4);
}

/* === Grille de choix (2x2) === */
#choices {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 90%;
    max-width: 560px;
    margin: 0 auto;
}

/* === Boutons de choix === */
.choice {
    display: block;
    width: auto;
    font-size: 17px;
    padding: 14px 12px;
    background: linear-gradient(135deg, var(--rouge-empire), var(--rouge-clair));
    color: var(--or);
    border: 2px solid rgba(255, 215, 0, 0.4);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.25s ease;
    font-weight: 600;
    letter-spacing: 0.3px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
    min-height: 48px;
    animation: slideUp 0.4s ease-out backwards;
}

/* Lignes de dates dans les boutons de choix */
.date-line {
    display: block;
    line-height: 1.4;
}

/* Delai d'animation pour chaque bouton */
.choice:nth-child(1) { animation-delay: 0.05s; }
.choice:nth-child(2) { animation-delay: 0.1s; }
.choice:nth-child(3) { animation-delay: 0.15s; }
.choice:nth-child(4) { animation-delay: 0.2s; }

.choice:focus,
.choice:active {
    background: linear-gradient(135deg, var(--rouge-clair), #b01515);
    transform: scale(1.02);
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.3), 0 4px 15px rgba(0, 0, 0, 0.3);
}

@media (hover: hover) {
    .choice:hover {
        background: linear-gradient(135deg, var(--rouge-clair), #b01515);
        transform: scale(1.02);
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
        border-color: var(--or);
    }
}

.choice:disabled {
    cursor: default;
    transform: none;
    opacity: 0.9;
}

/* Couleurs pour bonne/mauvaise reponse */
.choice.correct {
    background: linear-gradient(135deg, var(--vert-correct), #388e3c);
    color: #fff;
    border-color: #43a047;
    animation: pulse 0.5s ease;
}

.choice.incorrect {
    background: linear-gradient(135deg, var(--rouge-incorrect), #d32f2f);
    color: #fff;
    border-color: #e53935;
}

/* === Boutons Rejouer / Menu === */
#replayButton,
#resultMenuButton {
    font-size: 22px;
    padding: 16px 36px;
    background: linear-gradient(135deg, var(--rouge-empire), var(--rouge-clair));
    color: var(--or);
    border: 2px solid var(--or);
    border-radius: var(--rayon-carte);
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 700;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 15px rgba(139, 0, 0, 0.4);
    min-height: 48px;
}

#replayButton:focus, #replayButton:active,
#resultMenuButton:focus, #resultMenuButton:active {
    background: linear-gradient(135deg, var(--rouge-clair), #b01515);
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.4);
    transform: scale(1.03);
}

@media (hover: hover) {
    #replayButton:hover,
    #resultMenuButton:hover {
        background: linear-gradient(135deg, var(--rouge-clair), #b01515);
        box-shadow: 0 6px 20px rgba(139, 0, 0, 0.5);
        transform: scale(1.03);
    }
}

/* === Bouton Menu fixe === */
#menuButton {
    font-size: 14px;
    padding: 10px 20px;
    position: fixed;
    top: max(15px, env(safe-area-inset-top));
    left: max(15px, env(safe-area-inset-left));
    z-index: 10;
    background: var(--fond-carte);
    backdrop-filter: var(--flou-carte);
    -webkit-backdrop-filter: var(--flou-carte);
    color: var(--or);
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    min-height: 44px;
    min-width: 44px;
}

#menuButton:focus,
#menuButton:active {
    background: rgba(139, 0, 0, 0.6);
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.3);
}

@media (hover: hover) {
    #menuButton:hover {
        background: rgba(139, 0, 0, 0.6);
    }
}

/* === Ecran de resultat === */
#result-screen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    position: relative;
    padding: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
}

/* Image de fond pour l'ecran de resultat (meme technique que le jeu) */
#result-screen::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('images/roman_emperor_game.webp');
    background-size: cover;
    background-position: center;
    z-index: -1;
}

.result-box h1 {
    color: var(--or);
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 28px;
    margin-top: 0;
}

#result-message {
    font-size: 18px;
    line-height: 1.7;
    margin-bottom: 20px;
}

.result-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 10px;
}

/* === Responsive - tablette === */
@media (max-width: 768px) {
    #background-video {
        width: 80%;
    }

    .text-box {
        width: 92%;
        padding: 16px 18px;
        font-size: 17px;
    }

    .choice {
        font-size: 16px;
        padding: 13px 14px;
    }

    #choices {
        width: 92%;
    }

    #roman-emperor h1 {
        font-size: 22px;
    }

    #image {
        width: 140px;
        height: 140px;
    }
}

/* === Responsive - mobile === */
@media (max-width: 480px) {
    #background-video {
        width: 95%;
    }

    .text-box {
        width: 96%;
        padding: 14px 14px;
        font-size: 16px;
    }

    .choice {
        font-size: 15px;
        padding: 12px 10px;
    }

    #choices {
        width: 96%;
    }

    #playGameButton {
        font-size: 17px;
        padding: 14px 28px;
    }

    #roman-emperor h1 {
        font-size: 20px;
    }

    #image {
        width: 120px;
        height: 120px;
    }

    #menuButton {
        font-size: 13px;
        padding: 8px 14px;
    }

    #replayButton,
    #resultMenuButton {
        font-size: 18px;
        padding: 14px 28px;
    }

    #result-message {
        font-size: 16px;
    }
}

/* === Responsive - tres petit ecran (iPhone SE) === */
@media (max-width: 375px) {
    #roman-emperor h1 {
        font-size: 18px;
    }

    #image {
        width: 100px;
        height: 100px;
    }

    #choices {
        grid-template-columns: 1fr;
    }

    .choice {
        font-size: 14px;
        padding: 11px 12px;
    }

    #score {
        font-size: 13px;
    }

    #progression {
        font-size: 13px;
    }

    #question .text-box {
        font-size: 15px;
    }
}
