/* --------------------------------------------------------------------------
   Grafiken in Blogartikeln (nur Artikel mit grafiken: true im Frontmatter laden diese Datei).
   Gleiches Muster wie die Motive in styles.css: main.js setzt an [data-motiv] erst
   motiv--wartet, beim Hinscrollen motiv--spielt; dort pausiert bzw. startet die Bewegung,
   bei „weniger Bewegung“ läuft keine. Ohne Klasse (kein JavaScript) steht das Endbild.
   Farben nur aus den Tokens von styles.css; Linien unterscheiden sich zusätzlich im Strich.
   -------------------------------------------------------------------------- */
.grafik {
    margin: var(--space-8) 0;
}

/* Container-Abfragen statt Media Queries: Die Grafik richtet sich nach der Breite der Textspalte
   in ihrer eigenen Schriftgröße, bei 200 % Schrift kippt sie so von selbst untereinander */
.grafik__flaeche {
    container-type: inline-size;
    padding: var(--space-5);
    border: 1px solid var(--linie);
    border-radius: var(--radius-karte);
    background-color: var(--flaeche-2);
    background-image: radial-gradient(circle, var(--zonen-rand) 1px, transparent 1.5px);
    background-size: 16px 16px;
}

.grafik figcaption {
    margin-top: var(--space-3);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

/* ---- Kostenrechnung: Linien über 24 Monate ---- */
.kosten__diagramm {
    display: block;
    width: 100%;
    height: auto; /* Seitenverhältnis 2:1 aus der viewBox, der Punkt bleibt rund */
}

.kosten__diagramm path {
    fill: none;
    vector-effect: non-scaling-stroke;
}

.kosten__achse { stroke: var(--color-border-strong); stroke-width: 1; } /* Null-Linie, trägt Bedeutung: 3:1 */
.kosten__ohne { stroke: var(--color-text-muted); stroke-width: 2; }
.kosten__fokus { stroke: var(--violett); stroke-width: 3; }
.kosten__breit { stroke: var(--violett-tief); stroke-width: 2; stroke-dasharray: 6 5; }
.kosten__punkt { fill: var(--violett); }

/* Achsen: Jede Zahl ist ein Punkt ohne Breite. space-between setzt die Punkte genau auf
   0, 1/n … 100 %, die Schrift hängt mittig darüber, am Rand bündig nach innen. */
.kosten__monate,
.dauer__achse {
    display: flex;
    justify-content: space-between;
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
}

.kosten__monate span,
.dauer__achse span {
    display: flex;
    justify-content: center;
    width: 0;
    white-space: nowrap;
}

.kosten__monate span:first-child,
.dauer__achse span:first-child { justify-content: flex-start; }
.kosten__monate span:last-child,
.dauer__achse span:last-child { justify-content: flex-end; }

.grafik__achsentitel {
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    text-align: center;
}

.grafik__legende {
    display: grid;
    gap: var(--space-2);
    margin: var(--space-4) 0 0;
    padding: 0;
    list-style: none;
    font-size: var(--text-sm);
    color: var(--tinte);
}

.grafik__legende li {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.grafik__legende li::before {
    content: '';
    flex: 0 0 1.75rem;
    border-top: 2px solid var(--color-text-muted);
}

.grafik__legende .ist-fokus::before { border-top: 3px solid var(--violett); }
.grafik__legende .ist-breit::before { border-top: 2px dashed var(--violett-tief); }
.grafik__legende .ist-punkt::before {
    flex-basis: 0.75rem;
    height: 0.75rem;
    margin: 0 0.5rem;
    border: 0;
    border-radius: 50%;
    background: var(--violett);
}

/* ---- Projektdauer: Balken auf einer Achse von sechs Monaten ---- */
.dauer {
    display: grid;
    gap: var(--space-4);
}

.dauer__zeile {
    display: grid;
    gap: var(--space-1);
    font-size: var(--text-sm);
    color: var(--tinte);
}

.dauer__kopf {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0 var(--space-3);
}

.dauer__kopf strong { font-weight: 600; }
.dauer__kopf span { color: var(--color-text-secondary); }

.dauer__spur {
    height: 0.75rem;
    border-radius: var(--radius-full);
    background: var(--violett-hell);
    overflow: hidden;
}

.dauer__balken {
    display: block;
    height: 100%;
    border-radius: var(--radius-full);
    background: var(--violett);
    transform-origin: left center;
}

/* 6 Monate = 26 Wochen = 100 %: hell bis 3 Monate, kräftig von 3 bis 6 Monate */
.dauer__balken--monate {
    width: 100%;
    background: linear-gradient(to right, var(--violett-rand) 50%, var(--violett-tief) 50%);
}
.dauer__balken--tage { width: max(0.75rem, 2%); }
.dauer__balken--wochen { width: 19.8%; } /* gut fünf Wochen: 36 von 182 Tagen */

.dauer__achse { margin-top: var(--space-2); }

/* ---- Datenweg Mistral ---- */
.datenweg {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-3);
}

.datenweg__station {
    min-width: 0;
    overflow-wrap: break-word;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--violett-rand);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    font-size: var(--text-sm);
    color: var(--tinte);
}

.datenweg__station strong {
    display: block;
    font-weight: 600;
}

.datenweg__pfeil {
    position: relative;
    align-self: center;
    width: 2px;
    height: 2.5rem;
    background: var(--color-border-strong);
}

