/*
 * Staging-only gallery viewport refinements.
 * Deliberately scoped to the two existing gallery roots.
 */
@media (max-width: 1024px), (hover: none) and (pointer: coarse) {
  #galleryGrid {
    display: none !important;
  }

  #propSlider {
    display: block !important;
    box-sizing: border-box;
    width: 100%;
    max-width: 100vw;
    overflow: hidden;
  }

  #propSlider.slider-wrap {
    height: var(--av-gallery-height, min(72dvh, 680px)) !important;
    min-height: 280px !important;
    aspect-ratio: auto !important;
    background: #0d1b2a;
  }

  #propSlider .slider-track {
    max-width: 100%;
    touch-action: pan-y pinch-zoom;
  }

  #propSlider .slide {
    min-width: 100%;
    max-width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }

  #propSlider .slide > img {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: min(68dvh, 720px);
    object-fit: contain;
    object-position: center;
  }

  #thumbStrip.thumb-strip {
    display: flex !important;
    box-sizing: border-box;
    width: 100%;
    max-width: 100vw;
    overflow-x: auto;
    overscroll-behavior-x: contain;
  }

  #propSlider .slider-btn,
  #galleryLightbox .glb-close,
  #galleryLightbox .glb-prev,
  #galleryLightbox .glb-next,
  #galleryLightbox button {
    min-width: 44px;
    min-height: 44px;
    touch-action: manipulation;
  }

  #galleryLightbox {
    box-sizing: border-box;
    width: 100%;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    padding: 0;
  }

  #galleryLightbox.open {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: space-between;
  }

  #galleryLightbox .glb-main {
    box-sizing: border-box;
    position: relative;
    width: 100%;
    height: auto;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    touch-action: pan-y pinch-zoom;
    padding:
      env(safe-area-inset-top, 0px)
      env(safe-area-inset-right, 0px)
      env(safe-area-inset-bottom, 0px)
      env(safe-area-inset-left, 0px);
  }

  #galleryLightbox #glbImg {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    object-position: center;
    border-radius: 0;
  }

  #galleryLightbox .glb-close {
    position: absolute;
    z-index: 5;
    top: calc(env(safe-area-inset-top, 0px) + 10px);
    right: calc(env(safe-area-inset-right, 0px) + 10px);
  }

  #galleryLightbox .glb-prev,
  #galleryLightbox .glb-next {
    position: absolute;
    z-index: 4;
    top: 50%;
    transform: translateY(-50%);
  }

  #galleryLightbox .glb-prev {
    left: calc(env(safe-area-inset-left, 0px) + 8px);
  }

  #galleryLightbox .glb-next {
    right: calc(env(safe-area-inset-right, 0px) + 8px);
  }

  #galleryLightbox .glb-counter,
  #galleryLightbox .glb-count,
  #galleryLightbox [data-gallery-counter] {
    position: absolute;
    z-index: 4;
    left: 50%;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
    transform: translateX(-50%);
    max-width: calc(100% - 112px);
  }
}

@media (hover: none) and (pointer: coarse) {
  #propSlider {
    position: relative;
    left: 50%;
    width: 100vw;
    max-width: 100vw;
    margin: 0;
    transform: translateX(-50%);
    border-radius: 0 !important;
  }
}

@media (max-width: 767px) {
  #propSlider .slide > img {
    max-height: min(68dvh, 640px);
  }

  #propSlider .slider-btn {
    min-width: 48px;
    min-height: 48px;
  }

  #galleryLightbox .glb-main {
    width: 100%;
    height: auto;
  }
}

@media (orientation: landscape) and (max-height: 600px) {
  #propSlider .slide > img {
    max-height: 76dvh;
  }

  #galleryLightbox .glb-close {
    top: max(6px, env(safe-area-inset-top));
  }

  #galleryLightbox .glb-counter,
  #galleryLightbox .glb-count,
  #galleryLightbox [data-gallery-counter] {
    bottom: max(6px, env(safe-area-inset-bottom));
  }
}

@media (hover: none) and (pointer: coarse) {
  #propSlider,
  #galleryLightbox {
    -webkit-tap-highlight-color: transparent;
  }

  #propSlider .slider-btn,
  #galleryLightbox .glb-close,
  #galleryLightbox .glb-prev,
  #galleryLightbox .glb-next,
  #galleryLightbox button {
    min-width: 48px;
    min-height: 48px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #propSlider *,
  #galleryLightbox * {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
