/* ----------------------------------------
  1. IMPORTATIONS ET RÉINITIALISATION
---------------------------------------- */
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@200;300;400;600;700&display=swap");

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: "Poppins", sans-serif;
    background: #f4f6f9;
    color: #333;
}

/* ----------------------------------------
  2. VARIABLES DE COULEURS
---------------------------------------- */
:root {
    --color-animaux: #757575;
    --color-education: #6d4c41;
    --color-emploi: #e53935;
    --color-energie: #f677a6;
    --color-famille: #fb8c00;
    --color-habitation: #fdd835;
    --color-mobilite: #c0ca33;
    --color-sante: #227a26;
    --color-seniors: #25c0b0;
    --color-social: #1e88e5;
    --color-sport: #3949ab;
    --color-divers: #7f2275;
    --color-all: #000;

    --shadow-default: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 6px 16px rgba(0, 0, 0, 0.15);
    --transition-standard: 0.3s ease;
}

/* ----------------------------------------
  3. EN-TÊTE ET FILTRES 
---------------------------------------- */
h1 {
    letter-spacing: -0.05em;
}

h3 {
    font-weight: 500;
    font-size: 1.45em;
    line-height: 0.9em;
}

h3 img {
    height: 40px;
    vertical-align: middle;
    mix-blend-mode: darken;
}

.prime-header {
    text-align: center;
}

#search {
    padding: 0.5rem 1rem;
    border: 1px solid #ccc;
    border-radius: 30px;
    width: 80%;
    max-width: 400px;
    font-size: 0.95rem;
}

#filters {
    background: #c3d7ef;
    padding: 10px;
    margin: 1.7em auto 0;
    max-width: 500px;
    border-radius: 12px;
    box-shadow: var(--shadow-default);
    border: 1px solid #b2cce3;
}

/* ----------------------------------------
  4. BOUTONS DE CATÉGORIES
---------------------------------------- */
.category-toggle {
    --btn-color: var(--color-all);
    background: rgba(0, 0, 0, 0.05);
    color: #333;
    border: none;
    border-radius: 20px;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    transition:
        background var(--transition-standard),
        color var(--transition-standard);
    opacity: 0.8;
    margin: 5px 3px;
}

.category-toggle.active {
    background: var(--btn-color);
    color: #fff;
    opacity: 1;
}

/* Attribution des couleurs par catégorie */
.category-toggle.category-animaux {
    --btn-color: var(--color-animaux);
}
.category-toggle.category-education {
    --btn-color: var(--color-education);
}
.category-toggle.category-emploi {
    --btn-color: var(--color-emploi);
}
.category-toggle.category-energie {
    --btn-color: var(--color-energie);
}
.category-toggle.category-famille {
    --btn-color: var(--color-famille);
}
.category-toggle.category-habitation {
    --btn-color: var(--color-habitation);
    color: #333;
}
.category-toggle.category-mobilite {
    --btn-color: var(--color-mobilite);
}
.category-toggle.category-sante {
    --btn-color: var(--color-sante);
}
.category-toggle.category-seniors {
    --btn-color: var(--color-seniors);
}
.category-toggle.category-social {
    --btn-color: var(--color-social);
}
.category-toggle.category-sport {
    --btn-color: var(--color-sport);
}
.category-toggle.category-divers {
    --btn-color: var(--color-divers);
}
.category-toggle[data-value="all"] {
    --btn-color: var(--color-all);
}

/* ----------------------------------------
  5. CONTENEUR DE CARTES
---------------------------------------- */
#cards-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
}

#cards-container h3 {
    width: 100%;
    margin-top: 1.5rem;
    font-size: 1.8rem;
    font-weight: 200;
    text-transform: uppercase;
    text-align: center;
    color: #333;
    padding-top: 0.5em;
    border-top: 1px solid #ccc;
}
/* ----------------------------------------
  6. STYLE DES CARTES
---------------------------------------- */
.card {
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--shadow-default);
    width: 280px;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    position: relative;
    transition:
        transform var(--transition-standard),
        box-shadow var(--transition-standard);
    cursor: pointer;
}

.card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-hover);
}

.card h2 {
    font-size: 1.2rem;
    margin: 0.5rem 0;
    line-height: 1.1em;
}

