:root {
    --bg-dark: #050505;        /* Fond de page quasi noir */
    --parchment-bg: #1a1815;   /* Couleur de fond du "Codex" */
    --accent-gold: #8e7341;    /* Or vieilli/terne */
    --text-old: #b9b19a;       /* Blanc cassé / Papyrus */
    --border-style: 2px double var(--accent-gold);
    --font-titles: 'Cinzel', serif;
    --font-body: 'Montserrat', sans-serif;
}

* {margin: 0; padding: 0; box-sizing: border-box;}

body {
    font-family: 'Montserrat', sans-serif;
    background-color: var(--deep-black);
    color: #eee;
    line-height: 1.6;
}

.codex-wrapper {
    max-width: 1450px;
    margin: 60px auto;
    padding: 20px;
}

/* --- La Carte Codex (Effet Manuscrit) --- */
.project-detail-card {
    background-color: var(--parchment-bg);
    border: 1px solid #332f2a;
    outline: 4px double var(--accent-gold); /* Double bordure dorée */
    outline-offset: -15px; /* Décale la bordure vers l'intérieur */
    padding: 80px 60px;
    position: relative;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.9);
}

/* Ornements aux coins */
.project-detail-card::before, .project-detail-card::after {
    content: "✦";
    position: absolute;
    color: var(--accent-gold);
    font-size: 1.5rem;
}
.project-detail-card::before { top: 25px; left: 25px; }
.project-detail-card::after { bottom: 25px; right: 25px; }

/* --- En-tête --- */
.project-header {
    text-align: center;
    margin-bottom: 60px;
}

.project-header h1 {
    font-family: var(--font-titles);
    font-size: 3.2rem;
    color: var(--accent-gold);
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    margin: 0;
    letter-spacing: 3px;
}

.header-ornament {
    font-size: 1.5rem;
    color: var(--accent-gold);
    opacity: 0.6;
    margin: 10px 0;
}

/* --- Mise en page type "Registre" --- */
.project-grid {
    display: flex;
    flex-direction: column; /* On empile pour faire défilement vertical */
    gap: 40px;
}

.project-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    border-top: 1px solid var(--accent-gold);
    border-bottom: 1px solid var(--accent-gold);
    padding: 20px 0;
    text-align: center;
}

.info-block h3 {
    font-family: var(--font-titles);
    font-size: 0.8rem;
    letter-spacing: 2px;
    margin-bottom: 5px;
    color: var(--accent-gold);
}

.info-block p {
    font-size: 0.9rem;
    margin: 0;
    text-transform: uppercase;
}

/* --- Contenu de l'Archive --- */
.project-description {
    position: relative;
    padding-top: 20px;
}

/* --- COLLABORATEURS TAB --- */
.collab-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); /* Légèrement élargi pour plus de confort */
    gap: 25px;
    margin-top: 20px;
}

.collab-card {
    background: rgba(28, 28, 28, 0.6);
    border: 1px solid rgba(197, 160, 89, 0.2);
    border-radius: 8px;
    padding: 25px;
    transition: 0.3s;
    position: relative;
    overflow: hidden; /* Sécurité pour le contenu */
}

.collab-card:hover {
    border-color: var(--accent-gold);
    background: rgba(28, 28, 28, 0.9);
    transform: translateY(-5px);
}

.collab-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(197, 160, 89, 0.1);
    padding-bottom: 15px;
}

.collab-avatar {
    width: 55px;
    height: 55px;
    background: var(--accent-gold);
    color: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.5rem;
    border-radius: 4px;
    font-family: var(--font-titles);
}

.collab-identity h3 {
    margin: 0;
    font-family: var(--font-titles);
    color: var(--accent-gold);
    font-size: 1.2rem;
}

