/* ==========================================================================
   AUDIENCE — l'écran des chiffres (chantier 42)
   ==========================================================================

   LA PALETTE DES DONNÉES N'EST PAS CELLE DE LA CHARTE. L'accent de
   l'administration suit la couleur du site ; une donnée, elle, doit rester
   lisible quelle que soit cette couleur, et distincte pour un œil qui ne voit
   pas toutes les teintes. D'où une palette fixe, validée le 2026-09-24 sur le
   fond blanc des cartes (séparation en vision des couleurs : tous les contrôles
   passés). Trois teintes (3, 4, 5) sont sous 3:1 de contraste : c'est pourquoi
   chaque graphique a une légende ÉCRITE et un tableau « Voir les chiffres ».

   L'ORDRE DES TEINTES EST FIXE ET SUIT L'ENTITÉ, jamais son rang : « Moteurs de
   recherche » garde sa couleur même quand un filtre en retire une autre.

   L'administration n'a pas de mode sombre (voulu) : une seule série de valeurs.
   ========================================================================== */

.audience {
    --viz-1: #2a78d6;   /* bleu      — la série principale, accès direct */
    --viz-2: #eb6834;   /* orange */
    --viz-3: #1baf7a;   /* aqua */
    --viz-4: #eda100;   /* jaune */
    --viz-5: #e87ba4;   /* magenta */
    --viz-6: #008300;   /* vert */
    --viz-comparaison: #a9a79f;   /* la période d'avant : présente, en retrait */
    --viz-grille: #e7e6e0;
    --viz-base: #c3c2b7;
    --viz-zero: #f1f0ec;          /* une case vide de la carte de chaleur */
    /* Une seule teinte, du clair au foncé : la quantité. */
    --viz-seq-1: #cde2fb;
    --viz-seq-2: #9ec5f4;
    --viz-seq-3: #6da7ec;
    --viz-seq-4: #3987e5;
    --viz-seq-5: #256abf;
    --viz-seq-6: #184f95;
    --viz-seq-7: #0d366b;
}

/* --- Barre d'outils : période et comparaison, sur UNE rangée au-dessus ---- */
.audience-outils {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--ad-space-3) var(--ad-space-5);
    margin-bottom: var(--ad-space-4);
}
.audience-segments {
    display: inline-flex;
    padding: 3px;
    border-radius: var(--ad-r-pill);
    background: var(--ad-bg-sunk);
}
.audience-segments a {
    padding: 6px 14px;
    border-radius: var(--ad-r-pill);
    color: var(--ad-text-soft);
    font-size: var(--ad-fs-sm);
    font-weight: 600;
    text-decoration: none;
}
.audience-segments a:hover { color: var(--ad-text); }
.audience-segments a[aria-current="true"] {
    background: var(--ad-bg);
    color: var(--ad-text);
    box-shadow: var(--ad-shadow-sm);
}
.audience-outils__note { margin-left: auto; color: var(--ad-text-mute); font-size: var(--ad-fs-xs); }

/* --- Les chiffres clés ----------------------------------------------------- */
.audience-cles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: var(--ad-space-3);
    margin-bottom: var(--ad-space-4);
}
.audience-cle {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: "label label" "valeur trace" "ecart trace";
    align-items: end;
    gap: 2px var(--ad-space-3);
    padding: var(--ad-space-4);
    border: 1px solid var(--ad-border);
    border-radius: var(--ad-r-md);
    background: var(--ad-bg);
    box-shadow: var(--ad-shadow-sm);
}
.audience-cle__label { grid-area: label; color: var(--ad-text-soft); font-size: var(--ad-fs-sm); font-weight: 600; }
.audience-cle__valeur {
    grid-area: valeur;
    color: var(--ad-text);
    font-size: 32px;
    font-weight: 650;
    line-height: 1.1;
    letter-spacing: -.01em;
}
.audience-cle__ecart { grid-area: ecart; font-size: var(--ad-fs-xs); color: var(--ad-text-mute); }
.audience-cle__ecart b { font-weight: 650; }
.audience-cle__ecart.is-mieux b { color: var(--ad-success); }
.audience-cle__ecart.is-moins b { color: var(--ad-danger); }
.audience-cle .viz-etincelle { grid-area: trace; width: 96px; height: 32px; }

