/* ==========================================================================
   0. DESIGN SYSTEM & RESET (Le "White Cube")
   ========================================================================== */
:root {
    /* --- Couleurs --- */
    --c-body-bg: #f2f2f3;     /* Gris très doux pour le fond hors-page (écrans géants) */
    --c-page-bg: #ffffff;     /* Blanc immaculé pour la page elle-même */
    --c-text: #333333;        /* Gris très foncé pour reposer les yeux */
    --c-text-dark: #000000;   /* Noir absolu pour les titres forts */
    --c-accent: #000000;      /* Noir pour les interactions (survol) */
    --c-border: #eaeaea;      /* Bordures très discrètes */
    --c-bg-alt: #f8f9fa;      /* Fond pour les blocs secondaires / ressources */
    
    /* --- Typographie --- */
    --font-serif: 'Lora', serif;
    --font-sans: 'Montserrat', sans-serif;
    
    /* --- Dimensions & Espacements --- */
    --max-width: 1600px;      /* NOUVEAU : Conteneur élargi pour magnifier les œuvres */
    --sidebar-width: 260px;   /* Largeur du menu de gauche */
    --gap: 2rem;              /* Espacement standard (environ 32px) */
}

/* Reset propre */
*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    padding: 0;
    background-color: var(--c-body-bg); 
    color: var(--c-text);
    /* Typographie fluide : 16px sur mobile, grimpe jusqu'à 18px sur grand écran */
    font-size: clamp(1rem, 0.95rem + 0.25vw, 1.125rem); 
    font-family: var(--font-serif);
    line-height: 1.65;
    overflow-x: hidden;
}

/* Images fluides par défaut */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Styles des liens textuels (discrets et élégants) */
a { color: inherit; text-decoration: none; transition: all 0.3s ease; }
.content p a, .content li a, .cartel a {
    border-bottom: 1px solid #ccc;
    padding-bottom: 1px;
}
.content p a:hover, .content li a:hover, .cartel a:hover {
    color: var(--c-accent);
    border-bottom-color: var(--c-accent);
}
/* Exception : pas de soulignement si le lien contient une image */
.content a:has(img) { border-bottom: none; }


/* ==========================================================================
   1. STRUCTURE GÉNÉRALE (Le Passe-Partout)
   ========================================================================== */
.wrapper {
    max-width: var(--max-width);
    margin: 0 auto; /* Centre le site au milieu de l'écran */
    background-color: var(--c-page-bg);
    min-height: 100vh;
    box-shadow: 0 0 50px rgba(0,0,0,0.05); /* Ombre douce pour détacher la page */
    
    display: grid;
    /* Sur mobile par défaut, tout est empilé */
    grid-template-columns: 1fr;
    grid-template-areas: 
        "header" 
        "nav" 
        "content" 
        "footer";
}

.main-head { grid-area: header; padding: 2rem 1rem; text-align: center; }
.main-head h1 { 
    font-family: var(--font-sans); 
    font-weight: 700; 
    font-size: clamp(1.2rem, 3vw, 2.5rem); 
    margin: 0; 
    line-height: 1.2; 
    letter-spacing: 2px; 
    color: var(--c-text-dark); 
}

.content { grid-area: content; padding: 2rem var(--gap); min-width: 0; }

.main-footer { 
    grid-area: footer; 
    border-top: 1px solid var(--c-border); 
    padding: 2rem; 
    text-align: center; 
    font-size: 0.85em; 
    margin-top: 3rem;
}

/* --- Version Desktop (min 900px) --- */
@media (min-width: 900px) {
    .wrapper {
        grid-template-columns: var(--sidebar-width) 1fr;
        grid-template-areas: 
            "header header" 
            "side content" 
            "footer footer";
    }
    .main-head { padding: 4rem 0; }
    
    /* Le menu de gauche fixe l'identité visuelle */
    .side { 
        display: block; 
        grid-area: side; 
        padding-left: 2rem; 
        border-right: 1px solid var(--c-border); 
    }
    .side ul { list-style: none; padding: 0; margin: 0 0 2rem 0; }
    .side li { margin-bottom: 1.2rem; }
    .side a { 
        font-family: var(--font-sans); 
        font-size: 1rem; 
        font-weight: 500; 
        letter-spacing: 2px; 
        text-transform: uppercase; 
    }
    .side a:hover { padding-left: 5px; }

    /* On cache la mécanique du menu mobile */
    .main-nav, #sandwich, label[for="toggle"] { display: none !important; }
}


/* ==========================================================================
   2. TYPOGRAPHIE & CONFORT DE LECTURE
   ========================================================================== */
