/* Stratum history page: step-chart timeline, per-pool flip tables, summary.
   Explainer-native: dark fills, bright strokes, Courier New, tokens only. */

/* Capture line: this page has no freshness bead because it has no producer, so
   the stamp carries what a bead would have. Gold rule, matching the severed
   note in panels.css: a statement about what the numbers are, at body weight. */
.history-stamp {
  margin: 0 0 1rem;
  font-size: 0.86rem;
  line-height: 1.55;
  color: var(--text);
  border-left: 2px solid var(--gold);
  padding-left: 0.75rem;
}

/* Intro paragraph */
.history-intro {
  margin: 0 0 1.2rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.history-intro code {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--text);
  background: var(--surface);
  padding: 0.05rem 0.25rem;
  border-radius: var(--radius);
}

/* ---------------------------------------------------------------------- */
/* Step-chart timeline: colour = state at that point in time              */
/* ---------------------------------------------------------------------- */

.timeline-container {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* Header: label column + track area with absolutely-positioned day labels */
.timeline-header {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: 0.5rem;
  align-items: end;
}
.timeline-header-label {
  font-family: var(--body);
  font-size: 0.64rem;
  font-weight: 600;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: right;
  padding-bottom: 0.15rem;
}
.timeline-header-track {
  position: relative;
  height: 1.2rem;
}
.timeline-day-label {
  position: absolute;
  top: 0;
  text-align: center;
  font-size: 0.64rem;
  font-weight: 600;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-left: 1px solid var(--line);
  padding-left: 0.3rem;
}

/* Pool lanes */
.timeline-lanes {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.timeline-lane {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: 0.5rem;
  align-items: start;
}

.timeline-lane-labels,
.timeline-track {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.timeline-lane-label {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: 1.6rem;
  font-family: var(--body);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
  text-align: right;
}

.timeline-ep-row {
  height: 1.6rem;
  position: relative;
}

/* The line wrapper: single relative container for all absolute children */
.timeline-line-wrap {
  position: relative;
  width: 100%;
  height: 100%;
}

/* Step segments: coloured bars showing state during each interval */
.timeline-segment {
  position: absolute;
  top: 0;
  height: 100%;
  cursor: help;
}
.timeline-segment--signalling {
  background: var(--frost);
  opacity: 0.55;
}
.timeline-segment--quiet {
  background: var(--surface);
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  opacity: 0.6;
}
/* A span the archive contradicts itself about (js/stratum-history.js warns and
   falls back to this): the pending idiom from base.css, dashed and faint, so it
   cannot be misread as a confident state. */
.timeline-segment--unknown {
  background: transparent;
  border: 1px dashed var(--line-strong);
  opacity: 0.9;
}

/* One tooltip idiom, three carriers. Everything they share is declared once
   here; each carrier's own placement and colour follow it below. */
.timeline-segment:hover::before,
.timeline-flip-marker:hover::before,
.timeline-fork-marker:hover::before {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-raise);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0.2rem 0.4rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--text);
  white-space: nowrap;
  z-index: 10;
  pointer-events: none;
}
.timeline-segment:hover::before { bottom: calc(100% + 0.3rem); }

/* Day boundary ticks: aligned with header labels */
.timeline-day-tick {
  position: absolute;
  top: 10%;
  bottom: 10%;
  width: 1px;
  background: var(--line);
  opacity: 0.4;
}

/* Fork marker - vertical line */
.timeline-fork-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--caution);
  z-index: 5;
  pointer-events: auto;
  cursor: help;
}
/* The one tooltip that sits above its carrier. Like the other tooltips it is
   generated only on hover, so its unbroken label cannot widen a mobile page
   while hidden. */
.timeline-fork-marker::before {
  top: -1.6rem;
  border-color: var(--caution);
  color: var(--caution);
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
}

/* Flip markers - vertical arrows at transition points */
.timeline-flip-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  z-index: 3;
  cursor: help;
}
.timeline-flip-marker--on {
  background: var(--frost);
}
.timeline-flip-marker--on::after {
  content: "";
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 6px solid var(--frost);
}
.timeline-flip-marker--off {
  background: var(--reject);
}
.timeline-flip-marker--off::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 6px solid var(--reject);
}
.timeline-flip-marker:hover::before { bottom: calc(100% + 0.4rem); }