.card p {
    font-size: 0.9rem;
    line-height: 1.2;
    color: #555;
    margin: 0.3rem 0;
}

/* ----------------------------------------
  7. BADGES DE CATÉGORIES 
---------------------------------------- */
.category-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.category-style {
    --badge-color: var(--color-all);
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 300;
    color: #fff;
    background: var(--badge-color);
    letter-spacing: 0.05em;
}

/* Attribution des couleurs par catégorie */
.category-style.category-animaux {
    --badge-color: var(--color-animaux);
}
.category-style.category-education {
    --badge-color: var(--color-education);
}
.category-style.category-emploi {
    --badge-color: var(--color-emploi);
}
.category-style.category-energie {
    --badge-color: var(--color-energie);
}
.category-style.category-famille {
    --badge-color: var(--color-famille);
}
.category-style.category-habitation {
    --badge-color: var(--color-habitation);
    color: #333;
}
.category-style.category-mobilite {
    --badge-color: var(--color-mobilite);
}
.category-style.category-sante {
    --badge-color: var(--color-sante);
}
.category-style.category-seniors {
    --badge-color: var(--color-seniors);
}
.category-style.category-social {
    --badge-color: var(--color-social);
}
.category-style.category-sport {
    --badge-color: var(--color-sport);
}
.category-style.category-divers {
    --badge-color: var(--color-divers);
}

/* ----------------------------------------
  8. DÉTAILS ET BOUTON D'INFO
---------------------------------------- */
.info-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: none;
    cursor: pointer;
    width: 1.3rem;
    height: 1.3rem;
    color: #1961ac;
}

/* Icône "+" quand la carte est fermée */
.info-btn::before {
    content: "+";
    font-size: 1.2rem;
    color: currentColor;
    line-height: 1;
    display: block;
    text-align: center;
}

/* Icône "×" quand la carte est ouverte */
.card.expanded .info-btn::before {
    content: "×";
    font-size: 1.4rem;
}

.card-details {
    max-height: 0;
    overflow: auto;
    transition: max-height var(--transition-standard);
    margin-top: auto;
}

.card.expanded .card-details {
    max-height: 400px;
}

hr {
    border: 0;
    border-top: 1px solid lightgrey;
    margin: 1em 0;
}

/* Liens dans les cartes */
.card a {
    cursor: pointer;
    color: #1961ac;
    font-weight: bold;
}

details {
    font-size: 0.8em;
    background: #dae1e8;
    border-radius: 12px;
    padding: 0 10px;
    max-width: 500px;
    margin: 1em auto 0;
    width: fit-content;
}

summary {
    cursor: pointer;
}

.small-text {
    text-align: justify;
    line-height: 1.25em;
}

/* LOADING SCREEN */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #1961ac 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease-out;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    text-align: center;
    color: white;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

.loading-text {
    font-size: 18px;
    font-weight: 300;
    margin-bottom: 10px;
}

.loading-subtext {
    font-size: 14px;
    opacity: 0.8;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Masquer le contenu principal pendant le chargement */
.main-content {
    opacity: 0;
    transition: opacity 0.5s ease-in;
}

.main-content.loaded {
    opacity: 1;
}

.no-results {
    text-align: center;
    color: #555;
    font-style: italic;
    margin: 2rem 0;
    width: 100%;
}

#cards-container h3:first-of-type {
    border-top: 0;
}

@media (max-width: 500px) {
    h3 {
        line-height: 1.5em;
        font-size: 0.75em;
    }
    h1 {
        line-height: 1.1em;
        font-size: 1.2em;
    }
    #cards-container h3 {
        font-size: 1rem;
    }
    #cards-container {
        gap: 0.4rem;
    }
    .card {
        width: 47%;
        padding: 0.5rem;
    }
    .category-container {
        margin-bottom: 0.1rem;
    }
    .card p {
        font-size: 0.75rem;
    }
    .card h2 {
        font-size: 1rem;
        font-weight: 600;
    }
    #filters {
        padding: 5px;
        margin: 0.5em auto 0;
    }
    .category-toggle {
        font-size: 0.65rem;
    }
    .card:hover {
        transform: none;
        box-shadow: inherit;
    }
    .category-style {
        font-size: 0.6rem;
    }
    h3 img {
        height: 30px;
    }
}
