/* Mini bolides: the game bar and the pre-race page (Encre sobre). Load after the race
   stylesheets. The race keeps its own field, HUD, touch controls and footer. */

/* One page at a time: the circuits, or the race once Start hides them. */
#garage:not([hidden]) ~ .race-view {
  display: none;
}
.num {
  font-variant-numeric: tabular-nums;
}
.icon {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The game bar: back to the games, the title in the middle, sound on the right. */
.game-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
}
.back {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: var(--target);
  padding-right: var(--space-2);
  margin-left: -6px;
  color: var(--text-2);
  text-decoration: none;
  font-size: var(--fs-15);
  font-weight: 600;
}
@media (hover: hover) {
  .back:hover {
    color: var(--text);
  }
}
.bar-title {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--fs-17);
  font-weight: 600;
  white-space: nowrap;
}
.bar-end {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: var(--space-1);
  position: relative;
}
.icon-btn {
  width: var(--target);
  height: var(--target);
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  list-style: none;
}
.icon-btn::-webkit-details-marker {
  display: none;
}
@media (hover: hover) {
  .icon-btn:hover {
    background: var(--surface);
    color: var(--text);
    filter: none;
  }
}
.sound-volume[open] > .icon-btn {
  background: var(--surface);
  color: var(--text);
  filter: none;
}
#sound-toggle[data-sound='on'] {
  color: var(--lime);
}
#sound-toggle[data-sound='on'] .sound-off,
#sound-toggle[data-sound='off'] .sound-on {
  display: none;
}
summary.icon-btn:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 3px;
}
.sound-volume {
  position: relative;
}
.sound-popover {
  position: absolute;
  right: 0;
  top: calc(var(--target) + var(--space-2));
  z-index: 10;
  width: 260px;
  display: grid;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  background: var(--surface);
  font-size: var(--fs-14);
  color: var(--text-2);
}
.sound-popover label {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--text);
}
.sound-popover input {
  flex: 1;
  min-width: 0;
  min-height: var(--target);
  accent-color: var(--lime);
}
.sound-popover small {
  font-size: var(--fs-14);
  line-height: 1.45;
}
.sound-popover .credits {
  display: inline-flex;
  align-items: center;
  min-height: var(--target);
  color: var(--text);
  font-weight: 600;
}
.wide-only {
  display: none;
}
@media (min-width: 720px) {
  .wide-only {
    display: inline-flex;
  }
  .narrow-only {
    display: none;
  }
}
.narrow-only {
  margin-left: 6px;
  vertical-align: 1px;
}

/* During the race the bar keeps the heights the field was sized for, and spans the
   race's own width. The 1 px hairline below the bar counts in those heights. */
body:has(#garage[hidden]) .bar .wrap {
  max-width: 1400px;
  padding: 0 24px;
}
@media (max-width: 750px) {
  body:has(#garage[hidden]) .bar .wrap {
    padding: 0 var(--gutter);
  }
}
@media (max-width: 750px) and (orientation: portrait) {
  body:has(#garage[hidden]) {
    --bar: 47px;
  }
}
@media (max-height: 520px) and (orientation: landscape) {
  body:has(#garage[hidden]) {
    --bar: 41px;
  }
}

