/* Importation de polices modernes et typées "Dashboard de crise" */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&family=Space+Grotesk:wght@500;700&display=swap');

:root {
    --bg-dark: #0f0304;          /* Noir très profond avec une nuance écarlate */
    --bg-card: #1f0709;          /* Rouge sombre pour les cartes */
    --bg-card-hover: #2d0b0e;    /* Survol des cartes */
    --primary: #a81c26;          /* Rouge Orwell vif */
    --primary-hover: #c92631;    
    --primary-glow: rgba(168, 28, 38, 0.35);
    --secondary: #4a7314;        /* Vert olive militaire / tactique */
    --secondary-hover: #5d8f1b;
    --secondary-glow: rgba(74, 115, 20, 0.3);
    --text-light: #f5f5f7;
    --text-muted: #9fa0a6;
    --font-main: 'Plus Jakarta Sans', sans-serif;
    --font-title: 'Space Grotesk', sans-serif;
    --border-radius: 8px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- RESET TECHNIQUE --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-dark);
    color: var(--text-light);
    line-height: 1.5;
    padding: 15px;
    -webkit-font-smoothing: antialiased;
}

.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

a {
    text-decoration: none;
    color: inherit;
}

/* --- HEADER & LOGO --- */
.header {
    text-align: center;
    padding: 15px 0;
}

.header img {
    width: 75%;
    max-width: 260px;
    height: auto;
    filter: drop-shadow(0 0 12px var(--primary-glow));
    transition: var(--transition);
}

.header img:hover {
    transform: scale(1.03);
    filter: drop-shadow(0 0 18px rgba(168, 28, 38, 0.6));
}

/* --- TITRES DE SECTIONS (STYLE INTERCEPT) --- */
.sous-titre {
    font-family: var(--font-title);
    font-size: 1.15rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #fff;
    text-align: center;
    background: linear-gradient(90deg, rgba(168, 28, 38, 0.8), transparent);
    padding: 12px 16px;
    margin-bottom: 15px;
    border-left: 4px solid var(--primary);
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

/* --- GRILLES DE MOTS-CLÉS (ANALYSE.PHP) --- */
#analyse {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

/* On force l'affichage en grille responsive de vos blocs "Top20" */
.Top20 {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    width: 100%;
}

/* Permet au titre interne généré par analyse.php de prendre toute la largeur */
.Top20 .sous-titre {
    grid-column: 1 / -1;
}

.button-analyse {
    background: none;
    border: none;
    width: 100%;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
}

#monScore {
    background-color: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--border-radius);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    height: 100%;
    transition: var(--transition);
}

#monScore:hover {
    background-color: var(--bg-card-hover);
    border-color: rgba(168, 28, 38, 0.4);
    box-shadow: 0 4px 20px var(--primary-glow);
    transform: translateY(-2px);
}

.mots {
    font-size: 0.95rem;
    font-weight: 600;
    color: #e2e2e9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 8px;
}

.occurences {
    background-color: rgba(168, 28, 38, 0.2);
    color: #ff8a90;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
    border: 1px solid rgba(168, 28, 38, 0.3);
    transition: var(--transition);
}

#monScore:hover .occurences {
    background-color: var(--primary);
    color: #fff;
    box-shadow: 0 0 8px var(--primary);
}

/* --- FORMULAIRES DE RECHERCHE --- */
.search-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

/* Conteneur global des deux formulaires : largeur resserrée et
   centrée, plutôt que de s'étirer sur toute la largeur du site */
#form-word {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 620px;
    margin: 0 auto;
    width: 100%;
}

/* Chaque formulaire (recherche / comparaison) dans sa propre carte,
   pour bien les distinguer visuellement l'un de l'autre */
.search-card {
    background-color: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--border-radius);
    padding: 20px;
}

.search-card form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#form-word input[type="text"] {
    width: 100%;
    padding: 15px;
    font-size: 0.95rem;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--border-radius);
    color: #fff;
    font-family: var(--font-main);
    transition: var(--transition);
}

#form-word input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    background-color: rgba(255, 255, 255, 0.06);
    box-shadow: 0 0 12px rgba(168, 28, 38, 0.25);
}

#form-word input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

/* Bloc de dates compact : les deux champs "Du" / "au" restent côte
   à côte à leur largeur naturelle, sans s'étirer comme le champ de
   recherche principal */
.date-range {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.date-field {
    display: flex;
    align-items: center;
    gap: 6px;
}

.date-field label {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.date-field input[type="date"] {
    padding: 8px 10px;
    font-size: 0.85rem;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--border-radius);
    color: #fff;
    font-family: var(--font-main);
    color-scheme: dark;
    width: auto;
}

.date-field input[type="date"]:focus {
    outline: none;
    border-color: var(--primary);
    background-color: rgba(255, 255, 255, 0.06);
}

#form-word small {
    color: var(--text-muted);
    font-size: 0.8rem;
}

#form-word button {
    width: 100%;
    padding: 15px;
    font-size: 0.95rem;
    font-weight: 700;
    font-family: var(--font-title);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #fff;
    background-color: var(--primary);
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 12px var(--primary-glow);
}

#form-word button:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 18px rgba(168, 28, 38, 0.5);
    transform: translateY(-1px);
}

/* Bouton secondaire (Comparaison) */
#form-word button.btn-secondary {
    background-color: var(--secondary);
    box-shadow: 0 4px 12px var(--secondary-glow);
}

#form-word button.btn-secondary:hover {
    background-color: var(--secondary-hover);
    box-shadow: 0 4px 18px rgba(74, 115, 20, 0.5);
}

