/* 
#########################################################################################################
Feuille de style CSS principale.
#########################################################################################################

============================================================
Responsive Web Design
============================================================ 

Lageurs d'écrans :

Format Portrait : 
-------------------------------------------------------------
- Smartphones : 320px - 440px.
- Tablettes tactiles : 600px - 1032px.

Breakpoints : 
    -    0px <= vw < 500px  : Facteur de zoom rétrécissant sur la base de 500px.
    -  500px <= vw < 1200px : Echelle 1, Design adaptatif à la largeur.
    - 1200px <= vw          : Largeur du container principal bloquée à 1200px max.



Format paysage : 
-------------------------------------------------------------
- Smartphones : 568px - 956px.
- Tablettes tactiles : 1133px - 1376px.

Breakpoints : 
    -    0px <= vw < 1050px : Facteur de zoom rétrécissant sur la base de 1050px.
    - 1050px <= vw < 1400px : Echelle 1, Design adaptatif à la largeur.
    - 1400px <= vw          : Largeur du container principal bloquée à 1400px max.




============================================================
VARIABLES CSS GLOBALES — charte graphique rouge/noir/blanc
============================================================ 
*/
:root {

    --rouge-clair:  #FF6B6B;   /* rouge primaire */
    --rouge:        #E8001C;   /* rouge primaire */
    --rouge-sombre: #77000e;   /* rouge foncé pour hover */
    --noir:         #0A0A0A;   /* fond principal */
    --noir-card:    #141414;   /* fond des cartes */
    --noir-border:  #7c7c7c;   /* bordures subtiles */
    --blanc:        #FFFFFF;   /* texte principal */
    --gris-clair:   #B0B0B0;   /* texte secondaire */
    --vert-valide:  #22C55E;   /* couleur coche / bonne réponse */
    --highlight:    rgb(253, 220, 33); /* Texte mis en évidence */
    --video-player-bg: rgb(13, 13, 13); /* Couleur de fond du lecteur video Dailymotion */

    --radius:       20px;      /* rayon de bordure standard */
    --transition:   0.25s ease;
    --spacing:      20px;
    --footer-height: 50px;     /* hauteur de la barre d'état en bas */
}

/* 
============================================================
ANIMATIONS
============================================================ 
*/

