/*
 * web/landing/shells/ProgressLedger.css - the generic ledger of stages
 * (web/landing/shells/ProgressLedger.js documents the markup). A section brings it in with
 *   @import url('/web/landing/shells/ProgressLedger.css');
 * at the top of its own sheet.
 *
 * Generic only: a vertical list of stages on a rail, each with its mark, its name, its
 * state in the wire's own word, its timer, its last line, its snapshot and its downloads;
 * the replay's clock and the skips. A section that sets its stages as cards on a board
 * does that in sections/<id>.css. Mono for every state, time and file name; the stage
 * names are the section's (serif or sans, its call). The marks change in place, never
 * move: precise and quiet.
 *
 * Tokens are web/landing.css's.
 */

.progress-ledger {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.progress-ledger-clock {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.progress-ledger-clock:empty { display: none; }

/* ── The stages, on a rail ─────────────────────────────────────────────── */

.progress-ledger-stages {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  min-width: 0;
}

.progress-ledger-stage {
  --ledger-mark: 12px;
  position: relative;
  display: grid;
  grid-template-columns: var(--ledger-mark) minmax(0, 1fr) auto auto;
  grid-template-areas:
    "mark label state elapsed"
    ". line line line"
    ". snapshot snapshot snapshot"
    ". artifacts artifacts artifacts";
  align-items: baseline;
  column-gap: 12px;
  row-gap: 6px;
  min-width: 0;
  padding: 10px 0;
}

/* The rail: a hairline from each mark down to the next one. */
.progress-ledger-stages > .progress-ledger-stage:not(:last-child)::before {
  content: "";
  position: absolute;
  left: calc(var(--ledger-mark) / 2 - .5px);
  top: calc(10px + var(--ledger-mark) + 4px);
  bottom: -6px;
  width: 1px;
  background: var(--line);
}

.progress-ledger-mark {
  grid-area: mark;
  align-self: center;
  width: var(--ledger-mark);
  height: var(--ledger-mark);
  box-sizing: border-box;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: transparent;
  transition: background-color .15s, border-color .15s;
}

.progress-ledger-stage[data-state="queued"] .progress-ledger-mark { border-color: var(--muted); }
.progress-ledger-stage[data-state="running"] .progress-ledger-mark {
  border-color: var(--accent);
  background: radial-gradient(circle, var(--accent) 0 32%, transparent 36%);
}
.progress-ledger-stage[data-state="done"] .progress-ledger-mark { border-color: var(--accent); background: var(--accent); }
.progress-ledger-stage[data-state="failed"] .progress-ledger-mark { border-color: var(--danger); background: var(--danger); }
.progress-ledger-stage[data-state="skipped"] .progress-ledger-mark { border-style: dashed; border-color: var(--muted); }

.progress-ledger-label {
  grid-area: label;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
  font-weight: 600;
}

/* Not started yet: the name reads, quieter. */
.progress-ledger-stage:not([data-state]) .progress-ledger-label { color: var(--muted); }

.progress-ledger-state,
.progress-ledger-elapsed {
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.progress-ledger-state { grid-area: state; color: var(--muted); }
.progress-ledger-stage[data-state="running"] .progress-ledger-state { color: var(--accent); }
.progress-ledger-stage[data-state="done"] .progress-ledger-state { color: var(--text); }
.progress-ledger-stage[data-state="failed"] .progress-ledger-state { color: var(--danger); }

.progress-ledger-elapsed {
  grid-area: elapsed;
  min-width: 6ch;
  text-align: right;
  color: var(--muted);
}

/* A timer that is counting reads in the text colour; a frozen one stays quiet. */
.progress-ledger-stage[data-live] .progress-ledger-elapsed { color: var(--text); }

.progress-ledger-line {
  grid-area: line;
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.progress-ledger-snapshot { grid-area: snapshot; min-width: 0; }

.progress-ledger-artifacts {
  grid-area: artifacts;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
}

.progress-ledger-line[hidden],
.progress-ledger-snapshot[hidden],
.progress-ledger-artifacts[hidden],
.progress-ledger-skips[hidden],
[data-ledger-before][hidden],
[data-ledger-after][hidden] { display: none; }

.progress-ledger-artifact {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 11px;
  border: 1px dashed var(--muted);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  text-decoration: none;
}

.progress-ledger-artifact:hover { border-style: solid; border-color: var(--accent); }

/* ── Skips: the time the visitor did not watch, said out loud ──────────── */

.progress-ledger-skips {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.progress-ledger-skip {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 3px 0 3px 10px;
  border-left: 2px dashed var(--muted);
  font-size: 12.5px;
  color: var(--muted);
}

.progress-ledger-skip-time {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