/* --- LOGOS & BANDEAUX DES SITES --- */
.moreStats {
    margin: 20px 0;
    font-size: 0.9rem;
    color: var(--text-muted);
    text-align: center;
    font-weight: 500;
}

#bandeau-site {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
    gap: 12px;
    padding: 20px 0;
    justify-content: center;
}

.img-site {
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 6px;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 4 / 3; /* Aligne joliment tous les logos à la même proportion */
    transition: var(--transition);
}

.img-site:hover {
    transform: scale(1.1) translateY(-3px);
    background-color: #fff;
    box-shadow: 0 6px 15px rgba(255, 255, 255, 0.15);
}

.img-site img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* --- UTRE-MODERNE : BOUTON BACK TO TOP --- */
.button-home {
    display: none;
    align-items: center;
    justify-content: center;
    position: fixed;
    bottom: 25px;
    right: 25px;
    background-color: rgba(168, 28, 38, 0.85);
    backdrop-filter: blur(8px); /* Effet flou de fond */
    -webkit-backdrop-filter: blur(8px);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0,0,0,0.5);
    transition: var(--transition);
    z-index: 999;
}

.button-home:hover {
    transform: translateY(-4px);
    background-color: var(--primary-hover);
    box-shadow: 0 6px 20px var(--primary-glow);
}

/* --- BREAKPOINTS RESPONSIVE (MUTATION TABLETTE / DESKTOP) --- */

/* À partir des tablettes : alignement horizontal des inputs + boutons */
@media screen and (min-width: 640px) {
    .search-form {
        flex-direction: row;
        gap: 12px;
    }
}

/* À partir des écrans d'ordinateurs : Grilles plus larges et espacements aérés */
@media screen and (min-width: 960px) {
    body {
        padding: 50px 20px;
    }
    .header {
        padding: 20px 0 40px 0;
    }
    .header img {
        max-width: 320px;
    }
    .sous-titre {
        font-size: 1.25rem;
    }
    .Top20 {
        grid-template-columns: repeat(5, 1fr); /* 5 colonnes parfaites */
        gap: 14px;
    }
    #bandeau-site {
        grid-template-columns: repeat(auto-fill, minmax(95px, 1fr));
        gap: 16px;
    }
    #form-word button {
        width: auto;
        align-self: flex-end;
        padding-left: 30px;
        padding-right: 30px;
    }
}

/* ==========================================================================
   PAGE : LISTE DES TITRES (FLUX D'ACTUALITÉS)
   ========================================================================== */

/* Compteur de résultats */
.result-counter {
    background-color: var(--bg-card);
    border-left: 4px solid var(--primary);
    padding: 15px;
    border-radius: var(--border-radius);
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.result-counter .highlight {
    color: #fff;
    font-weight: 700;
}

.result-counter strong {
    color: #ff8a90;
    font-family: var(--font-title);
    font-size: 1.1rem;
}

/* Grille principale du flux */
#liste-titres {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
}

/* Séparateur temporel (Ligne de temps) */
.titres-date-separator {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 20px 0 10px 0;
    width: 100%;
}

.titres-date-separator::before,
.titres-date-separator::after {
    content: '';
    flex: 1;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.15);
}

.titres-date-separator span {
    font-family: var(--font-title);
    background-color: var(--secondary);
    color: #fff;
    padding: 6px 16px;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-radius: 20px;
    margin: 0 15px;
    box-shadow: 0 0 10px var(--secondary-glow);
}

/* La Carte Article (Design Mobile-First par défaut) */
.titre-card {
    background-color: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--border-radius);
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: var(--transition);
}

.titre-card:hover {
    border-color: rgba(168, 28, 38, 0.3);
    box-shadow: 0 4px 20px var(--primary-glow);
    transform: translateX(2px); /* Léger décalage vers la droite au survol */
}

/* En-tête de la carte (Logo du média) */
.card-header {
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 8px;
}

.nom-site {
    background-color: rgba(255, 255, 255, 0.95);
    padding: 4px 10px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    height: 32px;
}

.nom-site img {
    height: 22px;
    width: auto;
    object-fit: contain;
}

/* Corps de la carte */
.card-body {
    display: flex;
    flex-direction: column; /* Image au-dessus du texte sur mobile */
    gap: 15px;
}

/* Image de l'article */
.card-image {
    width: 100%;
    max-height: 180px;
    overflow: hidden;
    border-radius: 6px;
    background-color: rgba(0,0,0,0.2);
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.titre-card:hover .card-image img {
    transform: scale(1.04);
}

/* Contenu textuel et liens */
.card-text {
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--text-light);
}

.card-text a {
    color: var(--text-light);
    display: block;
}

.card-text a:hover {
    color: #ff8a90;
}

/* Surlignage du mot-clé recherché */
.card-text mark {
    background: linear-gradient(180deg, transparent 60%, rgba(168, 28, 38, 0.4) 40%);
    background-color: rgba(168, 28, 38, 0.2);
    color: #fff;
    font-weight: 700;
    padding: 0 4px;
    border-radius: 2px;
    border-bottom: 2px solid var(--primary);
}


/* ==========================================================================
   MEDIA QUERIES (MUTATION POUR LES GRANDS ÉCRANS)
   ========================================================================== */

@media screen and (min-width: 768px) {
    /* Sur tablette et PC, on passe l'image à gauche et le texte à droite */
    .card-body {
        flex-direction: row;
        align-items: flex-start;
    }

    .card-image {
        width: 140px; /* Taille fixe de la miniature sur PC */
        min-width: 140px;
        height: 90px;
    }
    
    .card-text {
        font-size: 1.1rem;
        padding-top: 2px;
    }
}