/* ===================================================
 * VARIABLES & FONT-FACE
 * =================================================== */

:root {
    --primary-color: #333;
    --secondary-color: #555;
    --accent-color: #42a3c9;

    --background-page-color: #f4f4f4;
    --background-element-color: whitesmoke;
    --background-darker-color: #e0e0e0;
    --background-shadow-color: #acacac;
    --text-color: #333;
}

/* Polices personnalisées */
@font-face {
    font-family: 'MainFont';
    src: url('/assets/fonts/Comfortaa-Bold.ttf') format('truetype');
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'TitleFont';
    src: url('/assets/fonts/Syntha.ttf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}


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

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* réserve l'espace de la scrollbar pour éviter le saut */
html {
    scrollbar-gutter: stable;
}

::-webkit-scrollbar {
    width: 1em;
    height: 1em;
}

::-webkit-scrollbar-track {
    background: var(--background-darker-color);
}

::-webkit-scrollbar-thumb {
    background: var(--background-shadow-color);
    border-radius: 1em;
}

::-webkit-scrollbar-thumb:hover {
    background: rgb(130, 130, 130);
}

body {
    font-family: 'MainFont', sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background-color: var(--background-darker-color);
    color: var(--text-color);
}

main {
    margin: 0;
    padding: 0;
}

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

header {
    /* Positionnement et dimensionnement */
    position: fixed;
    top: 0;
    left: 0;

    width: 100%;
    min-height: 85vh;
    padding: 10px;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;

    /* Styles Thème */
    color: var(--text-color);
    text-align: left;
    border: var(--primary-color) 2px solid;
    border-radius: 0 0 1em 1em;

    /* Effets */
    background-color: var(--background-element-color);
    box-shadow: 0 5px 0 0 var(--primary-color);
    transform: translateY(0);
    overflow: hidden;

    /* Transition */
    transition: all 0.7s ease-in-out;
}

header::before {
    /* Dégradé de fond */
    content: "";
    position: absolute;
    top: 0;
    left: 0;

    width: 100%;
    height: 100%;
    z-index: 1;
    /* Devant le canvas (z-index: 0) mais derrière le texte (z-index: 2) */

    pointer-events: none;
    /* Permet d'interagir avec les éléments derrière */
    background: linear-gradient(to bottom, var(--background-page-color) 0%, transparent 100%);
}


/* Elements du header */
header h1,
header p,
header button{
    position: relative;
    z-index: 2;
    /* Pour passer devant le dégradé (z-index: 1) */
    margin: 0.3em;
}

header h1 {
    font-family: 'TitleFont', sans-serif;
    font-size: 3em;
    /* Transition */
    transition: all 0.7s ease-in-out;
}

/* Canvas de fond Three.js */
#header-3d-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    z-index: 0;

    /* Effet de flou */
    filter:blur(0.5px);
}

/* État Réduit (Appliqué par JavaScript) */
.header-scrolled {
    min-height: 10vh;
    /* Hauteur réduite du header */

    position: fixed;
    top: 0;
    left: 0;
}

/* Texte plus petit lorsque le header est reduit */
.header-scrolled h1,
.header-scrolled p {
    font-size: 1em;
}


#spacer {
    display: block;
    /* Caché par défaut */
    height: 85vh;

    /* Transition */
    transition: all 0.7s ease-in-out;
}

.scrolled #spacer {
    display: block;
    /* Affiché uniquement quand on scroll */
    height: 10vh;
}

#spacer-double {
    display: block;
    /* Caché par défaut */
    height: 20vh;
}


/* Bouton de scroll sur la page d'accueil */
.scroll-down-button {
    /* Positionnement et dimensionnement */
    display: block;
    margin-top: 1em;
    
    width: 100%;
    border:none;
    box-shadow: none;
    background-color: transparent;

    transition: all 0.7s ease-in-out;
}

.scroll-down-button:hover {
    box-shadow: none;
    transform: translateY(5px);
}

.scroll-down-button:active {
    transform: translateY(8px);
    /* Descend pour montrer le sens du scroll */
}