/* --- Cartes et grille ------------------------------------------------------ */
.audience-grille {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr));
    gap: var(--ad-space-4);
    align-items: start;
    /* Une carte absente (pas de campagne sur la période) ou pleine largeur (la
       carte de chaleur) laissait un trou à droite : la suivante vient le combler. */
    grid-auto-flow: row dense;
}
.audience .admin-card { margin-bottom: 0; }
/* La carte de chaleur a vingt-quatre colonnes : dans une demi-largeur, ses
   cases tombaient à dix pixels et ses heures devenaient illisibles. */
.audience-pleine { grid-column: 1 / -1; }
.audience-pleine .viz-chaleur { max-width: 1100px; }
.audience-large { margin-bottom: var(--ad-space-4); }
.audience-carte__tete {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--ad-space-2) var(--ad-space-4);
    margin-bottom: var(--ad-space-3);
}
.audience-carte__tete h2 { margin: 0; }
.audience-carte__sous { color: var(--ad-text-mute); font-size: var(--ad-fs-xs); }
.audience-cles-legende { display: flex; flex-wrap: wrap; gap: var(--ad-space-4); color: var(--ad-text-soft); font-size: var(--ad-fs-xs); }
.audience-cles-legende span { display: inline-flex; align-items: center; gap: 6px; }
.audience-cles-legende i { display: inline-block; width: 16px; height: 2px; border-radius: 1px; background: var(--viz-1); }
.audience-cles-legende i.is-comparaison { background: var(--viz-comparaison); }

