/* The instrument band above the field (#122): the running lap and its time, the alert
   line, the last lap and its gap to the record, then « Replacer » and the pause. It has a
   fixed height per layout, so a message never resizes the field, and it never covers the
   road. No text under 13 px. */
/* Timing colours, as on motor-racing screens: purple for a record, green for the best of the
   race, yellow for slower (sim/sector-timing.ts). Light enough for the band and the pause
   panel, at 7 : 1 or more against the band. */
.race {
  --time-purple: #cf9cff;
  --time-green: #7fe28f;
  --time-yellow: #ffd866;
}
.hud {
  grid-area: hud;
  display: grid;
  grid-template-columns: minmax(112px, auto) minmax(0, 1fr) auto auto auto auto;
  grid-template-areas: 'now msg last best speed actions';
  align-items: center;
  column-gap: var(--space-5);
  height: 64px;
  padding: 0 var(--space-3) 0 var(--space-4);
  background: var(--surface);
  border-bottom: 1px solid var(--line-2);
  color: var(--text);
}
.hud-cell {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}
.hud-label {
  font-size: var(--fs-13);
  line-height: 16px;
  color: var(--text-2);
  white-space: nowrap;
}
.hud-value {
  font-size: var(--fs-22);
  font-weight: 600;
  line-height: 26px;
  white-space: nowrap;
}
.num {
  font-variant-numeric: tabular-nums;
}
.hud-now {
  grid-area: now;
}
.hud-now .hud-value {
  font-size: var(--fs-28);
  line-height: 32px;
  letter-spacing: -0.01em;
}
/* The last lap stays until the next one; for three seconds after the line it says
   « Tour 2 bouclé » (or « Record battu ! ») on a lime tint. */
.hud-last {
  grid-area: last;
  padding: 2px var(--space-2);
  border-radius: var(--r);
}
/* Time and gap on one baseline, within the value's line: the cell keeps its row. */
.hud-last .hud-value {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.hud-last[data-fresh='true'] {
  background: rgb(215 248 121 / 0.14);
}
.hud-last[data-fresh='true'] .hud-label {
  color: var(--lime);
}
.hud-last #last-gap {
  font-size: var(--fs-13);
  font-weight: 600;
  color: var(--text-2);
}
.hud-last[data-tone='purple'] #last-gap {
  color: var(--time-purple);
}
.hud-last[data-tone='green'] #last-gap {
  color: var(--time-green);
}
.hud-last[data-tone='yellow'] #last-gap {
  color: var(--time-yellow);
}
.hud-best {
  grid-area: best;
}
.hud-best .hud-value {
  color: var(--lime);
}
.hud-speed {
  grid-area: speed;
  min-width: 4.5em;
}
.hud-messages {
  grid-area: msg;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  min-width: 0;
  overflow: hidden;
}
.hud-alert {
  min-width: 0;
  margin: 0;
  font-size: var(--fs-15);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hud-alert:empty {
  display: none;
}
.hud-alert[data-tone='alert'] {
  color: var(--gold);
}
.hud-alert[data-tone='good'] {
  color: var(--lime);
}
.hud-alert[data-tone='purple'] {
  color: var(--time-purple);
}
.hud-alert[data-tone='green'] {
  color: var(--time-green);
}
.hud-alert[data-tone='yellow'] {
  color: var(--time-yellow);
}
.hud-actions {
  grid-area: actions;
  display: flex;
  gap: var(--space-2);
}
.hud-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: var(--target);
  min-height: var(--target);
  padding: 0 var(--space-3);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--raised);
  color: var(--text);
  font-size: var(--fs-14);
  font-weight: 600;
}
.hud-btn:disabled {
  opacity: 0.45;
  cursor: default;
}
.hud-btn .icon {
  width: 20px;
  height: 20px;
}
@media (max-width: 1000px) {
  .hud {
    column-gap: var(--space-4);
  }
  .hud-speed {
    display: none;
  }
}
/* A phone held upright: two rows, the alert line under the instruments. On a narrow phone
   the last lap's gap goes under its time rather than under the buttons (#125): the first row
   holds three lines. */
@media (max-width: 750px) and (orientation: portrait) {
  .hud {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: 50px 22px;
    grid-template-areas: 'now last actions' 'msg msg msg';
    column-gap: var(--space-2);
    height: 72px;
    padding: 0 max(var(--space-2), env(safe-area-inset-right)) 0
      max(var(--space-3), env(safe-area-inset-left));
  }
  .hud-messages {
    justify-content: flex-start;
    align-self: start;
    height: 20px;
  }
  .hud-alert {
    font-size: var(--fs-14);
    line-height: 20px;
  }
  .hud-last {
    padding: 0 6px;
  }
  .hud-last .hud-label {
    line-height: 15px;
  }
  .hud-last .hud-value {
    flex-wrap: wrap;
    row-gap: 0;
    line-height: 19px;
  }
  .hud-last #last-gap {
    line-height: 15px;
  }
}
/* The narrowest phones: the longest alert (« Tour non compté : 82 % du tour, 90 % requis »)
   fits whole at 13 px, the floor, where it needs 302 px at 14 px; « Record battu ! » fits its
   tinted box with tighter gaps. */
@media (max-width: 359px) and (orientation: portrait) {
  .hud {
    column-gap: 4px;
    padding-right: max(6px, env(safe-area-inset-right));
  }
  .hud-actions {
    gap: 4px;
  }
  .hud-last {
    padding: 0 4px;
  }
  .hud-alert {
    font-size: var(--fs-13);
  }
  .hud-actions {
    gap: 6px;
  }
}
/* Phones, both ways: icon buttons, no record or speed in portrait, smaller figures. */
@media (max-width: 750px), (max-height: 520px) and (orientation: landscape) {
  .hud-now .hud-value {
    font-size: var(--fs-22);
    line-height: 26px;
  }
  .hud-last .hud-value strong {
    font-size: var(--fs-18);
  }
  .hud-btn {
    width: var(--target);
    padding: 0;
  }
  .hud-btn span {
    display: none;
  }
}
@media (max-width: 750px) and (orientation: portrait) {
  .hud-best,
  .hud-speed {
    display: none;
  }
  .hud-last .hud-value strong {
    font-size: var(--fs-17);
  }
}
/* A short landscape screen: one 48 px row. */
@media (max-height: 520px) and (orientation: landscape) {
  .hud {
    grid-template-columns: minmax(100px, auto) minmax(0, 1fr) auto auto auto;
    grid-template-areas: 'now msg last best actions';
    column-gap: var(--space-4);
    height: 48px;
    padding: 0 max(var(--space-2), env(safe-area-inset-right)) 0
      max(var(--space-3), env(safe-area-inset-left));
  }
  .hud-label {
    line-height: 15px;
  }
  .hud-now .hud-value,
  .hud-value {
    line-height: 24px;
  }
  .hud-speed {
    display: none;
  }
}