/* ne pas afficher si scrolled */
.scrolled .scroll-down-button {
    opacity: 0;
}

/* ===================================================
 * FOOTER
 * =================================================== */

footer {
    text-align: center;
    padding: 1em;
    margin-top: 1em;
    background-color: var(--background-element-color);
    color: var(--secondary-color);
    font-size: 0.9em;
}

/* permet d'afficher des éléments dans le footer sur une seule ligne */
.footer-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

footer #contact {
    margin:0;
    box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.05);
}

footer #contact:hover {
    background-color: var(--background-page-color);
    box-shadow: 0 0 100px 100px rgba(0, 0, 0, 0.2);
}

footer #contact:active {
    background-color: var(--background-shadow-color);
    box-shadow: 0 0 100px 100px rgba(0, 0, 0, 0.2);
}


/* Message dans le footer */
#message {
    margin-top: 15px;
    font-weight: bold;
    color: var(--accent-color);
}


/* ===================================================
 * CARDS
 * =================================================== */
.card {
    /* Positionnement et dimensionnement */
    padding: 1em;
    margin-top: 0em;
    margin-left: 1em;
    margin-right: 1em;
    margin-bottom: 2em;
    height: 100%;
    max-width: none;

    /* Styles Thème */
    background-color: var(--background-element-color);
    border-radius: 1em;
    border: 2px solid var(--primary-color);

    /* Effets */
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 5px 0 0 var(--primary-color);

    /* Transition */
    transition: all 0.2s ease;
}

.card-focus {
    z-index: 1000;
    transform: translateY(-2px);
    box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.05), 0 5px 0 0 var(--primary-color);
    transition: all 0.7s ease;
}


.card-focus:hover {
    transform: translateY(-2px);
    scale: 1.01;
    z-index:1000;
    box-shadow: 0 0 100px 100px rgba(0, 0, 0, 0.2), 0 5px 0 0 var(--primary-color);
}

.card-small {
    width: 100%;
    min-height: 150px;

    padding: 1em;
    margin-top: 0;
    margin-left: 0;
    margin-right: 0;
    margin-bottom: 1em;

    box-shadow: 0 3px 0 0 var(--primary-color);
}

.card-small:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 0 0 var(--primary-color);
}

/* évite que les liens aient deux fois la marge */
.card-small a {
    margin: 0;
}

/* laisser un espace entre le texte et les élements suivants */
.card-small p {
    margin-bottom: 1em;
}

/* ===================================================
 * Elements d'interface
 * =================================================== */

button {
    /* Positionnement et dimensionnement */
    position: relative;
    overflow: hidden;
    padding: 1em 2em;

    /* Styles Thème */
    font-family: 'MainFont', sans-serif;
    background-color: var(--background-element-color);
    color: var(--text-color);
    border-radius: 1em;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid var(--primary-color);

    box-shadow: 0 2px 0 0 var(--primary-color);
}

button:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 0 0 var(--primary-color);
}

button:active {
    transform: translateY(3px);
    box-shadow: 0 0 0 0 var(--primary-color);
    scale: 0.98;
}

.button-link {
    /* Positionnement et dimensionnement */
    margin: 1em;
    padding: 1em 1em;
    white-space: nowrap;

    white-space: normal;
    word-break: break-word;

    /* Ajoutez : */
    display: flex;
    align-items: center;
    gap: 0.5em;
    justify-content: center;

    /* Styles Thème */
    font-family: 'MainFont', sans-serif;
    text-align: center;
    font-size: 17px;
    font-weight: 600;
    text-decoration: none;
    color: var(--text-color);

    /* Effets */
    background-color: var(--background-darker-color);
    border: transparent 2px solid;
    border-radius: 1em;
    box-shadow: none;

    /* Transition */
    transition: all 0.2s ease;
}

.button-link:hover {
    border: var(--background-shadow-color) 2px solid;
    box-shadow: none;
    transform: translateY(-3px);
}

