/*
 * buwx-Diagramme – Darstellung. Nutzt die Design-Tokens des Templates buwx (mit Rückfallwerten,
 * damit die Diagramme auch mit anderen Templates lesbar bleiben).
 */

.bxc-figure {
  margin: 0 0 var(--space-6, 2rem);
  min-width: 0;
}

.bxc-figure > figcaption {
  margin-bottom: var(--space-3, 0.75rem);
}

.bxc-figure__title {
  display: block;
  font-size: var(--fs-lg, 1.125rem);
  font-weight: var(--fw-semibold, 600);
  line-height: var(--lh-tight, 1.15);
}

.bxc-figure__subtitle {
  display: block;
  color: var(--c-text-muted, #55626e);
  font-size: var(--fs-sm, 0.875rem);
}

.bxc {
  display: block;
  position: relative;
  min-width: 0;
  color: var(--c-text, #1f2a33);
  font-variant-numeric: tabular-nums;
}

/* Platz reservieren, solange geladen wird (kein Layout-Sprung) */
.bxc[aria-busy="true"] .bxc-plot:empty {
  min-height: 18rem;
  border-radius: var(--radius-md, 0.625rem);
  background: var(--c-surface-2, #eaeef2);
}

buwx-heatmap[aria-busy="true"] .bxc-plot:empty { min-height: 16rem; }

.bxc[aria-busy="true"] .bxc-plot { opacity: 0.6; transition: opacity var(--dur-base, 200ms); }

.bxc-plot {
  position: relative;
  min-width: 0;
  touch-action: pan-y;
}

.bxc-plot > canvas,
.bxc-svg {
  display: block;
  max-width: 100%;
  font-family: var(--font-sans, system-ui, sans-serif);
  user-select: none;
  -webkit-user-select: none;
}

.bxc-plot > canvas:focus-visible,
.bxc-svg:focus-visible {
  outline: 3px solid var(--c-focus, #b4540a);
  outline-offset: 2px;
}

.bxc-hit { cursor: crosshair; }

.bxc-fallback {
  padding: var(--space-4, 1rem);
  border: 1px dashed var(--c-border-strong, #7a8896);
  border-radius: var(--radius-md, 0.625rem);
  color: var(--c-text-muted, #55626e);
  text-align: center;
}

.bxc-error {
  border-style: solid;
  border-color: var(--c-danger, #b3261e);
  color: var(--c-text, #1f2a33);
}

/* Tooltip */
.bxc-tip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  display: grid;
  gap: 0.125rem;
  max-width: min(20rem, 90%);
  padding: var(--space-2, 0.5rem) var(--space-3, 0.75rem);
  border: 1px solid var(--c-border-strong, #7a8896);
  border-radius: var(--radius-sm, 0.375rem);
  background: var(--c-surface, #fff);
  box-shadow: var(--shadow-2, 0 4px 12px rgb(0 0 0 / 0.15));
  color: var(--c-text, #1f2a33);
  font-size: var(--fs-sm, 0.875rem);
  line-height: 1.35;
  pointer-events: none;
}

.bxc-tip[hidden] { display: none; }

.bxc-tip strong { font-weight: var(--fw-semibold, 600); }

.bxc-tip__row b { font-weight: var(--fw-semibold, 600); }

.bxc-swatch {
  display: inline-block;
  width: 0.75em;
  height: 0.75em;
  margin-right: 0.35em;
  border-radius: 50%;
  background: var(--swatch, currentColor);
  vertical-align: baseline;
}

/* Bedienleiste */
.bxc-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2, 0.5rem);
  align-items: center;
  margin-bottom: var(--space-3, 0.75rem);
}

.bxc-toolbar__nav {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--space-1, 0.25rem);
  align-items: center;
}

.bxc-button {
  min-width: 2.75rem;
  min-height: 2.25rem;
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--c-border-strong, #7a8896);
  border-radius: var(--radius-pill, 999px);
  background: var(--c-surface, #fff);
  color: var(--c-text, #1f2a33);
  font: inherit;
  font-size: var(--fs-sm, 0.875rem);
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}

.bxc-button:hover { background: var(--c-surface-2, #eaeef2); }

.bxc-button[aria-pressed="true"] {
  border-color: var(--c-accent, #0077bb);
  background: var(--c-accent, #0077bb);
  color: var(--c-accent-contrast, #fff);
}

:root[data-theme="dark"] .bxc-button[aria-pressed="true"] { color: #0e151b; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .bxc-button[aria-pressed="true"] { color: #0e151b; }
}

.bxc-button:disabled { opacity: 0.45; cursor: default; }

.bxc-button:focus-visible,
.bxc-date input:focus-visible,
.bxc-legend__item:focus-visible,
.bxc-table summary:focus-visible,
.bxc-table__scroll:focus-visible {
  outline: 3px solid var(--c-focus, #b4540a);
  outline-offset: 2px;
}

.bxc-button--reset { margin-left: auto; }

.bxc-date input {
  min-height: 2.25rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--c-border-strong, #7a8896);
  border-radius: var(--radius-sm, 0.375rem);
  background: var(--c-surface, #fff);
  color: var(--c-text, #1f2a33);
  font: inherit;
  font-size: var(--fs-sm, 0.875rem);
}

/* Legende (Zeitreihen: Schaltflächen zum Ein-/Ausblenden) */
.bxc-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1, 0.25rem) var(--space-3, 0.75rem);
  align-items: center;
  margin-bottom: var(--space-2, 0.5rem);
  font-size: var(--fs-sm, 0.875rem);
}

.bxc-legend__title { width: 100%; font-weight: var(--fw-semibold, 600); }

.bxc-legend__item {
  display: inline-flex;
  align-items: center;
  min-height: 1.5rem;
  padding: 0.125rem 0.25rem;
  border: 0;
  border-radius: var(--radius-sm, 0.375rem);
  background: none;
  color: inherit;
  font: inherit;
}

button.bxc-legend__item { cursor: pointer; }

button.bxc-legend__item[aria-pressed="false"] {
  color: var(--c-text-muted, #55626e);
  text-decoration: line-through;
}

button.bxc-legend__item[aria-pressed="false"] .bxc-swatch { opacity: 0.3; }

/* Linienart im Farbfeld (Information nicht nur über Farbe) */
.bxc-legend__item .bxc-swatch {
  width: 1.4em;
  height: 0;
  border-top: 3px solid var(--swatch, currentColor);
  border-radius: 0;
  background: none;
}

.bxc-legend__item--dashed .bxc-swatch { border-top-style: dashed; }
.bxc-legend__item--dotted .bxc-swatch { border-top-style: dotted; }
.bxc-legend__item--bar .bxc-swatch { height: 0.75em; border: 0; background: var(--swatch); }
.bxc-legend__item--dots .bxc-swatch { width: 0.5em; height: 0.5em; border: 0; border-radius: 50%; background: var(--swatch); }

/* Farbskala der Heatmap */
.bxc-scale {
  max-width: 24rem;
  margin: 0 0 var(--space-3, 0.75rem) 44px;
  padding-bottom: 1.25rem;
  font-size: var(--fs-xs, 0.75rem);
  color: var(--c-text-muted, #55626e);
}

.bxc-scale__bar { height: 0.75rem; border-radius: 2px; }

.bxc-scale__ticks { position: relative; }

.bxc-scale__ticks span {
  position: absolute;
  top: 0.2rem;
  transform: translateX(-50%);
  white-space: nowrap;
}

.bxc-scale__ticks span:first-child { transform: none; }
.bxc-scale__ticks span:last-child { transform: translateX(-100%); }

.bxc-cursor {
  position: absolute;
  outline: 2px solid var(--c-text, #1f2a33);
  outline-offset: 0;
  box-shadow: 0 0 0 3px var(--c-surface, #fff);
  pointer-events: none;
}

/* Wettersymbole (schwarz) im Dunkelmodus hell darstellen */
:root[data-theme="dark"] .bxc-symbols image { filter: invert(0.9); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .bxc-symbols image { filter: invert(0.9); }
}

/* Kennzahlen, Kurzfassung, Quellen */
.bxc-summary,
.bxc-credits {
  margin: var(--space-2, 0.5rem) 0 0;
  color: var(--c-text-muted, #55626e);
  font-size: var(--fs-sm, 0.875rem);
}

.bxc-stats {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: var(--space-1, 0.25rem) var(--space-3, 0.75rem);
  margin: var(--space-3, 0.75rem) 0 0;
  font-size: var(--fs-sm, 0.875rem);
}

.bxc-stats dt { color: var(--c-text-muted, #55626e); }
.bxc-stats dd { margin: 0; }
.bxc-stats b { font-weight: inherit; }

/* Datentabelle */
.bxc-table { margin-top: var(--space-3, 0.75rem); }

.bxc-table summary {
  display: inline-block;
  min-height: 1.5rem;
  color: var(--c-link, #00639c);
  cursor: pointer;
}

.bxc-table__scroll {
  position: relative;
  max-height: 24rem;
  margin: var(--space-2, 0.5rem) 0;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--c-border, #d5dce3);
  border-radius: var(--radius-sm, 0.375rem);
}

.bxc-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm, 0.875rem);
  white-space: nowrap;
}

.bxc-table th,
.bxc-table td {
  padding: 0.25rem 0.5rem;
  border-bottom: 1px solid var(--c-border, #d5dce3);
  text-align: right;
}

.bxc-table th[scope="row"],
.bxc-table thead th:first-child { text-align: left; font-weight: var(--fw-regular, 400); }

.bxc-table thead th {
  position: sticky;
  top: 0;
  background: var(--c-surface-2, #eaeef2);
  font-weight: var(--fw-semibold, 600);
}

.bxc-sr {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .bxc[aria-busy="true"] .bxc-plot { transition: none; }
}

@media print {
  .bxc-toolbar, .bxc-table, .bxc-tip { display: none !important; }
}
