/* ==========================================================================
   Galaxy Star - hero slider
   --------------------------------------------------------------------------
   Slides the hero banners. The slides sit on top of each other and fade
   through, each one turning very slightly as it comes in, so the change reads
   as movement rather than as a flicker.

   Sized from two custom properties the PHP writes:
     --slide-h    height on a desktop
     --slide-h-m  height on a phone

   Rules it keeps to:
   - The viewport clips, so a slide can never widen the page. An overflowing
     slider is the classic way a carousel breaks a phone layout.
   - Every slide is the same height and its text sits in a fixed band, so
     swapping between a long caption and a short one does not make the page
     jump under the customer.
   - Nothing animates under prefers-reduced-motion.
   ========================================================================== */

.slider__viewport {
  position: relative;
  overflow: hidden;              /* the reason the page cannot be widened */
  min-height: var(--slide-h-m, 440px);
}

.slider__track {
  position: relative;
}

/*
  Stacked. opacity and visibility rather than display:none, so a hidden slide
  keeps its box and the height never changes as it turns. visibility is what
  takes it out of the tab order - otherwise a customer could tab into the links
  of a slide they cannot see.
*/
.slider__slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  transform: perspective(1200px) translate3d(0, 26px, 0) rotateX(5deg) scale(.985);
  transform-origin: 50% 60%;
  transition:
    opacity .72s cubic-bezier(.22, .68, .32, 1),
    transform .72s cubic-bezier(.22, .68, .32, 1),
    visibility 0s linear .72s;   /* only hide once the fade has finished */
  min-height: var(--slide-h-m, 440px);
  display: grid;
  align-items: center;
}

.slider__slide.is-on {
  opacity: 1;
  visibility: visible;
  transform: perspective(1200px) translate3d(0, 0, 0) rotateX(0deg) scale(1);
  transition-delay: 0s;
  z-index: 2;
}

@media (min-width: 761px) {
  .slider__viewport,
  .slider__slide { min-height: var(--slide-h, 520px); }
}

/* A soft wash so the words stay readable over any photograph. */
.slider__slide::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, .34), rgba(255, 255, 255, 0) 42%);
  pointer-events: none;
}

/* The words sit above that wash. */
.slider__slide .hero__grid {
  position: relative;
  z-index: 1;
  width: 100%;
}

/* --------------------------------------------------------------- the caption */
.slider__count {
  position: absolute;
  inset-block-end: 14px;
  inset-inline-end: 18px;
  z-index: 4;
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.slider__count b { color: var(--ink); font-size: 14px; }

/* -------------------------------------------------------------- the controls */
.slider__nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  padding-top: 16px;
  padding-bottom: 6px;
}

.slider__dots {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.slider__dot {
  /* 44px is the smallest comfortable tap target, so the button is that big and
     the visible dot is drawn inside it. A 10px dot is a 10px tap target, which
     is how a slider ends up being unusable on a phone. */
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  border-radius: 50%;
}
.slider__dot::after {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--line);
  transition: width .3s cubic-bezier(.2, .7, .3, 1), background-color .3s ease;
}
.slider__dot:hover::after { background: var(--pink-light); }
.slider__dot.is-on::after {
  width: 26px;
  border-radius: 999px;
  background: var(--pink);
}
.slider__dot:focus-visible { outline: 2px solid var(--pink); outline-offset: 2px; }

.slider__arrows {
  display: flex;
  gap: 8px;
}

.slider__arrow {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background-color .25s ease, color .25s ease, transform .25s ease, border-color .25s ease;
}
.slider__arrow:hover {
  background: var(--pink);
  border-color: var(--pink);
  color: #fff;
}
.slider__arrow:active { transform: scale(.94); }
.slider__arrow:focus-visible { outline: 2px solid var(--pink); outline-offset: 2px; }

/* The icon comes in pointing up, so it is turned to point sideways. */
.slider__arrow .ico { transform: rotate(90deg); }
.slider__arrow--prev .ico { transform: rotate(-90deg); }

/* --------------------------------------------------------- full-bleed option */
.hero--full .slider__viewport {
  width: 100vw;
  margin-inline: calc(50% - 50vw);
}

/* ------------------------------------------------------------ small screens */
@media (max-width: 760px) {
  .slider__nav { gap: 8px; padding-top: 12px; }
  .slider__count { inset-block-end: 10px; inset-inline-end: 12px; }
}

/* Touch has no hover, so the slide should not be sitting half-turned waiting
   for a pointer that will never arrive. */
@media (hover: none) {
  .slider__slide {
    transform: perspective(1200px) translate3d(0, 14px, 0) scale(.99);
  }
  .slider__slide.is-on {
    transform: none;
  }
}

/* ------------------------------------------------------------------ reduced */
@media (prefers-reduced-motion: reduce) {
  /*
    The slide still changes, it just arrives instead of turning. visibility
    needs no delay here or the outgoing slide would vanish on top of the
    incoming one.
  */
  .slider__slide {
    transform: none !important;
    transition: opacity .18s linear, visibility 0s linear 0s !important;
  }
  .slider__slide.is-on { transform: none !important; }

  .slider__dot::after,
  .slider__arrow,
  .slider__count {
    transition: none !important;
  }
  .slider__arrow:active { transform: none !important; }
}

/* If the browser is old enough to not do 3D, a plain fade is better than a
   flat sideways slide that looks like a mistake. */
@supports not (transform: perspective(1px)) {
  .slider__slide { transform: none; }
  .slider__slide.is-on { transform: none; }
}
