/**
 * slider.css — home slider (Q81, template-parts/home/slider.php + assets/js/slider.js). Written from the values
 * measured on the live (LayerSlider 6 «Homepage» / «Homepage Mobile»); nothing of LayerSlider is used.
 *
 * Every layer carries its canvas position/size (--x --y --w --h, canvas px) and the stage its canvas (--sw --sh):
 * one canvas px is --u = slider width / canvas width, the scale the live applies. The stage height is the canvas
 * height on that scale rounded to whole pixels, as on the live (1366 → 662, 768 → 372, mobile 600–767 → 1000/900);
 * the mobile slider is 178vw tall up to 600px (former theme rule). Motion: layers fade in 1000ms and out 770ms
 * (easeInOutQuint), loops zoom back and forth after the fade-in, a slide lasts 5000ms from the start of its fade-in.
 */

.np-slider {
  container-type: inline-size;
  position: relative;
  width: 100%;
}

.np-slider__stage {
  --u: calc(100cqw / var(--sw));
  position: relative;
  width: 100%;
  margin: 0 auto;
  aspect-ratio: var(--sw) / var(--sh);
  height: round(nearest, calc(100cqw * var(--sh) / var(--sw)), 1px);
  overflow: hidden;
  /* the live never lets the visitor select or drag the pictures of the slider */
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: pan-y;
}

/* device split: the live gave phones the mobile slider and every other device the desktop one */
.np-slider__stage--mobile { display: none; }
@media (max-width: 767px) {
  .np-slider__stage--desktop { display: none; }
  .np-slider__stage--mobile { display: block; }
}
@media (max-width: 600px) {
  .np-slider__stage--mobile { height: 178vw; }
}

.np-slider__slide {
  position: absolute;
  inset: 0;
  display: none;
  z-index: 1;
}
.np-slider__slide.is-active,
.np-slider__slide.is-leaving,
.np-slider__slide.is-prepared { display: block; }
.np-slider__slide.is-active { z-index: 2; }
/* the incoming slide is drawn over the leaving one (as on the live: its layers come later in the stack) */
.np-slider__slide.is-leaving { z-index: 1; }

.np-slider__layer {
  position: absolute;
  left: calc(var(--x, 0) * var(--u));
  top: calc(var(--y, 0) * var(--u));
  width: calc(var(--w) * var(--u));
  height: calc(var(--h) * var(--u));
  margin: 0;
  padding: 0;
  opacity: 0;
  transition: opacity 770ms cubic-bezier(0.83, 0, 0.17, 1);
  pointer-events: none;
  /* each layer is its own compositing layer, as on the live: the pictures are scaled the same way (GPU), pixel for
     pixel; without it the downscaled photos differ at their edges (0.5% of the mobile slider) */
  will-change: opacity;
}
.np-slider__layer.is-cx { left: calc(50% - var(--w) * var(--u) / 2); }
.np-slider__layer.is-cy { top: calc(50% - var(--h) * var(--u) / 2); }
.np-slider__layer.is-auto { width: auto; height: auto; }
.np-slider__layer.is-auto.is-cx { left: 50%; translate: -50% 0; }
.np-slider__layer.is-auto.is-cy { top: 50%; translate: 0 -50%; }
.np-slider__layer.is-auto.is-cx.is-cy { translate: -50% -50%; }

.np-slider__slide.is-active .np-slider__layer {
  opacity: 1;
  transition: opacity 1000ms cubic-bezier(0.83, 0, 0.17, 1);
}
/* before the script has started the slider nothing shows (the live keeps the slider hidden until it starts) */
.np-slider__stage:not(.is-started) .np-slider__layer { transition: none; }
.np-slider__stage:not(.is-started) .np-slider__slide.is-active .np-slider__layer { opacity: 0; }
.np-slider__stage.is-instant .np-slider__layer { transition: none; }

.np-slider__img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: none;
  -webkit-user-drag: none;
}
.np-slider__layer.is-auto .np-slider__img {
  width: auto;
  height: auto;
  max-width: none;
}

.np-slider__text {
  margin: 0;
  padding: 0;
  white-space: nowrap;
  font-size: calc(var(--fs, 16) * var(--u));
  line-height: calc(var(--lh, 20) * var(--u));
}
.np-slider__layer--text:not(.is-auto) .np-slider__text { white-space: normal; }
.np-slider__layer--text:not(.is-auto) { height: auto; }

/* endless zoom of a layer (1 ↔ --ls), started when the slide's fade-in has ended (class is-in) */
.np-slider__loop {
  width: 100%;
  height: 100%;
  transform-origin: 50% 50%;
}
.np-slider__slide.is-in .np-slider__loop {
  animation: np-slider-loop var(--ld, 2000ms) var(--le, ease-in-out) infinite alternate;
}
@keyframes np-slider-loop {
  from { transform: scale(1); }
  to { transform: scale(var(--ls, 1.1)); }
}

/* the whole slide as a link (when the editor gives one): over every layer */
.np-slider__link {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}
.np-slider__slide.is-active .np-slider__link { pointer-events: auto; }
.np-slider__link:focus-visible {
  outline: 3px solid #fff;
  outline-offset: -6px;
}

@media (prefers-reduced-motion: reduce) {
  .np-slider__layer,
  .np-slider__slide.is-active .np-slider__layer { transition: none; }
  .np-slider__slide.is-in .np-slider__loop { animation: none; }
}
