/*
 * statistik.css – Statistikseite ?p=stat (EXPERIMENTELL, docs/STATISTIK.md)
 *
 * Diagramme sind SVG aus public/js/statistik.js. Farben nur über die Tokens --stat-* (tokens.css): jede Fakultät hat
 * einen festen Slot (.s0 = «Übrige», .s1–.s8); die Klasse setzt --c, die Marke entscheidet, ob Füllung oder Strich.
 * Marken dünn, Gitter fein und durchgezogen, Text nie in Datenfarbe.
 */

/* ---- Farb-Slots ------------------------------------------------------------------------------------------------ */
.statistik .s0 {
    --c: var(--stat-0);
}
.statistik .s1 {
    --c: var(--stat-1);
}
.statistik .s2 {
    --c: var(--stat-2);
}
.statistik .s3 {
    --c: var(--stat-3);
}
.statistik .s4 {
    --c: var(--stat-4);
}
.statistik .s5 {
    --c: var(--stat-5);
}
.statistik .s6 {
    --c: var(--stat-6);
}
.statistik .s7 {
    --c: var(--stat-7);
}
.statistik .s8 {
    --c: var(--stat-8);
}

/* ---- Kopf ------------------------------------------------------------------------------------------------------ */
.statistik {
    max-width: var(--page);
}
.statistik .stat-fuss {
    max-width: none;            /* Einleitung (.lead) ist schon in bausteine.css ganz breit */
}
.badge-experimentell {
    display: inline-block;
    vertical-align: middle;
    margin-left: .5rem;
    padding: .1rem .55rem;
    border: 1px solid var(--yellow);
    border-radius: 1rem;
    background: var(--yellow-bg);
    color: var(--yellow-dark);
    font-size: .8rem;
    font-weight: 400;
}

/* ---- Reiter «Gesamtuniversität» / «Fakultäten» --------------------------------------------------------------- */
.stat-tabs {
    display: flex;
    gap: .25rem;
    margin-top: 1.5rem;
    border-bottom: 2px solid var(--staff-stroke);
}
.stat-tabs [role="tab"] {
    margin-bottom: -2px;
    padding: .7rem 1.2rem;
    border: 1px solid transparent;
    border-bottom: 2px solid transparent;
    border-radius: var(--radius) var(--radius) 0 0;
    background: none;
    color: var(--grey-dark);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}
.stat-tabs [role="tab"]:hover {
    color: var(--staff);
}
.stat-tabs [role="tab"][aria-selected="true"] {
    border-color: var(--staff-stroke);
    border-bottom-color: var(--staff);
    background: var(--staff-kopf);
    color: var(--staff);
}

/* ---- Filter: farbig abgesetzter Kasten über den Diagrammen, so breit wie die Karten, scrollt mit ---------------- */
.stat-filter {
    max-width: none;               /* Formulare sind sonst auf --measure begrenzt (formulare.css) */
    margin: 0 0 2rem;
    padding: 1rem 1.25rem 1.1rem;
    border: 1px solid var(--staff-stroke);
    border-top: 0;
    border-left: 4px solid var(--staff);
    border-radius: 0 0 var(--radius) var(--radius);
    background: var(--staff-kopf);
}
.stat-filter-kopf {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .2rem .5rem;
    margin-bottom: .8rem;
    color: var(--grey);
    font-size: .85rem;
}
.stat-filter-kopf strong {
    color: var(--staff);
    font-size: 1.05rem;
}
.stat-filter-kopf svg {
    width: 1.2rem;
    height: 1.2rem;
    fill: none;
    stroke: var(--staff);
    stroke-width: 1.8;
    stroke-linejoin: round;
}
/* Drei Abschnitte: Fakultäten (nur im Reiter «Fakultäten», ganze Breite), Semester, Darstellung */
.stat-filter-teile {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    gap: 1rem 2.5rem;
}
.stat-filter .teil {
    min-width: 0;
    margin: 0;
    padding: .8rem 0 0;
    border: 0;
    border-top: 1px solid var(--staff-stroke);
}
.stat-filter .teil.fak {
    grid-column: 1 / -1;
}
.stat-filter .teil[hidden] {
    display: none;
}
.stat-filter legend {
    float: left;                   /* legend sonst über dem Rahmen; so beginnt der Abschnitt mit seinem Titel */
    width: 100%;
    margin-bottom: .6rem;
    padding: 0;
    color: var(--staff);
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.stat-filter .zeile {
    clear: both;
    display: grid;
    grid-template-columns: 9.5rem minmax(0, 1fr);
    align-items: center;
    gap: .3rem 1rem;
    margin-bottom: .6rem;
}
.stat-filter .zeile > label,
.stat-filter .zeile > .label {
    color: var(--grey-dark);
    font-size: .9rem;
}
.stat-filter .steuer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem .9rem;
}
.stat-filter .steuer label {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    margin: 0;
    color: var(--black);
    font-size: .95rem;
}
.stat-filter .steuer .bis {
    color: var(--grey);
    font-size: .9rem;
}
.stat-filter select {
    width: 14rem;
    max-width: 100%;
    height: 2.4rem;
    padding: 0 2rem 0 .6rem;
    border: 1px solid var(--grey-mid-darker);
    border-radius: var(--radius);
    background: var(--white) var(--icon-chevron) no-repeat right .7rem center / .8rem auto;
    font: inherit;
    font-size: .95rem;
    appearance: none;
}
.stat-filter select.kurz {
    width: 9rem;
}
.stat-filter .hinweis-klein {
    clear: both;
    max-width: none;
    margin: -.3rem 0 .6rem 10.5rem;
    color: var(--grey);
    font-size: .8rem;
}
.chip-reihe {
    clear: both;
    display: inline-flex;
    flex-wrap: wrap;
    gap: .4rem;
}
.stat-filter .chip {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .3rem .7rem;
    border: 1px solid var(--grey-mid);
    border-radius: 1rem;
    background: var(--white);
    color: var(--grey);
    font: inherit;
    font-size: .9rem;
    cursor: pointer;
}
.stat-filter .chip[aria-pressed="true"] {
    border-color: var(--staff);
    color: var(--black);
}
.stat-filter .chip[aria-pressed="false"] .tip-key {
    background: var(--grey-mid);
}
.stat-alle {
    margin-left: .6rem;
    padding: 0;
    border: 0;
    background: none;
    color: var(--link);
    font: inherit;
    font-size: .9rem;
    text-decoration: underline;
    text-decoration-color: var(--link-underline);
    cursor: pointer;
}
@media (max-width: 52rem) {
    .stat-filter-teile {
        grid-template-columns: minmax(0, 1fr);
    }
    .stat-filter .zeile {
        grid-template-columns: minmax(0, 1fr);
    }
    .stat-filter .hinweis-klein {
        margin-left: 0;
    }
}