.datenweg__pfeil::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 100%;
    width: 0.625rem;
    height: 0.625rem;
    margin: -0.625rem 0 0 -0.3125rem;
    border-radius: 50%;
    background: var(--violett);
}

/* .grafik davor, sonst gewinnt die Absatzregel des Artikels (.article-content p) */
.grafik .datenweg__abseits {
    margin: var(--space-4) 0 0;
    line-height: inherit;
    padding: var(--space-3) var(--space-4);
    border: 1px dashed var(--color-border-strong);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
}

@container (min-width: 30em) {
    .datenweg {
        flex-direction: row;
        align-items: center;
    }
    .datenweg__station { flex: 1 1 0; }
    .datenweg__pfeil {
        flex: 0 0 3.5rem;
        width: auto;
        height: 2px;
    }
    .datenweg__pfeil::after {
        left: 100%;
        top: 50%;
        margin: -0.3125rem 0 0 -0.625rem;
    }
}

/* ---- Weg zum geförderten Test: fünf Stationen untereinander ----
   Nebeneinander wären es in der Textspalte (knapp 600 px) unter 80 px Text je Station */
.foerderweg {
    display: grid;
    gap: var(--space-3);
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: station;
}

.foerderweg li {
    min-width: 0;
    overflow-wrap: break-word;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--violett-rand);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    font-size: var(--text-sm);
    color: var(--tinte);
    counter-increment: station;
}

.foerderweg li::before {
    content: counter(station);
    flex: 0 0 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: var(--violett);
    color: var(--color-text-inverted);
    font-weight: 600;
    line-height: 1.75rem;
    text-align: center;
}

.foerderweg .ist-zu {
    border-style: dashed;
    border-color: var(--color-border-strong);
    background: transparent;
    color: var(--color-text-secondary);
}

.foerderweg .ist-zu::before { background: var(--color-text-muted); }

.foerderweg__schloss {
    flex: 0 0 auto;
    width: 1rem;
    height: 1rem;
    margin-left: auto;
    fill: none;
    stroke: var(--color-text-muted);
    stroke-width: 2;
}

/* ---- Bewegung, einmal beim Hinscrollen ---- */
/* Aufdecken von links statt Strich-Animation: so bleibt das Strichmuster der Linien erhalten */
:is(.motiv--wartet, .motiv--spielt) .kosten__diagramm {
    animation: grafik-aufdecken 1.3s ease-out backwards;
}
:is(.motiv--wartet, .motiv--spielt) .kosten__punkt {
    animation: grafik-auftauchen 0.4s var(--feder) 1.4s backwards;
    transform-box: fill-box;
    transform-origin: center;
}

:is(.motiv--wartet, .motiv--spielt) .dauer__balken {
    animation: grafik-wachsen 0.9s ease-out backwards;
}
:is(.motiv--wartet, .motiv--spielt) .dauer__zeile:nth-child(2) .dauer__balken { animation-delay: 0.5s; }
:is(.motiv--wartet, .motiv--spielt) .dauer__zeile:nth-child(3) .dauer__balken { animation-delay: 0.8s; }

:is(.motiv--wartet, .motiv--spielt) .datenweg__station,
:is(.motiv--wartet, .motiv--spielt) .datenweg__abseits {
    animation: grafik-auftauchen 0.5s ease-out backwards;
}
:is(.motiv--wartet, .motiv--spielt) .datenweg__station:last-child { animation-delay: 0.6s; }
:is(.motiv--wartet, .motiv--spielt) .datenweg__abseits { animation-delay: 1.1s; }
:is(.motiv--wartet, .motiv--spielt) .datenweg__pfeil::after {
    animation: grafik-pfeil-hoch 0.7s ease-in-out 0.3s backwards;
}
@container (min-width: 30em) {
    :is(.motiv--wartet, .motiv--spielt) .datenweg__pfeil::after { animation-name: grafik-pfeil-quer; }
}

:is(.motiv--wartet, .motiv--spielt) .foerderweg li {
    animation: grafik-auftauchen 0.45s ease-out backwards;
}
:is(.motiv--wartet, .motiv--spielt) .foerderweg li:nth-child(2) { animation-delay: 0.2s; }
:is(.motiv--wartet, .motiv--spielt) .foerderweg li:nth-child(3) { animation-delay: 0.4s; }
:is(.motiv--wartet, .motiv--spielt) .foerderweg li:nth-child(4) { animation-delay: 0.6s; }
:is(.motiv--wartet, .motiv--spielt) .foerderweg li:nth-child(5) { animation-delay: 0.8s; }

/* Gedruckt wird das Endbild: Eine noch nicht ins Bild gescrollte Grafik stünde sonst pausiert im Anfangsbild
   (motiv--wartet hält die Animation an), im PDF wäre nur ein leerer Rahmen */
@media print {
    .grafik[data-motiv] *,
    .grafik[data-motiv] *::before,
    .grafik[data-motiv] *::after { animation: none !important; }
}

@keyframes grafik-aufdecken { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes grafik-wachsen { from { transform: scaleX(0); } }
@keyframes grafik-auftauchen { from { opacity: 0; transform: translateY(0.5rem); } }
@keyframes grafik-pfeil-hoch { from { top: 0; margin-top: 0; } }
@keyframes grafik-pfeil-quer { from { left: 0; margin-left: 0; } }
