/* ==========================================
   PAGE : CATEGORIE.PHP (css/categorie.css)
   ========================================== */

:root {
    /* --- BOUTONS SOUS-CATÉGORIES --- */
    --cat-sub-btn-bg: #01060d;           /* Fond par défaut des sous-catégories */
    --cat-sub-btn-text: #ffffff;         /* Texte par défaut des sous-catégories */
    --cat-sub-btn-hover-bg: #f1cb4f;     /* Fond au survol des sous-catégories */
    --cat-sub-btn-hover-text: #050202;   /* Texte sombre au survol pour meilleure lisibilité */

    /* --- CARTES DE SITES / CATEGORIES --- */
    --cat-card-bg: #faf5e5;              /* Fond des cartes (Beige charte) */
    --cat-card-border: #01060d;          /* Bordure noire solide des cartes */
    --cat-img-bg: #f8f9fa;               /* Fond de secours pour les images */

    /* --- TEXTES ET LIENS --- */
    --cat-title-color: #01060d;          /* Titre des cartes (Noir charte) */
    --cat-text-muted: #01040b;           /* Description, clics et détails */
    --cat-tag-color: #01040b;            /* Étiquette/Tag de la catégorie */

    /* --- BOUTONS (EN SAVOIR PLUS & VISITER LE SITE) --- */
    --cat-btn-more-bg: #000000;          /* Fond noir du bouton */
    --cat-btn-more-border: #000000;      /* Bordure noire du bouton */
    --cat-btn-more-text: #ffffff;        /* Texte blanc du bouton */
    --cat-btn-more-hover-bg: #f1cb4f;    /* Fond au survol (Jaune or charte) */
    --cat-btn-more-hover-text: #050202;  /* Texte au survol */

    /* --- DÉGRADÉ DE FOND (TRONCATURE) --- */
    --cat-fade-color: #faf5e5;           /* Aligné avec --cat-card-bg pour un fondu invisible */
}

/* Espacement global et sécurité anti-débordement */
html body main.category-page-container,
html body main {
    margin-bottom: 4rem;
    padding-bottom: 2rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Section Sous-catégories */
html body .section-sous-categories {
    margin: 20px 0 30px;
    width: 100%;
}

html body .list-sous-categories {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

html body .btn-sous-cat {
    padding: 8px 15px;
    background: var(--cat-sub-btn-bg);
    color: var(--cat-sub-btn-text);
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.2s, color 0.2s;
}

html body .btn-sous-cat:hover {
    background: var(--cat-sub-btn-hover-bg);
    color: var(--cat-sub-btn-hover-text);
}

/* ==========================================
   GRILLE DES CATEGORIES & SITES (FLUIDE)
   ========================================== */
html body main .grid-sites,
html body main .grid-categories,
html body main .categories-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
    width: 100%;
    box-sizing: border-box;
}

/* Structure unifiée des cartes */
html body .card-site,
html body .card-category,
html body .category-card {
    background: var(--cat-card-bg);
    border-radius: 12px;
    border: 2px solid var(--cat-card-border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

html body .card-site img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background-color: var(--cat-img-bg);
}

html body .card-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    box-sizing: border-box;
}

html body .tag-cat {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--cat-tag-color);
    font-weight: 600;
    margin-bottom: 0.25rem;
    text-decoration: none;
}

html body .card-body h3,
html body .card-body h3 a {
    color: var(--cat-title-color);
    text-decoration: none;
    font-size: 1.3rem;
    font-weight: 700;
}

html body .card-body h3 a:hover {
    text-decoration: underline;
}

html body .card-body p:not(.fiche-body-text) {
    color: var(--cat-text-muted);
    font-size: 0.9rem;
    margin: 0.5rem 0 1rem;
    flex-grow: 1;
}

html body .card-body hr {
    border: 0;
    border-top: 1px solid var(--cat-card-border);
    margin: 0.75rem 0;
}

/* Système "En savoir plus" */
html body .card-site .card-body .fiche-body-text {
    line-height: 1.6;
    color: var(--cat-text-muted);
    font-size: 0.9rem;
    margin: 0.5rem 0 0;
    flex-grow: 0;
    transition: max-height 0.3s ease;
}

html body .card-site .card-body .fiche-body-text.truncated {
    max-height: 150px;
    overflow: hidden;
    position: relative;
}

html body .card-site .card-body .fiche-body-text.truncated::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50px;
    background: linear-gradient(to bottom, rgba(250, 245, 229, 0), var(--cat-fade-color));
    pointer-events: none;
}

/* --- BOUTONS ET ACTIONS EN BAS DE CARTE --- */
html body .card-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: auto;
    padding-top: 0.75rem;
}

html body .card-site .card-body button.btn-read-more,
html body .card-site .card-body .btn-read-more,
html body .btn-visit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    background-color: var(--cat-btn-more-bg);
    border: 1px solid var(--cat-btn-more-border);
    color: var(--cat-btn-more-text);
    padding: 0.45rem 0.75rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.85rem;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

html body .card-site .card-body button.btn-read-more:hover,
html body .card-site .card-body .btn-read-more:hover,
html body .btn-visit:hover {
    background-color: var(--cat-btn-more-hover-bg);
    border-color: var(--cat-btn-more-hover-bg);
    color: var(--cat-btn-more-hover-text);
}

html body .card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--cat-card-border);
    padding-top: 0.75rem;
    margin-top: 0.75rem;
    gap: 0.5rem;
}

html body .nb-clics {
    font-size: 0.85rem;
    color: var(--cat-text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

/* ==========================================
   ADAPTATION RESPONSIF (TABLETTE ET MOBILE)
   ========================================== */

/* --- Tablettes (641px à 1024px) : 2 colonnes strictes --- */
@media screen and (max-width: 1024px) {
    html body .banner-title,
    html body .category-header h1,
    html body .page-title,
    html body h1 {
        font-size: 1.6rem;
    }

    html body main .grid-sites,
    html body main .grid-categories,
    html body main .categories-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
    }

    html body .card-body h3,
    html body .card-body h3 a {
        font-size: 1.2rem;
    }
}

/* --- Mobiles (jusqu'à 640px) : 1 colonne --- */
@media screen and (max-width: 640px) {
    html body .banner-title,
    html body .category-header h1,
    html body .page-title,
    html body h1 {
        font-size: 1.3rem;
        line-height: 1.2;
    }

    html body main .grid-sites,
    html body main .grid-categories,
    html body main .categories-container {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    html body .card-site img {
        display: none;
    }

    html body .card-body {
        padding: 1rem;
    }

    html body .card-body h3,
    html body .card-body h3 a {
        font-size: 1.15rem;
    }

    html body .list-sous-categories {
        gap: 6px;
    }

    html body .btn-sous-cat {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    html body .card-actions {
        flex-direction: column;
        align-items: stretch;
    }

    html body .card-site .card-body button.btn-read-more,
    html body .card-site .card-body .btn-read-more,
    html body .btn-visit {
        width: 100%;
        text-align: center;
    }
}