/* ---- Abschnitte, Karten ---------------------------------------------------------------------------------------- */
[role="tabpanel"] {
    margin-bottom: 2.5rem;
}
[role="tabpanel"] h2 span {
    color: var(--staff);
}
.stat-raster {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem;
}
.stat-karte {
    margin: 0;
    padding: 1rem 1.2rem 1.1rem;
    border: 1px solid var(--grey-mid);
    border-radius: var(--radius);
    background: var(--white);
    min-width: 0;
}
.stat-karte.breit {
    grid-column: 1 / -1;
}
.stat-karte figcaption {
    margin-bottom: .6rem;
}
.stat-karte figcaption strong {
    display: block;
    color: var(--black);
}
.stat-karte figcaption span {
    color: var(--grey);
    font-size: .85rem;
}
@media (max-width: 52rem) {
    .stat-raster {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ---- Kennzahlen ------------------------------------------------------------------------------------------------ */
.kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.kpi {
    padding: .9rem 1.1rem;
    border: 1px solid var(--staff-stroke);
    border-radius: var(--radius);
    background: var(--staff-bg);
}
.kpi-label {
    color: var(--grey);
    font-size: .85rem;
}
.kpi-wert {
    color: var(--black);
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}
.kpi-delta,
.kpi-extra {
    color: var(--grey-dark);
    font-size: .85rem;
}
.kpi-extra {
    color: var(--grey);
}
.kpi-delta .pfeil {
    font-size: .7rem;
}

/* ---- SVG-Grundlagen -------------------------------------------------------------------------------------------- */
.stat-svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
    font-family: var(--font);
}
.stat-svg:focus-visible {
    outline: 2px solid transparent; /* siehe basis.css :focus-visible */
    box-shadow: var(--focus);
}
.stat-svg .gitter line,
.stat-svg .gitter .ring {
    stroke: var(--stat-gitter);
    stroke-width: 1;
    fill: none;
}
.stat-svg .achse {
    fill: var(--grey);
    font-size: 12px;
}
.stat-svg .wert {
    fill: var(--grey-dark);
    font-size: 12px;
    font-weight: 700;
}
.stat-svg .klein {
    font-size: 11px;
}
.stat-svg .referenz {
    stroke: var(--stat-achse);
    stroke-width: 1;
}

/* ---- Marken ---------------------------------------------------------------------------------------------------- */
.stat-svg .linie {
    fill: none;
    stroke: var(--c);
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;
}
.stat-svg .wash {
    fill: var(--c);
    fill-opacity: .1;
}
.stat-svg .punkt {
    fill: var(--c);
    stroke: var(--white);
    stroke-width: 2;
}
.stat-svg .punkt.stich {
    stroke: var(--black);
}
.stat-svg .bar,
.stat-svg .seg,
.stat-svg .stapel {
    fill: var(--c);
}
.stat-svg .bar.plus {
    fill: var(--stat-plus);
}
.stat-svg .bar.minus {
    fill: var(--stat-minus);
}
.stat-svg .stapel {
    stroke: var(--white);
    stroke-width: 1.5;
}
.stat-svg .geist {
    fill: var(--c);
    fill-opacity: .18;
}
.stat-svg .bar.stich {
    stroke: var(--black);
    stroke-width: 1.5;
}
.stat-svg .hell,
.stat-svg .seg:hover,
.stat-svg .seg:focus {
    opacity: .75;
    outline: none;
}
.stat-svg .seg-text {
    fill: var(--white);
    font-size: 11px;
    pointer-events: none;
}
.stat-svg .seg-text.dunkel {
    fill: var(--black);
}
.stat-svg .treffer,
.stat-svg .kreuz-feld {
    fill: transparent;
}
.stat-svg .treffer:focus {
    outline: none;
    fill: var(--stat-fokus);
}
.stat-svg .kreuz-feld.klickbar,
.stat-svg .treffer.klickbar {
    cursor: pointer;
}
.stat-svg .kreuz {
    stroke: var(--stat-achse);
    stroke-width: 1;
    pointer-events: none;
}
.stat-svg .kreuz-punkte {
    pointer-events: none;
}

/* Radar: Stichsemester im Akzent, Vergleich grau; Flächen nur als Hauch */
.stat-svg .radar-flaeche {
    stroke-width: 2;
    stroke-linejoin: round;
    fill-opacity: .1;
}
.stat-svg .radar-flaeche.akzent {
    stroke: var(--stat-1);
    fill: var(--stat-1);
}
.stat-svg .radar-flaeche.vergleich {
    stroke: var(--stat-0);
    fill: var(--stat-0);
}
.stat-svg .punkt.akzent {
    fill: var(--stat-1);
}
.stat-svg .punkt.vergleich {
    fill: var(--stat-0);
}

/* ---- Legende, Farbschlüssel ------------------------------------------------------------------------------------ */
.stat-legende {
    display: flex;
    flex-wrap: wrap;
    gap: .3rem 1rem;
    margin: .6rem 0 0;
    padding: 0;
    list-style: none;
    color: var(--grey-dark);
    font-size: .85rem;
}
.stat-legende li {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
}
.tip-key {
    display: inline-block;
    flex: none;
    width: .7rem;
    height: .7rem;
    border-radius: 2px;
    background: var(--c);
}
.tip-key.linie {
    height: 2px;
    width: .9rem;
    border-radius: 1px;
}

/* ---- Tooltip --------------------------------------------------------------------------------------------------- */
.stat-tip {
    position: fixed;
    z-index: 50;
    max-width: 18rem;
    padding: .5rem .7rem;
    border: 1px solid var(--grey-mid);
    border-radius: var(--radius);
    background: var(--white);
    box-shadow: var(--shadow-pop);
    font-size: .85rem;
    pointer-events: none;
}
.stat-tip .tip-titel {
    margin-bottom: .25rem;
    color: var(--grey);
}
.stat-tip .tip-zeile {
    display: flex;
    align-items: center;
    gap: .4rem;
}
.stat-tip strong {
    color: var(--black);
}
.stat-tip .tip-name {
    color: var(--grey-dark);
}

/* ---- Heatmap --------------------------------------------------------------------------------------------------- */
.heat-huelle,
.tabelle-huelle {
    overflow-x: auto;
}
.heat {
    border-collapse: separate;
    border-spacing: 2px;
    font-size: .8rem;
}
.heat th {
    padding: .2rem .4rem;
    color: var(--grey);
    font-weight: 400;
    text-align: left;
    white-space: nowrap;
}
.heat thead th {
    text-align: center;
}
.heat th .tip-key {
    margin-right: .35rem;
}
.heat td {
    min-width: 2.4rem;
    padding: .35rem .2rem;
    border-radius: 3px;
    background: var(--grey-very-light);
    color: var(--grey-dark);
    text-align: center;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
}
.heat td.hell {
    color: var(--white);
}
.heat td:focus {
    outline: 2px solid transparent; /* siehe basis.css :focus-visible */
    box-shadow: var(--focus);
}
.heat .stich {
    box-shadow: inset 0 0 0 2px var(--black);
}
.heat thead th.stich {
    box-shadow: none;
    color: var(--black);
    font-weight: 700;
}
.heat tr.summe th {
    color: var(--black);
    font-weight: 700;
}
.heat-skala {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-top: .6rem;
    color: var(--grey);
    font-size: .8rem;
}
.heat-skala .verlauf {
    width: 10rem;
    height: .6rem;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--stat-minus), var(--stat-mitte), var(--stat-plus));
}

/* ---- Tabellen zum Aufklappen, Leerzustand, Fuss --------------------------------------------------------------- */
.stat-tabelle {
    margin-top: .7rem;
    font-size: .85rem;
}
.stat-tabelle summary {
    color: var(--link);
    cursor: pointer;
}
.stat-tabelle table {
    margin-top: .5rem;
    border-collapse: collapse;
}
.stat-tabelle th,
.stat-tabelle td {
    padding: .25rem .6rem;
    border-bottom: 1px solid var(--grey-light);
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.stat-tabelle th:first-child {
    text-align: left;
}
.stat-leer {
    color: var(--grey);
}
.stat-fuss {
    color: var(--grey);
    font-size: .85rem;
}
