/* SPDX-License-Identifier: MIT */

.driving-demo {
  --drive-accent: #537e8f;
  --drive-speed: #8c4c0d;
  --drive-rate: #9e2b2b;
  --drive-road: #363d45;
  margin-block: 1rem;
  padding: clamp(.65rem, 2vw, 1.1rem);
  border: 1px solid var(--bs-border-color);
  border-radius: .8rem;
  background: var(--bs-body-bg);
}

body.quarto-dark .driving-demo {
  --drive-accent: #a7c7c6;
  --drive-speed: #fccf9c;
  --drive-rate: #ebadad;
}

.driving-demo .drive-road {
  position: relative;
  display: flex;
  justify-content: end;
  align-items: start;
  min-height: 5.3rem;
  overflow: hidden;
  padding: .5rem .75rem;
  border-radius: .45rem;
  background: var(--drive-road);
  color: #fffdfc;
}

.driving-demo .drive-lane {
  position: absolute;
  inset: auto 0 .65rem;
  height: 2px;
  background: linear-gradient(90deg, #fffdfc 24px, transparent 24px)
    var(--road-offset, 0px) 0 / 55px 100%;
  opacity: .7;
}

.driving-demo .drive-car {
  position: absolute;
  left: 19%;
  bottom: 1.2rem;
  width: 3.6rem;
  height: 1rem;
  border-radius: .3rem .65rem .25rem .25rem;
  background: #f6b265;
}

.driving-demo .drive-car::before {
  content: "";
  position: absolute;
  bottom: 75%;
  left: 20%;
  width: 52%;
  height: .8rem;
  border: .18rem solid #f6b265;
  border-radius: .5rem .8rem 0 0;
  background: #a7c7c6;
}

.driving-demo .drive-car::after {
  content: "";
  position: absolute;
  bottom: -.22rem;
  left: .36rem;
  width: .6rem;
  height: .6rem;
  border: .12rem solid #a7c7c6;
  border-radius: 50%;
  background: var(--drive-road);
  box-shadow: 2.25rem 0 0 -.12rem var(--drive-road), 2.25rem 0 #a7c7c6;
}

.driving-demo .drive-speedometer {
  font-variant-numeric: tabular-nums;
}

.driving-demo .drive-speedometer strong {
  font-size: 1.4em;
}

.driving-demo .drive-controls {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  margin-block: .65rem .3rem;
}

.driving-demo .drive-controls button {
  min-height: 44px;
}

.driving-demo [data-pedal] {
  touch-action: none;
  user-select: none;
}

.driving-demo .drive-touch-tip {
  margin-block: 0 .25rem;
  font-size: .9rem;
}

@media (not (any-pointer: coarse)) {
  .driving-demo [data-pedal],
  .driving-demo .drive-touch-tip {
    display: none;
  }
}

.driving-demo [data-pedal].is-held {
  background: var(--bs-secondary-bg);
  color: var(--bs-emphasis-color);
  border-color: var(--drive-accent);
}

.driving-demo .drive-status {
  min-height: 1.5em;
  margin-block: 0 .65rem;
  color: var(--bs-secondary-color);
  font-size: .9rem;
}

.driving-demo .drive-graph {
  border-top: 1px solid var(--bs-border-color);
  padding-top: .35rem;
}

.driving-demo .drive-graph-label {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  column-gap: .5rem;
  font-size: .9rem;
  font-variant-numeric: tabular-nums;
}

.driving-demo canvas {
  display: block;
  width: 100%;
  height: 88px;
}

.driving-demo [data-graph="position"] { color: var(--drive-accent); }
.driving-demo [data-graph="speed"] { color: var(--drive-speed); }
.driving-demo [data-graph="rate"] { color: var(--drive-rate); }

@media (prefers-reduced-motion: reduce) {
  .driving-demo .drive-lane {
    background-position: 0 0;
  }
}
