/**
 * statistiche.css — statistiche di accesso per paese: la mappa del mondo
 * (pagina iniziale e admin-statistiche.php), il riquadro "Da dove ci
 * visitano" della pagina iniziale e la pagina di amministrazione.
 * Richiede tema.css.
 *
 * Colori della mappa: una sola tinta (la giada del marchio), dal chiaro
 * (poche visite) allo scuro (molte); i paesi senza visite restano grigi.
 */

:root {
    --mappa-vuoto: #e2e8e4;
    --mappa-1: #d3efe2;
    --mappa-2: #93d8ba;
    --mappa-3: #3fba89;
    --mappa-4: #00875c;
    --mappa-5: #004f34;
    --mappa-mare: #f6faf8;
}

/* ============================== MAPPA ============================== */

.mappa-mondo {
    position: relative;
    background: var(--mappa-mare);
    border: 1px solid var(--c-bordo);
    border-radius: 12px;
    padding: .5rem;
    /* Proporzioni della mappa (viewBox di mondo.svg) riservate prima del caricamento: la pagina non salta. */
    aspect-ratio: 1010 / 652;
    overflow: hidden;
}
.mappa-mondo-tela {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--c-pietra);
    font-size: .9rem;
}
.mappa-mondo-tela svg {
    display: block;
    width: 100%;
    height: 100%;
}
.mappa-mondo-tela path {
    fill: var(--mappa-vuoto);
    stroke: #fff;
    stroke-width: .5;
    stroke-linejoin: round;
    transition: fill .2s;
    cursor: default;
    outline: none;
}
.mappa-mondo-tela path.livello-1 { fill: var(--mappa-1); }
.mappa-mondo-tela path.livello-2 { fill: var(--mappa-2); }
.mappa-mondo-tela path.livello-3 { fill: var(--mappa-3); }
.mappa-mondo-tela path.livello-4 { fill: var(--mappa-4); }
.mappa-mondo-tela path.livello-5 { fill: var(--mappa-5); }
.mappa-mondo-tela path.attivo,
.mappa-mondo-tela path:focus-visible {
    stroke: var(--c-inchiostro);
    stroke-width: 1.2;
}
.mappa-mondo-tela path:not([class*="livello-"]).attivo {
    fill: #d2d9d5;
}

.mappa-mondo-etichetta {
    position: absolute;
    z-index: 2;
    max-width: 260px;
    padding: .4rem .7rem;
    border-radius: 8px;
    background: var(--c-inchiostro);
    color: #fff;
    font-size: .85rem;
    font-weight: 600;
    line-height: 1.35;
    pointer-events: none;
    box-shadow: var(--ombra-morbida);
}
.mappa-mondo-etichetta.senza-visite {
    background: #fff;
    color: var(--c-pietra);
    font-weight: 500;
    border: 1px solid var(--c-bordo);
}

.mappa-mondo-legenda {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .3rem;
    margin-top: .6rem;
    font-size: .8rem;
    color: var(--c-pietra);
}
.mappa-mondo-legenda i {
    display: inline-block;
    width: 22px;
    height: 10px;
    border-radius: 3px;
}
.mappa-mondo-legenda .livello-1 { background: var(--mappa-1); }
.mappa-mondo-legenda .livello-2 { background: var(--mappa-2); }
.mappa-mondo-legenda .livello-3 { background: var(--mappa-3); }
.mappa-mondo-legenda .livello-4 { background: var(--mappa-4); }
.mappa-mondo-legenda .livello-5 { background: var(--mappa-5); }
.mappa-mondo-legenda-zero {
    margin-left: 1rem;
    display: inline-flex;
    align-items: center;
    gap: .3rem;
}
.mappa-mondo-legenda-zero i { background: var(--mappa-vuoto); }

/* =================== PAGINA INIZIALE: "Da dove ci visitano" =================== */

.statistiche {
    max-width: 1000px;
    margin: 2.5rem auto 0;
    padding: 0 1.25rem 3rem;
}
.statistiche-testa {
    text-align: center;
    margin-bottom: 1rem;
}
.statistiche-testa h2 {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--c-inchiostro);
    margin-bottom: .35rem;
}
.statistiche-testa h2 i {
    color: var(--c-giada);
    margin-right: .3rem;
}
.statistiche-frase {
    color: var(--c-inchiostro-attenuato);
    margin: 0;
}
.statistiche-frase strong {
    color: var(--c-inchiostro);
}
.statistiche .mappa-mondo-legenda {
    justify-content: center;
}
.statistiche-nota {
    text-align: center;
    font-size: .78rem;
    color: var(--c-pietra);
    margin: .8rem 0 0;
}
.statistiche-nota a {
    color: inherit;
}

