[data-machine-gallery] .thumbs {
  justify-content: center;
  gap: 10px;
  overflow-x: auto;
  padding: 6px 8px;
}

[data-machine-gallery] .machine-thumb {
  position: relative;
  border: 2px solid transparent;
  border-radius: 4px;
  margin: 0 2px;
  display: inline-block;
  flex: 0 0 auto;
  background: transparent;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
}

/* Thumbnail images: approx 60-70px square on desktop */

[data-machine-gallery] .machine-thumb img {
  width: 66px;
  height: 66px;
  object-fit: contain;
  display: block;
  border-radius: 4px;
}

/* Active thumbnail border (orange) */

[data-machine-gallery] .machine-thumb.active {
  border-color: #f4771e;
}

/* Video thumbnail overlay: darker and a centered white play icon */

[data-machine-gallery] .machine-thumb.video-thumb .video-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.45);
  border-radius: 4px;
  pointer-events: none;
}

[data-machine-gallery] .machine-thumb.video-thumb .video-overlay svg {
  width: 28px;
  height: 28px;
  display: block;
  opacity: 0.98;
}

/* Make overlay invisible when not needed for accessibility (screen-readers will still see button) */

[data-machine-gallery] .machine-thumb.video-thumb img {
  display: block;
}

/* Slightly smaller thumbs on narrow viewports and allow horizontal scroll */

@media (max-width: 767.98px) {
  [data-machine-gallery] .machine-thumb img {
    width: 48px;
    height: 48px;
  }
}

@media (max-width: 767.98px) {
  [data-machine-gallery] .thumbs {
    gap: 8px;
  }
}

/* Ensure videos inside the carousel keep the same responsive behavior and show the full frame */

/* Scoped so only the carousel inside the data-machine-gallery is affected. */

/* =====================================================================
   Video sizing fix for the machine gallery (scoped to data-machine-gallery)
   - Scoped so other carousels are unaffected.
   - Removes the global carousel video absolute/min-size behavior and
     keeps the video in-flow so the slide matches the machine images.
   - Preserves aspect ratio and uses object-fit: contain (no cropping).
   - Uses max-height on desktop/tablet and allows fluid width on mobile.
   ===================================================================== */

/* Reset any global carousel sizing for this gallery and let slides size naturally */

[data-machine-gallery] .carousel, [data-machine-gallery] .carousel-inner, [data-machine-gallery] .carousel-item {
  height: auto;
}

/* Video wrapper: center the video and constrain its available height on larger viewports.
   Do NOT set inline heights; this uses max-height so layout can respond at breakpoints. */

[data-machine-gallery] .video-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-height: 560px;
  overflow: hidden;
  box-sizing: border-box;
  background-color: #000;
  padding-top: 18px;
  padding-bottom: 18px;
}

/* Keep the actual video element in the normal flow (not absolutely positioned),
   scale it to the available width while preserving aspect ratio, and never crop. */

[data-machine-gallery] #carousel-2 .carousel-item video, [data-machine-gallery] .video-wrapper video {
  position: static;
  width: 100%;
  height: auto;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

/* Mobile: do not force the desktop max-height; allow video to scale with width. */

@media (max-width: 575.98px) {
  [data-machine-gallery] .video-wrapper {
    max-height: none;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    background-color: #000;
  }
}

@media (max-width: 575.98px) {
  [data-machine-gallery] .carousel-item video, [data-machine-gallery] video#custom-video {
    width: 100%;
    height: auto;
    max-height: none;
  }
}

/* Ensure thumbnails / thumbnail fallback images remain block-level and scale consistently. */

[data-machine-gallery] #carousel-2 .carousel-item .thumbnail, [data-machine-gallery] #carousel-2 .carousel-item .video-wrapper .thumbnail {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

/* =========================================
   MACHINE GALLERY - VIDEO LAYOUT OVERRIDE
   Scoped only to data-machine-gallery
   ========================================= */

[data-machine-gallery] .video-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

[data-machine-gallery] .video-wrapper > video {
  position: static !important;
  width: 100%;
  height: 100%;
  min-width: 0 !important;
  min-height: 0 !important;
  max-width: 100%;
  max-height: 100%;
  top: auto !important;
  left: auto !important;
  transform: none !important;
  object-fit: contain;
  display: block;
}

/* Keep machine gallery height stable between slides */

[data-machine-gallery] .carousel-inner {
  aspect-ratio: 3 / 2;
}

[data-machine-gallery] .carousel-item {
  width: 100%;
  height: 100%;
}

