/* History screen: stat tiles, filter, spread chart, heatmap, run list, run sheet. */

.hist { padding-bottom: var(--s6); }
.hist-body { display: flex; flex-direction: column; gap: var(--s3); }
.hist-csv .icon { width: 16px; height: 16px; }

/* ------------------------------------------------------------ chart cards */
.hist-card { display: flex; flex-direction: column; gap: 10px; }
.hist-caption { min-height: 16px; font: 400 var(--t-caption)/1.35 var(--mono-font); color: var(--ink); }
/* a run's caption is one line or two (three on ALL below 360 px, with a
   long rudiment name): always keep that room, so stepping through the
   points never moves the cards below */
.spread-caption { min-height: calc(2 * 1.35em); }
@media (max-width: 359px) { .spread-caption { min-height: calc(3 * 1.35em); } }

.spread-plot { position: relative; height: var(--h-trend); cursor: pointer; touch-action: manipulation; }
.spread-plot svg { display: block; width: 100%; height: var(--h-trend); overflow: visible; }
.sp text { font-family: var(--mono-font); }
.sp-grid { stroke: var(--rule); stroke-width: 1; }
.sp-zero { stroke: var(--ink); stroke-width: 1.5; }
.sp-tick { font-size: var(--t-axis); fill: var(--ink60); }
.sp-base { stroke: var(--ink60); stroke-width: 1; }
.sp-base-label {
  font-size: var(--t-axis); fill: var(--ink60);
  paint-order: stroke; stroke: var(--white); stroke-width: 4px; stroke-linejoin: round;
}
/* one series per run kind, same mark on every filter: rudiments circles,
   timing squares, unknown kinds hollow ink60 rings. Data is ink (spec 8.5);
   red is the CTA and the R hand. With both kinds on the chart (.sp--multi,
   plot and legend) timing steps back to an ink60 dashed line (7.58:1 on
   white), so mark and dash tell the kinds apart, not hue.
   Marks carry a 2 px white ring so a crossing line never runs through them. */
