:root {
    --primary-blue: #1D2F6F;
    --secondary-blue: #8390FA;
    --accent-orange: #FAB348;
    --text-dark: #2d3748;
    --text-light: #718096;
    --white: #ffffff;
    --bg-gray: #f7fafc;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-gray);
    color: var(--text-dark);
    line-height: 1.6;
}

/* Réutilisation de la Navigation du Portfolio */
nav {
    background-color: var(--primary-blue);
    color: var(--white);
    padding: 0.7rem 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.back-link {
    color: var(--white);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    transition: var(--transition);
}

.back-link:hover {
    color: var(--accent-orange);
}

/* Main Content Container */
.project-container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

.project-header {
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--secondary-blue);
    padding-bottom: 1.5rem;
}

.category-tag {
    display: inline-block;
    padding: 0.3rem 1rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
    text-transform: uppercase;
    margin-bottom: 1rem;
}

.project-title {
    font-size: 2rem;
    color: var(--primary-blue);
    margin-bottom: 0.5rem;
}

#title-section{
    display: flex; 
    flex-direction: column; 
    flex: 1 1 400px; 
    margin: 2rem 2rem 0 2rem;
}

.project-meta {
    color: var(--text-light);
    font-style: italic;
}

/* Sommaire / Table of contents */
.sommaire {
    background: var(--white);
    padding: 1.5rem;
    margin: 2rem 1.5rem 0 1.5rem; /* Margin for mobile view */
    border-radius: 8px;
    border-left: 3px solid var(--secondary-blue);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.sommaire h3 {
    font-size: 1.1rem;
    color: var(--primary-blue);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sommaire ul { list-style: none; padding: 0; margin: 0; }
.sommaire li { margin-bottom: 0.6rem; font-size: 0.9rem; }
.sommaire a { color: var(--text-dark); text-decoration: none; transition: var(--transition); }
.sommaire a:hover { color: var(--secondary-blue); text-decoration: underline; }
.sommaire details ul { margin-top: 0.4rem; padding-left: 1rem; border-left: 1px solid #e2e8f0; }
.sommaire summary { cursor: pointer; outline: none; }
.sommaire summary a { display: inline-block; width: calc(100% - 20px); }

.annotation {
    font-size: 0.80rem;
    font-weight: bold;
    color: var(--accent-orange);
    cursor: help; /* Changes cursor to a question mark or pointer to indicate interactivity */
    position: relative; /* Crucial: establishes a positioning context for the tooltip */    
}
.annotation:hover {
    color: var(--text-dark);
    text-decoration: underline;
}
.annotation::after {
    content: attr(data-annotation); /* Extracts the text from your HTML attribute */
    
    /* Positioning */
    position: absolute;
    bottom: 150%; /* Pushes the tooltip above the number */
    left: 50%;
    transform: translateX(-80%); /* Centers the tooltip perfectly over the number */
    
    /* Box Styling */
    width: max-content; 
    max-width: 200px; /* Prevents the tooltip from stretching entirely across the screen */
    background-color: var(--text-dark); /* Dark background for contrast */
    color: #fff;
    padding: 8px 12px;
    font-size: 0.85rem;
    border-radius: 6px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    
    /* Hiding mechanism */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease-in-out; /* Smooth fade-in effect */
    z-index: 10; 
    pointer-events: none; /* Prevents the hidden tooltip from blocking clicks */

    text-align: left;
}
/* Show the tooltip when hovering over the number */
.annotation:hover::after {
    opacity: 1;
    visibility: visible;
}


.wiki-tooltip {
    position: absolute;
    width: 440px;
    max-width: 80vw; /* Ensures it doesn't overflow on smaller screens */
    background: var(--bg-gray); /* Dark theme to match your previous Iframely look */
    color: var(--text-dark);
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    padding: 15px;
    font-size: 0.9rem;
    line-height: 1.4;
    z-index: 1000;
    
    /* Hidden by default */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease;
    pointer-events: none; /* Prevents cursor interference */
}
/* Class added by JS to show the tooltip */
.wiki-tooltip.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto; /* Allows the user to click the link inside the tooltip */
}
.wiki-body::after {
    content: "";
    display: table;
    clear: both;
}
/* Style only the thumbnail image, not the logo */
.wiki-tooltip .wiki-thumb {
    float: left;
    max-width: 80px;
    margin-right: 15px;
    margin-bottom: 5px;
    border-radius: 4px;
}
.wiki-tooltip h4 {
    margin: 0 0 5px 0;
    font-size: 1.1rem;
    color: var(--primary-blue);
}
/* The new footer styling */
.wiki-footer {
    font-size: 0.75rem;
    color: var(--text-light);
    display: flex;
    align-items: center; /* Vertically centers the logo and text */
}
/* The Wikipedia 'W' logo */
.wiki-tooltip .wiki-logo {
    width: 16px;
    height: auto;
    margin-right: 6px;
    opacity: 0.8; /* Dims the logo slightly so it isn't distracting */
    border: 1px solid var(--text-light);
    border-radius: 4px;
    box-sizing: border-box;
}


/* Description et analyse */
.article-body {
    background: var(--white);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    margin-bottom: 3rem;
}

.article-body img {
    border-radius: 8px;
}

.article-body h2 {
    color: var(--primary-blue);
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}
.article-body h3 {
    color: var(--primary-blue);
    margin-bottom: 0.8rem;
    font-size: 1.1rem;
}

.article-body p {
    margin-bottom: 1.2rem;
    text-align: justify;
}
.wiki-body p{
    text-align: left;
    font-size: 0.8rem;
    margin-bottom: 8px;
}

.article-body ul {
    margin: 0 0 0 2rem;
}
.article-body li{
    margin: 0 0 0.8rem 0;
}

.article-body u{
    text-decoration: none;
    background-color: #FAB34847 /*#8391fa47*/;
}

a{
    color: var(--secondary-blue);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

/* .wikimedia {

}*/

figure{
    border: 1px solid var(--text-dark);
    border-radius: 8px;
    width: min-content;
}

figcaption{
    font-size: 0.8rem;
    text-align: center;
    hyphens: auto;
    height: min-content;
    padding: 0 0.4rem 0.4rem 0.4rem;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    opacity: 0.6;
    font-size: 0.8rem;
}


/* Responsiveness: Desktop Layout Changes */
@media (min-width: 1025px) {
    body {
        display: grid;
        /* Column 1: Fixed sidebar space on the far left edge 
           Column 2: Flexible remaining area for the main content */
        grid-template-columns: 280px 1fr;
        grid-template-rows: auto 1fr auto;
    }

    /* Keep Navigation and Footer stretching across both columns */
    nav, footer {
        grid-column: 1 / -1;
    }

    .sommaire {
        grid-column: 1;
        margin: 0; /* Clear mobile margins */
        padding: 2rem 1.5rem;
        background: transparent; /* Wikipedia sidebars usually blend into the background */
        box-shadow: none;
        border-radius: 0;
        border-left: none;
        border-right: 1px solid #e2e8f0; /* Subtle dividing line on the right edge */
        
        /* Fixed/Sticky Behavior */
        position: sticky;
        top: 4.5rem; 
        height: calc(100vh - 4.5rem);
        overflow-y: auto;
    }

    .project-container {
        grid-column: 2;
        width: 100%;
        max-width: 1000px; /* Restricting the text line-length for optimal reading comfort */
        margin: 2rem auto; /* Centers the article container within the right side of the screen */
        padding: 0 3rem;
    }
}

/* Medium tablets adjustment */
@media (max-width: 1024px) and (min-width: 769px) {
    .sommaire {
        margin: 2rem auto 0 auto;
        max-width: 1200px;
        width: calc(100% - 3rem);
    }
}

@media (max-width: 768px) {
    .project-title { font-size: 1.8rem; }

    .annotation::after {
    /* Transform from a floating tooltip to a fixed bottom panel */
    position: fixed;
    bottom: 20px;
    top: auto;
    left: 50%;
    transform: translateX(-50%);
    
    /* Adjust sizing for mobile */
    width: calc(100vw - 40px); /* Stretches across the screen with 20px margins */
    max-width: none;
    box-sizing: border-box;
    
    /* Ensure it floats above everything else, including your sticky nav */
    z-index: 2000; 
    
    /* Optional: Make the text slightly larger for easier mobile reading */
    font-size: 0.9rem;
    padding: 12px 15px;
    }

    #title-section{
        margin: 1rem 1rem 0 1rem;
    }

    .project-container{
        padding: 1rem;
    }

    .article-body{
        padding: 1rem;
    }

    .article-body p {
    hyphens: auto;
    }
}