/* --- RESEAUX SOCIAUX (ICON FONTS) --- */
.collab-socials {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.collab-socials a {
    color: var(--text-old);
    text-decoration: none;
    font-size: 1.1rem; /* Taille adaptée pour Font Awesome */
    transition: 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.collab-socials a:hover {
    color: var(--accent-gold);
    transform: scale(1.2);
}

/* --- INFOS ET TEXTE (REGLAGE DEBORDEMENT) --- */
.collab-info-item {
    margin-bottom: 15px;
}

.collab-info-item strong {
    display: flex;
    align-items: center;
    gap: 8px; /* Espace entre l'icône et le texte */
    color: var(--accent-gold);
    font-size: 0.85rem;
    text-transform: uppercase;
    margin-bottom: 5px;
    font-family: var(--font-titles);
}

.collab-info-item strong .material-symbols-outlined {
    font-size: 1.1rem; /* Taille de l'icône harmonisée */
}

.collab-info-item p {
    font-size: 0.9rem;
    color: var(--text-old);
    line-height: 1.5;
    margin: 0;
    /* --- SOLUTION AU DEBORDEMENT --- */
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-all; /* Force la coupure si le mot est trop long (type qzdzq...) */
}

/* --- AVIS ET NOTES --- */
.collab-reviews {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 15px;
}

.review-box {
    background: rgba(0, 0, 0, 0.4);
    padding: 12px;
    border-radius: 4px;
    border-top: 1px solid rgba(197, 160, 89, 0.1);
}

.review-box small {
    display: block;
    color: var(--accent-gold);
    font-size: 0.65rem;
    text-transform: uppercase;
    margin-bottom: 5px;
    font-weight: bold;
    letter-spacing: 1px;
}

.review-box p {
    font-size: 0.8rem;
    font-style: italic;
    margin: 0;
    color: #ccc;
    word-wrap: break-word;
    word-break: break-all;
}

/* Lettrine (Première lettre plus grande) */
.content-text::first-letter {
    float: left;
    font-family: var(--font-titles);
    font-size: 4rem;
    line-height: 1;
    padding-right: 12px;
    color: var(--accent-gold);
    font-weight: bold;
}

.content-text {
    font-size: 1.1rem;
    line-height: 1.8;
    text-align: justify;
    color: #cdc1a7;
}

/* --- Bouton de retour --- */
.btn-back {
    display: inline-block;
    color: var(--accent-gold);
    text-decoration: none;
    font-family: var(--font-titles);
    margin-bottom: 20px;
    text-transform: uppercase;
    font-size: 0.8rem;
}

.btn-back:hover {
    filter: brightness(1.3);
}

/* --- Système d'onglets --- */
.codex-tabs {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 20px;
}

.tab-btn {
    background: transparent;
    border: none;
    font-family: var(--font-titles);
    color: var(--text-old);
    font-size: 0.9rem;
    cursor: pointer;
    text-transform: uppercase;
    padding: 10px 20px;
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
    opacity: 0.6;
}

.tab-btn:hover {
    opacity: 1;
    color: var(--accent-gold);
}

.tab-btn.active {
    opacity: 1;
    color: var(--accent-gold);
    border-bottom: 2px solid var(--accent-gold);
    text-shadow: 0 0 10px rgba(142, 115, 65, 0.3);
}

/* --- Contenu des onglets --- */
.tab-content {
    display: none; /* Caché par défaut */
    animation: fadeIn 0.5s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Section GitHub --- */
.github-card {
    display: flex;
    align-items: center;
    gap: 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed var(--accent-gold);
    padding: 20px;
    text-decoration: none;
    color: var(--text-old);
    transition: 0.3s;
    margin-top: 20px;
}

.github-card:hover {
    background: rgba(142, 115, 65, 0.1);
}

/* --- Section Skills --- */
.skills-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 20px;
}

.skill-rune {
    border: 1px solid var(--accent-gold);
    padding: 5px 15px;
    font-size: 0.8rem;
    text-transform: uppercase;
    background: rgba(0,0,0,0.3);
    color: var(--accent-gold);
    box-shadow: inset 0 0 5px rgba(142, 115, 65, 0.2);
}

/* --- Grille des Technologies --- */
.tech-stack {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 2rem;
    padding: 2rem 0;
}

.tech-card {
    background: rgba(20, 20, 20, 0.6);
    border: 1px solid rgba(143, 107, 30, 0.2);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
}

.tech-card::before {
    content: "";
    position: absolute;
    top: 0; left: 0; width: 100%; height: 2px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    transform: translateX(-100%);
    transition: 0.5s;
}

.tech-card:hover {
    border-color: var(--gold);
    transform: translateY(-10px);
    background: rgba(30, 30, 30, 0.8);
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
}

.tech-card:hover::before {
    transform: translateX(100%);
}

.tech-icon-container {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: grayscale(100%) sepia(50%) brightness(80%); /* Effet "vieux grimoire" */
    transition: all 0.3s ease;
}

.tech-card:hover .tech-icon-container {
    filter: grayscale(0%) sepia(0%) brightness(110%); /* Retour aux couleurs au survol */
    transform: scale(1.1);
}

.tech-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Conteneur pour aligner le texte proprement */
.tech-details {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 100%;
}

.tech-name {
    font-family: 'Cinzel', serif;
    font-size: 0.95rem;
    color: var(--gold);
    text-align: center;
    letter-spacing: 1px;
}

/* Le label du type de tech */
.tech-type-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    color: #888;
    letter-spacing: 2px;
    
    display: inline-block;   /* Permet de contrôler la largeur et le centrage */
    width: fit-content;      /* S'adapte à la taille du mot */
    max-width: 90%;          /* Évite de toucher les bords de la carte */
    margin: 0 auto;          /* Centre le bloc lui-même */
    
    border-top: 1px solid rgba(143, 107, 30, 0.2);
    padding-top: 6px;
    line-height: 1.2;
}

/* Effet au survol de la carte */
.tech-card:hover .tech-type-label {
    color: var(--dark-gold);
    border-top-color: var(--dark-gold);
}

.tech-card:hover .tech-name {
    color: var(--gold);
}

.tech-placeholder {
    font-size: 2rem;
    color: var(--dark-gold);
}

.github-container {
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 300px;
}

#languagesChart {
    max-width: 100% !important;
    max-height: 250px !important; /* Contrôle la taille du cercle */
    margin-bottom: 20px;
}