.sp-line { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.sp--multi .sp-line.sp-s--tim { stroke: var(--ink60); stroke-dasharray: 5 4; stroke-linecap: butt; }
.sp-dot { fill: var(--ink); stroke: var(--white); stroke-width: 4; paint-order: stroke; }
.sp--multi .sp-dot.sp-s--tim { fill: var(--ink60); }
.sp-dot.sp-s--other { fill: var(--white); stroke: var(--ink60); stroke-width: 2; paint-order: normal; }
.sp-sel { fill: none; stroke: var(--ink); stroke-width: 2; }
/* ALL: a row per kind above the plot, names padded to RUDIMENTS' 9 characters
   so the latest values line up in one column */
.sp-legend { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; margin-top: -2px; }
.sp-legend[hidden] { display: none; }
.sp-legend__key {
  display: flex; align-items: center; gap: 6px;
  font: 400 var(--t-caption)/1.3 var(--mono-font); color: var(--ink);
}
.sp-legend__name { min-width: 9ch; margin-right: 6px; }
.sp-legend__val { white-space: nowrap; }
.sp-legend__val b { font-weight: 700; }
.sp-key { flex: none; overflow: visible; }
.sp-last {
  font-size: 13px; font-weight: 700; fill: var(--ink);
  paint-order: stroke; stroke: var(--white); stroke-width: 4px; stroke-linejoin: round;
}

/* ---------------------------------------------------------------- heatmap
   10 week columns x 7 day rows of 26 x 18 cells, 3 px gaps. Under 375 px
   the card is narrower than the grid: the columns shrink (never the rows)
   so this week, today's ring included, stays in the card. */
.heat-grid {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 8px; row-gap: 4px;
  justify-content: start;
}
.heat-months {
  grid-column: 2; grid-row: 1;
  justify-self: start;
  display: grid; grid-template-columns: repeat(10, minmax(0, 26px)); column-gap: 3px;
  font: 400 var(--t-axis)/1.3 var(--mono-font); color: var(--ink60);
  white-space: nowrap;
}
.heat-days {
  grid-column: 1; grid-row: 2;
  display: grid; grid-template-rows: repeat(7, 18px); row-gap: 3px;
  font: 400 var(--t-axis)/18px var(--mono-font); color: var(--ink60);
}
.heatmap {
  grid-column: 2; grid-row: 2;
  display: grid;
  grid-auto-flow: column;
  justify-self: start;
  grid-template-rows: repeat(7, 18px);
  grid-auto-columns: minmax(0, 26px);
  gap: 3px;
  cursor: pointer;
  touch-action: manipulation;
}
.heatmap i, .heat-legend .sw {
  display: block;
  background: var(--heat0);
  box-shadow: inset 0 0 0 1px rgba(20, 18, 16, .18);
}
.heatmap i.h1, .heat-legend .sw.h1 { background: var(--heat1); }
.heatmap i.h2, .heat-legend .sw.h2 { background: var(--heat2); }
.heatmap i.h3, .heat-legend .sw.h3 { background: var(--heat3); }
.heatmap i.is-future { background: none; box-shadow: none; }
.heatmap i.is-today { position: relative; box-shadow: inset 0 0 0 1px rgba(20, 18, 16, .18), 0 0 0 2px var(--white), 0 0 0 4px var(--ink); }
.heatmap i.is-sel { position: relative; z-index: 1; box-shadow: inset 0 0 0 2px var(--white), 0 0 0 2px var(--ink); }
.heat-legend {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px;
  font: 400 var(--t-axis)/1.3 var(--mono-font); color: var(--ink60);
}
.heat-key { display: inline-flex; align-items: center; gap: 5px; }
.heat-legend .sw { width: 16px; height: 11px; }

/* --------------------------------------------------------------- run list */
.log-list { display: flex; flex-direction: column; gap: var(--s2); }
.log-row { grid-template-columns: 56px minmax(0, 1fr) auto; align-items: start; color: var(--ink); }
.log-row:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.log-date b { display: block; font: 700 var(--t-label)/1.25 var(--mono-font); white-space: nowrap; }
.log-date span { display: block; font: 400 var(--t-axis)/1.35 var(--mono-font); color: var(--ink60); }
.log-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.log-title { font: 700 var(--t-control)/1.2 var(--label-font); letter-spacing: .02em; overflow-wrap: anywhere; }
.log-meta { font: 400 var(--t-caption)/1.5 var(--mono-font); color: var(--ink60); }
.log-meta .nw { white-space: nowrap; }
.log-tag {
  display: inline-block; margin-right: 6px; padding: 0 5px;
  border: 1.5px solid var(--ink); color: var(--ink);
  font: 600 var(--t-axis)/15px var(--label-font); letter-spacing: .08em;
  vertical-align: 1px;
}
.log-badge--acc {
  display: inline-block; padding: 0 5px;
  background: var(--tint); color: var(--ink);
  font: 700 var(--t-caption)/18px var(--mono-font);
  white-space: nowrap;
}
.log-val { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.log-val .log-badge { font: 700 20px/1 var(--mono-font); letter-spacing: -.02em; white-space: nowrap; }
.log-unit { font: 600 var(--t-caption)/1 var(--label-font); letter-spacing: .04em; color: var(--ink60); white-space: nowrap; }
.hist-more { align-self: flex-start; }

.hist-empty { padding-top: var(--s2); }

/* --------------------------------------------------------------- run sheet */
.hist-sheet__head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: var(--s3) var(--gutter) 0;
}
.hist-sheet__head h2 { min-width: 0; overflow-wrap: anywhere; }
.hist-sheet__body {
  display: flex; flex-direction: column; gap: var(--s3);
  padding: var(--s3) var(--gutter) var(--s6);
  overflow-y: auto;
}
.hist-sheet__when { font: 400 var(--t-caption)/1.35 var(--mono-font); color: var(--ink60); }
.hist-accents { font: 400 var(--t-label)/1.4 var(--mono-font); }
.hist-accents b { font: 700 var(--t-label)/1 var(--label-font); letter-spacing: .08em; margin-right: 4px; }
