/* Mini bolides' race view (#122): the instrument band (race-hud.css), the field, the touch
   controls (touch-layout.css) and the footer (race-footer.css), on the Encre sobre tokens.
   Nothing lies over the road but the touch controls, and only where the layout needs it. */
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
a {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 4px;
}
[hidden] {
  display: none !important;
}
.race-view {
  max-width: 1400px;
  margin: auto;
  padding: 0 24px;
  font-family: var(--font);
}
/* While the race view is up, a swipe that misses a button never pulls the page down to reload
   it, nor drags it past its ends. */
html:has(#garage[hidden]) {
  overscroll-behavior: none;
}
/* The band on top, the field, then the touch bar where a phone held upright docks it. Over the
   race a touch never zooms (a double tap or a pinch) nor scrolls: it drives. The pause and
   results panel scrolls again; it does not zoom, since a pinch obeys every ancestor's
   `touch-action`, the race's included. */
.race {
  touch-action: none;
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: 'hud' 'field' 'pad';
  height: calc(100dvh - 145px);
  min-height: 430px;
  max-height: 900px;
  overflow: clip;
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.field {
  grid-area: field;
  position: relative;
  min-height: 0;
  background: #c6a47c;
}
#track {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
/* « 3, 2, 1, Partez ! » over a car that has not moved yet. */
#countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 72px;
  font-weight: 700;
  line-height: 1;
  color: var(--lime);
  text-shadow: 0 3px 0 #172319;
  pointer-events: none;
}
.overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  padding: var(--space-4);
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: manipulation;
  /* Flat, as Encre sobre asks: the stopped race shows through, dimmed, unblurred. */
  background: rgb(17 19 29 / 0.72);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
/* Phones: the race spans the screen's width; with touch controls the footer leaves, its
   actions being in the pause panel, and the race takes the height under the bar. */
@media (max-width: 750px) {
  .race-view {
    padding: 0;
  }
  .race {
    height: calc(100dvh - var(--bar) - 1px - 128px);
    min-height: 380px;
    max-height: none;
    border-width: 0;
    border-radius: 0;
  }
  .overlay {
    padding: var(--space-2);
  }
}
@media (max-height: 520px) and (orientation: landscape) {
  .race-view {
    padding: 0;
  }
  .race {
    height: calc(100dvh - var(--bar) - 1px - 64px);
    min-height: 240px;
    max-height: none;
    border-width: 0;
    border-radius: 0;
  }
}
@media (max-width: 750px), (max-height: 520px) and (orientation: landscape) {
  .touch-enabled .race {
    height: calc(100dvh - var(--bar) - 1px);
    min-height: 0;
  }
  .touch-enabled .race-view footer {
    display: none;
  }
}
/* In landscape the site bar folds away while the car moves, so the field takes the
   screen's full height; it comes back with the pause panel. */
@media (max-height: 520px) and (orientation: landscape) {
  body.touch-enabled:has(#garage[hidden]):has(#overlay[hidden]) > .bar {
    display: none;
  }
  body.touch-enabled:has(#garage[hidden]):has(#overlay[hidden]) .race {
    height: 100dvh;
  }
}
