/* ---------- Metrics: the computed and AI-estimated values of news, stories and dossiers ----------
 * Shown in components/metrics.html. Every block has a normal and a compact size; a missing value
 * is a state ("nincs adat", "kevés adat", "elavult"), never a zero. Objectivity appears only as an
 * aggregate (1–20, higher = more objective); a single article shows its signals instead
 * (article-signals.css). Chart colors: one hue for magnitude (--color-primary), a
 * warm/cool pair with a gray midpoint for the political context (positive / neutral / negative),
 * checked for color vision deficiency in both modes. */

.mx {
  --mx-fill: var(--color-primary);
  --mx-track: var(--track);
  --mx-positive: color-mix(in oklab, var(--color-blue) 80%, var(--color-background));
  --mx-negative: color-mix(in oklab, var(--color-orange) 80%, var(--color-background));
  --mx-neutral: var(--line-bright);
  min-width: 0;
  color: var(--text);
  font-size: 12px;
}

[data-theme="light"] .mx {
  --mx-positive: var(--color-blue);
  --mx-negative: var(--color-orange);
}

.mx-panel { padding: 14px 16px; }
.mx-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; min-width: 0; margin: 0 0 12px; }
.mx-title { overflow: hidden; min-width: 0; margin: 0; color: var(--muted); font-family: var(--font-mono); font-size: 10px; font-weight: 500; letter-spacing: .06em; text-overflow: ellipsis; white-space: nowrap; }
.mx-meta { flex: none; color: var(--muted); font-family: var(--font-mono); font-size: 9px; letter-spacing: .04em; white-space: nowrap; }
.mx-foot { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; line-height: 1.5; }
.mx-foot .icon { margin-right: 4px; color: var(--muted); }
.mx-label { overflow: hidden; min-width: 0; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.mx-value { color: var(--text); font-family: var(--font-mono); font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mx-value small { color: var(--muted); font-size: 9px; }

/* A continuous meter on the 1–20 scale: thin track, rounded fill end */
.mx-meter { position: relative; height: 6px; border-radius: 3px; background: var(--mx-track); }
.mx-meter > i { position: absolute; inset: 0 auto 0 0; width: calc(var(--v) / 20 * 100%); border-radius: 3px; background: var(--mx-fill); }
.mx-meter.is-empty > i { display: none; }

/* State labels: a missing value is never shown as zero */
.mx-state { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-family: var(--font-mono); font-size: 9px; letter-spacing: .04em; white-space: nowrap; }
.mx-state .icon { font-size: 12px; }
.mx-state.is-stale { color: var(--color-warning-text); }

/* ---- Score chip: an aggregate objectivity inside a row (a story's per-source average) ---- */
.mx-chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 6px; border: 1px solid var(--line); border-radius: 3px; color: var(--muted); font-family: var(--font-mono); font-size: 9px; letter-spacing: .04em; white-space: nowrap; }
.mx-chip strong { color: var(--text); font-weight: 600; }

/* ---- Political context: per article chips, per story or dossier a diverging stacked bar ---- */
.mx-stance-list { display: grid; gap: 8px; margin: 0; }
.mx-stance-list div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.mx-stance-list dt { overflow: hidden; font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.mx-stance-list dt small { margin-left: 6px; color: var(--muted); font-family: var(--font-mono); font-size: 9px; font-weight: 500; }
.mx-stance-list dd { margin: 0; }
.mx-stance { display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px 2px 5px; border: 1px solid var(--line); border-radius: 3px; font-family: var(--font-mono); font-size: 9px; letter-spacing: .04em; white-space: nowrap; }
.mx-stance::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--mx-neutral); }
.mx-stance.is-positive::before { background: var(--mx-positive); }
.mx-stance.is-negative::before { background: var(--mx-negative); }
.mx-stance .icon { font-size: 11px; color: var(--muted); }
.mx-stance-inline { display: flex; flex-wrap: wrap; gap: 4px; }

