/* FALLSHIFT prologue: a scroll-linked opening that sits above the Echo Falls lookout.
   It plays itself slowly on open, and the reader can scroll back up to any beat. */

html.pro-pending body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 90;
  background: #05070d;
}

/* Length of the prologue, in screens. Zero when motion is off. */
#desk[data-arrival][data-mode="jacket"] { --pro-screens: 8; --pro: calc(var(--pro-screens) * 100svh); }
body[data-motion="off"] #desk[data-arrival] { --pro-screens: 0; }
@media (prefers-reduced-motion: reduce) { #desk[data-arrival] { --pro-screens: 0; } }

/* Push the lookout, cover and scroll space down below the prologue. */
#desk[data-arrival][data-mode="jacket"] #cover-info { top: calc(var(--pro) + 100svh - var(--arrival-floor)); z-index: 3; }
#desk[data-arrival][data-mode="jacket"] .scene { top: calc(var(--pro) + 150svh); }
#desk[data-arrival][data-mode="jacket"] #cover-tools { top: calc(var(--pro) + 200svh - 60px); }
#desk[data-mode="jacket"] .arrival-scroll-space { height: calc(var(--pro) + 250svh); }

.prologue, .pro-ui { display: none; }
#desk[data-arrival][data-mode="jacket"] .prologue {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
  perspective: 1400px;
  color: #fff0dc;
}
body[data-motion="off"] .prologue, body[data-motion="off"] .pro-ui { display: none !important; }

