/* =========================================================== the plane */
/* The home page's plane (assets/js/plane.js, owner request 2026-10-28): the
   flight path in the page margins on computers and, since 2026-10-29, on any
   screen at least 1024px wide (large tablets, touch laptops); the line on the
   header's bottom edge on phones and smaller tablets. Decoration only: no pointer events,
   hidden in print and for reduced motion (the script does not start then
   either).
   Colours are tokens, so the theme switch repaints it with no code; in dark
   mode the plane turns light so it shows on the deep background.
   Layers: above the page content (z 10/20 at most), under the sticky header
   (--z-header) and every fixed panel (dropdowns, docks, dialogs). */
:root,
[data-theme="light"] {
  --plane-body: var(--brand-deep);
  --plane-wing-edge: var(--brand-lagoon);
  --plane-wing-mid: var(--brand-pacific);
  --plane-tip: var(--brand-gold);
  --plane-glass: var(--brand-sky);
  --plane-spine: rgb(255 255 255 / 0.18);
  --plane-shadow: var(--brand-deep);
  --plane-shadow-strength: 0.2;
  --plane-trail: var(--brand-sky);
}

[data-theme="dark"] {
  --plane-body: #eaf3f6;
  --plane-wing-edge: var(--brand-lagoon);
  --plane-wing-mid: var(--brand-sky);
  --plane-tip: var(--brand-gold);
  --plane-glass: var(--brand-pacific);
  --plane-spine: rgb(10 48 64 / 0.2);
  --plane-shadow: #000000;
  --plane-shadow-strength: 0.45;
  --plane-trail: var(--brand-sky);
}

/* The wing gradient lives in a rendered 0x0 box: inside display: none it
   would not paint in every browser. */
.pesa-plane-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

.pesa-plane__body { fill: var(--plane-body); }
.pesa-plane__wing { fill: url(#pesa-plane-wing); }
.pesa-plane__w-edge { stop-color: var(--plane-wing-edge); }
.pesa-plane__w-mid { stop-color: var(--plane-wing-mid); }
.pesa-plane__tip { fill: var(--plane-tip); }
.pesa-plane__glass { fill: var(--plane-glass); }
.pesa-plane__spine { fill: none; stroke: var(--plane-spine); stroke-width: 2; }
.pesa-plane__sil { fill: var(--plane-shadow); }

/* ------------------------------------------------------- route (computers) */
/* The contrail and the landing ring, in page coordinates (the script sets the
   box and its viewBox, and clips the dots to the margins and the empty bands
   between sections). Clipped to the page width, so nothing widens it. */
.pesa-plane-trail {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 89;
  overflow: hidden;
  pointer-events: none;
}

.pesa-plane-trail__dots path {
  fill: none;
  stroke: var(--plane-trail);
  stroke-linecap: round;
}

.pesa-plane-ping {
  fill: none;
  stroke: var(--plane-trail);
  stroke-width: 2;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
}

/* Three soft rings the first time the plane lands, 4.5 s in all (under the
   five seconds of WCAG 2.2.2), then nothing moves. */
.pesa-plane-ping.is-on {
  animation: pesa-plane-ping 1.5s ease-out 3;
}

@keyframes pesa-plane-ping {
  from { opacity: 0.75; transform: scale(0.6); }
  to   { opacity: 0;    transform: scale(1.8); }
}

/* The flight runs from the plane's spot in the first screen to the landing
   spot; the pilot inside sticks at that spot of the window while the page
   scrolls (so it never trails the scroll), then scrolls away with the page
   once it has landed. overflow-x: clip keeps the vertical axis visible and
   makes no scroll box, so the sticky still follows the window. */
.pesa-plane-flight {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 90;
  overflow-x: clip;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.pesa-plane-flight.is-ready { opacity: 1; }

.pesa-plane-pilot {
  position: sticky;
  top: var(--plane-anchor, 42vh);
  height: 0;
}

.pesa-plane-craft,
.pesa-plane-shadow {
  position: absolute;
  left: calc(var(--plane-size, 46px) / -2);
  top: calc(var(--plane-size, 46px) / -2);
  width: var(--plane-size, 46px);
  height: var(--plane-size, 46px);
  will-change: transform;
}

.pesa-plane-shadow { filter: blur(3px); }
.pesa-plane-shadow svg { opacity: var(--plane-shadow-strength); }

.pesa-plane-craft svg,
.pesa-plane-shadow svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* ---------------------------------------------- line (phones and tablets) */
/* On the sticky header's bottom edge; the half below the edge hangs over the
   page, as in the prototype. */
.pesa-plane-line {
  position: absolute;
  inset-inline: 0;
  bottom: -1px;
  height: 0;
  pointer-events: none;
}

.pesa-plane-line > svg {
  position: absolute;
  left: 0;
  top: -14px;
  width: 100%;
  height: 28px;
  overflow: visible;
}

.pesa-plane-line__base {
  stroke: var(--plane-trail);
  stroke-opacity: 0.35;
  stroke-width: 1;
}

.pesa-plane-line__done {
  stroke: var(--plane-trail);
  stroke-width: 2;
  stroke-linecap: round;
}

@media print {
  .pesa-plane-trail,
  .pesa-plane-flight,
  .pesa-plane-line { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  .pesa-plane-trail,
  .pesa-plane-flight,
  .pesa-plane-line { display: none !important; }
}
