/* ─── Page Statistiques des tableaux (#16) ────────────────── */
.av-stats {
    --stats-encre  : #2c2416;
    --stats-brun   : #5a4e3c;
    --stats-sable  : #9a8a72;
    --stats-filet  : #c8bfaa;
    --stats-papier : #ede8de;
    --stats-piste  : #e9e3d7;
    --stats-carte  : #fff;
    --stats-ombre  : 0 2px 12px rgba(44, 36, 22, 0.06);

    max-width   : 960px;
    margin      : 0 auto;
    padding     : 2.5rem 2rem 6rem; /* titre à ~40 px de la navigation, comme les autres pages */
    font-family : 'Georgia', serif;
    color       : var(--stats-encre);
}

.av-stats__titre {
    text-align : center;
    margin     : 0 0 0.6rem;
}


.av-stats__intro {
    text-align     : center;
    font-style     : italic;
    font-size      : 15px;
    color          : var(--stats-brun);
    margin         : 1.4rem 0 2.8rem;
}

/* ─── Chiffres clés ───────────────────────────────────────── */
.av-stats__chiffres {
    display               : grid;
    grid-template-columns : repeat(4, 1fr);
    gap                   : 1.2rem;
    margin-bottom         : 1.6rem;
}

.av-stats__chiffre {
    display        : flex;
    flex-direction : column;
    align-items    : center;
    justify-content: center;
    gap            : 0.6rem;
    padding        : 1.6rem 1rem 1.5rem;
    text-align     : center;
    background     : var(--stats-carte);
    border         : 1px solid var(--stats-filet);
    border-top     : 2px solid var(--stats-brun);
    box-shadow     : var(--stats-ombre);
}

.av-stats__chiffre-valeur {
    font-size   : 32px;
    line-height : 1.1;
    color       : var(--stats-encre);
}

.av-stats__chiffre-valeur--attente {
    font-size  : 24px;
    font-style : italic;
    color      : var(--stats-sable);
}

.av-stats__chiffre-label {
    font-size      : 11px;
    letter-spacing : 0.18em;
    text-transform : uppercase;
    color          : var(--stats-brun);
}

/* ─── Cartes des graphiques ───────────────────────────────── */
.av-stats__section {
    background    : var(--stats-carte);
    border        : 1px solid var(--stats-filet);
    box-shadow    : var(--stats-ombre);
    padding       : 1.8rem 2.2rem 2.2rem;
    margin-bottom : 1.6rem;
}

.av-stats__entete {
    border-bottom : 1px solid var(--stats-piste);
    padding-bottom: 1rem;
    margin-bottom : 1.8rem;
}

/* Carte sans graphique (donnée pas encore saisie) : pas de filet sous l'en-tête */
.av-stats__entete:last-child {
    border-bottom  : 0;
    padding-bottom : 0;
    margin-bottom  : 0;
}

.av-stats__section-titre {
    margin : 0 0 0.3rem;
}

.av-stats__note {
    font-size  : 13px;
    font-style : italic;
    color      : var(--stats-sable);
}

.av-stats__duo {
    display               : grid;
    grid-template-columns : 1fr 1fr;
    gap                   : 1.6rem;
    margin-bottom         : 1.6rem;
}

.av-stats__duo .av-stats__section {
    margin-bottom : 0;
}

/* ─── Histogramme ─────────────────────────────────────────── */
.av-histo {
    padding-left : 1.6rem; /* place des graduations */
}

.av-histo__zone {
    position   : relative;
    height     : 220px;
    overflow-x : clip; /* filet de sécurité : aucune infobulle ne déborde sur les côtés */
}

.av-histo__grille {
    position   : absolute;
    left       : 0;
    right      : 0;
    height     : 0;
    border-top : 1px solid var(--stats-piste);
}

.av-histo__grille span {
    position    : absolute;
    left        : -1.6rem;
    transform   : translateY(-50%);
    font-size   : 11px;
    color       : var(--stats-sable);
    font-variant-numeric : tabular-nums;
}

.av-histo__colonnes {
    position    : absolute;
    inset       : 0;
    display     : flex;
    align-items : flex-end;
}

.av-histo__colonne {
    position        : relative;
    flex            : 1;
    height          : 100%;
    display         : flex;
    align-items     : flex-end;
    justify-content : center;
}

