/* Modern UI Phase 5 — Gallery UX
   Progressive media loading, clearer thumbnail states and touch-friendly strips.
   This layer does not alter viewer dimensions or document rendering logic. */

:root {
  --gallery-radius: var(--radius-lg, 14px);
  --gallery-thumb-radius: var(--radius-md, 10px);
  --gallery-accent: var(--color-primary, #086973);
  --gallery-active: var(--color-accent, #cb3b94);
  --gallery-transition: 220ms cubic-bezier(.2,.7,.2,1);
}

/* Horizontal thumbnail areas */
.doc2026__thumbs,
.viewer4__thumbs,
.bx-wrapper .bx-viewport,
.swiper-wrapper {
  scroll-behavior: smooth;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

.doc2026__thumbs,
.viewer4__thumbs {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--gallery-accent) 55%, transparent) transparent;
  scroll-snap-type: inline proximity;
  touch-action: pan-x pan-y;
}

.doc2026__thumbs::-webkit-scrollbar,
.viewer4__thumbs::-webkit-scrollbar {
  height: 8px;
}

.doc2026__thumbs::-webkit-scrollbar-track,
.viewer4__thumbs::-webkit-scrollbar-track {
  background: transparent;
}

.doc2026__thumbs::-webkit-scrollbar-thumb,
.viewer4__thumbs::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: color-mix(in srgb, var(--gallery-accent) 48%, transparent);
}

.doc2026__thumb,
.viewer4__thumb,
.bx-wrapper li,
.swiper-slide {
  scroll-snap-align: start;
}

/* Progressive image reveal. Existing images stay visible until JS marks them. */
.gallery-ux-managed {
  opacity: .01;
  filter: saturate(.86) contrast(.96);
  transition: opacity 280ms ease, filter 360ms ease, transform var(--gallery-transition);
}

.gallery-ux-managed.gallery-ux-loaded {
  opacity: 1;
  filter: none;
}

.gallery-ux-managed.gallery-ux-error {
  opacity: .42;
  filter: grayscale(1);
}

/* Thumbnail affordance */
.doc2026__thumb,
.viewer4__thumb {
  position: relative;
  isolation: isolate;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.doc2026__thumb::after,
.viewer4__thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: inset 0 0 0 0 transparent;
  transition: box-shadow var(--gallery-transition), background-color var(--gallery-transition);
}

@media (hover: hover) and (pointer: fine) {
  .doc2026__thumb:hover::after,
  .viewer4__thumb:hover::after {
    background: linear-gradient(to top, rgba(8,105,115,.08), transparent 42%);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gallery-accent) 35%, transparent);
  }
}

.doc2026__thumb[aria-current="true"]::after,
.doc2026__thumb.is-active::after,
.doc2026__thumb.active::after,
.viewer4__thumb[aria-current="true"]::after,
.viewer4__thumb.is-active::after,
.viewer4__thumb.active::after {
  box-shadow: inset 0 0 0 2px var(--gallery-active);
}

.doc2026__thumb:active,
.viewer4__thumb:active {
  transform: translateY(0) scale(.985);
}

/* Main image transition without borders or outlines. */
.doc2026__image-wrap,
.viewer4__stage,
.viewer4__image-wrap {
  position: relative;
}

.doc2026__image-wrap img,
.viewer4__stage img,
.viewer4__image-wrap img {
  transition: opacity 240ms ease, filter 300ms ease;
}

.gallery-ux-busy .doc2026__image-wrap::before,
.gallery-ux-busy .viewer4__stage::before,
.gallery-ux-busy .viewer4__image-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  border-radius: var(--gallery-radius);
  background: linear-gradient(100deg, transparent 20%, rgba(255,255,255,.36) 45%, transparent 70%);
  background-size: 220% 100%;
  animation: gallery-ux-shimmer 1.2s linear infinite;
}

@keyframes gallery-ux-shimmer {
  to { background-position: -220% 0; }
}

/* Controls remain large enough for touch. */
.doc2026__controls button,
.doc2026__controls select,
.viewer4__controls button,
.viewer4__toolbar button,
.bx-controls-direction a,
.swiper-button-prev,
.swiper-button-next {
  min-inline-size: 44px;
  min-block-size: 44px;
  touch-action: manipulation;
}

@media (max-width: 640px) {
  .doc2026__thumbs,
  .viewer4__thumbs {
    gap: clamp(.5rem, 2.5vw, .875rem);
    padding-block: .5rem;
  }

  .doc2026__thumb,
  .viewer4__thumb {
    scroll-snap-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .doc2026__thumbs,
  .viewer4__thumbs { scroll-behavior: auto; }
  .gallery-ux-managed,
  .doc2026__thumb,
  .viewer4__thumb,
  .doc2026__thumb::after,
  .viewer4__thumb::after,
  .doc2026__image-wrap img,
  .viewer4__stage img,
  .viewer4__image-wrap img { transition: none !important; }
  .gallery-ux-busy .doc2026__image-wrap::before,
  .gallery-ux-busy .viewer4__stage::before,
  .gallery-ux-busy .viewer4__image-wrap::before { animation: none; }
}

@media print {
  .doc2026__thumbs-wrap,
  .viewer4__thumbs,
  .bx-controls,
  .swiper-button-prev,
  .swiper-button-next { display: none !important; }
}