/* The pre-race page. */
.lab-return {
  display: inline-flex;
  align-items: center;
  min-height: var(--target);
  margin-top: var(--space-2);
  color: var(--text-2);
  font-size: var(--fs-15);
  font-weight: 600;
  text-decoration: none;
}
.garage-head {
  padding: var(--space-6) 0 var(--space-4);
}
.garage-head h2 {
  margin: 0;
  font-size: var(--fs-24);
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.garage-head p {
  margin: var(--space-1) 0 0;
  font-size: var(--fs-15);
  color: var(--text-2);
}
.circuits {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}
@media (min-width: 640px) {
  .circuits {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
/* A card is a label around a native radio, which covers it to take taps and clicks. */
.circuit {
  position: relative;
  display: block;
  min-width: 0;
  cursor: pointer;
}
.circuit input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.circuit-card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  pointer-events: none;
}
@media (hover: hover) {
  .circuit:hover .circuit-card {
    border-color: var(--line-2);
  }
}
.circuit input:checked + .circuit-card {
  border-color: var(--cyan);
  box-shadow: 0 0 0 1px var(--cyan);
}
.circuit input:focus-visible + .circuit-card {
  outline: 3px solid var(--cyan);
  outline-offset: 3px;
}
.thumb {
  position: relative;
  display: block;
  aspect-ratio: 4 / 3;
  width: 100%;
  background: var(--tint, #4a4f5e);
}
.thumb img,
.thumb svg {
  display: block;
  width: 100%;
  height: 100%;
  padding: 6%;
}
/* A circuit seen from above (#145) fills the thumb; an outline stands inside it. */
.thumb img.view {
  padding: 0;
  object-fit: cover;
}
/* Each theme's ground, darkened toward the ink, under an outline and until a view loads. */
.thumb[data-theme='desk'],
.thumb[data-theme='lumi'],
.thumb[data-theme='food'],
.thumb[data-theme='food-preview'] {
  --tint: #786855;
}
.thumb[data-theme='studio'] {
  --tint: #26303a;
}
.thumb[data-theme='campus'] {
  --tint: #74746e;
}
.thumb[data-theme='pcb'] {
  --tint: #174e41;
}
.chosen {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  display: none;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--cyan);
  color: var(--on-cyan);
}
.chosen svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.circuit input:checked + .circuit-card .chosen {
  display: grid;
}
.circuit-body {
  display: grid;
  gap: 2px;
  padding: 10px var(--space-3) var(--space-3);
}
.circuit-body strong {
  font-size: var(--fs-16);
  line-height: 1.3;
  font-weight: 600;
  color: var(--text);
}
.circuit-body span {
  font-size: var(--fs-13);
  color: var(--text-3);
}
.circuit-body .rec {
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
/* A record's medal colours its line; the medal's name is in the text. 6.5 : 1 or more on the
   cards and the dock. */
.garage {
  --medal-gold: #f2c55c;
  --medal-silver: #cdd5e3;
  --medal-bronze: #e3a676;
}
[data-track-record][data-medal='gold'] {
  color: var(--medal-gold);
}
[data-track-record][data-medal='silver'] {
  color: var(--medal-silver);
}
[data-track-record][data-medal='bronze'] {
  color: var(--medal-bronze);
}
/* The chosen circuit's medal times. */
.side-medals {
  font-size: var(--fs-13);
  color: var(--text-3);
}

/* The chosen circuit: a dock at the bottom of a phone, a panel beside the cards on a
   wide screen. A card scrolled into view on a phone stops above the dock, whose height
   garage.ts keeps in `--dock-height`. */
@media (max-width: 959px) {
  .circuit,
  .circuit input {
    scroll-margin-top: var(--space-3);
    scroll-margin-bottom: calc(var(--dock-height, 0px) + var(--space-3));
  }
}
.garage-side {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: grid;
  gap: 10px;
  margin: var(--space-4) calc(-1 * var(--gutter)) 0;
  padding: var(--space-3) var(--gutter) calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line-2);
  background: var(--surface);
}
.side-art,
.side-head,
.side-description,
.side-record,
.garage-keys {
  display: none;
}
.garage-side p {
  margin: 0;
}
.dock-line {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  column-gap: var(--space-3);
}
.dock-line strong {
  font-size: var(--fs-17);
  font-weight: 600;
}
.dock-line span {
  margin-left: auto;
  font-size: var(--fs-14);
  color: var(--text-2);
}
.car {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--fs-14);
  color: var(--text-2);
}
/* The car drives up in its preview; turned a quarter, it lies along the row. */
.car-art {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 30px;
}
.car-art canvas {
  display: block;
  width: 30px;
  height: 44px;
  transform: rotate(90deg);
}
.car-name {
  display: grid;
  min-width: 0;
  line-height: 1.35;
}
.car-name b {
  color: var(--text);
  font-weight: 600;
}
.text-btn {
  margin-left: auto;
  min-height: var(--target);
  padding: 0 var(--space-1);
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: var(--fs-15);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}
/* « Les records de ce circuit ont été remis à zéro », after a change of the circuit or the driving. */
.record-notice {
  padding: var(--space-2) var(--space-3);
  border-left: 3px solid var(--gold);
  border-radius: var(--r-sm);
  background: var(--raised);
  font-size: var(--fs-14);
  color: var(--text);
}
.car-status:empty,
.art-note:empty {
  display: none;
}
.car-status,
.art-note {
  margin: 0;
  font-size: var(--fs-13);
  color: var(--text-2);
}
/* The start button and its art note move together between the garage and the panel
   over the race. */
.start-group {
  display: grid;
  gap: var(--space-2);
}
.vehicle-picker {
  display: grid;
  gap: var(--space-3);
}
.vehicle-picker[hidden] {
  display: none;
}
.vehicle-picker p {
  font-size: var(--fs-14);
  color: var(--text-2);
}
.vehicle-picker fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.vehicle-picker legend {
  padding: 0;
  margin-bottom: 6px;
  font-size: var(--fs-13);
  font-weight: 600;
  color: var(--text-3);
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.chip {
  position: relative;
  cursor: pointer;
}
.chip input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.chip span {
  display: inline-flex;
  align-items: center;
  min-height: var(--target);
  padding: 0 var(--space-3);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  font-size: var(--fs-14);
  color: var(--text);
  pointer-events: none;
}
.chip input:checked + span {
  border-color: var(--cyan);
  box-shadow: 0 0 0 1px var(--cyan);
}
.chip input:focus-visible + span {
  outline: 3px solid var(--cyan);
  outline-offset: 2px;
}
.btn-block {
  width: 100%;
}
.btn-secondary {
  background: transparent;
  border-color: var(--line-2);
  color: var(--text);
}
/* The panel over the race keeps the race type; its buttons stay in Inter. */
.btn {
  font-family: var(--font);
}
#start:disabled {
  opacity: 0.55;
  cursor: wait;
  filter: none;
}

/* A short landscape phone: one row for the chosen circuit, the car and Start. */
@media (max-height: 520px) and (orientation: landscape) and (max-width: 959px) {
  .garage-side {
    grid-template-columns: minmax(0, 1fr) auto minmax(200px, 260px);
    align-items: center;
    column-gap: var(--space-4);
  }
  .dock-line {
    flex-direction: column;
    gap: 0;
  }
  .car-status,
  .record-notice,
  .vehicle-picker {
    grid-column: 1 / -1;
  }
  .start-slot {
    grid-row: 1;
    grid-column: 3;
  }
}

@media (min-width: 960px) {
  .garage {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: var(--space-10);
    align-items: start;
    padding-top: var(--space-8);
    padding-bottom: var(--space-10);
  }
  .garage-head {
    padding-top: 0;
  }
  .garage-head h2 {
    font-size: 30px;
  }
  .circuits {
    gap: var(--space-4);
  }
  .circuit-body {
    padding: var(--space-3) 14px 14px;
  }
  .circuit-body strong {
    font-size: var(--fs-17);
  }
  .circuit-body span {
    font-size: var(--fs-14);
  }
  .garage-side {
    position: sticky;
    top: var(--space-6);
    bottom: auto;
    gap: 14px;
    margin: 0;
    padding: var(--space-4);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
  }
  .dock-line {
    display: none;
  }
  .side-art,
  .side-head,
  .side-description,
  .garage-keys {
    display: block;
  }
  .side-art .thumb {
    border-radius: var(--r-md);
    overflow: hidden;
  }
  .side-art .thumb img,
  .side-art .thumb svg {
    padding: 5%;
  }
  .side-art .thumb img.view {
    padding: 0;
  }
  .side-head h2 {
    margin: 0;
    font-size: var(--fs-24);
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: -0.01em;
  }
  .garage-side .kicker {
    margin-top: 2px;
    font-size: var(--fs-14);
    color: var(--text-3);
  }
  .side-description {
    font-size: var(--fs-15);
    color: var(--text-2);
  }
  .side-record {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    font-size: var(--fs-15);
    color: var(--text-2);
  }
  .side-record b {
    color: var(--text);
    font-weight: 600;
  }
  .garage-keys {
    font-size: var(--fs-13);
    color: var(--text-3);
  }
}

/* Pause and results: a flat panel over the stopped race. It takes the start button
   and, after a race, a way back to the circuits. */
.start-panel {
  flex-shrink: 0;
  width: min(420px, 100%);
  margin: auto;
  padding: var(--space-6);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  background: var(--surface);
  font-family: var(--font);
  line-height: 1.5;
  text-align: center;
}
.start-panel p {
  margin: 0;
}
.start-panel .eyebrow {
  font-size: var(--fs-14);
  font-weight: 600;
  color: var(--cyan);
}
.start-panel h2 {
  margin: var(--space-1) 0 var(--space-2);
  font-size: var(--fs-28);
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.01em;
}
#panel-copy {
  font-size: var(--fs-15);
  color: var(--text-2);
}
.sector-details summary {
  display: flex;
  align-items: center;
  min-height: var(--target);
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
}
.sector-details summary::before {
  content: '▸';
  width: 1.25em;
  color: var(--text-2);
}
.sector-details[open] summary::before {
  content: '▾';
}
.sector-details summary::-webkit-details-marker {
  display: none;
}
.sector-details summary:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 2px;
}
.sector-details .sector-hud {
  display: grid;
  gap: var(--space-1);
  padding-bottom: var(--space-2);
  font-size: var(--fs-14);
  font-variant-numeric: tabular-nums;
}
/* The timing colours of the band (race-hud.css), with their word in the text. */
.sector-details [data-tone='purple'] {
  color: var(--time-purple);
}
.sector-details [data-tone='green'] {
  color: var(--time-green);
}
.sector-details [data-tone='yellow'] {
  color: var(--time-yellow);
}
.sector-details [data-tone='red'] {
  color: #ffaaa9;
}
.start-panel .start-slot {
  margin-top: var(--space-4);
}
.start-panel #panel-circuits,
.start-panel #panel-restart {
  margin-top: var(--space-2);
}
/* The touch-control settings (#122), folded in the pause and results panel. */
.sector-details,
.control-settings {
  margin-top: var(--space-3);
  text-align: left;
  font-size: var(--fs-14);
  color: var(--text-2);
}
.control-settings summary {
  display: flex;
  align-items: center;
  min-height: var(--target);
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
}
.control-settings summary::before {
  content: '▸';
  width: 1.25em;
  color: var(--text-2);
}
.control-settings[open] summary::before {
  content: '▾';
}
.control-settings summary::-webkit-details-marker {
  display: none;
}
.control-settings summary:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 2px;
}
.control-fields {
  display: grid;
  gap: var(--space-2);
}
.control-fields label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: var(--target);
  color: var(--text);
}
.control-fields select {
  min-height: var(--target);
  padding: 0 var(--space-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: var(--raised);
  color: var(--text);
  font: inherit;
}
.control-fields .control-check {
  justify-content: flex-start;
}
.control-check input {
  flex: none;
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--lime);
}
.control-fields select:focus-visible,
.control-check input:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 2px;
}
.start-panel .control-note {
  margin-top: var(--space-2);
  font-size: var(--fs-13);
  color: var(--text-3);
}
.touch-help {
  display: none;
}
.touch-enabled .touch-help {
  display: block;
  margin-top: var(--space-3);
  font-size: var(--fs-13);
  color: var(--text-2);
}
.start-panel .panel-note {
  margin-top: var(--space-3);
  font-size: var(--fs-13);
  color: var(--text-3);
}
@media (max-height: 520px) and (orientation: landscape) {
  .start-panel {
    padding: var(--space-4);
  }
  .start-panel h2 {
    font-size: var(--fs-22);
  }
}

/* The test site's handling trial under the garage's circuits (racer/handling-lab.ts), never in
   production. Its sentence wraps; it is never cut. */
.handling-lab {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--target);
  margin-top: var(--space-4);
  font-size: var(--fs-13);
  color: var(--gold);
}
.handling-lab input {
  width: 22px;
  height: 22px;
  flex: none;
}
