/* The roads of /road-safety (road-traffic.js): the page's background as on
   the Pleyi site (ambient-bg.css: dots falling slowly) in sky blue, with a
   car's winding tyre tracks down its sides, and the road between two parts
   of the page.
   html.rs-road-bg is on while the background shows. */

/* ── The background ── */

:root {
  --rs-bg: #6ec3ff;
}

html.rs-road-bg:has(body.page-road),
html.rs-road-bg body.page-road {
  background: var(--rs-bg);
}

/* !important: clean-site.css makes every child of body position:relative
   with z-index 1. */
.rs-ambient {
  position: fixed !important;
  inset: 0;
  z-index: 0 !important;
  overflow: hidden;
  pointer-events: none;
  direction: ltr;
  background: var(--rs-bg);
}

html:not(.rs-road-bg) .rs-ambient {
  display: none;
}

.rs-amb-dot {
  position: absolute;
  top: -8vh;
  width: var(--dot-size, 4px);
  height: var(--dot-size, 4px);
  border-radius: 50%;
  background: var(--dot-color);
  opacity: 0;
  box-shadow: 0 0 calc(var(--dot-size, 4px) * 1.8) var(--dot-glow);
  animation: rs-amb-fall linear infinite;
}

@keyframes rs-amb-fall {
  0% {
    transform: translate3d(0, -8vh, 0);
    opacity: 0;
  }
  6% {
    opacity: var(--dot-opacity, 0.35);
  }
  92% {
    opacity: var(--dot-opacity, 0.35);
  }
  100% {
    transform: translate3d(var(--drift, 0px), 112vh, 0);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rs-amb-dot {
    animation: none;
    opacity: var(--dot-opacity, 0.28);
  }
}

/* The page sits over it. */
html.rs-road-bg body.page-road main,
html.rs-road-bg body.page-road footer {
  position: relative;
  z-index: 1;
}

/* A car's tyre tracks winding down both sides of the page, from its very
   top (behind the bar) to its bottom, scrolling with it: a layer over the
   background (road-traffic.js draws the marks, some dark and some worn,
   and now and then drives a car down them). */
body.page-road {
  position: relative;
}

.rs-tracks {
  --rs-track-w: 130px;
  --rs-track-x: 0px;
  position: absolute !important;
  inset: 0;
  z-index: 0 !important;
  overflow: hidden;
  pointer-events: none;
}

html:not(.rs-road-bg) .rs-tracks {
  display: none;
}

.rs-tracks-col {
  position: absolute;
  top: 0;
  bottom: 0;
  width: var(--rs-track-w);
  background-repeat: repeat-y;
  background-size: 100% auto;
}

.rs-tracks-col--l {
  left: var(--rs-track-x);
}

.rs-tracks-col--r {
  right: var(--rs-track-x);
}

.rs-tracks-car {
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform;
  filter: drop-shadow(2px 3px 0 rgba(10, 40, 80, 0.28));
}

.rs-tracks-car svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

@media (max-width: 720px) {
  .rs-tracks {
    --rs-track-w: 62px;
    --rs-track-x: -4px;
  }
}

/* A part on asphalt keeps it. */
html.rs-road-bg body.page-road main section:not(.rs-asphalt) {
  background: transparent;
}

/* ── A whole part on the road strips' rough asphalt (road-traffic.js
   draws it on a canvas behind the part's content). ── */

.rs-asphalt {
  position: relative;
  isolation: isolate;
  background: #2a2c30;
}

.rs-asphalt-canvas {
  position: absolute;
  inset: 0;
  z-index: -1;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ── The road between two parts: a rough black road with a white dashed
   line and a zebra, a car that stops before it and a man who crosses,
   drawn by road-traffic.js on its canvas. ── */

.rs-road {
  position: relative;
  height: clamp(70px, 5.6vw, 80px);
  border-top: 4px solid #000;
  border-bottom: 4px solid #000;
  background: #2a2c30;
  overflow: hidden;
}

.rs-road-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

@media (max-width: 640px) {
  .rs-road {
    height: 70px;
  }
}
