/*
 * LMS3 PDF slideshow (EXT:lms3pdfslides): the transition from one slide to the next. The package builder
 * copies this file to lib/transitions.css and gives every slide the transition as data-transition, only for
 * a slideshow with a transition (Service\Appearance): the packages without one stay as they were, and their
 * slides change at once.
 *
 * reveal.js hides every slide but the current one with the attribute "hidden", which lib/slides.css turns
 * into display: none (that keeps the slides out of the way of a theme's style sheet). For a transition, the
 * slides next to the current one, which reveal.js shows with display: block, stay shown, so that the slide
 * that goes can leave and the one that comes can enter. They stay out of reach of screen readers through
 * aria-hidden, and out of reach of the mouse through reveal.js (pointer-events: none).
 */
.reveal .slides > section[data-transition][hidden][style*="display: block"] {
  display: block !important;
}

/*
 * The slide that goes moves to the place of the slides before the current one (.past), the one that comes
 * from the place of the slides after it (.future); going back it is the other way round. So a slide comes from
 * the side the transition is named after when the learner goes forward, and from the opposite side going
 * back: what the slideshow does tells forward from back. Jumping through the menu, the slides in between go
 * from one place to the other unseen.
 *
 * The places are one width (or height) of the stage away, in the units of the slides, which reveal.js scales
 * by --slide-scale: a slide that leaves is out of sight also when it is much smaller than the stage, e.g. a
 * slide of landscape format on a phone held upright. Duration, curve and fading are those of the slide
 * transition of reveal.js (lib/reveal/reveal.css); only transform and opacity change.
 */
.reveal .slides > section[data-transition] {
  --slides-away-x: calc(var(--viewport-width, 100vw) / var(--slide-scale, 1));
  --slides-away-y: calc(var(--viewport-height, 100vh) / var(--slide-scale, 1));
}

/* from the right (as the slide transition of reveal.js): forward the next slide comes from the right */
.reveal .slides > section[data-transition="from-right"].past {
  transform: translate(calc(-1 * var(--slides-away-x)), 0);
}
.reveal .slides > section[data-transition="from-right"].future {
  transform: translate(var(--slides-away-x), 0);
}

/* from the left: forward the next slide comes from the left, the slide before goes to the right */
.reveal .slides > section[data-transition="from-left"].past {
  transform: translate(var(--slides-away-x), 0);
}
.reveal .slides > section[data-transition="from-left"].future {
  transform: translate(calc(-1 * var(--slides-away-x)), 0);
}

/* from the top: forward the next slide comes down from the top, the slide before goes down */
.reveal .slides > section[data-transition="from-top"].past {
  transform: translate(0, var(--slides-away-y));
}
.reveal .slides > section[data-transition="from-top"].future {
  transform: translate(0, calc(-1 * var(--slides-away-y)));
}

/* from the bottom: forward the next slide comes up from the bottom, the slide before goes up */
.reveal .slides > section[data-transition="from-bottom"].past {
  transform: translate(0, calc(-1 * var(--slides-away-y)));
}
.reveal .slides > section[data-transition="from-bottom"].future {
  transform: translate(0, var(--slides-away-y));
}

/*
 * A jump through the menu to a slide further away than the slides reveal.js keeps shown (viewDistance in
 * lib/slides.js): the slide that goes is gone at once and the one that comes was not shown, so it cannot come
 * from a side. It fades in instead, in the time of the transition. Not when the slideshow starts (.ready is
 * set by reveal.js after the first slide is shown).
 */
@starting-style {
  .reveal.ready .slides > section[data-transition].present {
    opacity: 0;
  }
}

/* with less motion in the settings of the system the slides change at once (as in lib/slides.css) */
@media (prefers-reduced-motion: reduce) {
  .reveal .slides > section[data-transition] {
    transition: none !important;
  }
}