/* =========================================
   MACHINE GALLERY - CUSTOM VIDEO PREVIEW
   ========================================= */

/* Establish overlay positioning */

[data-machine-gallery] .machine-video-wrapper {
  position: relative;
  overflow: hidden;
}

/* Image 2 fills the complete gallery viewport */

[data-machine-gallery] .machine-video-poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  z-index: 1;
}

/* Dark layer over poster */

[data-machine-gallery] .machine-video-wrapper:not(.is-playing)::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.52);
  z-index: 2;
  pointer-events: none;
}

/* Custom play button */

[data-machine-gallery] .machine-video-play {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 82px;
  height: 82px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 3;
  transform: translate(-50%, -50%) scale(1);
  transition: transform 0.25s ease, background-color 0.25s ease;
}

/* Zoom the WHOLE button on hover */

[data-machine-gallery] .machine-video-play:hover {
  transform: translate(-50%, -50%) scale(1.13);
  background: rgba(0, 0, 0, 0.55);
}

/* White play triangle */

[data-machine-gallery] .machine-video-play svg {
  width: 38px;
  height: 38px;
  fill: #fff;
  margin-left: 4px;
  pointer-events: none;
}

/* Playback started:
   remove poster + overlay + custom play button */

[data-machine-gallery] .machine-video-wrapper.is-playing .machine-video-poster, [data-machine-gallery] .machine-video-wrapper.is-playing::after, [data-machine-gallery] .machine-video-wrapper.is-playing .machine-video-play {
  display: none;
}

/* Actual playing video stays uncropped */

[data-machine-gallery] .machine-video-wrapper.is-playing > video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Make thumbnail selection match thumbnail shape */

[data-machine-gallery] .machine-thumb {
  width: 66px;
  height: 50px;
  overflow: hidden;
  border-radius: 3px;
}

[data-machine-gallery] .machine-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* =========================================
   MOBILE THUMBNAIL FILMSTRIP
   ========================================= */

[data-machine-gallery] .thumbs {
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

[data-machine-gallery] .thumbs::-webkit-scrollbar {
  display: none;
}

/* Don't allow thumbnails to shrink */

[data-machine-gallery] .machine-thumb {
  flex: 0 0 auto;
}

/* Keep first and last thumbnails fully visible */

[data-machine-gallery] .thumbs {
  padding-left: 8px;
  padding-right: 8px;
  box-sizing: border-box;
}

/* =========================================
   MOBILE THUMBNAILS - LEFT ALIGNED SCROLLER
   ========================================= */

@media (max-width: 767.98px) {
  [data-machine-gallery] .thumbs {
    justify-content: flex-start !important;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding-left: 8px;
    padding-right: 8px;
    box-sizing: border-box;
    scrollbar-width: none;
  }
}

@media (max-width: 767.98px) {
  [data-machine-gallery] .thumbs::-webkit-scrollbar {
    display: none;
  }
}

@media (max-width: 767.98px) {
  [data-machine-gallery] .machine-thumb {
    flex: 0 0 auto;
  }
}

/* =========================================================
   MACHINE GALLERY - FULLSCREEN IMAGE VIEWER
   ========================================================= */

[data-machine-gallery] .machine-zoomable-image {
  cursor: zoom-in;
}

/* Small expand button on main gallery */

[data-machine-gallery] .machine-zoom-button {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.48);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
  transition: transform 0.2s ease, background-color 0.2s ease;
}

[data-machine-gallery] .machine-zoom-button:hover {
  transform: scale(1.08);
  background: rgba(0, 0, 0, 0.65);
}

[data-machine-gallery] .machine-zoom-button svg {
  width: 23px;
  height: 23px;
  fill: #fff;
}

/* Prevent page scrolling while viewer is open */

body.machine-lightbox-open {
  overflow: hidden;
}

/* Fullscreen viewer */

.machine-lightbox {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.94);
  display: none;
  z-index: 99999;
}

.machine-lightbox.is-open {
  display: block;
}

/* Image stage */

.machine-lightbox-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  touch-action: none;
}

.machine-lightbox-stage.is-dragging {
  cursor: grabbing;
}

/* Full resolution image */

.machine-lightbox-image {
  max-width: 92%;
  max-height: 88%;
  width: auto;
  height: auto;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  transform-origin: center center;
  transition: transform 0.08s linear;
}

/* Close */

.machine-lightbox-close {
  position: absolute;
  top: 18px;
  right: 20px;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 42px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  z-index: 4;
  opacity: 0.85;
}

