/* The beat: the hand-over from the drowned city to the revenants (js/sections/beat.js).
   .beat is only scroll length: with motion on, everything happens on one fixed layer, the seam,
   so the city never slides away as a block and the roster never rises as one. With reduced motion
   the seam is off and .beat simply shows its line between the two chapters. */

.beat {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  min-height: 90svh;
  padding: 0 var(--pad);
  text-align: center;
  background: var(--surface-revenants);
}
/* the seam has its own copy of the line */
html:not(.reduced):not(.compact-layout) .beat-line {
  visibility: hidden;
}

/* ---------- The seam ---------- */
.seam {
  position: fixed;
  inset: 0;
  z-index: 11; /* under the petals (12), the rail and the brand, over every chapter */
  overflow: hidden;
  pointer-events: none;
  visibility: hidden;
}
.seam.on {
  visibility: visible;
}
html:is(.reduced, .compact-layout) .seam {
  display: none;
}

/* The city, its shade and the night, faded together when the night lifts */
.seam-back {
  position: absolute;
  inset: 0;
  opacity: var(--back, 1);
}
/* the same plate, size and grade as .world-art, so the hand-over can't be seen */
.seam-city {
  position: absolute;
  inset: -8%;
  width: 116%;
  height: 116%;
  max-width: none;
  object-fit: cover;
  filter: saturate(0.75);
  will-change: transform; /* graded once, then only moved */
}
.seam-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, #0a100bea, #0a100b77 50%, #0a100b08), linear-gradient(0deg, #111510e0, transparent 40%);
}
.seam-night {
  position: absolute;
  inset: 0;
  background: #04080c; /* a cold night, so the ghosts' pale light reads */
  opacity: var(--night, 0);
}

/* The line, a little above the middle, so the ghosts rise beneath it */
.seam-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 26%;
  padding: 0 var(--pad);
  text-align: center;
  color: var(--paper);
  opacity: var(--line, 0);
  filter: blur(calc((1 - var(--line-sharp, 1)) * 8px));
  transform: translateY(calc(-50% + var(--line-y, 0px)));
}

/* ---------- The ghosts ----------
   Each ghost's box has the size and place of the roster's portrait (.character-art-wrap), and the JS
   only moves and scales it. That's why Aya's lands exactly on the real Aya. */
.seam-ghost {
  position: absolute;
  left: 0;
  bottom: 8%;
  width: 61%;
  height: 72%;
  transform-origin: 50% 75%;
  opacity: var(--ghost-a, 0);
  transform: translate3d(var(--ghost-x, 0px), var(--ghost-y, 0px), 0) scale(var(--ghost-s, 1)) rotate(var(--ghost-r, 0deg));
  will-change: transform, opacity;
}
.seam-ghost :is(img, .living-frame) {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
}
/* Two copies of Aya: the ghost (pale, glowing) and her real colours, cross-faded by --solid.
   Fading two finished pictures is cheap. Animating the filter itself would repaint every frame. */
.seam-ghost .pale {
  filter: grayscale(1) brightness(1.6) drop-shadow(0 0 24px #9fd8cc);
  opacity: calc(1 - var(--solid, 0));
}
.seam-ghost .true {
  filter: drop-shadow(0 20px 22px #0005); /* the roster portrait's own shadow */
  opacity: var(--solid, 0);
}

/* ---------- Tablet and phone: the boxes follow the roster portrait's own layout ---------- */
@media (max-width: 1100px) {
  .seam-ghost {
    width: 60%;
    left: -2%;
  }
}
@media (max-width: 760px) {
  .beat {
    min-height: 70svh;
  }
  .seam-ghost {
    top: 13%;
    bottom: auto;
    left: auto;
    right: -20%;
    width: 96%;
    height: 58%;
  }
  .seam-ghost :is(img, .living-frame) {
    object-position: center top;
  }
}