/* --- Le dessin ------------------------------------------------------------- */
.viz-cadre { position: relative; }
.audience svg { display: block; width: 100%; height: auto; overflow: visible; }
.viz-grille { stroke: var(--viz-grille); stroke-width: 1; shape-rendering: crispEdges; }
.viz-base { stroke: var(--viz-base); }
.viz-graduation {
    fill: var(--ad-text-mute);
    font: 500 11px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
    font-variant-numeric: tabular-nums;
}
.viz-ligne { fill: none; stroke: var(--viz-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz-ligne--comparaison { stroke: var(--viz-comparaison); }
.viz-aire { fill: var(--viz-1); opacity: .1; }
.viz-point { fill: var(--viz-1); stroke: var(--ad-bg); stroke-width: 2; }
.viz-reticule { stroke: var(--ad-text-mute); stroke-width: 1; }
.viz-survol { fill: transparent; cursor: crosshair; }
.viz-serie-1 { fill: var(--viz-1); } .viz-serie-2 { fill: var(--viz-2); } .viz-serie-3 { fill: var(--viz-3); }
.viz-serie-4 { fill: var(--viz-4); } .viz-serie-5 { fill: var(--viz-5); } .viz-serie-6 { fill: var(--viz-6); }
.viz-seq-0 { fill: var(--viz-zero); }
.viz-seq-1 { fill: var(--viz-seq-1); } .viz-seq-2 { fill: var(--viz-seq-2); } .viz-seq-3 { fill: var(--viz-seq-3); }
.viz-seq-4 { fill: var(--viz-seq-4); } .viz-seq-5 { fill: var(--viz-seq-5); } .viz-seq-6 { fill: var(--viz-seq-6); }
.viz-seq-7 { fill: var(--viz-seq-7); }
/* Ce qu'on survole se soulève à peine : il répond, il ne crie pas. */
[data-viz-bulle] { transition: opacity .12s ease; }
svg:hover [data-viz-bulle]:not(:hover) { opacity: .72; }
.viz-parts { height: 22px; }
.viz-etincelle polyline { fill: none; stroke: var(--viz-1); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.viz-etincelle circle { fill: var(--viz-1); }

/* --- Légende : la pastille porte la couleur, le texte reste à l'encre ----- */
.viz-legende {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: 6px var(--ad-space-3);
    margin: var(--ad-space-3) 0 0;
    padding: 0;
    list-style: none;
    font-size: var(--ad-fs-sm);
}
.viz-legende li { display: contents; }
.viz-pastille { width: 10px; height: 10px; margin-top: 5px; border-radius: 3px; background: currentColor; }
.viz-pastille.viz-serie-1 { background: var(--viz-1); } .viz-pastille.viz-serie-2 { background: var(--viz-2); }
.viz-pastille.viz-serie-3 { background: var(--viz-3); } .viz-pastille.viz-serie-4 { background: var(--viz-4); }
.viz-pastille.viz-serie-5 { background: var(--viz-5); } .viz-pastille.viz-serie-6 { background: var(--viz-6); }
.viz-legende__nom { color: var(--ad-text); }
.viz-legende__valeur { color: var(--ad-text); font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.viz-legende__part { color: var(--ad-text-mute); font-variant-numeric: tabular-nums; text-align: right; min-width: 3.5em; }

.viz-echelle { display: flex; align-items: center; gap: 3px; margin: var(--ad-space-2) 0 0; color: var(--ad-text-mute); font-size: var(--ad-fs-xs); }
.viz-echelle span:first-child { margin-right: 6px; }
.viz-echelle span:last-child { margin-left: 6px; }
.viz-echelle__cran { width: 18px; height: 10px; border-radius: 2px; }
.viz-echelle__cran.viz-seq-1 { background: var(--viz-seq-1); } .viz-echelle__cran.viz-seq-2 { background: var(--viz-seq-2); }
.viz-echelle__cran.viz-seq-3 { background: var(--viz-seq-3); } .viz-echelle__cran.viz-seq-4 { background: var(--viz-seq-4); }
.viz-echelle__cran.viz-seq-5 { background: var(--viz-seq-5); } .viz-echelle__cran.viz-seq-6 { background: var(--viz-seq-6); }
.viz-echelle__cran.viz-seq-7 { background: var(--viz-seq-7); }

/* --- Tableaux classés, avec leur jauge ------------------------------------ */
.audience-table { width: 100%; border-collapse: collapse; font-size: var(--ad-fs-sm); }
.audience-table th {
    padding: 0 0 var(--ad-space-2);
    color: var(--ad-text-mute);
    font-size: var(--ad-fs-xs);
    font-weight: 600;
    text-align: left;
    border-bottom: 1px solid var(--ad-border);
}
.audience-table td { padding: 8px 0; border-bottom: 1px solid var(--ad-border); vertical-align: middle; }
.audience-table tr:last-child td { border-bottom: 0; }
.audience-table .is-nombre { width: 1%; padding-left: var(--ad-space-3); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.audience-table .is-jauge { width: 30%; padding-left: var(--ad-space-3); }
.audience-table a { color: var(--ad-text); text-decoration: none; }
.audience-table a:hover { color: var(--ad-accent); text-decoration: underline; }
.audience-table small { display: block; color: var(--ad-text-mute); font-size: var(--ad-fs-xs); overflow-wrap: anywhere; }
.viz-jauge { display: block; height: 8px; border-radius: 4px; background: var(--ad-bg-sunk); overflow: hidden; }
.viz-jauge span { display: block; height: 100%; border-radius: 4px; background: var(--viz-1); }

/* « Voir les chiffres » : le tableau qui double chaque graphique. */
.viz-chiffres { margin-top: var(--ad-space-3); }
.viz-chiffres summary { color: var(--ad-text-mute); font-size: var(--ad-fs-xs); cursor: pointer; }
.viz-chiffres table { margin-top: var(--ad-space-2); }

/* --- La bulle de survol ---------------------------------------------------- */
.viz-bulle {
    position: fixed;
    z-index: 1200;
    max-width: 280px;
    padding: 8px 12px;
    border-radius: var(--ad-r-sm);
    background: var(--ad-text);
    color: #fff;
    font-size: var(--ad-fs-xs);
    line-height: 1.4;
    pointer-events: none;
    box-shadow: var(--ad-shadow-md);
}
.viz-bulle[hidden] { display: none; }
.viz-bulle__date { color: #d6d8dd; margin-bottom: 4px; }
.viz-bulle__ligne { display: flex; align-items: center; gap: 8px; }
.viz-bulle__ligne b { font-size: 14px; font-weight: 650; }
.viz-bulle__cle { width: 12px; height: 2px; border-radius: 1px; background: var(--viz-1); }
.viz-bulle__cle.is-comparaison { background: var(--viz-comparaison); }
.viz-bulle__ligne span:last-child { color: #d6d8dd; }

/* --- Éteinte : la présentation --------------------------------------------- */
.audience-accueil { max-width: 820px; }
.audience-accueil__cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--ad-space-4); }
.audience-accueil h3 { margin: 0 0 var(--ad-space-2); font-size: var(--ad-fs-md); }
.audience-accueil ul { margin: 0; padding-left: 1.2em; color: var(--ad-text-soft); font-size: var(--ad-fs-sm); }
.audience-accueil li + li { margin-top: 4px; }
.audience-vide { padding: var(--ad-space-6) var(--ad-space-4); text-align: center; color: var(--ad-text-mute); }

@media (prefers-reduced-motion: reduce) {
    [data-viz-bulle] { transition: none; }
}
@media print {
    .audience-outils, .viz-chiffres summary, .audience-reglage { display: none; }
}

