/* ==========================================================================
   Variables globales
   ========================================================================== */
:root {
    --bg-beige: #F9F6F0;
    --bg-beige-dark: #EFEBE4;
    --bleu-pastel: #A9C2D0;
    --bois-sombre: #4A3E3D;
    --bois-moyen: #7A6253;
    --bg-beige-doux: #fffefc;
    --blanc: #FFFFFF;
}

/* ==========================================================================
   Base
   ========================================================================== */
html {
    scroll-behavior: smooth;
}

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Helvetica, Arial, sans-serif;
    background-color: var(--bg-beige);
    color: var(--bois-sombre);
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

h1, h2, h3 { color: var(--bois-moyen); font-weight: 600; }

/* ==========================================================================
   Navigation (Header)
   ========================================================================== */
nav {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem 2rem;
    background-color: var(--bg-beige);
    box-shadow: none;
}

nav .logo {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-weight: bold;
    color: inherit;
    text-decoration: none;
}

.logo-img {
    height: 48px;
    width: 48px;
    object-fit: contain;
    border-radius: 4px;
}

nav > ul {
    display: flex;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 1rem;
}

nav > ul > li > a {
    text-decoration: none; color: var(--bois-sombre); font-weight: 500;
    padding-bottom: 5px; border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
}

nav > ul > li > a:hover {
    color: var(--bois-moyen); border-bottom: 2px solid var(--bleu-pastel);
}

/* ==========================================================================
   Menu Déroulant
   ========================================================================== */
.menu-deroulant {
    position: relative;
}

.sous-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: var(--blanc);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-radius: 8px;
    min-width: 250px;
    padding: 0.5rem 0;
    z-index: 100;
    list-style: none;
    margin: 0;
}

/* :focus-within rend le sous-menu accessible à la navigation clavier */
.menu-deroulant:hover .sous-menu,
.menu-deroulant:focus-within .sous-menu {
    display: block;
}

.sous-menu li {
    width: 100%;
    margin: 0;
    padding: 0;
}

.sous-menu a {
    display: block;
    padding: 0.6rem 1.5rem;
    text-align: left;
    color: var(--bois-sombre);
    text-decoration: none;
    font-size: 0.95rem;
    border-bottom: none !important;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.sous-menu a:hover {
    background-color: var(--bg-beige);
    color: var(--bois-moyen);
    border-bottom: none !important;
}

/* Bouton Prendre RDV dans la barre de navigation */
.btn-rdv-menu {
    background-color: var(--bois-moyen);
    color: var(--blanc) !important;
    font-weight: 500;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.4rem 1.2rem !important;
    border-radius: 20px;
    line-height: 1.5;
    transition: background-color 0.3s ease;
}

.btn-rdv-menu:hover {
    background-color: var(--bois-sombre) !important;
}

/* Bouton Menu Burger (masqué sur ordinateur) */
.menu-toggle {
    display: none;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 24px;
    flex-direction: column;
    justify-content: space-between;
    z-index: 101;
}

.menu-toggle span {
    display: block;
    width: 100%;
    height: 3px;
    background-color: var(--bois-moyen);
    border-radius: 2px;
    transition: all 0.3s ease-in-out;
}

/* ==========================================================================
   Section d'Accueil (Hero Modernisé à 2 colonnes)
   ========================================================================== */
.hero {
    background-color: var(--bleu-pastel);
    padding: 4rem 2rem;
}

.hero-container {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 3rem;
}

.hero-photo {
    flex: 1;
    max-width: 350px;
    display: flex;
    justify-content: center;
}

.portrait-img {
    width: 100%;
    aspect-ratio: 1 / 1;
    max-height: 300px;
    object-fit: cover;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(74, 62, 61, 0.15);
    background-color: #EFEBE4;
}

.hero-texte {
    flex: 1.5;
    text-align: left;
    color: var(--bois-sombre);
}

.hero-texte h1 {
    color: var(--bois-sombre);
    font-size: 2.6rem;
    margin-top: 0;
    margin-bottom: 1rem;
    line-height: 1.2;
}

.hero-texte p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
}

/* ==========================================================================
   Boutons globaux et Sections
   ========================================================================== */
.btn-rdv {
    display: inline-block; background-color: var(--bois-moyen); color: var(--blanc);
    text-decoration: none; padding: 1rem 2.5rem; border-radius: 50px;
    font-weight: bold; box-shadow: 0 4px 15px rgba(122, 98, 83, 0.3);
    transition: all 0.3s ease;
}