/* Fondu en entrée */
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Fondu en entrée avec glissement vers le haut */
@keyframes fadeInSlideUp {
    from { opacity: 0; transform: translateY(50px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Animation pulsante de couleur verte (pour les boutons correspondant à la bonne réponse d'une question) */
@keyframes pulseGreen {
    0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); }
    70%  { box-shadow: 0 0 0 12px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* 
============================================================
STYLES GLOBAUX
============================================================ 
*/

html
{
    height: 100%;
    font-size: 20px; /* Définition du 1 rem */
}

body
{
    display:flex;
    margin: 0;
    padding: 0;
    height: 100%;
    background: linear-gradient(to bottom, var(--noir) 0%, var(--noir) 30%, #3b0000 90%, var(--rouge-sombre) 100%);
    background-attachment: fixed;
    color: var(--blanc);
    font-family: 'DM Sans', sans-serif;
    line-height: 1.2;
    -webkit-tap-highlight-color: transparent; /* supprime le flash bleu sur mobile */
}

/*
Dimensions de référence : 360/640 (format 16/9 pour s'adapter aux écrans de tablettes.)
*/

/* Facteur de zoom en format portrait : */
body.portrait
{
    zoom: clamp(0, calc(100vw / 500px), 1); /* Largeur de référence en format portrait : 500px */
}

/* Facteur de zoom en format paysage : */
body.landscape
{
    zoom: clamp(0, calc(100vw / 1050px), 1); /* Largeur de référence en format paysage : 1050px */
}


card 
{
    display:flex;
    flex-flow: column nowrap;
    gap: 5px;
    padding: 12px;
    background-color: rgba(255, 255, 255, 0.08);
    border-radius : var(--radius);
}

/* Titres */
h2
{
    display: block;
    text-align: center;
    margin: 0;
    padding: 0;
    font-size: 1.45rem;
    font-weight: 500;
    animation: fadeInSlideUp 0.5s 0.1s ease both;
}

h3 {
    display: block;
    text-align: center;
    font-size: 1.75em;
    font-weight: normal;
    margin: -8px 0px 5px 0px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

/* Boutons */
button 
{
    background-color: var(--noir-card);
    color: var(--blanc);
    border: 2px solid var(--noir-border);
    border-radius: 40px;
    padding: 20px;
    font-size: 1.5rem;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    transition: background-color var(--transition), border-color var(--transition), transform var(--transition);
    position: relative;
    overflow: hidden;
}
button:hover{
    transform: scale(1.03);
}

button.answer-correct
{
    background-color: rgba(34, 197, 94, 0.2);
    border-color: var(--vert-valide);
    color: var(--vert-valide);
    animation: pulseGreen 1.2s ease infinite;
}

button.answer-incorrect
{
    background-color: rgba(232, 0, 28, 0.15);
    border-color: var(--rouge);
    color: var(--rouge-clair);
}

/* Masquer les éléments avec l'attribut hidden */
*[hidden] 
{
    display: none !important;
}

.score-style
{
    font-family: 'Bebas Neue', sans-serif !important;
    font-weight: 200 !important;
    color: var(--rouge) !important;
}


/* 
============================================================
LAYOUT
============================================================ 
*/

/* Conteneur principal de la page */
div#page-container
{
    flex-grow: 1;
    display: flex;
    flex-flow: column nowrap;
    padding: calc(var(--spacing) * 0.5) var(--spacing);
    gap: var(--spacing);
}


/* Zone d'affichage des écrans */
main
{
    flex-grow: 1;
    display:flex;
    flex-flow : column nowrap;
    gap: var(--spacing);
}

/* Ecrans */
screen
{
    flex-grow: 1;
    position:relative;
    display:flex;
    flex-flow : column nowrap;
    justify-content: space-between;
    align-items: stretch;
    gap: var(--spacing);
}

/* Ecrans qui ont la barre d'état en bas : */
screen.with-footer
{
    padding-bottom: calc(var(--footer-height) + var(--spacing));
}

/* Animation sur les écrans (tous les écrans sauf l'écran vidéo) : */
screen:not(#screen-video)
{
    animation: fadeInSlideUp 0.5s 0.1s ease both;
}

/* Largeur maximale des écrans pour les tablettes au format portrait : */
body.portrait screen:not(#screen-video, #screen-posters)
{
    max-width: 700px !important;
    margin-left: max(calc(50% - 350px), 0px);
}

/* Largeur maximale des écrans pour les tablettes au format paysage : */
body.landscape screen:not(#screen-video, #screen-posters)
{
    max-width: 1400px !important;
    margin-left: max(calc(50% - 700px), 0px);
}



/* 
============================================================
EN-TETE — commun à tous les écrans
============================================================ 
*/
header {
    display: flex;
    position: relative;
    justify-content: center;
    align-items: center;
}

img#btn-hamburger
{
    cursor: pointer;
    display:block;
    position: absolute;
    top: 5px;
    left: 0;
    width: 40px;
    transition: var(--transition);
}

img#btn-hamburger:hover
{
    transform: scale(1.1);
}

img#logo {
    margin: 0;
    height: auto;
    object-fit: contain;
    transition: 0.5s ease;
}

img#logo.large
{
    width: 280px;
}

img#logo.small
{
    width: 180px;
}


/* 
============================================================
SCREEN START
============================================================ 
*/

screen#screen-start {
    align-items: center;
    justify-content: space-around !important;
}

screen#screen-start img {
    max-width: 460px;
    max-height: 25vh;
}

screen#screen-start ol
{
    width:fit-content;
    margin: 0;
}

screen#screen-start li
{
    hyphens: auto;
    font-size: 1.4rem;
    padding-bottom: var(--spacing);
}


/* 
============================================================
SCREEN LEVELS
============================================================ 
*/

screen#screen-levels
{
    justify-content: space-evenly !important;
}

div#levels-list
{
    flex-grow: 1;
    align-self: stretch;
    display:flex;
    flex-flow : column nowrap;
    gap: calc(var(--spacing) * 0.5);  
    justify-content: flex-start;
}

body.landscape div#levels-list
{
    flex-flow: row nowrap !important;
    align-items: flex-start !important;
}

body.landscape div#levels-list card {
    flex-grow: 1;
    max-width: 400px;
}

.content-zone {
    display:flex;
    flex-flow: row nowrap;
    gap: 10px;
}

.score-zone {
    flex-grow: 0;
    width: 6.8rem;
    display: flex;
    flex-flow: column nowrap;
    margin: 19px 0px 8px 0px;
}
body.landscape .score-zone {
    margin-top: 0 !important;
}

.score-title {
    font-size: 1rem !important;
    color: var(--gris-clair);
}

.score-number {
    font-size: 4.1rem;
    line-height: 0.9;
    margin-bottom: -14px;
}

.btn-zone {
    width: 6.8rem;
    flex-grow: 1;
    display: flex;
    flex-flow: column nowrap;
    justify-content: center;
    align-items: stretch;
    gap: 5px;
}

.btn-menu {
    font-size: 1.5rem !important;
    padding: 6px 2px !important;
}

body.landscape div#levels-list .btn-menu {
    font-size: 0.75rem !important;
}



/* 
============================================================
SCREEN POSTERS
============================================================ 
*/

screen#screen-posters
{
    justify-content: flex-start !important;
}

div#grid-posters
{
    align-self: stretch;
    display: flex;
    flex-flow: row wrap;
    justify-content: space-evenly;
    gap: var(--spacing) calc(var(--spacing) * 0.6);
}

/* Vignettes : */
div.thumbnail
{
    display: block;
    position: relative;
    /* Sur mobile : 2 vignettes par ligne, avec gap pris en compte */
    width: clamp(120px, 45%, 240px);
    flex-grow: 0;
    /* Ratio carré */
    aspect-ratio: 1 / 1;
    border-radius: var(--radius);
    overflow: hidden;
    border: 2px solid var(--noir-border);
    transition: var(--transition);
    background-color: var(--noir-card);
}

body.landscape div.thumbnail
{
    width: 230px !important;
}

/* Effet au survol/tap des vignettes */
div#grid-posters div.thumbnail:hover,
div#grid-posters div.thumbnail:active {
    transform: scale(1.03);
    border-color: var(--rouge);
    box-shadow: 0 8px 32px rgba(232, 0, 28, 0.35);
}

div.thumbnail img
{
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.3s;
}

/* Numéro affiché sur la vignette : */
div.thumbnail .thumbnail-number
{
    position: absolute;
    display: block;
    top: 0.1rem;
    left: 0.5rem;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 3rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.6);
}

/* Coche verte (question terminée) — coin inférieur droit */
div.thumbnail div.badge
{
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--blanc);
    display: flex;
    align-items: center;
    justify-content: center;
    transform: scale(1.6);
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;    
}

div.thumbnail div.badge.correct
{
    background-color: var(--vert-valide);  
}

div.thumbnail div.badge.incorrect
{
    background-color: var(--rouge);  
}

div.thumbnail div.badge svg 
{
    width: 18px;
    height: 18px;
    stroke: var(--blanc);
    stroke-width: 3;
    fill: none;
}

div.thumbnail div.reactive-zone
{
    display: block;
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    cursor: pointer;
}



/* 
============================================================
SCREEN QUESTION
============================================================ 
*/

#question-number,
#question-number-reminder
{
    font-family: 'Bebas Neue', sans-serif;
    color: var(--gris-clair);
}

div#choices-container
{
    align-self: stretch;
    display: flex;
    flex-flow: column nowrap;
    gap: var(--spacing);
}

body.landscape div#choices-container
{
    flex-flow: row wrap;
}

body.landscape div#choices-container button
{
    flex-grow: 1;
    width: 40%
}

div#choices-container.answered button
{
    cursor: default !important;
    transform: none !important;
}

div#navigation-zone
{
    display: flex;
    flex-flow: row wrap;
    gap: var(--spacing);
    justify-content: space-between;
    align-items: baseline;
}

div#navigation-zone > *
{
    flex-grow: 1;
}

/* Bouton de retour aux affiches */
button.navigation-button
{
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background-color: rgba(255,255,255, 0.15);
    color: var(--gris-clair);
    border: 2px solid var(--noir-border);
    border-radius: 40px;
    padding: 3px 3px;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.35rem;
    
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

button.navigation-button.back
{
    padding-left: 0 !important;
}

button.navigation-button.forward
{
    padding-right: 0 !important;
}


div#answer-overlay {
    z-index: 200;
    position:absolute;
    display:block;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.95);
    animation: fadeIn 0.5s 0.1s ease both;
}

