/* ==========================================================================
   Telamorph — Media carousel
   A lightweight crossfade carousel for background-image media tiles. Slides
   stack absolutely and the active one fades in; carousel.js auto-advances
   (paused on hover, focus and when offscreen) and injects clickable dots.
   Progressive enhancement: with no JS the first slide stays visible and no
   dots are added. Reduced motion: no autoplay and instant slide swaps.
   ========================================================================== */

/* Generic slide — used by the equipment frames and the composite pinned panel */
.media-carousel-slide {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: var(--focus, center);
  opacity: 0;
  transition: opacity 0.8s ease;
}

.media-carousel-slide.is-active {
  opacity: 1;
}

/* Step media reuses the existing .svc-media-bg slides so the scroll drift and
   hover zoom keep working; we layer the crossfade on top. The incoming slide
   also eases from slightly oversized down to the base zoom as it fades in —
   mirroring the composite scrolly's settle so the swap reads as an intentional
   move rather than a flat dissolve over a resizing frame. */
.svc-media[data-carousel] .svc-media-bg {
  opacity: 0;
  scale: 1.2;
  transition:
    scale 1.2s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.8s ease;
}

.svc-media[data-carousel] .svc-media-bg.is-active {
  opacity: 1;
  scale: 1.12;
}

/* Keep the hover zoom on the visible slide — must out-specify .is-active above. */
.svc-media[data-carousel]:hover .svc-media-bg.is-active {
  scale: 1.18;
}

/* --- Dots ---
   Each dot's clickable area is bigger than its visual mark: the button is
   the (invisible) hit target, sized via ::after so the dot still reads as
   small. Mouse/trackpad pointers keep a tight 22px box; touch gets the full
   44px (Apple/WCAG) minimum, since a finger can't aim at a 9px circle. */
.media-carousel-dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0.85rem;
  z-index: 3;
  display: flex;
  justify-content: center;
  gap: 0.3rem;
  pointer-events: none; /* let the container keep its hover/parallax behaviour */
}

.media-carousel-dot {
  pointer-events: auto;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.media-carousel-dot::after {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.55);
  transition:
    background-color var(--transition),
    transform var(--transition);
}

.media-carousel-dot:hover::after {
  background: rgba(255, 255, 255, 0.75);
}

.media-carousel-dot.is-active::after {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.3);
}

.media-carousel-dot:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 50%;
}

@media (hover: none), (pointer: coarse) {
  .media-carousel-dot {
    width: 44px;
    height: 44px;
  }
}

/* --- Prev/next arrows ---
   Hidden by default; precise pointers (mouse/trackpad) reveal them on
   hover/focus over the tile, matching the "press the sides" affordance.
   Touch has no hover state and uses swipe instead (see carousel.js), so the
   arrows never render there — nothing to accidentally tap. */
.media-carousel-arrow {
  position: absolute;
  top: 50%;
  translate: 0 -50%;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(10, 10, 12, 0.4);
  color: #fff;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity var(--transition),
    background-color var(--transition),
    border-color var(--transition);
}

.media-carousel-arrow--prev {
  left: 0.6rem;
}

.media-carousel-arrow--next {
  right: 0.6rem;
}

.media-carousel-arrow .icon-cycle {
  width: 14px;
  height: 14px;
}

.media-carousel-arrow:hover {
  background: rgba(10, 10, 12, 0.65);
  border-color: rgba(255, 255, 255, 0.6);
}

.media-carousel-arrow:focus-visible {
  opacity: 1;
  pointer-events: auto;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (hover: hover) and (pointer: fine) {
  [data-carousel]:hover .media-carousel-arrow,
  [data-carousel]:focus-within .media-carousel-arrow {
    opacity: 1;
    pointer-events: auto;
  }
}

@media (hover: none) {
  .media-carousel-arrow {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .media-carousel-slide,
  .svc-media[data-carousel] .svc-media-bg {
    transition: none;
  }

  .media-carousel-arrow {
    transition: none;
  }
}