/* Timeline legend */
.timeline-legend {
  display: flex;
  gap: 1.2rem;
  flex-wrap: wrap;
  margin-top: 0.6rem;
  font-size: 0.72rem;
  color: var(--muted);
}
.timeline-legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.timeline-legend-line {
  width: 1.5rem;
  height: 3px;
  border-radius: 1px;
}
.timeline-legend-line.signalling {
  background: var(--frost);
  opacity: 0.75;
}
.timeline-legend-line.quiet {
  background: var(--line-strong);
  opacity: 0.25;
}
.timeline-legend-line.unknown {
  height: 0.5rem;
  background: transparent;
  border: 1px dashed var(--line-strong);
}
.timeline-legend-line.fork {
  width: 2px;
  background: var(--caution);
}
.timeline-legend-marker {
  width: 2px;
  height: 0.7rem;
  position: relative;
}
.timeline-legend-marker.up {
  background: var(--frost);
}
.timeline-legend-marker.up::after {
  content: "";
  position: absolute;
  top: -3px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
  border-bottom: 4px solid var(--frost);
}
.timeline-legend-marker.down {
  background: var(--reject);
}
.timeline-legend-marker.down::after {
  content: "";
  position: absolute;
  bottom: -3px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
  border-top: 4px solid var(--reject);
}

/* ---------------------------------------------------------------------- */
/* Per-pool flip tables                                                   */
/* ---------------------------------------------------------------------- */

.flip-scope-note {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.flip-tables {
  display: flex;
  flex-direction: column;
  gap: 1.8rem;
}

.pool-flip-table-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  overflow-x: auto;
}

/* The pool name above each table uses base.css's .section-label, the site's one
   uppercase label role, rather than a seventh copy of the same declarations. */

.pool-flip-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.pool-flip-table th,
.pool-flip-table td {
  text-align: left;
  padding: 0.4rem 0.65rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.pool-flip-table th {
  font-family: var(--body);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.66rem;
  font-weight: 600;
  color: var(--faint);
  border-bottom: 1px solid var(--line-strong);
}

.flip-endpoint { color: var(--text); font-family: var(--mono); }
.flip-time { color: var(--muted); font-family: var(--mono); font-size: 0.76rem; }
.flip-direction { font-weight: 600; }
.flip-direction--on { color: var(--frost); }
.flip-direction--off { color: var(--reject); }
.flip-duration { color: var(--faint); font-family: var(--mono); font-size: 0.76rem; text-align: right; }
.flip-note { color: var(--muted); font-size: 0.76rem; }

/* Fork row in flip table */
.fork-table-row {
  background: var(--surface-raise);
}
.fork-table-row td {
  border-top: 1px solid var(--caution);
  border-bottom: 1px solid var(--caution);
  padding: 0.35rem 0.65rem;
  font-weight: 600;
  color: var(--caution);
  text-align: center;
  font-size: 0.76rem;
}

/* ---------------------------------------------------------------------- */
/* Summary: every endpoint belonging to a pool that signalled              */
/* ---------------------------------------------------------------------- */

.summary-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Says how many monitored endpoints the grid below actually shows, so the
   selected cards cannot be mistaken for the whole dataset. */
.summary-note {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 0.6rem;
}

.summary-card {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.7rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}
.summary-card--signalling {
  border-color: var(--frost);
  background: var(--frost-wash);
}
.summary-card--flipped {
  border-color: var(--caution);
}
.summary-card--partial {
  border-color: var(--caution);
  background: var(--surface);
}

.summary-card-name {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--text);
  font-weight: 600;
}
.summary-card-state {
  margin: 0;
  font-size: 0.76rem;
  color: var(--muted);
}
.summary-card-state--signalling { color: var(--frost); }
.summary-card-state--quiet { color: var(--faint); }
.summary-card-detail {
  margin: 0;
  font-size: 0.72rem;
  color: var(--faint);
}

.download-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0.55rem;
  padding: 0;
  list-style: none;
}

.download-list li {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line-strong);
  background: var(--surface);
}

.download-list a {
  color: var(--frost);
  font-family: var(--mono);
  font-size: 0.82rem;
}

.download-list span,
.download-note {
  color: var(--faint);
  font-size: 0.76rem;
}

@media (max-width: 720px) {
  .timeline-header,
  .timeline-lane {
    grid-template-columns: 6.5rem 1fr;
  }
  .timeline-lane-label,
  .timeline-header-label {
    font-size: 0.64rem;
  }
  .summary-grid {
    grid-template-columns: 1fr;
  }
}