.button-link:active {
    background-color: var(--background-shadow-color);
    box-shadow: none;
    scale: 0.98;
}

.button-link.disabled {
    opacity: 0.6;
    pointer-events: none;
}

img {
    /* Positionnement et dimensionnement */
    margin-top: 1em;
    margin-bottom: 1em;
    width: 100%;
    height: 200px;
    object-fit: cover;

    /* Styles Thème */
    background-color: var(--background-element-color);
    border-radius: 1em;

    /* Effets */
    border: var(--background-darker-color) 4px solid;
    box-shadow: 0 0 0 0 var(--background-shadow-color);

    /* Transition */
    transition: all 0.3s ease;
}

img:hover {
    box-shadow: 0 5px 0 0 var(--background-shadow-color);
    transform: translateY(-5px);
}

.img-noHover:hover {
    box-shadow: 0 0 0 0 var(--background-shadow-color);
    transform: none;
}

.img-noHeight {
    height: auto;
}

.img-square {
    width: 50%;
    height: 50%;

    min-width: 200px;
   /* centrer image */
   display: block;
   margin-left: auto;
   margin-right: auto;
}


/* ===================================================
 * DIVERS
 * =================================================== */

/* Motif de points (Dots) */
.dots-background {
    /* Positionnement et dimensionnement */
    width: 100%;
    height: 100%;
    background-color: var(--background-element-color);
    background-image: radial-gradient(var(--background-darker-color) 3px, transparent 0);
    background-size: 30px 30px;


    animation: move 2s linear infinite;
    animation-play-state: paused;
    /* Pause par défaut */
    transition: animation-duration 0.5s ease-in-out, transform 0.3s ease;
}

/* Animation au survol */
.dots-background:hover {
    animation-play-state: running;
}

/* évite d'avoir une animation, pour avoir un effet statique */
.dots-background.noAnimation {
    animation-play-state: paused;
}

/* Animation */
@keyframes move {
    0% {
        background-position: 0 0;
    }

    100% {
        background-position: 30px 30px;
    }
}

.linear-gradient {
    background-image: linear-gradient(to bottom, rgba(245, 245, 245, 0.8) 0%, rgba(0, 0, 0, 0)10%);
}

.info-section {
    margin-bottom: 1em;
    display: flex;
    flex-direction: column;
}

.info-section h3 {
    /* Ajoute un espace de 1em sous le titre */
    margin-bottom: 1em;
}

.divider {
    display: block;
    width: 100%;
    height: 2px;
    margin-top: auto;
    margin-bottom: 1em;

    background-color: var(--primary-color);
    border-radius: 1em;
}

.space {
    display: block;
    width: 100%;
    height: 1em;
}

/* ===================================================
 * PANNEAU LATÉRAL / MENU
 * =================================================== */

.menu-panel {
    /*Positionnement et dimensionnement */
    position: fixed;
    top: 0;
    right: 0;
    padding: 1em;
    z-index: 1001; /* pour être devant le fond transparent noir */

    min-width: 30%;
    width: 400px;
    max-width: 80%;

    /* Styles Thème */
    background-color: var(--background-page-color);
    color: var(--text-color);
    font-weight: bolder;

    /* Effets */
    border: 2px solid var(--primary-color);
    border-radius: 0 0 0 1em;
    box-shadow: 0 0 10px var(--primary-color), 0 5px 0 0 var(--primary-color);

    /* Masquage initial */
    transform: translateY(-200%);

    /*Animation de transition */
    transition: transform 0.3s ease-out;
}

/* État Actif : Afficher le menu */
.menu-panel.is-open {
    transform: translateX(0);
}

/* Overlay pour cliquer à l'extérieur et fermer le menu */
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;

    background-color: rgba(0, 0, 0, 0.5);
     /* fond transparent noir */

    z-index: 1000;
    display: none;
    /* Caché par défaut */
}

.menu-overlay.is-active {
    display: block;
}

.menu-close-btn {
    float: right;
    z-index: 1002; /* Pour passer devant le menu et éviter les conflits avec les autres éléments du menu*/
}

