/**
 * Case Study Image Marquee — a rotated plane of counter-drifting image rows.
 *
 * The section is a fixed-height window. The plane inside it is oversized and
 * absolutely centred so that rotating it never uncovers a corner, and each row
 * clips its own track. No background is painted here: the Elementor section's
 * own background control shows through.
 */
.case-study-image-marquee {
  --case-study-marquee-gap: 14px;
  --case-study-marquee-row-gap: 14px;
  --case-study-marquee-rotate: -13deg;
  --case-study-marquee-plane-width: 135%;
  --case-study-marquee-plane-bleed: 440px;
  --case-study-marquee-height: 760px;
  position: relative;
  width: 100%;
  min-height: var(--case-study-marquee-height);
  overflow: hidden;
  isolation: isolate;
  color: #171a1b;
}

.case-study-image-marquee * {
  box-sizing: border-box;
}

/**
 * The plane bleeds past the section on every side, because rotating a wide
 * rectangle needs roughly width x sin(angle) of extra height to keep the
 * section's corners covered. The rows then divide whatever height the plane
 * has, so the image height follows from the row count instead of being a
 * second number an editor has to keep in step.
 */
.case-study-image-marquee__plane {
  position: absolute;
  top: 50%;
  left: 50%;
  display: flex;
  flex-direction: column;
  gap: var(--case-study-marquee-row-gap);
  width: var(--case-study-marquee-plane-width);
  height: calc(var(--case-study-marquee-height) + var(--case-study-marquee-plane-bleed));
  transform: translate(-50%, -50%) rotate(var(--case-study-marquee-rotate));
  transform-origin: center center;
}

.case-study-image-marquee__row {
  flex: 1 1 0;
  min-height: 0;
}

.case-study-image-marquee__viewport {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.case-study-image-marquee__viewport:focus-visible {
  outline: 3px solid currentColor;
  outline-offset: -3px;
}

.case-study-image-marquee__track {
  display: flex;
  align-items: stretch;
  width: max-content;
  min-width: max-content;
  height: 100%;
  gap: var(--case-study-marquee-gap);
  margin: 0;
  padding: 0;
  list-style: none;
  transform: translate3d(0, 0, 0);
  will-change: transform;
}

.case-study-image-marquee__item {
  flex: 0 0 auto;
  width: auto;
  margin: 0;
}

.case-study-image-marquee__figure {
  position: relative;
  height: 100%;
  margin: 0;
  overflow: hidden;
  box-shadow: 0 18px 44px rgba(17, 24, 24, 0.14);
}

/* Double-scoped to outrank Elementor's own `.elementor img` height/max-width. */
.case-study-image-marquee .case-study-image-marquee__image {
  display: block;
  width: auto;
  height: 100%;
  max-width: none;
  object-fit: contain;
}

.case-study-image-marquee__figure figcaption {
  position: absolute;
  right: 12px;
  bottom: 12px;
  max-width: calc(100% - 24px);
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(17, 24, 24, 0.78);
  color: #fff;
  font-size: 0.75rem;
  line-height: 1.2;
  letter-spacing: 0.02em;
}

.case-study-image-marquee--empty {
  display: grid;
  min-height: 200px;
  place-items: center;
  padding: 40px;
  border: 1px dashed rgba(23, 26, 27, 0.32);
  background: transparent;
}

.case-study-image-marquee--empty p {
  margin: 0;
  color: inherit;
  font-size: 0.95rem;
}

@media (max-width: 767px) {
  .case-study-image-marquee {
    --case-study-marquee-gap: 8px;
    --case-study-marquee-row-gap: 8px;
    --case-study-marquee-plane-width: 150%;
  }
}

/**
 * Reduced motion un-rotates the plane into an ordinary stack of rows, each
 * scrollable by keyboard, so every image stays reachable without any travel.
 */
@media (prefers-reduced-motion: reduce) {
  .case-study-image-marquee {
    min-height: 0;
  }

  .case-study-image-marquee__plane {
    position: static;
    width: 100%;
    height: auto;
    transform: none;
  }

  .case-study-image-marquee__row {
    flex: 0 0 auto;
    height: min(48vw, 240px);
  }

  .case-study-image-marquee__viewport {
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
  }

  .case-study-image-marquee__track {
    transform: none !important;
    will-change: auto;
  }

  .case-study-image-marquee__item {
    scroll-snap-align: start;
  }
}
