/* ==========================================================================
   Feldtests (.runs): eine Spalte je Lauf, ein Quadrat je Agent.
   Auswertung statt Ablauf, daher hell bzw. im Design der Seite.
   ========================================================================== */

.runs {
  --runs-label: 9.5rem;
  --runs-pad: clamp(1rem, 2.5vw, 1.75rem);
  min-width: 0;
  border: 1px solid var(--c-line-strong);
  border-radius: var(--radius-l);
  background: var(--c-surface);
  box-shadow: var(--hard-shadow);
}
.case-block > .runs + .case-text--after { margin-top: clamp(1.25rem, 3vw, 2.25rem); }
.runs > * { padding-inline: var(--runs-pad); }

.runs-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 1.5rem;
  padding-block: 1.25rem 1rem;
}
.runs-head h3 { font-size: 1.25rem; letter-spacing: -0.02em; }
.runs-sum { font-size: 0.92rem; color: var(--c-ink-2); font-variant-numeric: tabular-nums; }
html:not(.js) :is(.runs-chart, .runs-pick, .runs-detail, .runs-sum) { display: none; }

/* ---- Raster ---------------------------------------------------------------- */
.runs-chart { --at: 0; position: relative; display: grid; cursor: pointer; }
.runs-row {
  position: relative;
  display: grid;
  grid-template-columns: var(--runs-label) repeat(var(--runs), minmax(0, 1fr));
  align-items: center;
  border-top: 1px solid var(--c-line);
}
.runs-phases,
.runs-ids { border-top: 0; }
.runs-label { padding-right: 0.75rem; font-size: 0.85rem; line-height: 1.3; color: var(--c-ink); }
.runs-group { position: relative; padding-top: 1rem; padding-bottom: 0.4rem; font: 400 0.75rem/1.4 var(--font-mono); color: var(--c-ink-3); }
.runs-phase {
  margin-right: 4px;
  padding: 0 0 0.3rem 0.15rem;
  border-bottom: 2px solid var(--c-line-strong);
  font: 400 0.75rem/1.4 var(--font-mono);
  color: var(--c-ink-2);
  white-space: nowrap;
}
.runs-phase:last-child { margin-right: 0; border-color: var(--c-accent); }
.runs-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 1.75rem;
  padding-block: 0.3rem;
}
.runs-ids .runs-cell { font: 400 0.75rem/1 var(--font-mono); color: var(--c-ink-3); }
.runs-ids .is-on { color: var(--c-ink); font-weight: 700; }
.runs-agent { width: 9px; height: 9px; background: var(--c-accent); }
/* Raute statt Quadrat: auch ohne Farbe von den Agenten zu unterscheiden */
.runs-hit { width: 9px; height: 9px; background: var(--c-bad); transform: rotate(45deg); }
.runs-bars { margin-top: 1rem; }
.runs-bars .runs-cell { height: 5rem; justify-content: flex-end; padding-bottom: 0; }
.runs-bar { width: min(60%, 1.1rem); min-height: 2px; border-radius: 2px 2px 0 0; background: var(--c-ink-3); }
.runs-errors .runs-cell { font: 600 0.8rem/1 var(--font-mono); color: var(--c-ink); }
.runs-errors .is-zero { color: var(--c-ink-3); font-weight: 400; }

/* Gewählter Lauf: ein Band hinter der Spalte */
.runs-cursor {
  --_col: calc((100% - 2 * var(--runs-pad) - var(--runs-label)) / var(--runs));
  position: absolute;
  top: 1.7rem; bottom: 0;
  left: calc(var(--runs-pad) + var(--runs-label) + var(--at) * var(--_col));
  width: var(--_col);
  border: 1px solid var(--c-accent);
  border-bottom: 0;
  border-radius: 2px 2px 0 0;
  background: var(--c-accent-soft);
  transition: left 0.25s var(--ease);
}

/* Regler: der Griff sitzt unter der Mitte der Spalte (16 px breit) */
.runs-pick {
  display: grid;
  grid-template-columns: var(--runs-label) minmax(0, 1fr);
  align-items: center;
  padding-block: 0.75rem 1rem;
}
.runs-pick label { font-size: 0.85rem; color: var(--c-ink); }
.runs-pick input {
  width: calc(100% - 100% / var(--runs) + 16px);
  margin: 0 0 0 calc(100% / var(--runs) / 2 - 8px);
  accent-color: var(--c-accent);
  cursor: ew-resize;
}