.menu-links {
    list-style: none;
    padding: 0;
}

.menu-links li {
    margin: 15px 0;
}

.menu-links a {
    color: var(--text-color);
    text-decoration: none;
    font-size: 1.2em;
    transition: color 0.2s;
    display: block;
    transition: all 0.3s ease;
}

.menu-links a:hover {
    color: var(--accent-color);
    transform: translateY(-2px);
}

/* ===================================================
 * MODALE
 * =================================================== */

.project-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3000;
    /* Assurer qu'elle est au-dessus de tout, y compris du menu latéral */
    display: flex;
    justify-content: center;
    align-items: center;

    /* Masqué par défaut avec transition */
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}


.project-modal.is-open {
    visibility: visible;
    opacity: 1;
}

.modal-overlay {
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    /* Fond transparent noir */
}

.modal-content {
    padding-left: 1em;
    margin-bottom: 4em;
    position: relative;
    z-index: 3001;

    width: 90%;
    max-width: 900px;
    max-height: 90%;
    overflow:clip;

    border: 2px solid var(--primary-color);
    border-radius: 1em;
    background-color: var(--background-element-color);
    box-shadow: 0 5px 0 0 var(--primary-color);

    transform: translateY(-100px);
    transition: transform 0.3s ease;
}

/* Le scroll se fait sur le contenu interne */
#modal-project-content {
    max-height: calc(90vh - 60px);
    /* 60px = padding haut + bas de .modal-content */
    overflow-y: auto;
    padding-right: 1em;
    /* Optionnel : compense visuellement la scrollbar */
}

.project-modal.is-open .modal-content {
    transform: translateY(0px);
}

#modal-close {
    position: fixed;
    bottom: 1em;
    z-index: 3002;

    display: flex;
    flex-direction: row;
    align-items: center;

    gap: 8px;
}

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

.cards-grid {
    display: grid;
    margin-bottom: 1em;

    /* 1. auto-fit: Remplir l'espace avec autant de colonnes que possible. */
    /* 2. minmax(300px, 1fr): Chaque colonne doit faire au moins 300px, sinon elle prend le reste de l'espace (1fr). */
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5em;
}

.img-grid {
    /* Retire la grille */
    display: block;

    /* Utilise les colonnes pour l'effet maçonnerie */
    column-width: 250px;
    column-count: auto;
    width:100%
}

.img-grid img {
    width: 100%;
    margin-top: 0em;
    margin-bottom: 1em;

    /* IMPORTANT : permet le recalcul du nombre de colonnes nécessaires en fonction du contenu */
    display: block;
}

.link-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));

}

/* ===================================================
 * STYLES DE PAGE DE PROJET (basés sur le template HTML)
 * =================================================== */

.project-section {
    /* Utilise l'arrière-plan plus clair pour la mise en page */
    background-color: var(--background-element-color);
    padding: 1.5em;
    margin-bottom: 2em;
    border-radius: 1em;
    border: 2px solid var(--primary-color);
    box-shadow: 0 5px 0 0 var(--primary-color);
    text-align: justify;
    text-justify: inter-word;
}

.project .button-link {
    margin: 0;
    margin-bottom: 1em;
    display: inline-block;
    width: 100%;
}


.project h2 {
    /* Style pour les sous-titres de section */
    border-bottom: 2px solid var(--background-darker-color);
    padding-bottom: 0.5em;
    margin-bottom: 1em;
    font-size: 1.8em;
}

/* --- Bloc Highlight --- */
.highlight {
    background-color: var(--background-darker-color);
    padding: 1em;
    border-radius: 0.5em;
    margin-top: 1.5em;
    border-left: 5px solid var(--accent-color);
    /* Bande de couleur pour l'accentuation */
    font-style: italic;
}

/* --- Code Block pour l'API --- */
pre {
    background-color: var(--primary-color);
    color: var(--background-element-color);
    padding: 1em;
    border-radius: 1em;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: monospace;
    font-size: 0.9em;
    border: 2px solid var(--text-color);
}