.av-histo__barre {
    width         : 70%;
    max-width     : 24px;
    background    : var(--stats-brun);
    border-radius : 4px 4px 0 0;
    transition    : background-color 0.2s ease;
}

a.av-histo__colonne {
    cursor          : pointer;
    text-decoration : none;
}

.av-histo__colonne:hover .av-histo__barre {
    background : var(--stats-encre);
}

.av-histo__colonne:hover {
    background : rgba(154, 138, 114, 0.12);
}

.av-histo__colonne::after {
    content        : attr(data-info);
    position       : absolute;
    bottom         : calc(100% + 6px);
    left           : 50%;
    transform      : translateX(-50%);
    padding        : 0.35rem 0.7rem;
    background     : var(--stats-encre);
    color          : #f0ece3;
    font-size      : 12px;
    white-space    : nowrap;
    pointer-events : none;
    opacity        : 0;
    transition     : opacity 0.15s ease;
    z-index        : 2;
}

.av-histo__colonne:hover::after {
    opacity : 1;
}

/* Infobulles des colonnes aux bords : alignées vers l'intérieur, sinon elles sortent
   du graphique (et, même invisibles, créent un défilement horizontal sur mobile). */
.av-histo__colonne:nth-child(-n+4)::after {
    left      : 0;
    transform : none;
}

.av-histo__colonne:nth-last-child(-n+4)::after {
    left      : auto;
    right     : 0;
    transform : none;
}

.av-histo__annees {
    display    : flex;
    border-top : 1px solid var(--stats-filet);
    padding-top: 0.4rem;
}

.av-histo__annees span {
    flex        : 1;
    min-width   : 0;
    font-size   : 11px;
    color       : var(--stats-sable);
    text-align  : center;
    white-space : nowrap;
    overflow    : visible;
    display     : flex;
    justify-content : center;
}

/* ─── Barres horizontales ─────────────────────────────────── */
.av-stats__barres {
    list-style : none;
    margin     : 0;
    padding    : 0;
}

.av-stats__barres li {
    display     : flex;
    align-items : center;
    gap         : 1rem;
    padding     : 0.4rem 0;
}

.av-stats__barre-nom {
    flex           : 0 0 7.5rem;
    font-size      : 12px;
    letter-spacing : 0.14em;
    text-transform : uppercase;
    color          : var(--stats-brun);
}

.av-stats__barre-piste {
    flex          : 1;
    display       : flex;
    align-items   : center;
    gap           : 0.6rem;
    min-width     : 0;
    padding-right : 5.5rem; /* réserve la place de la valeur, qui suit la barre */
}

.av-stats__barre {
    height        : 18px;
    min-width     : 4px;
    background    : var(--stats-brun);
    border-radius : 0 4px 4px 0;
    flex-shrink   : 1;
}

.av-stats__barre-valeur {
    font-size   : 13px;
    color       : var(--stats-encre);
    white-space : nowrap;
    margin-right: -5.5rem;
}

/* Ligne cliquable : mène à la liste des tableaux filtrée */
.av-stats__ligne {
    flex            : 1;
    display         : flex;
    align-items     : center;
    gap             : 1rem;
    min-width       : 0;
    margin          : -0.25rem -0.5rem;
    padding         : 0.25rem 0.5rem;
    border-radius   : 4px;
    color           : inherit;
    text-decoration : none;
    transition      : background-color 0.2s ease;
}

.av-stats__ligne:hover,
.av-stats__ligne:focus-visible {
    background : rgba(154, 138, 114, 0.12);
}

.av-stats__ligne:hover .av-stats__barre,
.av-stats__ligne:focus-visible .av-stats__barre {
    background : var(--stats-encre);
}

.av-stats__ligne:hover .av-stats__barre-nom,
.av-stats__ligne:focus-visible .av-stats__barre-nom {
    color : var(--stats-encre);
}

.av-stats__barres-manquant .av-stats__barre-nom,
.av-stats__barres-manquant .av-stats__barre-valeur {
    font-style : italic;
    color      : var(--stats-sable);
}

.av-stats__barres-manquant .av-stats__barre-nom {
    text-transform : none;
    letter-spacing : 0.04em;
    font-size      : 13px;
}

/* ─── Présence d'eau ──────────────────────────────────────── */
.av-stats__eau {
    display       : flex;
    gap           : 2px;
    height        : 18px;
    border-radius : 4px;
    overflow      : hidden;
}