div#answer-modale {

    /* Centrage de la modale par rapport à son parent : */
    position:absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-sizing: border-box;

    display:flex;
    flex-flow: column nowrap;  
    justify-content: center;
    align-items: center;  
    text-align: center;
    white-space: nowrap;

    background-color: #1f1c1c;
    border: 1px solid var(--noir-border);
    padding: 1.5rem;
    gap: 1.5rem;
    border-radius : var(--radius);
    font-size: 1.8rem;
}



/*
============================================================
SCREEN RESULT
============================================================
*/

/* Gestion de l'affichage des vignettes : */
body.landscape #thumbnail-reminder-portrait { display: none; }
body.portrait #thumbnail-reminder-landscape { display: none; }
body.landscape div#thumbnail-reminder-landscape.thumbnail
{
    width: 140px !important;
}

div#reminder-zone
{
    display:flex;
    flex-flow: column nowrap;
    justify-content: flex-start;
    align-items: center;
    gap: var(--spacing);
}

body.landscape div#thumbnail-reminder {
    display: none;
}

card#result-zone
{
    flex-flow: row nowrap !important;
    justify-content: space-evenly;
    align-items: center;
    text-align: center;
    gap: var(--spacing);
    font-size: 1.4rem;
}

div#result-texts
{
    display:flex;
    flex-flow: column nowrap;
    gap: 12px;
    justify-content: space-around;
}