.mx-diverging { display: grid; gap: 10px; margin: 0; }
.mx-diverging div { display: grid; grid-template-columns: minmax(0, 92px) minmax(0, 1fr) 28px; gap: 10px; align-items: center; }
.mx-diverging dt { overflow: hidden; font-size: 11px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.mx-diverging dd { display: contents; }
.mx-diverging .mx-value { text-align: right; color: var(--muted); font-size: 9px; }
.mx-dbar { position: relative; display: flex; gap: 2px; height: 10px; }
.mx-dbar::after { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--muted); opacity: .5; }
.mx-dbar i { height: 100%; }
.mx-dbar i:first-child { border-radius: 3px 0 0 3px; }
.mx-dbar i:last-child { border-radius: 0 3px 3px 0; }
.mx-dbar .is-negative { background: var(--mx-negative); }
.mx-dbar .is-neutral { background: var(--mx-neutral); }
.mx-dbar .is-positive { background: var(--mx-positive); }
.mx-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 0 0 12px; padding: 0; list-style: none; color: var(--muted); font-size: 10px; }
.mx-legend li { display: inline-flex; align-items: center; gap: 5px; }
.mx-legend i { width: 8px; height: 8px; border-radius: 2px; background: var(--mx-neutral); }
.mx-legend .is-positive { background: var(--mx-positive); }
.mx-legend .is-negative { background: var(--mx-negative); }
.mx-legend .is-rank-1 { background: var(--mx-fill); }
.mx-legend .is-rank-2 { background: color-mix(in oklab, var(--mx-fill) 55%, var(--mx-track)); }
.mx-legend .is-rank-3 { background: color-mix(in oklab, var(--mx-fill) 25%, var(--mx-track)); }
.mx-dbar-mini { width: 64px; height: 6px; }
.mx-dbar-mini::after { top: -2px; bottom: -2px; }

/* ---- Story and dossier figures: a row of stat tiles, a range on the score scale ---- */
.mx-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 1px; margin: 0; background: var(--line); border: 1px solid var(--line); }
.mx-stats div { display: grid; gap: 2px; min-width: 0; padding: 10px 12px; background: var(--panel); }
.mx-stats dt { overflow: hidden; color: var(--muted); font-family: var(--font-mono); font-size: 9px; letter-spacing: .05em; text-overflow: ellipsis; white-space: nowrap; }
.mx-stats dd { margin: 0; font-family: var(--font-heading); font-size: 20px; font-weight: 600; line-height: 1.2; }
.mx-stats dd small { margin-left: 3px; color: var(--muted); font-family: var(--font-body); font-size: 11px; font-weight: 500; }
@media (max-width: 540px) {
  /* Four cells stay in one row: the labels wrap instead of being cut, the values line up */
  .mx-stats { grid-template-columns: repeat(auto-fit, minmax(68px, 1fr)); }
  .mx-stats div { align-content: space-between; padding: 9px 10px; }
  .mx-stats dt { overflow: visible; white-space: normal; overflow-wrap: break-word; }
}
.mx-statline { display: flex; flex-wrap: wrap; gap: 4px 10px; color: var(--muted); font-family: var(--font-mono); font-size: 9px; letter-spacing: .04em; }
.mx-statline strong { color: var(--text); font-weight: 600; }

.mx-range { margin-top: 14px; }
.mx-range-track { position: relative; height: 18px; margin-top: 8px; }
.mx-range-track::before { content: ""; position: absolute; left: 0; right: 0; top: 8px; height: 2px; border-radius: 1px; background: var(--mx-track); }
.mx-range-span { position: absolute; top: 6px; height: 6px; left: calc((var(--min) - 1) / 19 * 100%); width: calc((var(--max) - var(--min)) / 19 * 100%); border-radius: 3px; background: color-mix(in oklab, var(--mx-fill) 40%, var(--mx-track)); }
.mx-range-dot { position: absolute; top: 3px; left: calc((var(--v) - 1) / 19 * 100%); width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: var(--mx-fill); box-shadow: 0 0 0 2px var(--panel); }
.mx-range-scale { display: flex; justify-content: space-between; color: var(--muted); font-family: var(--font-mono); font-size: 9px; }