.btn-rdv:hover {
    background-color: #655044; transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(122, 98, 83, 0.5);
}

/* Conteneur centré du bouton RDV en fin d'article */
.bloc-cta {
    text-align: center;
    margin-top: 3rem;
}

section { padding: 4rem 1rem; max-width: 800px; margin: 0 auto; }

#motifs {
    background-color: var(--bg-beige-dark); max-width: 100%; padding: 4rem 2rem;
}

.container-motifs { max-width: 800px; margin: 0 auto; }

.grille-cartes {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem; margin-top: 2rem;
}

.carte {
    background-color: var(--blanc); padding: 1.5rem; border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04); font-weight: 500;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.carte:hover {
    transform: translateY(-5px); box-shadow: 0 8px 20px rgba(74, 62, 61, 0.1);
}

#approche ul {
    margin-bottom: 1.5rem;
    padding-left: 2rem;
}

#approche ul li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

/* Lien mis en valeur dans le corps de page (AFTCC, email…) */
.lien-accent {
    color: var(--bois-moyen);
    font-weight: bold;
}

/* Bloc urgence (accueil) */
.bloc-urgence {
    margin-top: 2.5rem;
    padding: 1.25rem 1.5rem;
    background-color: var(--bg-beige-dark);
    border-radius: 12px;
    font-size: 0.95rem;
    color: var(--bois-sombre);
    line-height: 1.6;
}

.bloc-urgence p { margin: 0 0 0.5rem 0; }
.bloc-urgence p:last-child { margin-bottom: 0; }

.lien-tel {
    color: var(--bois-sombre);
    font-weight: bold;
    text-decoration: none;
    border-bottom: 1px dotted var(--bois-moyen);
}

/* ==========================================================================
   Fil d'Ariane (Breadcrumb)
   ========================================================================== */
.fil-ariane {
    font-size: 0.85rem;
    margin-bottom: 1rem;
    color: var(--bois-moyen);
    opacity: 0.7;
    overflow-wrap: break-word;
    word-break: break-word;
}

.fil-ariane a {
    color: var(--bois-moyen);
    text-decoration: none;
}

.fil-ariane span {
    color: var(--bois-sombre);
}

/* ==========================================================================
   Mise en page des Articles (Effet Carte Blanche)
   ========================================================================== */
.article-container {
    max-width: 900px;
    margin: 4rem auto;
    padding: 0 1rem;
}

.article-carte {
    background-color: var(--blanc);
    padding: 4rem 5rem;
    border-radius: 16px;
    box-shadow: none;
    border: 1px solid rgba(74, 62, 61, 0.08);
    color: var(--bois-sombre);
    line-height: 1.7;
    overflow-wrap: break-word;
    word-break: break-word;
}

.article-header {
    text-align: center;
    margin-bottom: 3.5rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--bg-beige-dark);
}

.article-header h1 {
    font-size: 2.5rem;
    color: var(--bois-moyen);
    margin-top: 0;
    margin-bottom: 1rem;
    line-height: 1.2;
    overflow-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
}

.article-description {
    font-size: 1.15rem;
    color: var(--bois-sombre);
    font-style: italic;
    opacity: 0.85;
    max-width: 700px;
    margin: 0 auto;
}

/* ==========================================================================
   Styles typographiques des articles (Markdown)
   ========================================================================== */
main p, main li {
    font-size: 1.1rem;
    color: var(--bois-sombre);
}

main h2 {
    margin-top: 3rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--bg-beige-dark);
}

main h3 {
    margin-top: 2rem;
    margin-bottom: 1rem;
}

main ul, main ol {
    margin-bottom: 2rem;
}

main li {
    margin-bottom: 0.8rem;
}

main blockquote {
    border-left: 4px solid var(--bleu-pastel);
    background-color: var(--bg-beige-dark);
    padding: 1.5rem;
    margin: 2rem 0;
    border-radius: 0 8px 8px 0;
    font-style: italic;
    color: var(--bois-moyen);
}

.table-wrapper {
    width: 100%;
    margin: 2rem 0;
    background-color: var(--blanc);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
}

.table-wrapper table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
    margin: 0;
}

main th, main td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--bg-beige-dark);
    overflow-wrap: break-word;
    word-break: break-word;
}

main th:first-child,
main td:first-child {
    overflow-wrap: normal;
    word-break: normal;
}

