/* Airplane bridge between the invitation and the Atlas (bridge.js). One and a half seconds:
   ivory veil in, plane crosses on a soft curve with a dotted trail, view swaps at the midpoint,
   veil out, element removed. The plane's travel (.bridge-flight) and its mirroring
   (.bridge-plane) are separate elements so their transforms never collide. */
.bridge {
  position: fixed; inset: 0; z-index: 8000; overflow: hidden; pointer-events: auto; /* swallows taps during the trip only */
  background: linear-gradient(180deg, rgba(248, 247, 243, .78) 0%, rgba(236, 246, 243, .74) 100%);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  opacity: 0; animation: bridge-veil 1500ms ease both;
}
@keyframes bridge-veil {
  0% { opacity: 0; }
  20% { opacity: 1; }
  78% { opacity: 1; }
  100% { opacity: 0; }
}

.bridge-trail { position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: visible; }
.bridge-dash { fill: none; stroke: #7fb9b2; stroke-width: 1.4; stroke-linecap: round; stroke-dasharray: 1.5 7; opacity: .85; }
.bridge-reveal {
  fill: none; stroke: #fff; stroke-width: 14;
  stroke-dasharray: var(--trail-length) var(--trail-length); stroke-dashoffset: var(--trail-length);
  animation: bridge-trail 1500ms cubic-bezier(.45, .05, .55, .95) both;
}
@keyframes bridge-trail { to { stroke-dashoffset: 0; } }

.bridge-flight {
  position: absolute; left: 0; top: 0;
  width: clamp(124px, calc(9vw + 90px), 240px); /* about 125px on phones, larger on wide screens */
  aspect-ratio: 720 / 357; will-change: transform;
  animation: 1500ms cubic-bezier(.45, .05, .55, .95) both;
}
.bridge-plane { display: block; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; }
.bridge.is-to-atlas .bridge-flight { animation-name: bridge-fly-right; }
.bridge.is-to-invitation .bridge-flight { animation-name: bridge-fly-left; }
.bridge.is-to-invitation .bridge-plane { transform: scaleX(-1); }

/* Points on the curve (-10,58) (50,38) (110,58) at t = 0, .25, .5, .75, 1 (vw / vh).
   Nose up while climbing, level at the top, nose down while descending. */
@keyframes bridge-fly-right {
  0%   { transform: translate(calc(-10vw - 100%), calc(58vh - 50%)) rotate(-7deg); }
  25%  { transform: translate(calc(20vw - 50%), calc(50.5vh - 50%)) rotate(-4deg); }
  50%  { transform: translate(calc(50vw - 50%), calc(48vh - 50%)) rotate(0deg); }
  75%  { transform: translate(calc(80vw - 50%), calc(50.5vh - 50%)) rotate(4deg); }
  100% { transform: translate(110vw, calc(58vh - 50%)) rotate(7deg); }
}
@keyframes bridge-fly-left {
  0%   { transform: translate(110vw, calc(58vh - 50%)) rotate(7deg); }
  25%  { transform: translate(calc(80vw - 50%), calc(50.5vh - 50%)) rotate(4deg); }
  50%  { transform: translate(calc(50vw - 50%), calc(48vh - 50%)) rotate(0deg); }
  75%  { transform: translate(calc(20vw - 50%), calc(50.5vh - 50%)) rotate(-4deg); }
  100% { transform: translate(calc(-10vw - 100%), calc(58vh - 50%)) rotate(-7deg); }
}

@media (prefers-reduced-motion: reduce) {
  .bridge { display: none; } /* bridge.js also skips the trip and switches at once */
}
