/* Styles par défaut - Mobile first */
/* main, .link fournis par components.css */

.hero {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.main-article {
    position: relative;
    background: #000;
    border-radius: 10px;
    overflow: hidden;
    width: 100%;
    height: 250px;
    order: 1;
}

.main-article img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.5;
}

.main-article-content {
    position: absolute;
    bottom: 15px;
    left: 15px;
    right: 15px;
    color: white;
}

.main-article-content h2 {
    font-size: 1.2em;
    margin: 0 0 8px;
    line-height: 1.3;
}

.main-article-content p {
    font-size: 0.9em;
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.side-articles {
    display: flex;
    flex-direction: column;
    gap: 12px;
    order: 2;
}

.side-article {
    display: flex;
    gap: 12px;
    padding: 15px;
    align-items: center;
    background-color: var(--secondary-bg-color);
    border-radius: 10px;
    height: 110px; /* Hauteur fixe pour tous les articles */
    width: 100%; /* Largeur fixe pour tous les articles */
    box-sizing: border-box;
}

.side-article img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.side-article-content {
    flex: 1;
    min-width: 0; /* Permet au contenu de se rétrécir */
    overflow: hidden; /* Important pour l'ellipse */
}

.side-article-content h2 {
    margin: 0 0 5px;
    font-size: 1em;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.side-article-content p {
    font-size: 0.85em;
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.content-wrapper {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 0 auto;
    max-width: 100%;
}

.article {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 15px;
    background-color: var(--secondary-bg-color);
    border-radius: 15px;
    padding: 15px;
    min-width: 0; /* Sinon un titre sans espaces peut forcer sa taille de
                     contenu minimale et faire déborder .content-wrapper
                     (flex ou grid selon le breakpoint). */
    box-sizing: border-box;
}

.article img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
}

.article > div {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Aligne le contenu en haut */
    min-height: 0; /* Permet au contenu de se rétrécir */
    min-width: 0; /* Idem en largeur : sans ça un titre sans espaces
                     (flex-direction row à partir de 601px) déborde au lieu
                     de se retrouver contraint par overflow-wrap. */
}

.article h2 {
    margin: 0 0 10px;
    flex-shrink: 0; /* Le titre garde sa taille */
    overflow: auto;
    overflow-wrap: break-word;
}

.article p {
    flex: 1; /* La description prend tout l'espace disponible */
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article-author-infos {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 15px; /* Espacement fixe au lieu de auto */
    line-height: 1;
    flex-shrink: 0; /* Les infos auteur gardent leur taille */
}

.article-author-infos img {
    height: 25px;
    width: 25px;
    border-radius: 50%;
}

.article-author-link {
    display: inline-flex;
    align-items: center;
    min-height: 25px;
}

.sidebar {
    border-radius: 8px;
    order: 1;
}

.popular-article {
    border-radius: 8px;
    background-color: var(--secondary-bg-color);
    padding: 10px;
}

.popular-article h3 {
    margin-top: 0;
    margin-bottom: 0;
    font-size: 1.1em;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.popular-article img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 5px;
    flex-shrink: 0;
}

.popular-article p {
    font-size: 0.85rem;
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sidebar .popular-article {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    align-items: center;
}

/* Tablettes - à partir de 601px */
@media (width >= 601px) {
    .hero {
        gap: 20px;
    }

    .main-article {
        height: 300px;
    }

    .main-article-content {
        bottom: 20px;
        left: 20px;
        right: 20px;
    }

    .main-article-content h1 {
        font-size: 1.4em;
    }

    .main-article-content h2 {
        font-size: 1.4em;
    }

    .main-article-content p {
        font-size: 1em;
        -webkit-line-clamp: 3;
        line-clamp: 3;
    }

    .side-article {
        padding: 20px;
        gap: 15px;
        height: 140px; /* Hauteur fixe pour tablettes */
        width: 100%; /* Largeur fixe pour tablettes */
    }

    .side-article img {
        width: 100px;
        height: 100px;
    }

    .side-article-content h2 {
        font-size: 1.1em;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 350px; /* Largeur adaptée aux tablettes */
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .side-article-content p {
        font-size: 0.9em;
        -webkit-line-clamp: 3;
        line-clamp: 3;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .content-wrapper {
        gap: 20px;
    }

    .article {
        flex-direction: row;
        align-items: flex-start; /* Aligne les éléments en haut */
        gap: 20px;
        padding: 20px;
        border-radius: 20px;
    }

    .article img {
        width: 200px;
        height: 150px;
        flex-shrink: 0;
    }

    .article > div {
        display: flex;
        flex-direction: column;
        justify-content: flex-start; /* Contenu aligné en haut */
        height: 150px; /* Hauteur fixe pour correspondre à l'image */
    }

    .article-author-infos img {
        height: 25px;
        width: 25px;
        border-radius: 50%;
    }
}

/* Desktop - à partir de 900px */
@media (width >= 900px) {
    .hero {
        display: grid;
        grid-template-columns: 60% 40%;
        min-height: 30em; /* Hauteur minimum au lieu de fixe */
        align-items: stretch; /* Les deux colonnes s'étirent sur toute la hauteur */
        gap: 20px;
    }

    .main-article {
        min-height: 30em; /* Hauteur minimum */
        order: unset;
    }

    .main-article-content h1 {
        font-size: 1.6em;
    }

    .main-article-content h2 {
        font-size: 1.6em;
    }

    .side-articles {
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        min-height: 30em; /* Hauteur minimum */
        order: unset;
        gap: 12px; /* Gap fixe entre les articles */
    }

    .side-article {
        padding: 15px;
        flex: none;
        height: calc((30em - 24px) / 3);
        box-sizing: border-box;
        display: flex;
        align-items: center;
        gap: 15px;
        width: 100%; /* Largeur définie pour que l'ellipse fonctionne */
        min-height: 0; /* Permet au contenu de se rétrécir */
        overflow: hidden; /* Évite le débordement */
    }

    .side-article img {
        width: 80px;
        height: 80px;
        flex-shrink: 0;
    }

    .side-article-content h2 {
        font-size: 1em;
        margin: 0 0 5px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        width: calc(100% - 20px); /* 100% moins un peu de marge pour être sûr */
        max-width: calc(40vw - 150px); /* 40% de la largeur de l'écran moins l'image et marges */
        display: block;
    }

    .side-article-content p {
        font-size: 0.85em;
        margin: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .content-wrapper {
        display: grid;
        grid-template-columns: minmax(0, 3fr) minmax(0, 1fr);
    }

    .article {
        padding: 25px;
        border-radius: 25px;
        margin-bottom: 20px;
        align-items: flex-start; /* Maintient l'alignement en haut sur desktop */
    }

    .article img {
        width: 200px;
        height: 200px;
    }

    .article > div {
        height: 200px; /* Hauteur fixe pour correspondre à l'image sur desktop */
    }

    .article-author-infos img {
        height: 25px;
        width: 25px;
        border-radius: 50%;
    }

    .sidebar {
        order: unset;
    }
}

/* Bouton "Voir plus d'articles" (lien vers ?page=N+1, enrichi en JS) */
.load-more-button {
    display: block;
    width: fit-content;
    margin: 0 auto 15px;
    padding: 10px 24px;
    border-radius: var(--radius-pill);
    background-color: var(--accent-color);
    color: var(--inverted-text-color);
    text-decoration: none;
    font-weight: 600;
    transition: background-color var(--transition-fast);
}

.load-more-button:hover {
    background-color: var(--accent-hover-color);
}

.load-more-button[aria-busy="true"] {
    opacity: 0.7;
    cursor: wait;
}