main th {
    background-color: var(--bleu-pastel);
    color: var(--bois-sombre);
    font-weight: 600;
}

/* ==========================================================================
   Grille des Articles (Cartes Carrées)
   ========================================================================== */
.grille-articles {
    display: grid;
    /* Crée automatiquement des colonnes d'environ 280px de large */
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
    margin-top: 3rem;
}

.carte-article-carree {
    background-color: var(--blanc);
    border: 1px solid var(--bg-beige-dark);
    border-radius: 16px;
    padding: 2rem;
    text-decoration: none !important;
    color: var(--bois-sombre);
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;

    /* La règle qui force la carte à être un carré parfait */
    aspect-ratio: 1 / 1;

    /* Centrage du contenu au milieu du carré */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    overflow: hidden;
}

.carte-article-carree:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(74, 62, 61, 0.12);
    border-color: var(--bleu-pastel);
}

.carte-titre {
    color: var(--bois-moyen);
    margin: 0 0 0.5rem 0 !important;
    font-size: 1.3rem;
    line-height: 1.3;
}

.carte-date {
    font-size: 0.85rem;
    opacity: 0.6;
    margin: 0 0 1rem 0 !important;
}

.carte-description {
    font-size: 0.95rem;
    opacity: 0.8;
    margin: 0 !important;

    /* Coupe proprement la description avec "..." si elle dépasse 3 lignes */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ==========================================================================
   Pages de liste (Motifs, Articles)
   ========================================================================== */
.page-liste {
    max-width: 1000px;
    margin: 4rem auto;
    padding: 0 2rem;
    color: var(--bois-sombre);
}

.page-liste-titre {
    color: var(--bois-moyen);
    font-size: 2.5rem;
    margin-bottom: 2rem;
    text-align: center;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 3rem;
    align-items: center;
}

.pagination a {
    color: var(--bois-moyen);
    text-decoration: none;
    font-weight: 500;
}

.pagination-info {
    font-size: 0.9rem;
    opacity: 0.7;
}

/* ==========================================================================
   Page 404
   ========================================================================== */
.page-404 {
    max-width: 600px;
    margin: 8rem auto;
    padding: 2rem;
    text-align: center;
    color: var(--bois-sombre);
}

.page-404-code {
    font-size: 4rem;
    margin-bottom: 0.5rem;
    color: var(--bois-moyen);
}

.page-404-titre {
    font-size: 1.3rem;
    margin-bottom: 2rem;
}

.btn-retour {
    display: inline-block;
    background-color: var(--bois-moyen);
    color: #fff;
    text-decoration: none;
    padding: 1rem 2.5rem;
    border-radius: 50px;
    font-weight: bold;
    margin-top: 2rem;
}

/* ==========================================================================
   Pied de page (Footer)
   ========================================================================== */
.pied-page {
    background-color: var(--bois-sombre);
    color: var(--blanc);
    text-align: center;
    padding: 2rem 1rem;
    margin-top: 4rem;
}

.pied-page-contenu {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
}

.pied-page-copyright {
    margin: 0 0 0.5rem 0;
    font-size: 0.95rem;
}

.pied-page-mention {
    font-size: 0.78rem;
    font-style: italic;
    opacity: 0.75;
    margin: 0.8rem 0 0.3rem 0;
    max-width: 500px;
    line-height: 1.4;
}

.pied-page-lien {
    color: #F8F5F2;
    text-decoration: none;
    font-size: 0.85rem;
    opacity: 0.8;
    display: inline-block;
    margin-top: 0.4rem;
    transition: opacity 0.3s ease;
}

.pied-page-lien:hover {
    opacity: 1;
    text-decoration: underline;
}

/* Protection anti-robots des coordonnées (mentions légales) */
.tel-protect::after { content: attr(data-fin); }
.mail-protect::after { content: attr(data-arobase) attr(data-domaine); }

/* ==========================================================================
   Accessibilité
   ========================================================================== */
:focus-visible {
    outline: 3px solid var(--bois-moyen);
    outline-offset: 3px;
    border-radius: 2px;
}

/* Sur le pied de page sombre, le marron tombe à 1,8:1 — on passe au blanc */
.pied-page :focus-visible {
    outline-color: var(--blanc);
}

/* Lien de saut : hors écran, révélé à la tabulation */
.lien-saut {
    position: absolute;
    left: -9999px;
    top: 0;
    background-color: var(--bois-sombre);
    color: var(--blanc);
    padding: 0.75rem 1.25rem;
    z-index: 200;
    text-decoration: none;
    border-radius: 0 0 8px 0;
}

.lien-saut:focus {
    left: 0;
}

/* ==========================================================================
   Adaptation pour les écrans de Smartphones (Responsive Global)
   --------------------------------------------------------------------------
   Ce bloc doit rester en FIN de fichier : à spécificité égale, la dernière
   règle déclarée l'emporte. Toute règle mobile ajoutée plus haut serait
   écrasée par les règles bureau qui la suivent.
   ========================================================================== */
@media (max-width: 768px) {
    /* --- 1. L'accueil et les articles --- */
    .hero-container { flex-direction: column; text-align: center; gap: 2rem; }
    .hero-texte { text-align: center; }
    .hero-texte h1 { font-size: 2rem; }
    .article-container { margin: 2rem auto; }
    .article-carte { padding: 2rem 1.5rem; border-radius: 12px; box-shadow: none; border: 1px solid rgba(74, 62, 61, 0.08); }
    .article-header h1 { font-size: 1.5rem; }
    .fil-ariane { display: none; }

    /* --- 2. Comportement du Menu Burger --- */
    .menu-toggle {
        display: flex;
    }

    /* Le menu devient une colonne masquée par défaut */
    .nav-links {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 75px; /* S'affiche juste sous le header */
        left: 0;
        width: 100%;
        background-color: var(--bg-beige);
        padding: 2rem 0;
        box-shadow: 0 10px 15px rgba(0,0,0,0.05);
        gap: 1.5rem;
        z-index: 100;

        /* Masqué par défaut */
        opacity: 0;
        visibility: hidden;
        transform: translateY(-20px);
        transition: all 0.3s ease;
    }

    /* Classe activée par le clic (JavaScript) */
    .nav-links.active {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    /* Centrer les éléments et réinitialiser les sous-menus pour le mobile */
    .nav-links li {
        text-align: center;
        width: 100%;
    }

    /* display: block indispensable : sans lui, le display: none de base
       persiste et les sous-menus ne s'ouvrent jamais au doigt. */
    .sous-menu {
        display: block;
        position: relative; /* Annule le positionnement flottant du PC */
        box-shadow: none;
        background-color: transparent;
        padding: 0.5rem 0;
    }

    .sous-menu a {
        text-align: center;
    }

    /* Animation du bouton qui se transforme en croix */
    .menu-toggle.open span:nth-child(1) { transform: translateY(10.5px) rotate(45deg); }
    .menu-toggle.open span:nth-child(2) { opacity: 0; }
    .menu-toggle.open span:nth-child(3) { transform: translateY(-10.5px) rotate(-45deg); }

    /* --- 3. Correction des Tableaux (Mode Cartes empilées) --- */
    .table-wrapper {
        margin: 1rem 0;
        background-color: transparent;
        border-radius: 0;
        overflow: visible;
        box-shadow: none;
    }

    main th:first-child,
    main td:first-child {
        white-space: normal;
        overflow-wrap: break-word;
        word-break: break-word;
    }

    main table,
    main tbody,
    main tr,
    main td {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }

    main table {
        border: none;
        margin: 0;
    }

    /* 1. On masque le bloc d'en-tête global, inutile en mode carte */
    main thead {
        display: none;
    }

    /* 2. Chaque ligne (tr) devient une "carte" indépendante */
    main tr {
        margin-bottom: 2rem;
        border: 1px solid var(--bg-beige-dark);
        border-radius: 12px;
        background-color: var(--blanc);
        overflow: hidden;
        box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    }

    /* 3. On transforme la 1ère case en "Titre" de la carte */
    main td:first-child {
        background-color: var(--bleu-pastel);
        color: var(--bois-sombre);
        font-weight: 600;
        font-size: 1.1rem;
        padding: 1rem 1.5rem;
        border-bottom: 1px solid rgba(0,0,0,0.05);
        overflow-wrap: break-word;
        word-break: break-word;
    }

    /* 4. Les autres cases (le texte d'explication) */
    main td {
        border-bottom: 1px solid var(--bg-beige-dark);
        white-space: normal !important;
        overflow-wrap: break-word;
        word-break: break-word;
        padding: 1.2rem 1.5rem;
    }

    /* Enlève la ligne de séparation sous la toute dernière case de la carte */
    main td:last-child {
        border-bottom: none;
    }
}

/* ==========================================================================
   Respect de la préférence système "réduire les animations"
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}