/*
 * Analytics.
 *
 * Four tiles that answer a different question from everything else on the desk. The desk
 * asks "what is happening"; these ask "is this working", and the visual language says so —
 * larger numbers, quieter surroundings, nothing that blinks. A trader looks here between
 * sessions, not between trades.
 */

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
  gap: var(--sp-1);
}

.kpi {
  display: grid;
  gap: 1px;
  padding: var(--sp-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-1);
  background: var(--bg-inset);
}

.kpi__value {
  font-size: var(--fs-3);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.kpi__label {
  color: var(--ink-muted);
  font-size: var(--fs-0);
  text-transform: lowercase;
}

.kpi__note {
  color: var(--ink-faint);
  font-size: var(--fs-0);
}

/* Tone is about the number's meaning, never just its sign — the win-rate tile stays neutral
   because a 40% win rate with a 3:1 payoff is a fine strategy. */
.kpi--up .kpi__value {
  color: var(--green);
}

.kpi--down .kpi__value {
  color: var(--orange);
}

.kpi--flat .kpi__value {
  color: var(--ink-muted);
}

.kpi--info .kpi__value {
  color: var(--ink-strong);
}

/*
 * The curve. Given real height because the shape is the content — a two-centimetre strip
 * would show a line going up and nothing about how it got there, which is the half that
 * matters.
 */
.equity-chart {
  position: relative;
  display: grid;
  min-block-size: 7rem;
  margin-block-start: var(--sp-2);
}

.equity-chart__canvas {
  inline-size: 100%;
  block-size: 100%;
  min-block-size: 7rem;
}

.equity-chart__dd {
  position: absolute;
  inset-block-start: 2px;
  inset-inline-end: 2px;
  color: var(--orange);
}

/*
 * The hour grid. Wide and short: twenty-four columns need the width, and seven rows read
 * fine at a few pixels each — the shape of where the losses cluster is what carries, not any
 * individual cell.
 */
.hours {
  display: grid;
  gap: var(--sp-1);
  margin-block-start: var(--sp-2);
}

.hours__canvas {
  inline-size: 100%;
  block-size: 5.5rem;
}

.hours__extremes {
  margin: 0;
  color: var(--ink-muted);
}

/*
 * The instrument ranking. Bars behind the text rather than beside it: the row still reads as
 * a row of numbers, and the bar is peripheral information the eye picks up without being
 * asked to compare lengths across a gutter.
 */
.ranking {
  display: grid;
  gap: 1px;
  margin-block-start: var(--sp-2);
}

.ranking__row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(5rem, 1fr) 5rem minmax(7rem, 1.2fr);
  gap: var(--sp-2);
  align-items: baseline;
  inline-size: 100%;
  padding: 2px var(--sp-1);
  border: 0;
  background: none;
  color: var(--ink);
  font-size: var(--fs-0);
  text-align: start;
  cursor: pointer;
}

.ranking__bar {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  overflow: hidden;
}

.ranking__bar i {
  display: block;
  block-size: 100%;
  opacity: 0.16;
}

.ranking__row--up .ranking__bar i {
  background: var(--green);
}

.ranking__row--down .ranking__bar i {
  background: var(--orange);
}

.ranking__inst,
.ranking__net,
.ranking__meta {
  position: relative;
  z-index: 1;
}

.ranking__inst {
  color: var(--ink-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking__net {
  text-align: end;
  font-weight: 700;
}

.ranking__row--up .ranking__net {
  color: var(--green);
}

.ranking__row--down .ranking__net {
  color: var(--orange);
}

/* The hold distribution. Short, because the shape is the message and the exact counts are
   what the labels are for. */
.holds {
  display: grid;
  gap: var(--sp-1);
  margin-block-start: var(--sp-2);
}

.holds__canvas {
  inline-size: 100%;
  block-size: 4.5rem;
}

.holds__centre {
  margin: 0;
  color: var(--ink-muted);
}

/* Streaks. The strip is the point: one tick per trade, and the run in progress at full
   height so the eye lands on what is still happening. */
.streaks {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--sp-1) var(--sp-2);
  align-items: center;
  margin-block-start: var(--sp-2);
}

.streaks__now {
  font-size: var(--fs-2);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.streaks__now--win {
  color: var(--green);
}

.streaks__now--loss {
  color: var(--orange);
}

.streaks__strip {
  grid-column: 1 / -1;
  inline-size: 100%;
  block-size: 1.25rem;
}

.streaks__tilt {
  grid-column: 1 / -1;
  margin: 0;
  padding: 2px var(--sp-1);
  border-inline-start: 2px solid var(--orange);
  color: var(--orange);
  font-size: var(--fs-0);
}

/* Fee drag. The ratio gets the big type because it is the sentence, and the bars are the
   evidence underneath it. */
.fees {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--sp-1) var(--sp-2);
  align-items: baseline;
  margin-block-start: var(--sp-2);
}

.fees__ratio {
  font-size: var(--fs-3);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.fees__ratio--up {
  color: var(--green);
}

.fees__ratio--warn {
  color: var(--orange);
}

.fees__ratio--down {
  color: var(--orange-hot);
}

.fees__ratio--flat {
  color: var(--ink-muted);
}

.fees__bars {
  grid-column: 1 / -1;
  inline-size: 100%;
  block-size: 2.25rem;
}

.fees__venues {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-2);
}

.fees__venue {
  grid-column: 1 / -1;
  color: var(--ink-muted);
}

/* The underwater area. Orange and filled: the area is the message — a line at the same
   coordinates reads as a value moving around, and an area reads as time spent under water. */
.underwater {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--sp-1) var(--sp-2);
  align-items: baseline;
  margin-block-start: var(--sp-2);
}

.underwater__depth {
  color: var(--orange);
  font-size: var(--fs-3);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.underwater__canvas {
  grid-column: 1 / -1;
  inline-size: 100%;
  block-size: 3.5rem;
}

/*
 * The period switch.
 *
 * Sits above the tiles because it governs every number under it - a control placed beside
 * one chart would read as belonging to that chart alone.
 */
.period {
  display: flex;
  gap: var(--sp-1);
  flex: 0 0 auto;
  margin-block-end: var(--sp-1);
}

/* The export row. Beside the period switch because both act on the same snapshot. */
.period__out {
  display: flex;
  gap: var(--sp-1);
  flex: 0 0 auto;
  margin-block-end: var(--sp-1);
}
