/* Stacked chapters and the dawn iris (the CSS half of js/core/chapters.js).
   On tall desktop screens, every chapter after the hero pulls itself up by 200svh with a negative
   margin and sits on a higher z-index, so it starts on top of the previous chapter's last screens.
   Its sticky frame is hidden behind a mask at first, and the JS opens the mask as you scroll.

   v1 opened each chapter with a different shape (circle, slash, curtains, split). v2 uses one:
   a soft-edged circle of light, the dawn iris, that grows from each chapter's focal point. The red
   sun swells at the end of the hero and the city opens out of it, so every chapter after that is
   another dawn. The soft edge (--iris-soft, 42vmin since V3) lets the old chapter glow through for a moment.

     world      opens from the sun, which sits right on the relic
     arts       opens from the wielder on the left
     districts  opens from the middle card
     end        opens from the seal

   --scene-tail and --scene-entry tell js/core/scroll-motion.js how each section is stacked. */

/* The wrappers are transparent where they overlap, so only the visible frame takes clicks. */
html.landing-motion :is(.world, .combat, .locations, .end) {
  pointer-events: none;
}
html.landing-motion :is(.world-frame, .combat-stage, .locations-stage, .end-stage) {
  pointer-events: auto;
}

@media (min-width: 761px) and (min-height: 780px) {
  html.landing-motion:not(.reduced):not(.compact-layout) {
    main > section {
      position: relative;
    }
    .hero {
      height: 285svh;
      z-index: 1;
      --scene-tail: 1;
    }
    .world {
      height: 245svh;
      margin-top: -200svh;
      z-index: 2;
      --scene-entry: 1;
      --iris-x: 75%;
      --iris-y: 50%;
    }
    .characters {
      height: 440svh;
      z-index: 3;
      --scene-tail: 1;
    }
    .combat {
      height: 545svh; /* V3: was 345svh. Two more screens, so the scroll steps through the three arts */
      margin-top: -200svh;
      z-index: 4;
      background: transparent;
      --scene-tail: 1;
      --scene-entry: 1;
      --iris-x: 27%;
      --iris-y: 58%;
    }
    .locations {
      height: 340svh;
      margin-top: -200svh;
      z-index: 5;
      background: transparent;
      --scene-tail: 1;
      --scene-entry: 1;
      --iris-x: 50%;
      --iris-y: 64%;
    }
    .end {
      height: 205svh;
      margin-top: -200svh;
      z-index: 6;
      background: transparent;
      --scene-entry: 1;
      --iris-x: 50%;
      --iris-y: 52%;
    }
    /* The iris edge is soft: a 140 px straight fade left a muddy grey
       band where a dark chapter met a light one. The edge is about three times wider and fades on a
       smoothstep curve, so the two chapters melt into each other. js/core/chapters.js grows the circle
       by the same 42vmin past the farthest corner. */
    :is(.world-frame, .combat-stage, .locations-stage, .end-stage) {
      --iris-soft: 42vmin;
      --iris-mask: radial-gradient(
        circle at var(--iris-x) var(--iris-y),
        #000 calc(var(--iris, 200vmax) - var(--iris-soft)),
        rgb(0 0 0 / 0.97) calc(var(--iris, 200vmax) - var(--iris-soft) * 0.9),
        rgb(0 0 0 / 0.85) calc(var(--iris, 200vmax) - var(--iris-soft) * 0.75),
        rgb(0 0 0 / 0.5) calc(var(--iris, 200vmax) - var(--iris-soft) * 0.5),
        rgb(0 0 0 / 0.15) calc(var(--iris, 200vmax) - var(--iris-soft) * 0.25),
        rgb(0 0 0 / 0.03) calc(var(--iris, 200vmax) - var(--iris-soft) * 0.1),
        transparent var(--iris, 200vmax)
      );
      -webkit-mask-image: var(--iris-mask);
      mask-image: var(--iris-mask);
    }
    /* Fully open: drop the mask, so the browser stops redrawing it */
    :is(.world-frame, .combat-stage, .locations-stage, .end-stage).iris-open {
      -webkit-mask-image: none;
      mask-image: none;
    }
  }
}

/* Reduced motion and short windows: chapters simply follow each other. */
html:is(.reduced, .compact-layout) :is(.world-frame, .combat-stage, .locations-stage, .end-stage) {
  -webkit-mask-image: none !important;
  mask-image: none !important;
}
