.download {
  position: relative;
  height: 100dvh;
  overflow: clip;
  outline: none;
  --download-sky: linear-gradient(#1c3459, #506f97);
  background: var(--download-sky);
}
.porthole-sky-still { display: none; }
[data-static-porthole] .porthole-sky-still {
  display: block;
  position: absolute;
  inset: 0;
  background: var(--download-sky);
  opacity: clamp(0, (var(--still-approach, 0) - .18) / .82, 1);
  pointer-events: none;
}
.porthole-frame.flight-camera {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  mask-image: none;
  pointer-events: none;
}
[data-window-flight] .porthole::before {
  opacity: calc((1 - .93 * var(--shade-drop)) * var(--wall-light));
}
[data-window-flight] .shade-control { visibility: hidden; }
[data-window-flight] .focus-copy {
  z-index: 1;
  opacity: calc(1 - var(--copy-exit, 0));
  transform: translateX(calc(clamp(-44px, -3vw, -16px) * var(--copy-exit, 0)));
  --cabin-defocus: calc(6px * var(--copy-exit, 0));
}

/* Paint the soft glyph as ink, allowing its blur to extend past the line box. */
@media (prefers-reduced-motion: no-preference) and (forced-colors: none) {
  .focus-copy .motion-glyph {
    --ink-blur: calc((1 - var(--blur-progress, var(--glyph-focus))) * var(--type-blur, min(.16em, 8px)));
    filter: none;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 calc(var(--ink-blur) + var(--cabin-defocus, 0px)) currentColor;
  }
}
.sky-meteor {
  position: absolute;
  inset: 0 auto auto 0;
  z-index: 1;
  pointer-events: none;
  transform-origin: 0 50%;
}

.download-layout {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  height: 100%;
  padding: 0 max(16px, env(safe-area-inset-left), env(safe-area-inset-right));
  color: #f6f8fb;
}
.download-copy {
  width: min(100%, 64rem);
  container-type: inline-size;
  text-align: center;
}
.download-label {
  display: block;
  font: 600 clamp(18px, 1.8vw, 30px)/1.2 -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
  font-stretch: 132%;
  color: #c9daec;
}
.download-copy h2 {
  margin: clamp(8px, 1.3dvh, 16px) 0 0;
  font: 600 clamp(48px, 8.3vw, 144px)/1.03 -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
  letter-spacing: -.035em;
}
.download-copy p {
  margin: clamp(8px, 1.5dvh, 18px) 0 0;
  font-size: clamp(20px, 2.3vw, 38px);
  line-height: 1.3;
  color: #e3eaf4;
}
.download-awards,
.download-copy .hero-actions {
  --pair-gap: clamp(12px, 1.4vw, 24px);
  --badge-height: min(clamp(46px, 4.3vw, 72px), (100cqw - var(--pair-gap)) / var(--pair-aspect, 6.94));
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: nowrap;
  gap: var(--pair-gap);
}
.download-awards { margin-top: clamp(24px, 4dvh, 48px); }
.download-awards img {
  display: block;
  width: auto;
  height: calc(.88 * var(--badge-height));
}
.download-copy .hero-actions { margin-top: clamp(18px, 2.8dvh, 34px); }
.download-copy .hero-actions img { width: auto; }
:lang(ko) .download-copy .hero-actions { --pair-aspect: 7.27; }
.download-copy .download-count {
  margin-top: clamp(8px, 1.5dvh, 16px);
  color: #c9daec;
  font-size: clamp(13px, 1.15vw, 17px);
}

/* Keep the sky and download content in their final viewport throughout the flight. */
[data-window-flight] .deep-focus { translate: 0 var(--cabin-offset); }
[data-window-flight] .download {
  z-index: 3;
  background: transparent;
  pointer-events: none;
}
[data-window-flight] .download-layout:not([inert]) a { pointer-events: auto; }
.download-copy .hero-actions a { animation: none; }

@media (max-height: 520px) and (orientation: landscape) {
  .download-layout {
    padding-top: calc(var(--header-top) + var(--header-height) + 8px);
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
  .download-label { font-size: 16px; }
  .download-copy h2 { font-size: clamp(34px, 11dvh, 52px); margin-top: 4px; }
  .download-copy p { margin-top: 4px; font-size: 18px; }
  .download-awards, .download-copy .hero-actions {
    --badge-height: clamp(34px, 10dvh, 44px);
    margin-top: 10px;
  }
}

.download-sketches {
  display: contents;
  pointer-events: none;
  user-select: none;
}
.download-sketches img {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--size);
  height: auto;
  translate: -50% -50%;
  rotate: var(--tilt, 0deg);
  opacity: .84;
}
.sketch-mac {
  --x: 18%; --y: 54%; --size: clamp(86px, 14vw, 214px);
  --tilt: -10deg; --period: 7s; --delay: -4s;
}
.sketch-iphone {
  --x: 77%; --y: 30%; --size: clamp(40px, 5.3vw, 84px);
  --tilt: 11deg; --period: 5.8s; --delay: -1s;
}
.sketch-ipad {
  --x: 81%; --y: 71%; --size: clamp(76px, 11vw, 170px);
  --tilt: 9deg; --period: 8.2s; --delay: -7s;
}
.sketch-cloud {
  --x: 14%; --y: 32%; --size: clamp(42px, 5vw, 82px);
  --tilt: -6deg; --period: 8s; --delay: -3s;
}
.sketch-plane {
  --x: 33%; --y: 84%; --size: clamp(55px, 6.4vw, 102px);
  --tilt: 6deg; --period: 7.6s; --delay: -5s;
}
.download-sketches .sketch-star { opacity: .91; }
.star-rise { --x: 26%; --y: 30%; --size: clamp(27px, 3.4vw, 51px); --tilt: -8deg; }
.star-east { --x: 86%; --y: 44%; --size: clamp(21px, 2.6vw, 40px); --tilt: 14deg; --delay: -3s; }
.star-west { --x: 11%; --y: 66%; --size: clamp(10px, 1.05vw, 17px); --delay: -5s; }
.star-south { --x: 67%; --y: 80%; --size: clamp(15px, 1.55vw, 25px); --tilt: -10deg; --delay: -8s; }
.star-high { --x: 64%; --y: 23%; --size: clamp(9px, .85vw, 14px); --tilt: 9deg; }

/* The climbing camera pitches up, so the sky travels down the screen.
   Each cue is a position on that same reversible camera path. */
@media (prefers-reduced-motion: no-preference) {
  .star-high { --cue: 0; }
  .sketch-cloud { --cue: .025; }
  .star-rise { --cue: .06; }
  .sketch-iphone { --cue: .095; }
  .download-label { --cue: .12; }
  .download-copy h2 { --cue: .18; --travel: clamp(26px, 5dvh, 54px); --defocus: 11px; }
  .star-east { --cue: .21; }
  .sketch-mac { --cue: .25; }
  .download-copy p { --cue: .30; }
  .star-west { --cue: .34; }
  .download-awards img { --cue: .38; }
  .download-awards img + img { --cue: .415; }
  .sketch-ipad { --cue: .445; }
  .sketch-plane { --cue: .475; }
  .download-copy .hero-actions a { --cue: .50; }
  .download-copy .hero-actions a + a { --cue: .535; }
  .download-copy .download-count { --cue: .55; }
  .star-south { --cue: .56; }

  .download-sketches img {
    --anchor: -50%;
    --travel: clamp(34px, 7dvh, 76px);
    --defocus: 8px;
    --ink: .84;
  }
  .download-sketches .sketch-star {
    --travel: clamp(16px, 3.5dvh, 36px);
    --defocus: 4px;
    --ink: .91;
  }
  [data-window-flight] :is(.download-sketches img, .download-label, .download-copy h2,
      .download-copy p, .download-awards img, .download-copy .hero-actions a) {
    --p: clamp(0, (var(--download-arrival, 0) - var(--cue)) / .44, 1);
    --rest: calc((1 - var(--p)) * (1 - var(--p)));
    opacity: calc(var(--ink, 1) * var(--p) * var(--p) * (3 - 2 * var(--p)));
    translate: var(--anchor, 0px) calc(var(--anchor, 0px) - var(--travel, clamp(20px, 4dvh, 42px)) * var(--rest));
    filter: blur(calc(var(--defocus, 7px) * var(--rest)));
  }
  @media (max-width: 700px) and (orientation: portrait) {
    .sketch-mac { --cue: .045; }
    .star-east { --cue: .08; }
    .star-west { --cue: .44; }
  }
}
@media (prefers-reduced-motion: reduce) {
  [data-window-flight] .download-layout { opacity: var(--download-arrival, 0); }
}

@media (prefers-reduced-motion: no-preference) {
  .download-sketches img {
    animation: sketch-float var(--period, 6.4s) var(--button-press) var(--delay, -2s) infinite alternate;
  }
  .download-layout[inert] .download-sketches img { animation-play-state: paused; }
}
@keyframes sketch-float {
  from { transform: translateY(3px) rotate(-1deg); }
  to { transform: translateY(-4px) rotate(1deg); }
}

@media (max-width: 700px) and (orientation: portrait) {
  .download-layout { grid-template-rows: 1fr auto 1fr; }
  .download-copy { grid-row: 2; }
  /* Anchor drawings in the free rows above and below the actual copy. */
  .download-sketches img { grid-row: 1 / 2; --y: calc(50% + (var(--header-top) + var(--header-height)) / 2); }
  .download-sketches :is(.sketch-ipad, .sketch-plane, .star-west, .star-south) { grid-row: 3 / 4; --y: 47%; }
  .sketch-mac { --x: 22%; --size: min(22vw, 13dvh); }
  .sketch-iphone { --x: 79%; --size: min(10vw, 6.6dvh); }
  .sketch-ipad { --x: 68%; --size: min(22vw, 14dvh); }
  .sketch-cloud { --x: 50%; --size: min(12vw, 6dvh); margin-top: -15px; }
  .sketch-plane { --x: 89%; --size: min(12vw, 7dvh); margin-top: -32px; }
  .star-rise { --x: 43%; --size: 22px; }
  .download-sketches .star-rise { margin-top: 14px; }
  .star-east { --x: 91%; --size: 16px; }
  .download-sketches .star-east { margin-top: -20px; }
  .star-west { --x: 42%; --size: 11px; margin-top: 34px; }
  .star-south { --x: 85%; --size: 12px; }
  .download-sketches .star-high { --x: 57%; margin-top: 12px; }
  .download-sketches .star-south { margin-top: 14px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .sketch-mac { --x: 14%; --y: 58%; --size: min(14vw, 30dvh); }
  .sketch-iphone { --x: 82%; --y: 40%; --size: min(5.3vw, 10dvh); }
  .sketch-ipad { --x: 86%; --y: 78%; --size: min(12vw, 23dvh); }
  .sketch-cloud { --x: 12%; --y: 33%; --size: min(8vw, 12dvh); }
  .sketch-plane { --x: 28%; --y: 89%; --size: min(8vw, 13dvh); }
  .star-high { --x: 68%; --y: 33%; }
  .star-east { --x: 92%; --y: 54%; }
  .star-west { --x: 6%; --y: 72%; }
  .star-south { --x: 73%; --y: 90%; }
}