div#result-texts span
{
    color: var(--highlight);
}

div#result-texts span#correct-answer
{
    font-size: 1.5rem;
}

div#result-texts span#won-points
{
    color: var(--rouge);
    font-size: 2rem;      
    vertical-align: baseline; /* Ajustement vertical par rapport à la baseline du texte environnant. */
}


/*
============================================================
SCREEN VIDEO
============================================================
*/

#screen-video
{
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 300;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--video-player-bg);

    overflow: hidden; /* Masquer le dépassement des contrôles sous la vidéo. */
}

#video-player
{
    width: 100%; /* Largeur par défaut, mise à jour par resizeVideoPlayer() au lancement d'une vidéo. */
}



/* 
============================================================
FOOTER (barre d'état fixe)
============================================================ 
*/

footer 
{
    position: fixed;
    z-index: 100;    
    bottom: 0;
    left: 0;
    right: 0;
    box-sizing: border-box;
    height: var(--footer-height);
    background-color: rgba(10, 10, 10, 0.70);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: var(--gris-clair);
    border-top: 1px solid var(--noir-border);

    display:flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 4px 25px 0;
    gap: var(--spacing);
    font-size: 1.2rem;

}

div#footer-level span
{
    color: var(--blanc);
    font-size: 1.6rem;
}

div#footer-score span
{
    font-size: 1.6rem;
}


/*
====================================================
Canvas pour l'animation des confettis
==================================================== 
*/
#canvas-confettis {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
}
