/* =========================================================
   THE FLIGHT: a little airliner that takes off beside the passport,
   follows the scroll through About and Side Quests, and lands on a
   runway at Experience. Everything is positioned in page coordinates
   by js/main.js; this file is the look and the micro-animations.
   Desktop (≥1024px) with motion allowed only.
   ========================================================= */
.flight-route, .plane { display: none; }

@media (min-width: 1024px) and (prefers-reduced-motion: no-preference) {
  .flight-route {
    display: block; position: absolute; top: 0; left: 0; width: 100%;
    pointer-events: none; z-index: 6; overflow: visible;
  }
  .flight-route__trail { fill: none; stroke: #1c2a4f; stroke-opacity: .32; stroke-width: 1.6; stroke-dasharray: 2 9; stroke-linecap: round; }
  .flight-route__runway rect { fill: rgba(28, 42, 79, .07); stroke: rgba(28, 42, 79, .22); }
  .flight-route__runway line { stroke: rgba(28, 42, 79, .35); stroke-width: 2; stroke-dasharray: 14 12; }
  .flight-route__runway text { font: 600 10px/1 ui-monospace, Menlo, monospace; letter-spacing: .2em; fill: rgba(28, 42, 79, .5); }

  .plane {
    display: block; position: absolute; top: 0; left: 0; width: 76px; height: 76px;
    margin: -38px 0 0 -38px; pointer-events: none; z-index: 7;
    will-change: transform; transition: opacity .6s ease;
  }
  .plane__shadow, .plane__craft { position: absolute; inset: 0; }
  .plane__shadow { filter: blur(3px); opacity: .2; color: #1c2a4f; }
  .plane__craft { will-change: transform; }
  .plane__bob { position: absolute; inset: 0; animation: plane-bob 3.4s ease-in-out infinite; }
  .plane svg { width: 100%; height: 100%; display: block; overflow: visible; }

  /* wingtip navigation lights: red (left), green (right), white strobe on the tail */
  .plane .nav-red   { fill: #e5484d; animation: plane-blink 1.6s steps(1) infinite; }
  .plane .nav-green { fill: #30a46c; animation: plane-blink 1.6s steps(1) infinite .1s; }
  .plane .strobe    { fill: #fff; animation: plane-strobe 2.2s ease-out infinite; }

  /* speed streaks behind the engines: grow with scroll speed (set by JS via --speed) */
  .plane .streak { stroke: #1c2a4f; stroke-width: 1.4; stroke-linecap: round; opacity: calc(var(--speed, 0) * .55);
                   transform-origin: 20px 50%; transform: scaleX(calc(.3 + var(--speed, 0) * 1.4)); transition: opacity .2s; }

  /* parked on the ground (start and after landing): lights steady, no bob */
  .plane.is-ground .plane__bob { animation: none; }
  .plane.is-ground .strobe { animation: none; opacity: 0; }
  .plane.is-landed .plane__bob { animation: plane-touchdown .55s cubic-bezier(.3, 1.6, .5, 1); }   /* touchdown bounce on the inner layer */

  /* hidden while the passport is closed */
  html.pp-locked .plane, html.pp-locked .flight-route { opacity: 0; visibility: hidden; }
}

@keyframes plane-bob {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  50%      { transform: translate(0, -2.5px) rotate(1.4deg); }
}
@keyframes plane-blink  { 0%, 55% { opacity: 1; } 56%, 100% { opacity: .15; } }
@keyframes plane-strobe { 0%, 6% { opacity: 1; } 12%, 100% { opacity: 0; } }
@keyframes plane-touchdown {
  0% { transform: scale(1.06); } 40% { transform: scale(.94); } 70% { transform: scale(1.02); } 100% { transform: scale(1); }
}


/* =========================================================
   Runways, ground roll, smoke and clouds
   ========================================================= */
.flight-sky { display: none; }
@media (min-width: 1024px) and (prefers-reduced-motion: no-preference) {
  .flight-sky { display: block; position: absolute; top: 0; left: 0; width: 0; height: 0; pointer-events: none; }
  html.pp-locked .flight-sky { visibility: hidden; }

  /* ground roll: a fine rumble while it accelerates down the runway */
  .plane.is-rolling .plane__bob { animation: plane-rumble .11s linear infinite; }

  /* clouds: soft puffy clusters; odd ones sit in front of the plane so it flies "through" them */
  .flight-cloud {
    position: absolute; left: 0; top: 0; width: 170px; height: 70px; margin: -35px 0 0 -85px;
    z-index: 5; opacity: calc(var(--air, 0) * .9); transition: opacity .35s ease;
    filter: drop-shadow(0 10px 12px rgba(28, 42, 79, .16));
  }
  .flight-cloud.is-front { z-index: 8; opacity: calc(var(--air, 0) * .62); }
  .flight-cloud i {
    position: absolute; border-radius: 50%;
    background: radial-gradient(circle at 42% 34%, #fff 0%, #fdfdfd 38%, rgba(214, 222, 236, .95) 58%, rgba(214, 222, 236, 0) 71%);
  }
  .flight-cloud i:nth-child(1) { left: 0;    top: 22px; width: 72px;  height: 50px; }
  .flight-cloud i:nth-child(2) { left: 38px; top: 0;    width: 84px;  height: 72px; }
  .flight-cloud i:nth-child(3) { left: 96px; top: 16px; width: 72px;  height: 56px; }
  .flight-cloud i:nth-child(4) { left: 18px; top: 30px; width: 136px; height: 42px; }

  /* engine smoke: puffs that swell, drift and fade behind each engine */
  .flight-puff {
    position: absolute; z-index: 6; margin: -6px 0 0 -6px; border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, .95) 0%, rgba(176, 186, 204, .8) 52%, rgba(176, 186, 204, 0) 72%);
    animation: plane-puff 1.4s ease-out forwards;
  }
}
@keyframes plane-rumble { 0%, 100% { transform: translate(0, 0); } 25% { transform: translate(.6px, -.4px); } 75% { transform: translate(-.6px, .4px); } }
@keyframes plane-puff {
  from { transform: scale(.55); opacity: .9; }
  to   { transform: translate(var(--dx, 0), var(--dy, 0)) scale(2.8); opacity: 0; }
}