.machine-lightbox-close:hover {
  opacity: 1;
}

/* Previous / Next */

.machine-lightbox-prev, .machine-lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 54px;
  height: 80px;
  border: 0;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 38px;
  cursor: pointer;
  z-index: 4;
  opacity: 0.8;
}

.machine-lightbox-prev {
  left: 12px;
}

.machine-lightbox-next {
  right: 12px;
}

.machine-lightbox-prev:hover, .machine-lightbox-next:hover {
  opacity: 1;
}

/* Small instruction */

.machine-lightbox-hint {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  pointer-events: none;
  z-index: 4;
}

/* Mobile */

@media (max-width: 767.98px) {
  [data-machine-gallery] .machine-zoom-button {
    width: 42px;
    height: 42px;
    right: 10px;
    bottom: 10px;
  }
}

@media (max-width: 767.98px) {
  .machine-lightbox-image {
    max-width: 100%;
    max-height: 90%;
  }
}

@media (max-width: 767.98px) {
  .machine-lightbox-prev, .machine-lightbox-next {
    width: 44px;
    height: 64px;
    font-size: 30px;
    background: rgba(0, 0, 0, 0.25);
  }
}

@media (max-width: 767.98px) {
  .machine-lightbox-prev {
    left: 0;
  }
}

@media (max-width: 767.98px) {
  .machine-lightbox-next {
    right: 0;
  }
}

@media (max-width: 767.98px) {
  .machine-lightbox-close {
    top: 8px;
    right: 8px;
  }
}

/* Larger thumbnails on desktop */

@media (min-width: 768px) {
  [data-machine-gallery] .machine-thumb {
    width: 82px;
    height: 62px;
  }
}

/* Keep mobile thumbnails compact */

@media (max-width: 767.98px) {
  [data-machine-gallery] .machine-thumb {
    width: 66px;
    height: 50px;
  }
}

/* Real video-frame thumbnail */

[data-machine-gallery] .machine-thumb-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

[data-machine-gallery] .machine-thumb-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

/* White letterbox around videos */

[data-machine-gallery] .machine-video-wrapper, [data-machine-gallery] .machine-video-wrapper > video {
  background-color: #fff !important;
}

/* Video preview - translucent white overlay */

[data-machine-gallery] .machine-video-wrapper:not(.is-playing)::after {
  background: transparent !important;
}

/* Center machine gallery images inside the fixed gallery viewport */

[data-machine-gallery] .carousel-item:not(.machine-video-slide) {
  text-align: center;
}

[data-machine-gallery] .carousel-item:not(.machine-video-slide) > img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
}

/* =========================================
   MACHINE GALLERY - CAROUSEL ARROW HIT AREA
   Prevent arrows from covering video controls
   ========================================= */

[data-machine-gallery] .carousel-control-prev, [data-machine-gallery] .carousel-control-next {
  top: 50%;
  bottom: auto;
  width: 48px;
  height: 64px;
  transform: translateY(-50%);
}

/* Keep left arrow against left edge */

[data-machine-gallery] .carousel-control-prev {
  left: 0;
}

/* Keep right arrow against right edge */

[data-machine-gallery] .carousel-control-next {
  right: 0;
}

/* =========================================
   MACHINE GALLERY - NAV ARROWS
   ========================================= */

[data-machine-gallery] .carousel-control-prev, [data-machine-gallery] .carousel-control-next {
  opacity: 1;
}

/* Dark translucent circle */

[data-machine-gallery] .carousel-control-prev-icon, [data-machine-gallery] .carousel-control-next-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: rgba(30, 30, 30, 0.58);
  background-size: 17px 17px;
  filter: none;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

/* Hover */

[data-machine-gallery] .carousel-control-prev:hover .carousel-control-prev-icon, [data-machine-gallery] .carousel-control-next:hover .carousel-control-next-icon {
  background-color: rgba(30, 30, 30, 0.82);
  transform: scale(1.08);
}

/* Mobile gallery: unobstructed photos and quicker swipe transitions. */

@media (max-width: 767.98px) {
  [data-machine-gallery] #carousel-2 > .carousel-control-prev, [data-machine-gallery] #carousel-2 > .carousel-control-next {
    display: none !important;
  }
}

@media (max-width: 767.98px) {
  [data-machine-gallery] #carousel-2 .carousel-item {
    transition-duration: 180ms !important;
  }
}

@media (max-width: 767.98px) and (prefers-reduced-motion: reduce) {
  [data-machine-gallery] #carousel-2 .carousel-item {
    transition: none !important;
  }
}

