@media (max-width: 767px), (pointer: coarse) {
  #flight[data-form-draft][data-state=draft] .axis-form-canvas { opacity: 1; }
  #flight[data-form-draft][data-state=draft] .axis-form-poster { visibility: hidden; }
  #flight[data-form-production][data-form-draft] :is(.axis-form-canvas, .axis-form-poster) { transition: none; }
  #flight[data-form-return]:not([data-form-live]) .axis-form-canvas { opacity: 0; }
  #flight[data-form-return]:not([data-form-live]) .axis-form-poster { opacity: 1; visibility: visible; }
  #flight[data-form-return][data-form-live] .axis-form-poster { visibility: hidden; }

  #flight[data-form-production].is-static .axis-form-stage {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    height: auto;
    min-height: 0;
    padding: max(82px, calc(70px + env(safe-area-inset-top))) var(--gutter)
      max(12px, env(safe-area-inset-bottom));
    background: transparent;
  }
  #flight[data-form-production].is-static .axis-form-stage > picture {
    position: relative;
    grid-column: 1 / -1;
    grid-row: 2;
    height: clamp(120px, calc(100svh - 192px), 340px);
    overflow: hidden;
  }
  #flight[data-form-production].is-static .axis-form-poster { padding: 0; transform: scale(1.2); }
  @media (orientation: landscape) and (max-height: 500px) {
    #flight[data-form-production]:not(.is-static) .axis-form-poster { padding: 76px var(--gutter) 44px; }
  }
  #flight[data-form-production].is-static :is(.axis-form-caption, .axis-form-skip, .axis-form-status) { position: static; }
  #flight[data-form-production].is-static :is(.axis-form-caption, .axis-form-skip) { grid-row: 1; }
  #flight[data-form-production].is-static .axis-form-status { grid-column: 1 / -1; }
  #flight[data-form-production].is-static :is(.axis-form-phase:empty, .axis-form-status:empty, .axis-form-atmosphere) { display: none; }
}

@supports (animation-timeline: view()) and (width: hypot(3px, 4px)) {
  @media (max-width: 767px) and (prefers-reduced-motion: no-preference),
         (pointer: coarse) and (prefers-reduced-motion: no-preference) {
    /* The host keeps its compact fallback until it starts the scroll stage. */
    html.motion-enabled #flight[data-form-draft]:not(.is-static) .axis-form-poster {
      /* The stage is 100lvh tall (see the end of this file); the drawing keeps clear of the browser bar while it shows. */
      padding: min(21svh, 168px) var(--gutter) calc(min(7svh, 52px) + 100lvh - 100svh);
      animation: axis-form-drawing-scroll 1ms linear both;
      animation-timeline: --axis-form-entry;
      animation-range: contain 0% contain 100%;
    }
  }
}

@keyframes axis-form-drawing-scroll {
  from { transform: translateY(0) scale(1); }
  45% { transform: translateY(-3svh) scale(1.16); }
  to { transform: translateY(-7svh) scale(1.28); }
}

/* The finished scene's loading mark, under the status sentence: a hairline that fills, and the share loaded. */
#flight .axis-form-status[data-loaded]::after {
  content: attr(data-loaded);
  display: block;
  margin-top: 10px;
  padding-left: 144px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  background: linear-gradient(90deg, currentColor calc(var(--axis-form-loaded, 0) * 100%), color-mix(in oklch, currentColor 26%, transparent) 0) left center / 132px 1px no-repeat;
}

/* The drawing dissolves into the finished scene at the same camera pose. */
#flight .axis-form-dissolve {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  animation: axis-form-dissolve-out .7s ease-out both;
}
#flight[data-form-production][data-form-dissolve] .axis-form-canvas { animation: axis-form-dissolve-in .7s ease-out both; }
@keyframes axis-form-dissolve-out { to { opacity: 0; } }
@keyframes axis-form-dissolve-in { from { opacity: 0; } }

/* Phones hide the browser bars while scrolling, and the visible area grows from the small viewport (svh) to the
   large one (lvh). The sticky stage takes the large height once: nothing below the section shows under it, and the
   canvas is never resized by the bars. The section length stays in svh, so the scroll distance does not change. */
@media (max-width: 767px) and (prefers-reduced-motion: no-preference),
       (pointer: coarse) and (prefers-reduced-motion: no-preference) {
  html.motion-enabled #flight[data-form-production]:not(.is-static) .axis-form-stage { height: 100lvh; }
  /* While the bars are shown, the lowest (lvh - svh) of the stage sits under them; the status stays above. */
  html.motion-enabled #flight[data-form-production]:not(.is-static) .axis-form-status {
    bottom: calc(max(24px, env(safe-area-inset-bottom)) + 100lvh - 100svh);
  }
}

/* AXIS on portrait screens: a distant skyline sign in the sky band under the heading, never behind the header,
   the heading, the phase or "Dalshe". The whole word stays inside the frame; the building passes in front of it.
   One idea along the route: as the camera comes down from the approach to the street, the sign slowly rises over the
   roofline (true parallax of a far object), and it steps back into the haze while the camera looks down at the roof. */
@property --axis-form-word-sky {
  syntax: '<number>';
  inherits: false;
  initial-value: 1;
}
@media (max-aspect-ratio: 4/5) {
  #flight[data-form-production][data-backdrop=midwam-warm] .axis-form-word {
    --axis-form-word-alpha: .15;
    top: 212px;
    left: 50%;
    font-size: min(44vw, 24svh);
    filter: blur(.5px);
    opacity: calc(var(--studio-reveal, .8) * var(--axis-form-word-alpha) * var(--axis-form-word-sky, 1));
    mask-image: linear-gradient(#000 40%, #0008 72%, #0000 100%);
  }
}
@supports (animation-timeline: view()) and (width: hypot(3px, 4px)) {
  @media (max-aspect-ratio: 4/5) and (prefers-reduced-motion: no-preference) {
    html.motion-enabled #flight[data-form-production][data-backdrop=midwam-warm]:not(.is-static) .axis-form-word {
      animation: axis-form-word-skyline 1ms linear both;
      animation-timeline: --axis-form-entry;
      animation-range: contain 0% contain 100%;
    }
  }
}
/* Phases on this route: drawing to .27, approach .28-.39, around the building .40-.65, along the facade .66-.79,
   from the road .80-1. */
@keyframes axis-form-word-skyline {
  0%, 16% { --axis-form-word-sky: .35; }
  0% { translate: 0 9svh; }
  27% { --axis-form-word-sky: 1; }
  38% { --axis-form-word-sky: 1; }
  50%, 62% { --axis-form-word-sky: .45; }
  80%, 100% { --axis-form-word-sky: 1; }
  100% { translate: 0 0; }
}
