/* The two handsets run the same route. Distances are normalized to 100
   along the original map path, so progress also scrubs smoothly in reverse. */
.mobile-lab-map .mobile-route-motion,
.mobile-lab-sync {
  display: none;
}

@media screen and (prefers-reduced-motion: no-preference) {
  #mobile-testing[data-motion-scene="mobile"][data-motion-ready] .mobile-lab-demo {
    --lab-time: var(--scene-progress, 1);
    --lab-gap: clamp(15px, 3.5vw, 52px);
    --handoff: clamp(0, calc((var(--lab-time) - .38) * 5), 1);
    gap: var(--lab-gap);
  }

  #mobile-testing[data-motion-scene="mobile"][data-motion-ready] .android {
    --route-time: clamp(0, calc((var(--lab-time) - .02) * 2.1), 1);
    --entry-tilt: -3deg;
    --entry-height: 10px;
  }

  #mobile-testing[data-motion-scene="mobile"][data-motion-ready] .ios {
    --route-time: clamp(0, calc((var(--lab-time) - .51) * 2.32), 1);
    --entry-tilt: 3deg;
    --entry-height: 14px;
  }

  #mobile-testing[data-motion-scene="mobile"][data-motion-ready] .mobile-lab-phone {
    transform-origin: 50% 62%;
    transform: translateY(calc((1 - var(--route-time)) * var(--entry-height)))
      rotate(calc((1 - var(--route-time)) * var(--entry-tilt)));
  }

  /* The street outline stays visible before the orange journey is traced. */
  #mobile-testing[data-motion-scene="mobile"][data-motion-ready] .mobile-route-outline {
    stroke: #897166;
  }

  #mobile-testing[data-motion-scene="mobile"][data-motion-ready] .mobile-route-motion {
    display: inline;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  #mobile-testing[data-motion-scene="mobile"][data-motion-ready] .mobile-route-trace {
    stroke: #ffac7e;
    stroke-width: 3;
    stroke-dasharray: 100 100;
    stroke-dashoffset: calc(100 * (1 - var(--route-time)));
  }

  #mobile-testing[data-motion-scene="mobile"][data-motion-ready] .mobile-route-cursor {
    stroke-dasharray: .2 101;
    stroke-dashoffset: calc(-100 * var(--route-time));
    opacity: clamp(0, min(calc(var(--route-time) * 18), calc((1 - var(--route-time)) * 18)), 1);
  }

  #mobile-testing[data-motion-scene="mobile"][data-motion-ready] .mobile-route-aura {
    stroke: #ffa270;
    stroke-width: 13;
    stroke-opacity: .28;
  }

  #mobile-testing[data-motion-scene="mobile"][data-motion-ready] .mobile-route-core {
    stroke: #ffe4d3;
    stroke-width: 5;
  }

  /* One packet crosses the real gap between the device screens. */
  #mobile-testing[data-motion-scene="mobile"][data-motion-ready] .mobile-lab-sync {
    display: block;
    position: absolute;
    left: 50%;
    top: 55%;
    width: var(--lab-gap);
    height: 1px;
    transform: translateX(-50%);
    background: linear-gradient(90deg, #618fe080, #f9ad7eaa);
    opacity: clamp(0, min(calc(var(--handoff) * 5), calc((1 - var(--handoff)) * 5)), 1);
    pointer-events: none;
  }

  #mobile-testing[data-motion-scene="mobile"][data-motion-ready] .mobile-lab-sync::after {
    content: "";
    position: absolute;
    width: min(12px, 45%);
    height: 3px;
    border-radius: 3px;
    left: calc(var(--handoff) * 100%);
    top: -1px;
    transform: translateX(-50%);
    background: linear-gradient(90deg, transparent, #ffbe95 70%, #fff1dd);
    box-shadow: 2px 0 7px #ff995e96;
  }
}

@media screen and (max-width: 780px) and (prefers-reduced-motion: no-preference) {
  #mobile-testing[data-motion-scene="mobile"][data-motion-ready] .mobile-lab-demo { --lab-gap: 14px; }
}

@media screen and (max-width: 650px) and (prefers-reduced-motion: no-preference) {
  #mobile-testing[data-motion-scene="mobile"][data-motion-ready] .mobile-lab-demo { --lab-gap: clamp(13px, 7vw, 30px); }
}