h2, h3, h4, .main-nav, #sandwich {
    font-family: var(--font-sans);
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--c-text-dark);
}

h2 { font-size: 1.5rem; margin-top: 0; margin-bottom: 2rem; border-bottom: 2px solid var(--c-border); padding-bottom: 0.5rem; }
h3 { font-size: 1.2rem; margin-top: 2.5rem; margin-bottom: 1rem; }
h4 { font-size: 1rem; margin-top: 2rem; margin-bottom: 1rem; }

b, strong { font-weight: 700; color: var(--c-text-dark); }

/* Contrainte de lecture pour les yeux : pas plus de 75 caractères par ligne */
.content p, .content ul, .content ol {
    max-width: 75ch; 
    text-align: left; /* Fin du justify qui fait des trous sur le web */
    margin-bottom: 1.5rem;
}

/* Séparateur propre */
.separation { width: 100%; height: 1px; background-color: var(--c-border); margin: 3rem 0; clear: both; }


/* ==========================================================================
   3. RÈGLES DES MÉDIAS (La règle des 65% / 100% / Habillage)
   ========================================================================== */

/* --- A. MÉDIA + TEXTE (Image ou Vidéo) -> 65% max et habillage --- */
.media-text-split, .layout-large-media {
    display: block;
    margin-bottom: 2rem;
    clear: both;
}
/* Clearfix pour empêcher le bloc de s'effondrer */
.media-text-split::after, .layout-large-media::after {
    content: ""; display: table; clear: both;
}
.media-text-split .media-part, .layout-large-media .media-container {
    width: 100%;
    margin-bottom: 1rem;
}

@media (min-width: 1100px) {
    .media-text-split .media-part {
        float: left;
        max-width: 65%; /* MAGIE : max-width au lieu de width. Le bloc s'adapte à l'image ! */
        margin-right: var(--gap);
        margin-bottom: 1rem;
    }
    .layout-large-media .media-container {
        float: left;
        width: 65%; /* On garde 65% fixe pour les vidéos pour garantir un grand lecteur */
        margin-right: var(--gap);
        margin-bottom: 1rem;
    }
}

/* La limite de hauteur universelle pour les images habillées */
.media-text-split .media-part img {
    max-height: 75vh; /* L'image ne dépasse jamais 75% de l'écran en hauteur */
    width: auto;      /* Garde le ratio intact */
    max-width: 100%;  /* Sécurité : ne dépasse jamais son conteneur */
    display: block;
}

.media-text-split .text-part, .layout-large-media .text-container {
    display: block;
}
/* Annule la marge haute du texte pour un alignement parfait avec le média */
.media-text-split .text-part > *:first-child, .layout-large-media .text-container > *:first-child {
    margin-top: 0;
}
/* Permettre l'habillage en annulant la limite de largeur du texte à côté des grands médias */
.media-text-split .text-part p,
.media-text-split .text-part ul,
.media-text-split .text-part ol,
.layout-large-media .text-container p,
.layout-large-media .text-container ul,
.layout-large-media .text-container ol {
    max-width: none; 
}
/* --- B. IMAGES SEULES (Sans texte) --- */

/* Image large sans texte -> 100% */
.media-single-wide {
    width: 100%;
    margin-bottom: 2rem;
    clear: both;
}
.media-single-wide img {
    width: 100%;
    height: auto;
    display: block;
}

/* Image haute sans texte -> 65% */
.media-single-portrait {
    width: 100%;
    margin-bottom: 2rem;
    clear: both;
}
@media (min-width: 1100px) {
    .media-single-portrait {
        width: 65%; /* Contraint l'image haute à 65% */
    }
}
.media-single-portrait img {
    width: 100%;
    height: auto;
    display: block;
}

/* --- C. Ratios pour les vidéos --- */
.ratio-16-9 { aspect-ratio: 16 / 9; }
.ratio-3-2 { aspect-ratio: 3 / 2; }
.media-container iframe, .media-container video { width: 100%; height: 100%; display: block; border: none; }


/* ==========================================================================
   4. SYSTÈME DE GRILLES RATIONNELLES (Zéro espace vide)
   ========================================================================== */
/* 
   MODE D'EMPLOI POUR VOS ARTICLES :
   Choisissez la classe en fonction du nombre total de photos.
   - 12 photos -> .grid-4, .grid-3, .grid-6 ou .grid-2
   - 8 photos -> .grid-4 ou .grid-2
   - 6 photos -> .grid-3 ou .grid-2
   - 5 photos -> .grid-5
*/

