/* The Stats view: Source chips (the Day view's, in styles.css), the trend
   charts and the day table. Colours are the tokens styles.css declares. */

.stats-sources {
  margin-bottom: 1rem;
}

/* ------------------------------------------------------------ stats charts */

.stats-charts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.stats-charts:empty {
  display: none;
}

.stats-chart {
  min-width: 0;
  margin: 0;
  padding: 0.9rem 1rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--paper);
}

.stats-chart-wide {
  grid-column: 1 / -1;
}

@media (max-width: 40rem) {
  .stats-charts {
    grid-template-columns: minmax(0, 1fr);
  }
}

.stats-chart figcaption {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem 0.9rem;
}

.stats-chart-title {
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 650;
}

.stats-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.8rem;
  margin: 0;
  padding: 0;
  color: var(--ink-muted);
  font-size: 0.75rem;
  list-style: none;
}

/* The key mirrors the mark: a filled square for bars, a stroke for lines. */
.stats-chart-key::before {
  content: "";
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  margin-right: 0.3rem;
  border-radius: 2px;
  background: var(--series);
}

.stats-chart-key-line::before {
  width: 0.8rem;
  height: 2px;
  vertical-align: middle;
}

.series-1 { --series: var(--chart-a); }
.series-2 { --series: var(--chart-b); }
.series-3 { --series: var(--chart-c); }

/* The selected day's values, in ink: the series colour is the legend's job.
   Two lines are always reserved, so a longer day never moves the plot. */
.stats-chart-readout {
  min-height: calc(2 * 1.3em);
  margin: 0.35rem 0 0.4rem;
  line-height: 1.3;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.stats-chart-scale,
.stats-chart-dates {
  margin: 0;
  color: var(--ink-faint);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.7rem;
}

.stats-chart-plot {
  display: block;
  width: 100%;
  height: 7rem;
  margin-top: 0.2rem;
  overflow: visible;
}

.stats-chart-wide .stats-chart-plot {
  height: 10rem;
}

.stats-chart-plot:focus-visible {
  border-radius: 2px;
  outline: 2px solid var(--signal);
  outline-offset: 2px;
}

.stats-chart-scale {
  margin-bottom: 0.3rem;
}

.stats-chart-dates {
  position: relative;
  height: 1.2em;
  margin-top: 0.4rem;
}

.stats-chart-dates span {
  position: absolute;
  top: 0;
  white-space: nowrap;
}

.stats-chart-date-first { left: 0; }
.stats-chart-date-last { right: 0; }
.stats-chart-date-middle { transform: translateX(-50%); }

.stats-chart-grid {
  stroke: var(--ink-faint);
  stroke-dasharray: 3 3;
  opacity: 0.35;
  vector-effect: non-scaling-stroke;
}

.stats-chart-axis {
  stroke: var(--ink-faint);
  opacity: 0.6;
  vector-effect: non-scaling-stroke;
}

.stats-chart-bar {
  fill: var(--series);
}

.stats-chart-zero {
  fill: var(--ink-faint);
}

.stats-chart-line {
  fill: none;
  stroke: var(--series);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.stats-chart-area {
  fill: var(--series);
  opacity: 0.16;
}

.stats-chart-crosshair {
  stroke: var(--ink-muted);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.stats-chart-hit {
  fill: transparent;
  cursor: pointer;
}

.stats-table-port {
  overflow-x: auto;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.stats-table th,
.stats-table td {
  padding: 0.55rem 0.9rem 0.55rem 0;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.stats-table th {
  color: var(--ink-faint);
  font-size: 0.75rem;
  font-weight: 600;
}

/* The day is the way into what happened on it. */
.stats-day {
  padding: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  font-weight: 650;
  text-align: left;
}

.stats-day:hover {
  color: var(--signal-hover);
}

/* Every figure is machine text; only the day is a link. */
.stats-table td:not(:first-child) {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
}