#lang-legend {
    font-family: 'Cinzel', serif;
    color: #d4af37;
    text-align: center;
    letter-spacing: 1px;
}

.github-container {
    display: flex;
    flex-direction: column;
    gap: 80px; /* Espace entre les blocs */
    padding: 20px 0;
}

.github-row {
    display: flex;
    align-items: center;
    gap: 40px;
    flex-wrap: wrap; /* Pour le responsive mobile */
}

/* L'alternance : texte à gauche, image à droite */
.github-row.reverse {
    flex-direction: row-reverse;
}

.github-visual {
    flex: 1;
    min-width: 300px;
    background: rgba(0, 0, 0, 0.2);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid rgba(212, 175, 55, 0.1);
}

.canvas-container {
    position: relative;
    height: 300px; /* Hauteur fixe pour les graphiques */
    width: 100%;
}

.github-text {
    flex: 1;
    min-width: 300px;
}

.github-text h3 {
    font-family: 'Cinzel', serif;
    color: #d4af37;
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.github-text p {
    font-family: 'Montserrat', sans-serif;
    color: #b9b19a;
    line-height: 1.6;
}

.github-status {
    text-align: center;
    font-style: italic;
    color: #d4af37;
    margin-top: 20px;
}

.pdf-container {
    margin-top: 30px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px;
    border-style: solid;
    border-color: #d4af37; /* Ton doré */
    border-radius: 8px;
    text-align: center;
}

.pdf-viewer {
    margin: 20px 0;
    border: 2px solid #1a1815;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    display: block;
    width: 100%;
    height: 500px;
}

.mosaic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    grid-auto-rows: 200px; /* Hauteur de base des lignes */
    grid-gap: 15px;
    grid-auto-flow: dense; /* Remplit les trous automatiquement */
}

.mosaic-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    border: 1px solid rgba(212, 175, 55, 0.3);
    cursor: pointer;
}

/* Variations de tailles pour l'effet mosaïque */
.mosaic-item.wide { grid-column: span 2; }
.mosaic-item.tall { grid-row: span 2; }

.mosaic-item img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Important pour ne pas déformer */
    transition: transform 0.5s ease;
}

/* Effet de survol doré */
.mosaic-item .overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(26, 24, 21, 0.8); /* Ton sombre */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    color: #d4af37;
    font-size: 2em;
}

.mosaic-item:hover .overlay { opacity: 1; }
.mosaic-item:hover img { transform: scale(1.1); }

/* La boîte noire qui couvre tout l'écran */
#lightbox {
    display: none;        /* Caché par défaut */
    position: fixed;      /* Reste en place même si on scroll */
    z-index: 10000;       /* Chiffre très haut pour être au-dessus du header */
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.9); /* Fond noir transparent */
    justify-content: center;
    align-items: center;
    cursor: pointer;      /* Curseur main pour indiquer qu'on peut fermer */
}

/* L'image à l'intérieur de la modale */
#lightbox-img {
    max-width: 90%;
    max-height: 85%;
    border: 2px solid #d4af37; /* Bordure dorée pour ton style Codex */
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
    object-fit: contain;
}

/* Optionnel : petite animation d'apparition */
#lightbox.active {
    display: flex !important;
    animation: fadeIn 0.3s ease-out;
}

.btn-download {
    display: inline-block;
    padding: 12px 25px;
    background: transparent;
    color: #d4af37;
    border: 1px solid #d4af37;
    text-decoration: none;
    font-family: 'Cinzel', serif;
    transition: all 0.3s ease;
    border-radius: 4px;
    font-size: 0.9em;
}

.btn-download:hover {
    background: #d4af37;
    color: #1a1815;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
}

.btn-download i {
    margin-right: 8px;
}

.readme-container {
    margin-top: 50px;
    padding: 30px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px dotted rgba(212, 175, 55, 0.3);
    border-radius: 8px;
    color: #e0e0e0;
    line-height: 1.6;
}

.markdown-body h1, .markdown-body h2 {
    color: #d4af37;
    font-family: 'Cinzel', serif;
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
    margin-top: 24px;
}

.markdown-body code {
    background: rgba(112, 0, 255, 0.1);
    color: #00b4d8;
    padding: 2px 5px;
    border-radius: 4px;
}

.markdown-body pre {
    background: #0d0d0d;
    padding: 15px;
    overflow-x: auto;
    border-left: 3px solid #7000ff;
}

/* --- Media Queries --- */
@media (max-width: 768px) {
    .codex-tabs { gap: 10px; flex-wrap: wrap; }
    .tab-btn { padding: 10px; font-size: 0.8rem; }
    
    .github-row, .github-row.reverse {
        flex-direction: column;
        text-align: center;
    }
    
    .mosaic-item.wide { grid-column: span 1; } /* Empêche les images larges de casser le layout mobile */
    .pdf-viewer { display: none; } /* On cache l'iframe sur mobile pour utiliser le bouton download */
}

@media (max-width: 600px) {
    .project-detail-card {
        padding: 40px 20px;
        outline-offset: -10px;
    }
    .project-header h1 {
        font-size: 2rem;
    }
    .project-info { grid-template-columns: 1fr; }
}