/* Base commune */
.grid-2, .grid-3, .grid-4, .grid-5, .grid-6, .grid-8, .grid-9 {
    display: grid;
    gap: var(--gap);
    margin-bottom: 2rem;
    clear: both;
}

.grid-2 img, .grid-3 img, .grid-4 img, .grid-5 img, .grid-6 img, .grid-8 img, .grid-9 img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border: 1px solid var(--c-border);
}

/* .grid-2 : GRANDES PHOTOS (Pour 2, 4, 6, 8, 10, 12 photos) */
.grid-2 { grid-template-columns: 1fr; }
@media (min-width: 600px) { .grid-2 { grid-template-columns: repeat(2, 1fr); } }

/* .grid-3 : PHOTOS MOYENNES (Pour 3, 6, 9, 12 photos) */
.grid-3 { grid-template-columns: 1fr; }
@media (min-width: 700px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }

/* .grid-4 : PETITES PHOTOS (Pour 4, 8, 12 photos) */
.grid-4 { grid-template-columns: 1fr; }
@media (min-width: 600px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .grid-4 { grid-template-columns: repeat(4, 1fr); } }

/* .grid-5 : Pour 5, 10 photos */
.grid-5 { grid-template-columns: 1fr; }
@media (min-width: 900px) { .grid-5 { grid-template-columns: repeat(5, 1fr); } }

