/* ── CHART — Balken-Diagramme in reinem HTML/CSS (Modul) ────────────
   Varianten:
   .chart            hell (im Artikel)
   .chart--dark      dunkel (in dunklen Sections)
   Typen:
   .chart-stack      gestapelter Balken — Segmentbreite per style="--w:34%"
   .chart-bar-group  vertikale Balken — Höhe per style="--h:37%"
   Balken wachsen beim Einscrollen (Klasse .anim am Balken-Container).
   .chart--motion  weichere Bewegung: Segmente/Balken nacheinander, Werte
                   erscheinen danach, Balkenwerte zählen hoch (data-count im Wert);
                   Delta als Pille: .chart-bar-delta (orange) · --green (grün)
   Chart-Farben: #8A8A8A Referenz · #E52148 · #FDC300 · #E84A43
   (die beiden Rottöne nie direkt nebeneinander, Gelb dazwischen).
   Schrift: chart-kicker t-body · chart-subkicker/-caption/-note t-xs
   UI: Achsen- und Balkenbeschriftungen haben feste Größen.            */
.chart { margin: clamp(32px,4vw,48px) 0; padding: 24px; background: var(--light-tint); }
.chart-kicker    { font-weight: 700; color: var(--light-ink); margin-bottom: 2px; }
.chart-subkicker { color: var(--light-mute); margin-bottom: clamp(18px,2.2vw,26px); }
.chart-caption   { color: var(--light-mute); margin-top: 12px; font-style: italic; }
.chart-note      { color: var(--light-mute); margin-top: 4px; }
.chart-legend      { display: flex; flex-wrap: wrap; gap: 16px; margin: 16px 0 4px; }
.chart-legend-item { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--light-mute); }
.chart-legend-dot  { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

/* Gestapelter Balken */
.chart-stack-row   { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.chart-stack-label { width: 64px; flex-shrink: 0; font-size: var(--fs-xs); font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--light-mute); }
.chart-stack       { flex: 1; display: flex; height: 40px; gap: 2px; border-radius: 3px; overflow: hidden; background: #f4f3f0; }
.chart-stack-seg   { width: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; transition: width 1s var(--ease-out); }
.chart-stack.in .chart-stack-seg { width: var(--w); }
.chart-stack-seg-text { padding: 0 6px; font-size: var(--fs-micro); font-weight: 700; line-height: 1.2; white-space: nowrap; color: var(--seg-ink, #fff); }

/* Vertikale Balken */
.chart-bar-group { display: flex; align-items: flex-end; gap: clamp(16px,3vw,32px); margin-top: 8px; padding: 0 clamp(8px,2vw,24px); }
.chart-bar-col   { flex: 1; display: flex; flex-direction: column; align-items: center; }
.chart-bar-val   { margin-bottom: 6px; font-size: var(--fs-small); font-weight: 700; white-space: nowrap; color: var(--light-ink); }
.chart-bar-delta { margin-left: 4px; font-size: var(--fs-xs); color: var(--light-green); }
.chart-bar-track { width: 100%; max-width: 90px; height: 160px; display: flex; align-items: flex-end; }
.chart-bar       { width: 100%; height: 0; border-radius: 4px 4px 0 0; transition: height 1.1s var(--ease-out); }
.chart-bar-group.in .chart-bar { height: var(--h); }
.chart-bar-label { margin-top: 10px; font-size: var(--fs-xs); line-height: 1.3; text-align: center; color: var(--light-mute); }

/* Variante: dunkel */
.chart--dark { background: var(--bg2); margin: clamp(24px,3vw,36px) 0; }
.chart--dark .chart-kicker,
.chart--dark .chart-bar-val { color: var(--ink); }
.chart--dark .chart-subkicker,
.chart--dark .chart-caption,
.chart--dark .chart-note,
.chart--dark .chart-legend-item,
.chart--dark .chart-stack-label,
.chart--dark .chart-bar-label { color: var(--mid); }

@media (max-width: 860px) {
  .chart-stack-label { width: 52px; }
  .chart-stack { height: 32px; }
  .chart-bar-track { height: 130px; max-width: 64px; }
  .chart-bar-group { gap: 14px; }
}

/* Variante: Bewegung — nacheinander, weiche Kurve, Werte danach.
   Dazu ruhigere Optik: weiße Karte, eckige Segmente mit Abstand,
   Säulen mit Hilfslinien, Glanz und Delta als Pille (Orange statt Grün). */
.chart--motion {
  --chart-ease: cubic-bezier(.65,0,.35,1);
  padding: clamp(24px, 3.2vw, 48px); background: var(--light-bg);
  border: 1px solid var(--light-line-soft); box-shadow: 0 24px 64px rgba(20,6,0,.07);
}
.chart--motion.chart--dark { background: var(--bg2); border-color: var(--line); box-shadow: none; }
.chart--motion .chart-subkicker { margin-bottom: clamp(24px, 3vw, 36px); }

/* Gestapelter Balken */
.chart--motion .chart-stack-row { gap: 16px; margin-bottom: 12px; }
.chart--motion .chart-stack-label { width: 84px; }
.chart--motion .chart-stack { height: 84px; gap: 4px; padding: 4px; border-radius: 0; overflow: visible; background: var(--light-tint); }
.chart--motion .chart-stack-row + .chart-stack-row { --row: .7s; }
.chart--motion .chart-stack-seg {
  position: relative; border-radius: 0; flex-shrink: 1;
  transition: width 1.1s var(--chart-ease), filter .2s; transition-delay: calc(var(--row, 0s) + var(--i, 0) * .16s), 0s;
}
.chart--motion .chart-stack-seg::after { /* UI: leichter Glanz */
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(120deg, rgba(255,255,255,.22), rgba(255,255,255,0) 55%, rgba(20,6,0,.08));
}
.chart--motion .chart-stack-seg:nth-child(2) { --i: 1; }
.chart--motion .chart-stack-seg:nth-child(3) { --i: 2; }
.chart--motion .chart-stack-seg:nth-child(4) { --i: 3; }
.chart--motion .chart-stack-seg:nth-child(5) { --i: 4; }
.chart--motion .chart-stack-seg-text {
  position: relative; z-index: 1; font-size: 14px;
  opacity: 0; translate: 0 6px; transition: opacity .5s ease, translate .5s var(--ease-out);
  transition-delay: calc(var(--row, 0s) + var(--i, 0) * .16s + .8s);
}
.chart--motion .chart-stack.in .chart-stack-seg-text { opacity: 1; translate: 0 0; }
.chart--motion .chart-stack-seg:hover { filter: brightness(1.08); }
.chart--motion .chart-legend { gap: 10px 22px; margin-top: 20px; padding-left: 100px; }
.chart--motion .chart-legend-dot { width: 12px; height: 12px; border-radius: 0; }
.chart--motion .chart-caption { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--light-line-soft); }
.chart--motion.chart--dark .chart-caption { border-color: var(--line); }
.chart--motion .chart-note {
  display: inline-block; margin-top: 10px; padding: 6px 12px; border-radius: 100px; font-weight: 600;
  color: var(--light-ink); background: color-mix(in srgb, var(--orange) 16%, transparent);
}

/* Säulen */
.chart--motion .chart-bar-group { gap: 0; padding: 0; }
.chart--motion .chart-bar-col { padding: 0 clamp(6px, 1.4vw, 18px); }
.chart--motion .chart-bar-track {
  position: relative; max-width: none; height: 240px; justify-content: center;
  border-bottom: 1px solid var(--light-line);
  background: repeating-linear-gradient(to top, transparent 0 59px, var(--light-line-soft) 59px 60px);
}
.chart--motion.chart--dark .chart-bar-track { border-color: var(--line); background-image: repeating-linear-gradient(to top, transparent 0 59px, color-mix(in srgb, var(--ink) 8%, transparent) 59px 60px); }
.chart--motion .chart-bar {
  position: relative; width: 56%; border-radius: 0;
  transition: height 1.3s var(--chart-ease); transition-delay: calc(var(--i, 0) * .2s);
}
.chart--motion .chart-bar::after { /* UI: Glanz von oben */
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  background: linear-gradient(120deg, rgba(255,255,255,.22), rgba(255,255,255,0) 55%, rgba(20,6,0,.08));
}
.chart--motion .chart-bar-col:nth-child(2) { --i: 1; }
.chart--motion .chart-bar-col:nth-child(3) { --i: 2; }
.chart--motion .chart-bar-col:last-child .chart-bar { box-shadow: 0 0 48px color-mix(in srgb, var(--red) 45%, transparent); }
.chart--motion .chart-bar-val {
  display: flex; align-items: center; gap: 6px; margin-bottom: 10px; font-size: 18px;
  opacity: 0; translate: 0 8px; transition: opacity .5s ease, translate .6s var(--ease-out);
  transition-delay: calc(var(--i, 0) * .2s + .6s);
}
.chart--motion .chart-bar-group.in .chart-bar-val { opacity: 1; translate: 0 0; }
.chart--motion .chart-bar-delta {
  margin: 0; padding: 2px 8px; border-radius: 100px; font-size: 12px;
  color: var(--orange); background: color-mix(in srgb, var(--orange) 16%, transparent);
}
.chart--motion .chart-bar-delta--green { color: var(--green); background: color-mix(in srgb, var(--green) 18%, transparent); }
.chart--motion .chart-bar-label { margin-top: 12px; }

@media (max-width: 860px) {
  .chart--motion .chart-stack { height: 60px; }
  .chart--motion .chart-stack-label { width: 60px; }
  .chart--motion .chart-legend { padding-left: 0; }
  .chart--motion .chart-stack-seg-text { font-size: 11px; }
  .chart--motion .chart-bar-track { height: 180px; background-size: auto; }
  .chart--motion .chart-bar-val { flex-direction: column; gap: 4px; font-size: 14px; }
}