/* ====================== AMMINISTRAZIONE ====================== */

.admin-statistiche-pagina {
    max-width: 1100px;
}
.statistiche-periodi {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin-bottom: 1.5rem;
}
.statistiche-periodi a {
    padding: .35rem .85rem;
    border-radius: 999px;
    border: 1px solid var(--c-bordo);
    color: var(--c-inchiostro);
    text-decoration: none;
    font-size: .9rem;
    background: #fff;
}
.statistiche-periodi a[aria-current="page"] {
    background: var(--c-giada-scuro);
    border-color: var(--c-giada-scuro);
    color: #fff;
    font-weight: 700;
}
.statistiche-avviso {
    padding: .75rem 1rem;
    border-radius: 8px;
    background: #fff7e0;
    border: 1px solid #ecd9a0;
    margin-bottom: 1.25rem;
    font-size: .9rem;
}
.statistiche-avviso code {
    font-size: .85em;
}

.statistiche-tessere {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .8rem;
    margin-bottom: 1.5rem;
}
.statistiche-tessera {
    background: #fff;
    border: 1px solid var(--c-bordo);
    border-radius: 10px;
    padding: .8rem 1rem;
}
.statistiche-tessera span {
    display: block;
    font-size: .8rem;
    color: var(--c-pietra);
}
.statistiche-tessera strong {
    display: block;
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--c-inchiostro);
    font-variant-numeric: tabular-nums;
}

.statistiche-due {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    gap: 1.5rem;
    margin-top: 1.5rem;
}

/* Barre orizzontali: classifica dei paesi e sezioni. */
.statistiche-barre {
    list-style: none;
    margin: 0;
    padding: 0;
}
.statistiche-barre li {
    display: grid;
    grid-template-columns: minmax(7rem, 11rem) minmax(0, 1fr) auto;
    align-items: center;
    gap: .6rem;
    padding: .22rem 0;
    font-size: .9rem;
}
.statistiche-barre .nome {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.statistiche-barre .barra {
    height: 12px;
    background: #eef2ef;
    border-radius: 0 4px 4px 0;
}
.statistiche-barre .barra i {
    display: block;
    height: 100%;
    min-width: 2px;
    background: var(--mappa-4);
    border-radius: 0 4px 4px 0;
}
.statistiche-barre .valore {
    font-variant-numeric: tabular-nums;
    color: var(--c-inchiostro-attenuato);
    text-align: right;
    min-width: 5.5rem;
}
.statistiche-barre .altri .barra i {
    background: #a8b5ae;
}

/* Andamento nel tempo (colonne in SVG). */
.statistiche-andamento svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}
.statistiche-andamento .colonna {
    fill: var(--mappa-4);
}
.statistiche-andamento .colonna-zona:hover .colonna,
.statistiche-andamento .colonna-zona:focus .colonna {
    fill: var(--mappa-5);
}
.statistiche-andamento .colonna-zona { outline: none; }
.statistiche-andamento .griglia {
    stroke: #e3e8e5;
    stroke-width: 1;
}
.statistiche-andamento text {
    font-size: 11px;
    fill: var(--c-pietra);
    font-family: var(--font-testo);
}

.statistiche-tabella {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}
.statistiche-tabella th,
.statistiche-tabella td {
    padding: .35rem .5rem;
    border-bottom: 1px solid var(--c-bordo);
    text-align: left;
}
.statistiche-tabella td.numero,
.statistiche-tabella th.numero {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.statistiche-dettagli {
    margin-top: 1.5rem;
}
.statistiche-dettagli summary {
    cursor: pointer;
    font-weight: 700;
    margin-bottom: .6rem;
}
.statistiche-metodo {
    margin-top: 2rem;
    font-size: .85rem;
    color: var(--c-pietra);
}
.statistiche-metodo li {
    margin-bottom: .25rem;
}

@media (max-width: 900px) {
    .statistiche-due {
        grid-template-columns: 1fr;
    }
    .statistiche-tessere {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (max-width: 520px) {
    .statistiche-barre li {
        grid-template-columns: minmax(5.5rem, 8rem) minmax(0, 1fr) auto;
        font-size: .82rem;
    }
    .statistiche-barre .valore {
        min-width: 4rem;
    }
    .mappa-mondo-legenda-zero {
        margin-left: .4rem;
    }
}