/* ---- Einzelheiten ------------------------------------------------------------ */
.runs-detail {
  display: grid;
  grid-template-columns: var(--runs-label) minmax(0, 1fr);
  min-height: 10.25rem;   /* Platz für den längsten Lauf, damit beim Wechseln nichts springt */
  padding-block: 1.25rem;
  border-top: 1px solid var(--c-line-strong);
}
.runs-name { font-family: var(--font-display); font-size: 1.25rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1.3; }
.runs-name code { display: table; margin-top: 0.35rem; font-size: 0.75rem; font-weight: 400; letter-spacing: 0; }
.runs-detail dl { display: grid; align-content: start; grid-template-columns: repeat(3, auto) minmax(0, 1fr); gap: 0.85rem 2rem; }
.runs-detail dt { font: 400 0.75rem/1.5 var(--font-mono); color: var(--c-ink-3); }
.runs-detail dd { font-size: 0.975rem; line-height: 1.5; color: var(--c-ink); text-wrap: pretty; }
.runs-detail dl > :last-child { grid-column: 1 / -1; }

.runs details { border-top: 1px solid var(--c-line); }
.runs summary { padding-block: 0.85rem; font-size: 0.9rem; color: var(--c-accent); cursor: pointer; }
.runs-scroll { overflow-x: auto; margin-bottom: 1rem; }
.runs table { width: 100%; min-width: 64rem; border-collapse: collapse; font-size: 0.82rem; line-height: 1.45; }
.runs :is(th, td) { padding: 0.45rem 0.75rem 0.45rem 0; border-top: 1px solid var(--c-line); text-align: left; vertical-align: top; font-weight: 400; color: var(--c-ink-2); }
.runs thead th { border: 0; font-weight: 600; color: var(--c-ink); }
.runs td:last-child { min-width: 22rem; }
.runs td code { white-space: nowrap; }
.runs figcaption { padding-block: 0 1.25rem; font-size: 0.8rem; line-height: 1.5; color: var(--c-ink-3); max-width: 62rem; }

/* ---- Beim ersten Hinsehen füllen sich die Spalten von Lauf 1 bis 22 ------------ */
.runs.is-armed :is(.runs-cell, .runs-cursor) { opacity: 0; }
.runs.is-armed.is-shown .runs-cell { opacity: 1; transition: opacity 0.6s var(--ease) calc(var(--i) * 0.14s); }
.runs.is-armed.is-shown .runs-cursor { opacity: 1; transition: left 0.25s var(--ease), opacity 0.6s 3.2s; }
.runs.is-armed .runs-bar { transform: scaleY(0); transform-origin: bottom; }
.runs.is-armed.is-shown .runs-bar { transform: none; transition: transform 0.9s var(--ease) 1s; }

/* Tablet: Das Team steht in einer eigenen Zeile, sonst bleibt neben den Zahlen zu wenig Platz */
@media (max-width: 1140px) {
  .runs-detail { min-height: 15rem; }
  .runs-detail dl { grid-template-columns: auto auto minmax(0, 1fr); }
  .runs-detail dl > :first-child { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  .runs { --runs-label: 5.6rem; }
  .runs-label { padding-right: 0.4rem; font-size: 0.7rem; }
  .runs-agent, .runs-hit { width: 6px; height: 6px; }
  .runs-cell { min-height: 1.5rem; }
  /* Schmal: nur jede fünfte Nummer und die gewählte */
  .runs-ids .runs-cell { font-size: 0.65rem; }
  .runs-ids .runs-cell:not(.is-on, :nth-child(5n + 6)),
  .runs-ids .is-on + .runs-cell,
  .runs-ids .runs-cell:has(+ .is-on) { visibility: hidden; }
  .runs-errors .runs-cell { font-size: 0.68rem; }
  .runs-phase { font-size: 0.66rem; overflow: hidden; }
  .runs-detail { grid-template-columns: minmax(0, 1fr); gap: 0.9rem; min-height: 24rem; align-content: start; }
  .runs-name code { display: inline; }
  .runs-detail dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .runs-detail dl > :is(:first-child, :nth-last-child(2)) { grid-column: 1 / -1; }
}