.av-stats__eau > * {
    flex-basis : 0;
}

.av-stats__eau a {
    transition : opacity 0.2s ease;
}

.av-stats__eau a:hover,
.av-stats__eau a:focus-visible {
    opacity : 0.75;
}

.av-stats__eau-oui {
    background : var(--stats-brun);
}

.av-stats__eau-non {
    background : var(--stats-sable);
}

/* Fiches pas encore renseignées : hachures claires */
.av-stats__eau-manquant {
    background : repeating-linear-gradient(135deg, var(--stats-piste) 0 6px, var(--stats-carte) 6px 9px);
}

.av-stats__legende {
    display    : flex;
    flex-wrap  : wrap;
    gap        : 0.5rem 2rem;
    list-style : none;
    margin     : 0.9rem 0 0;
    padding    : 0;
    font-size  : 13px;
    color      : var(--stats-encre);
}

.av-stats__cle {
    display        : inline-block;
    width          : 14px;
    height         : 4px;
    margin-right   : 0.5rem;
    vertical-align : middle;
    border-radius  : 2px;
}

.av-stats__cle--oui { background : var(--stats-brun); }
.av-stats__cle--non { background : var(--stats-sable); }
.av-stats__cle--manquant { background : var(--stats-filet); }

.av-stats__legende a {
    color                 : inherit;
    text-underline-offset : 3px;
}

.av-stats__legende-manquant {
    font-style : italic;
    color      : var(--stats-sable);
}

/* ─── Données brutes ──────────────────────────────────────── */
.av-stats__donnees {
    margin-top : 1.4rem;
    font-size  : 13px;
}

.av-stats__donnees summary {
    display        : inline-block;
    cursor         : pointer;
    font-style     : italic;
    color          : var(--stats-brun);
    border-bottom  : 1px solid var(--stats-sable);
}

.av-stats__donnees-contenu {
    overflow : hidden; /* pendant le déroulé */
}

.av-stats__donnees table {
    width           : auto; /* le thème parent met les tableaux en pleine largeur */
    min-width       : 16rem;
    margin          : 1rem 0 0;
    border          : 0;
    border-collapse : collapse;
    font-variant-numeric : tabular-nums;
}

.av-stats__donnees th,
.av-stats__donnees td {
    padding       : 0.6rem 2.5rem 0.6rem 0.9rem;
    border        : 0;
    border-bottom : 1px solid var(--stats-piste);
    background    : none;
    text-align    : left;
    font-weight   : 400;
}

/* Lignes alternées aux couleurs de la page (le thème parent impose un gris) */
.av-stats__donnees tbody > tr:nth-child(odd) > td {
    background : rgba(154, 138, 114, 0.06);
}

.av-stats__donnees tbody > tr:hover > td {
    background : rgba(154, 138, 114, 0.14);
}

.av-stats__donnees td a {
    color                 : var(--stats-brun);
    text-decoration       : underline;
    text-decoration-color : var(--stats-filet);
    text-underline-offset : 3px;
}

.av-stats__donnees td a:hover {
    color : var(--stats-encre);
}

.av-stats__donnees th {
    font-size      : 11px;
    letter-spacing : 0.14em;
    text-transform : uppercase;
    color          : var(--stats-sable);
}

/* ─── Retour ──────────────────────────────────────────────── */
.av-stats__retour {
    text-align : center;
    margin-top : 3rem;
}

.av-stats__retour a {
    font-size       : 13px;
    font-style      : italic;
    letter-spacing  : 0.08em;
    color           : var(--stats-brun);
    text-decoration : none;
    border-bottom   : 1px solid var(--stats-sable);
}

.av-stats__retour a:hover {
    color        : var(--stats-encre);
    border-color : var(--stats-encre);
}

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width: 760px) {
    .av-stats {
        padding : 2.5rem 1rem 4rem;
    }

    .av-stats__duo {
        grid-template-columns : 1fr;
        gap                   : 1.6rem;
    }

    .av-stats__chiffres {
        grid-template-columns : 1fr 1fr;
        gap                   : 0.8rem;
    }

    .av-stats__chiffre-valeur {
        font-size : 26px;
    }

    .av-stats__section {
        padding : 1.4rem 1.1rem 1.6rem;
    }

    .av-histo__lustre {
        visibility : hidden; /* une année sur dix seulement */
    }
}