.pro-bg { position: absolute; inset: 0; background: #05070d; }

.pro-beat {
  position: absolute;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  margin: 0;
  text-align: center;
}
.mask { display: inline-block; overflow: hidden; vertical-align: top; padding: .06em .04em .1em; margin: -.06em -.04em -.1em; }
.mask > span { display: inline-block; will-change: transform; }

/* Beat 1: place and time. */
.pro-date {
  display: grid;
  justify-items: center;
  gap: 18px;
  font: 500 clamp(12px, 1.05vw, 15px)/1 Mono, ui-monospace, monospace;
  letter-spacing: .42em;
  text-transform: uppercase;
  white-space: nowrap;
}
.pro-date .place { font: clamp(44px, 7vw, 112px)/.9 Bang, Impact, sans-serif; letter-spacing: .02em; color: #fff0dc; }
.pro-date .time { color: #8eeeff; }
.pro-rule { display: block; width: min(320px, 60vw); height: 1px; background: linear-gradient(90deg, transparent, #8eeeff, transparent); transform-origin: 50% 50%; }

/* Beat 2: the line. */
.pro-caption {
  width: min(92vw, 15ch);
  font: clamp(48px, 8.4vw, 132px)/.92 Bang, Impact, sans-serif;
  letter-spacing: .01em;
  color: #fff0dc;
}
.pro-caption em { font-style: normal; color: #8eeeff; }
.pro-caption .line { display: block; }

/* Beat 3: the river, framed like a wide panel. Art never shown above its real size. */
.pro-river {
  position: absolute;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  width: min(92vw, 1600px);
  aspect-ratio: 2.25;
  max-height: 74svh;
  margin: 0;
  overflow: hidden;
  border: clamp(3px, .3vw, 5px) solid #0b0b10;
  outline: 1px solid #fff0dc22;
  background: #0b1222;
  will-change: transform, opacity;
}
.pro-river img {
  position: absolute;
  left: -7%;
  top: -7%;
  width: 114%;
  height: 114%;
  object-fit: cover;
  will-change: transform;
}
.pro-river canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.pro-river::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, #05070dcc, transparent 34%), radial-gradient(ellipse at 50% 40%, transparent 50%, #05070d88);
}
.pro-clock {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: 7%;
  translate: -50% 0;
  margin: 0;
  font: 500 clamp(13px, 1.4vw, 20px)/1 Mono, ui-monospace, monospace;
  letter-spacing: .28em;
  color: #e9fbff;
  text-shadow: 0 0 18px #49e6ff;
  white-space: nowrap;
}
.pro-clock b { color: #8eeeff; font-weight: 500; }
.pro-clock small { display: block; margin-top: 10px; font-size: .62em; letter-spacing: .34em; color: #cfd8e2; text-shadow: none; }

/* Beat 4: a comic page, panel by panel. */
.pro-page {
  position: absolute;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  width: min(94vw, 1280px, calc(88svh * 1.62));
  aspect-ratio: 1.62;
  display: grid;
  grid-template: 1fr 1fr / 1fr 1.55fr;
  grid-template-areas: "adam sara" "adam room";
  gap: clamp(8px, 1vw, 14px);
  transform-style: preserve-3d;
  will-change: transform;
}
.pro-panel {
  position: relative;
  margin: 0;
  overflow: hidden;
  border: clamp(3px, .32vw, 5px) solid #0b0b10;
  background: #111520;
  box-shadow: 0 30px 60px -20px #000c;
  will-change: transform, opacity;
}
.pro-panel img {
  position: absolute;
  left: 0;
  top: -8%;
  width: 100%;
  height: 116%;
  object-fit: cover;
  will-change: transform;
}
.pro-panel.adam { grid-area: adam; }
.pro-panel.adam img { object-position: 36% 30%; }
.pro-panel.sara { grid-area: sara; }
.pro-panel.sara img { object-position: 78% 52%; }
.pro-panel.room { grid-area: room; }
.pro-panel.room img { object-position: 50% 96%; }

.pro-box {
  position: absolute;
  z-index: 1;
  max-width: 23ch;
  margin: 0;
  padding: .6em .8em;
  border: 2px solid #0b0b10;
  background: #ffe066;
  color: #0b0b10;
  font: 700 clamp(12px, 1.12vw, 17px)/1.28 Comic, "Comic Neue", sans-serif;
  text-transform: uppercase;
  box-shadow: 4px 4px 0 #0b0b10;
  will-change: transform;
}
.adam .pro-box { left: 6%; bottom: 5%; }
.sara .pro-box { right: 4%; top: 7%; background: #fff4e2; }
.room .pro-box { left: 3%; top: 7%; }
.pro-sfx {
  position: absolute;
  z-index: 1;
  right: 5%;
  top: 6%;
  margin: 0;
  font: clamp(34px, 4.6vw, 74px)/1 Bang, Impact, sans-serif;
  color: #8eeeff;
  -webkit-text-stroke: clamp(1.5px, .2vw, 3px) #0b0b10;
  paint-order: stroke fill;
  text-shadow: 5px 5px 0 #0b0b10;
  rotate: -12deg;
  will-change: transform;
}

/* Controls while the prologue is on screen. */
#desk[data-arrival][data-mode="jacket"] .pro-ui {
  display: flex;
  align-items: center;
  gap: 14px;
  position: fixed;
  z-index: 5;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  translate: -50% 0;
  white-space: nowrap;
}
.pro-ui[data-hidden] { visibility: hidden; }
.pro-hint { color: #cfd8e2; font: 500 12px/1 DM, system-ui, sans-serif; letter-spacing: .08em; text-transform: uppercase; }
.pro-skip, .replay-intro {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid #fff0dc66;
  border-radius: 999px;
  background: #05070dcc;
  color: #fff0dc;
  font: 500 13px/1 DM, system-ui, sans-serif;
  letter-spacing: .04em;
  cursor: pointer;
}
.pro-skip:hover, .pro-skip:focus-visible, .replay-intro:hover, .replay-intro:focus-visible { background: #fff0dc; color: #05070d; }
#desk[data-arrival][data-mode="jacket"] .cover-actions .replay-intro { min-height: 40px; }

/* Title letters and the cyan double that trails them. */
#cover-info h1 .ch { display: inline-block; will-change: transform; }
#cover-info { isolation: isolate; }
#cover-info .title-echo {
  position: absolute;
  z-index: -1;
  margin: 0 !important;
  pointer-events: none;
  color: #8eeeff !important;
  text-shadow: 0 0 24px #49e6ff99 !important;
}
#cover-info .title-echo em { color: inherit !important; }

@media (max-width: 760px), (orientation: portrait) {
  .pro-page {
    width: min(92vw, 520px);
    height: min(82svh, 860px);
    aspect-ratio: auto;
    grid-template: 1.25fr 1fr 1fr / 1fr;
    grid-template-areas: "adam" "sara" "room";
  }
  .pro-panel.sara img { object-position: 80% 50%; }
  .pro-river { width: 94vw; aspect-ratio: .78; }
  .pro-river img { object-position: 49% 50%; }
  .pro-hint { display: none; }
}

/* While the prologue covers the screen, stop painting the lookout and its looping water and mist. */
#desk[data-pro-covered] :is(.arrival-world, .arrival-current) { visibility: hidden; }
#desk[data-pro-covered] .arrival-world > div { animation-play-state: paused; }