/* .grid-6 : MINIATURES (Pour 6, 12 photos) */
.grid-6 { grid-template-columns: 1fr; }
@media (min-width: 600px) { .grid-6 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .grid-6 { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1200px) { .grid-6 { grid-template-columns: repeat(6, 1fr); } }

/* .grid-8 : Pour 8 photos */
.grid-8 { grid-template-columns: 1fr; }
@media (min-width: 600px) { .grid-8 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .grid-8 { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1400px) { .grid-8 { grid-template-columns: repeat(8, 1fr); } }

/* .grid-9 : Pour 9 photos */
.grid-9 { grid-template-columns: 1fr; }
@media (min-width: 700px) { .grid-9 { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1400px) { .grid-9 { grid-template-columns: repeat(9, 1fr); } }


/* ==========================================================================
   5. COMPOSANTS SPÉCIFIQUES (Boutons, Cartels, Ressources)
   ========================================================================== */

/* Boutons */
.btn {
    display: inline-block;
    background: var(--c-text-dark);
    color: #fff;
    font-family: var(--font-sans);
    text-transform: uppercase;
    font-size: 0.85em;
    letter-spacing: 1px;
    padding: 12px 24px;
    border: none;
    cursor: pointer;
}
.btn:hover { background: #444; color: #fff; border-bottom: none; }

/* Cartel d'œuvre */
.cartel {
    font-size: 0.9em;
    line-height: 1.5;
    color: var(--c-text);
    padding-left: 1rem;
    border-left: 3px solid var(--c-border);
    margin-top: 1rem;
    margin-bottom: 2rem;
}

/* Bloc ressource (pour les liens de la page texte/dessin) */
.bloc-ressource {
    background-color: var(--c-bg-alt);
    border: 1px solid var(--c-border);
    padding: 2rem;
    border-radius: 4px;
}
.bloc-ressource h3, .bloc-ressource .titre-ressource { margin-top: 0; font-size: 1.1em; }

/* Tuiles de l'accueil (Bento) */
.mosaik-card {
    position: relative;
    display: block;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: #000;
    border-radius: 4px;
}
.mosaik-card img {
    width: 100%; height: 100%; object-fit: cover;
    transition: transform 0.5s ease, opacity 0.5s ease;
    opacity: 0.85;
}
.mosaik-content {
    position: absolute; bottom: 0; left: 0; width: 100%;
    padding: 2rem;
    background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
    color: #fff;
}
.mosaik-content h3 { color: #fff; margin: 0 0 0.5rem 0; border: none; }
.mosaik-card:hover img { transform: scale(1.05); opacity: 0.6; }

/* Menu Mobile sans JS */
#toggle { display: none; }
@media (max-width: 899px) {
    .side { display: none; }
    .main-nav { grid-area: nav; border-top: 1px solid var(--c-border); border-bottom: 1px solid var(--c-border); }
    #menu-apparent { display: none; padding: 1rem; background: var(--c-bg-alt); }
    #toggle:checked + #menu-apparent { display: block; }
    #sandwich { display: block; padding: 1rem; cursor: pointer; text-align: center; margin:0;}
    .main-nav ul { list-style: none; padding: 0; margin: 0; }
    .main-nav li { padding: 0.5rem 0; border-bottom: 1px solid var(--c-border); }
}


/* ==========================================================================
   6. PAGES SPÉCIFIQUES (Peinture, Événements, Formulaires)
   ========================================================================== */

/* Galerie Masonry (Style Pinterest pour la page Peinture) */
.gallery-masonry {
    column-count: 1;
    column-gap: var(--gap);
    margin-bottom: 3rem;
}
@media (min-width: 600px) { .gallery-masonry { column-count: 2; } }
@media (min-width: 1000px) { .gallery-masonry { column-count: 3; } }
@media (min-width: 1400px) { .gallery-masonry { column-count: 4; } }

.gallery-masonry > div {
    break-inside: avoid;
    margin-bottom: var(--gap);
}
.gallery-masonry img {
    width: 100%; height: auto; display: block; border: 1px solid var(--c-border);
}
.gallery-masonry p {
    margin: 0.5rem 0 0 0; font-size: 0.85em; color: #666; line-height: 1.4;
}

/* Liste des événements (Cartes avec habillage de texte) */
.list-events {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--gap);
}
@media (min-width: 1000px) { .list-events { grid-template-columns: repeat(2, 1fr); } }

.event-card {
    display: block;
    background-color: var(--c-bg-alt);
    padding: 1.5rem;
    border: 1px solid var(--c-border);
    border-radius: 4px;
}
.event-card::after { content: ""; display: table; clear: both; }
.event-card > a {
    float: left;
    width: 85px;
    margin-right: 1.5rem;
    margin-bottom: 0.5rem;
}
.event-card img {
    width: 100%; height: 120px; object-fit: cover; border: 1px solid #ccc; display: block;
}
.event-card-content { display: block; }
.event-card-content h3 { margin-top: 0; font-size: 1.1rem; margin-bottom: 0.5rem; }
.event-card-content p { margin: 0; font-size: 0.9em; max-width: none; }

/* Formulaires (Contact, Newsletter) */
.form-container { display: flex; flex-direction: column; gap: 3rem; }
@media (min-width: 900px) {
    .form-container { flex-direction: row; align-items: flex-start; }
    .form-explications { flex: 1; }
    .form-fields { 
        flex: 1.5; background-color: var(--c-bg-alt); padding: 2.5rem; 
        border-radius: 4px; border: 1px solid var(--c-border); 
    }
}
.form-group { margin-bottom: 1.5rem; }
.form-group label { 
    display: block; font-family: var(--font-sans); font-size: 0.85em; 
    font-weight: 700; margin-bottom: 0.5rem; color: var(--c-text); 
    text-transform: uppercase; letter-spacing: 1px; 
}
.form-group input[type="text"], .form-group input[type="email"], .form-group textarea {
    width: 100%; padding: 12px; border: 1px solid #ccc; border-radius: 4px; 
    font-family: var(--font-serif); font-size: 1rem; background-color: #fff;
}
.form-group textarea { resize: vertical; min-height: 150px; }
.msg-error { 
    color: #d9534f; font-weight: bold; margin-top: 1rem; padding: 1rem; 
    border: 1px solid #d9534f; background-color: #fdf0f0; border-radius: 4px; 
}
.msg-success { 
    background-color: #e6fffa; border: 1px solid #008000; color: #008000; 
    padding: 2rem; border-radius: 4px; font-weight: bold; text-align: center; 
}


/* ==========================================================================
   7. LE JOURNAL (Navigation, Transcriptions, Audio)
   ========================================================================== */

/* Navigation inter-années */
.journal-nav {
    display: flex; gap: 1rem; margin-bottom: 2rem; padding-bottom: 1rem; border-bottom: 1px solid var(--c-border);
}
.journal-nav select {
    padding: 0.5rem; font-family: var(--font-sans); border: 1px solid var(--c-border); background: var(--c-bg-alt);
}

/* Structure des articles */
article.journal { margin-bottom: 4rem; padding-bottom: 2rem; border-bottom: 1px solid var(--c-border); clear: both; }
article.journal:last-of-type { border-bottom: none; }
article.journal h4 {
    background-color: var(--c-bg-alt); padding: 1rem; border-left: 4px solid var(--c-accent); margin-top: 0;
}

/* Transcriptions (Accordéons sans JS) */
.transcription-wrapper { margin-top: 1rem; margin-bottom: 1rem; clear: both; }
.transcription-content {
    max-height: 0; overflow: hidden; transition: max-height 0.5s ease, opacity 0.5s ease; opacity: 0;
    padding-left: 1rem; border-left: 2px solid var(--c-border);
}
.toggle-transcription:checked ~ .transcription-content {
    max-height: 5000px; opacity: 1; margin-top: 1rem; padding-bottom: 1rem;
}
.btn-transcription {
    display: inline-block; font-family: var(--font-sans); font-size: 0.75em; cursor: pointer;
    background: var(--c-bg-alt); padding: 8px 16px; border: 1px solid var(--c-border); text-transform: uppercase;
}
.btn-close-transcription { font-size: 0.8em; cursor: pointer; text-decoration: underline; color: #888; display: block; margin-top: 1rem;}

/* Audio (Jardin Sonore & LGT) */
.grid-audio {
    display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); margin-bottom: 3rem; clear: both;
}
.audio-card {
    background: var(--c-bg-alt); padding: 1.5rem; border: 1px solid var(--c-border); border-radius: 4px;
    display: flex; flex-direction: column; justify-content: space-between;
}
/* Annulation du style "titre d'article" pour les titres des lecteurs audio */
article.journal .audio-card h4 {
    background-color: transparent; padding: 0; border-left: none; margin-top: 0; margin-bottom: 0.5rem;
}
.audio-card p { font-size: 0.85em; color: #666; margin-bottom: 1rem; }
.audio-card audio { width: 100%; height: 40px; margin-top: auto; }


/* ==========================================================================
   8. MAPPING CSS (Rétrocompatibilité pour les archives non traitées)
   ========================================================================== */
/* Ces classes permettent aux anciens articles de s'afficher correctement 
   sans avoir à modifier leur code HTML. */

/* Les anciens Layouts Flottants */
.layout-float, .layout-float-wide { display: block; margin-bottom: 2rem; clear: both; }
.layout-float::after, .layout-float-wide::after { content: ""; display: table; clear: both; }
.float-img { width: 100%; margin-bottom: 1rem; }
@media (min-width: 900px) {
    /* On garde le déclenchement à 900px pour les anciens articles car ils utilisaient 40% de largeur (donc le texte avait de la place) */
    .float-img { float: left; margin-right: var(--gap); margin-bottom: 1rem; }
    .float-img.limit-small, .float-img.limit-cd { width: 35%; }
    .float-img.limit-intro, .float-img.limit-poster, .float-img.limit-invitation { width: 45%; }
    .float-img.limit-landscape { width: 55%; }
    .float-img:not([class*="limit-"]) { width: 40%; }
}
.float-img img { width: 100%; height: auto; display: block; }

/* Les anciennes Grilles (Rétrocompatibilité) */
.gallery-grid, .grid-2-late, .grid-retro { display: grid; gap: var(--gap); margin-bottom: 2rem; grid-template-columns: 1fr; }
@media (min-width: 600px) { .gallery-grid, .grid-2-late, .grid-retro { grid-template-columns: repeat(2, 1fr); } }
.grid-3-late, .grid-3-xl { display: grid; gap: var(--gap); margin-bottom: 2rem; grid-template-columns: 1fr; }
@media (min-width: 700px) { .grid-3-late, .grid-3-xl { grid-template-columns: repeat(3, 1fr); } }
.grid-1-2-3-6, .grid-lg, .grid-progressive-late { display: grid; gap: var(--gap); margin-bottom: 2rem; grid-template-columns: 1fr; }
@media (min-width: 600px) { .grid-1-2-3-6, .grid-lg, .grid-progressive-late { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .grid-1-2-3-6, .grid-lg, .grid-progressive-late { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1200px) { .grid-1-2-3-6, .grid-lg, .grid-progressive-late { grid-template-columns: repeat(6, 1fr); } }
.gallery-grid img, .grid-1-2-3-6 img, .grid-progressive-late img { width: 100%; height: 100%; object-fit: cover; border: 1px solid var(--c-border); }

/* Utilitaires divers */
.container-full, .media-natural { width: 100%; margin-bottom: 2rem; clear: both; }
.cartel-float { font-size: 0.9em; line-height: 1.5; padding-left: 1rem; border-left: 3px solid var(--c-border); margin-bottom: 1.5rem; }
.delayed-side-image { clear: both; margin-top: 2rem; padding-top: 2rem; border-top: 1px solid var(--c-border); }
.layout-text-columns { display: flex; flex-wrap: wrap; gap: var(--gap); margin-top: 2rem; }
.text-col-main { flex: 1 1 300px; }
.text-col-paper { flex: 1 1 400px; background: var(--c-bg-alt); padding: 2rem; border: 1px solid var(--c-border); }
.layout-split-text { display: flex; flex-wrap: wrap; gap: var(--gap); margin-top: 2rem; }
.split-intro { flex: 1 1 250px; font-style: italic; }
.split-paper { flex: 2 1 400px; background: var(--c-bg-alt); padding: 2rem; border: 1px solid var(--c-border); }