/* Chart animation: bars grow up from the bottom, lines draw left to right, labels fade in.
   Runs when a chart first scrolls into view and again each time it's shown (switching KPI / tab). */

@keyframes chart-grow {
    from { transform: scaleY(0); }
    to { transform: scaleY(1); }
}
@keyframes chart-draw {
    from { clip-path: inset(0 100% 0 0); }
    to { clip-path: inset(0 0 0 0); }
}
@keyframes chart-fade {
    from { opacity: 0; }
}

svg.chart .bar-stable,
svg.chart .bar-improved,
svg.chart .bar-empty {
    transform-box: fill-box;
    transform-origin: 50% 100%;
    animation: chart-grow .7s cubic-bezier(.2, .8, .2, 1) both;
}
svg.chart .bar-improved {
    animation-delay: .08s;
}
svg.chart .target-mark {
    animation: chart-fade .3s .5s both;
}

svg.chart .actual-average-line,
svg.chart .traffic-line {
    animation: chart-draw .9s .25s cubic-bezier(.4, 0, .2, 1) both;
}
svg.chart .target-average-line,
svg.chart .bto-line {
    animation: chart-draw .7s .15s cubic-bezier(.4, 0, .2, 1) both;
}
svg.chart .actual-average-dot,
svg.chart .traffic-dot,
svg.chart .actual-average-label,
svg.chart .target-average-label,
svg.chart .bto-label {
    animation: chart-fade .35s .8s both;
}

/* wait until the chart is on screen (class set by chart-animation.js) */
.chart-anim svg.chart:not(.in-view) *,
.chart-anim svg.chart:not(.in-view) {
    animation-play-state: paused;
}

@media (prefers-reduced-motion: reduce) {
    svg.chart * {
        animation: none !important;
    }
}