/* ---- Dossier activity: daily columns of the last 14 local days, stacked by relation ---- */
.mx-columns { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 3px; align-items: end; height: 64px; padding-bottom: 1px; border-bottom: 1px solid var(--line); }
.mx-columns > span { display: flex; flex-direction: column-reverse; gap: 2px; height: 100%; justify-content: flex-start; cursor: default; }
.mx-columns > span:hover i, .mx-columns > span:focus-visible i { filter: brightness(1.15); }
.mx-columns i { display: block; height: calc(var(--n) / var(--max) * 100%); min-height: 3px; background: var(--mx-fill); }
.mx-columns i:last-child { border-radius: 2px 2px 0 0; }
.mx-columns i.is-rank-2 { background: color-mix(in oklab, var(--mx-fill) 55%, var(--mx-track)); }
.mx-columns > span.is-empty::after { content: ""; display: block; height: 1px; background: var(--mx-track); }
.mx-columns > span.is-today i { box-shadow: 0 0 0 1px var(--panel), 0 0 0 2px var(--mx-fill); }
.mx-axis { display: flex; justify-content: space-between; margin-top: 4px; color: var(--muted); font-family: var(--font-mono); font-size: 9px; }
.mx-columns--mini { grid-template-columns: repeat(14, 4px); gap: 2px; height: 20px; border-bottom: 0; }
.mx-columns--mini i:last-child { border-radius: 1px 1px 0 0; }
.mx-columns--mini > span.is-today i { box-shadow: none; }

.mx-split { display: flex; gap: 2px; height: 6px; margin-top: 14px; }
.mx-split i { height: 100%; background: var(--mx-fill); }
.mx-split i:first-child { border-radius: 3px 0 0 3px; }
.mx-split i:last-child { border-radius: 0 3px 3px 0; }
.mx-split .is-rank-2 { background: color-mix(in oklab, var(--mx-fill) 55%, var(--mx-track)); }
.mx-split .is-rank-3 { background: color-mix(in oklab, var(--mx-fill) 25%, var(--mx-track)); }
.mx-split + .mx-legend { margin: 8px 0 0; }

/* ---- Metric card (ADR 0016 snapshots): value, change against yesterday, 7-day series ---- */
.mx-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: end; }
.mx-card .mx-head { grid-column: 1 / -1; margin-bottom: 4px; }
.mx-card-value { margin: 0; font-family: var(--font-heading); font-size: 30px; font-weight: 600; line-height: 1.1; }
.mx-card-value small { margin-left: 4px; color: var(--muted); font-family: var(--font-body); font-size: 13px; font-weight: 500; }
.mx-card-value.is-missing { color: var(--muted); font-size: 22px; }
.mx-delta { display: inline-flex; align-items: center; gap: 3px; margin-top: 4px; color: var(--muted); font-family: var(--font-mono); font-size: 10px; white-space: nowrap; }
.mx-delta strong { color: var(--text); font-weight: 600; }
.mx-delta .icon { font-size: 12px; }
.mx-spark { display: grid; grid-template-columns: repeat(7, 6px); gap: 3px; align-items: end; height: 34px; }
.mx-spark i { display: block; height: calc(var(--n) / var(--max) * 100%); min-height: 2px; border-radius: 2px 2px 0 0; background: color-mix(in oklab, var(--mx-fill) 45%, var(--mx-track)); }
.mx-spark i:last-child { background: var(--mx-fill); }
.mx-spark i.is-gap { height: 2px; background: var(--mx-track); }
.mx-card .mx-foot { grid-column: 1 / -1; margin-top: 8px; padding-top: 8px; font-family: var(--font-mono); font-size: 9px; letter-spacing: .04em; }
.mx-card--compact { grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 12px; }
.mx-card--compact .mx-head { grid-column: 1; margin: 0; }
.mx-card--compact .mx-head .mx-meta { display: none; }
.mx-card--compact > div { display: flex; align-items: baseline; gap: 10px; }
.mx-card--compact .mx-card-value { font-size: 18px; }
.mx-card--compact .mx-card-value small { font-size: 11px; }
.mx-card--compact .mx-delta { margin: 0; }
.mx-card--compact .mx-spark { display: none; }
.mx-card.is-stale .mx-card-value, .mx-card.is-stale .mx-spark { opacity: .55; }
