/*
 * The HUD.
 *
 * Read at a glance and only between trades, so the tiles are big, few, and stationary.
 * Every value is tabular and pre-formatted to a fixed width — a row of numbers that
 * reflows as they change is a row nobody can scan.
 */

.hud {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(6rem, 1fr));
  gap: var(--space-2, 0.5rem);
  height: 100%;
  align-content: start;
}

.hud__tile {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: var(--space-1, 0.25rem) var(--space-2, 0.5rem);
  border: 1px solid var(--line);
}

.hud__value {
  font-size: var(--font-size-lg, 1.125rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.hud__label {
  font-size: var(--font-size-xs, 0.6875rem);
  color: var(--ink-muted);
}

/*
 * Three states rather than a gradient: the question this tile answers — can I trust the
 * fast path right now — has three answers.
 */
.hud__tile--good .hud__value {
  color: var(--green);
}

.hud__tile--warn .hud__value {
  color: var(--ink);
}

.hud__tile--bad .hud__value {
  color: var(--orange);
}

.hud__tile--bad {
  border-color: var(--orange);
}

/*
 * The compact strip: nine vitals in one row. auto-fit rather than nine fixed columns, so
 * the strip holds its single row at any block width instead of wrapping into the layout
 * it was supposed to replace.
 */
.hud-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(3.5rem, 1fr));
  gap: var(--space-1, 0.25rem);
  align-items: center;
}

.hud-strip__cell {
  display: flex;
  flex-direction: column;
  min-width: 0;
  font-size: var(--font-size-xs, 0.6875rem);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-strip__cell b {
  color: var(--ink-muted);
  font-weight: 400;
}

.hud-strip__cell span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-strip__cell--good span,
.hud-strip__cell--ok span,
.hud-strip__cell--hot span {
  color: var(--green);
}

.hud-strip__cell--bad span,
.hud-strip__cell--cold span,
.hud-strip__cell--warn span,
.hud-strip__cell--over span {
  color: var(--orange);
}

.hud__density {
  align-self: flex-start;
  margin-bottom: var(--space-1, 0.25rem);
}

/*
 * Pace and streak. On-target and neutral are deliberately unstyled: a HUD where every
 * tile is coloured is one where colour has stopped meaning anything, so only the two
 * readings worth interrupting for get a colour.
 */
.hud__tile--pace-over .hud__value,
.hud__tile--streak-cold .hud__value {
  color: var(--orange);
}

.hud__tile--pace-under .hud__value {
  color: var(--ink-muted);
}

.hud__tile--streak-hot .hud__value {
  color: var(--green);
}

/* Three losses in a row earns a border, not just a colour — it is the one reading on
   this row that is about the trader rather than the market. */
.hud__tile--streak-cold {
  border-color: var(--orange);
}

/* The pulse fires because the class itself is new: crossing into hot or cold announces
   itself once, then the tile goes quiet and stays readable. */
.hud__tile--streak-hot,
.hud__tile--streak-cold {
  animation: streak-pulse 600ms ease-out 1;
}

@keyframes streak-pulse {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.04);
  }
  100% {
    transform: scale(1);
  }
}

/* The pace meter: peripheral vision reads the bar, the eye reads the number. */
.hud__meter {
  display: block;
  height: 2px;
  margin-top: 0.25rem;
  background: var(--line);
  overflow: hidden;
}

.hud__meter i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--green);
  transition: width 120ms linear;
}

.hud__tile--pace-over .hud__meter i,
.hud__tile--burn-warn .hud__meter i {
  background: var(--orange);
}

.hud__tile--burn-warn .hud__value {
  color: var(--orange);
}

@media (prefers-reduced-motion: reduce) {
  .hud__tile--streak-hot,
  .hud__tile--streak-cold {
    animation: none;
  }

  .hud__meter i {
    transition: none;
  }
}

/*
 * Venue LEDs. Colour carries the reading before the number does, which is the point of
 * having them — a glance answers "is it me or is it them" without reading milliseconds.
 */
.hud__tile--venues {
  gap: 0.2rem;
}

.hud__venue {
  display: flex;
  align-items: center;
  gap: var(--space-1, 0.25rem);
  font-size: var(--font-size-xs, 0.6875rem);
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.hud__venue b {
  margin-left: auto;
  color: var(--ink);
}

.led {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--ink-muted);
  flex: 0 0 auto;
}

.led--ok {
  background: var(--green);
  box-shadow: 0 0 4px var(--green);
}

.led--warn {
  background: var(--orange);
}

.led--bad {
  background: var(--orange);
  box-shadow: 0 0 6px var(--orange);
}

/* Never measured reads as unlit rather than as a fault: a desk starting its session
   must not look broken. */
.led--unknown {
  background: transparent;
  border: 1px solid var(--line);
}

/*
 * A breached spread. Flashing rather than merely coloured: slippage is what already
 * happened, a widening spread is what is about to, and it deserves the attention.
 */
.hud__tile--alert {
  border-color: var(--orange);
  animation: spread-alert 900ms ease-in-out infinite;
}

.hud__tile--alert .hud__value {
  color: var(--orange);
}

@keyframes spread-alert {
  0%,
  100% {
    box-shadow: 0 0 4px color-mix(in srgb, var(--orange) 30%, transparent);
  }
  50% {
    box-shadow: 0 0 12px color-mix(in srgb, var(--orange) 60%, transparent);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hud__tile--alert {
    animation: none;
  }
}
