/*
 * Shared gallery/favorites lightbox structure.
 * Page/theme styles keep their palettes; this file owns interaction sizing,
 * semantic thumbnail controls and small-screen behavior.
 */

.modal {
  z-index: 10000;
  overscroll-behavior: contain;
}

.modal-content {
  max-width: 1050px;
}

.close,
.prev,
.next,
.demo-button {
  touch-action: manipulation;
}

.close {
  z-index: 10002;
  min-width: 36px;
  min-height: 36px;
}

.prev,
.next {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  cursor: pointer;
}

.prev:focus-visible,
.next:focus-visible,
.close:focus-visible,
.demo-button:focus-visible {
  outline: 3px dashed #ffe461;
  outline-offset: 2px;
}

.caption-container {
  min-height: 42px;
}

.viewer-status {
  margin: 3px 0 0;
  font: 9px/1.35 "Courier New", monospace;
  opacity: .9;
}

.modal-thumbnail-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  margin-top: 7px;
}

.demo-button {
  min-width: 0;
  padding: 3px;
  background: rgba(255,255,255,.7);
  border: 2px outset #c8e2f3;
}

.demo-button:active {
  border-style: inset;
}

.demo-button .demo {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  opacity: .62;
  border: 1px solid #20376b;
}

.demo-button[aria-current="true"] .demo,
.demo-button:hover .demo,
.demo-button:focus-visible .demo {
  opacity: 1;
  outline: 2px solid #f45c9b;
  outline-offset: -2px;
}

.mySlides[aria-hidden="true"] {
  display: none !important;
}

@media (max-width: 600px) {
  .modal {
    padding: max(50px, env(safe-area-inset-top)) 0 max(12px, env(safe-area-inset-bottom));
  }

  .modal-content {
    width: 100%;
    max-width: 100%;
    padding-inline: 4px;
    border-inline: 0;
    box-shadow: none;
  }

  .close {
    top: max(5px, env(safe-area-inset-top));
    right: max(6px, env(safe-area-inset-right));
    width: 44px;
    height: 44px;
  }

  .prev,
  .next {
    top: 50%;
    width: 46px;
    height: 52px;
    margin-top: -26px;
    padding: 0;
    font-size: 30px;
  }

  .prev { left: 4px; }
  .next { right: 4px; }

  .mySlides img,
  .mySlides video {
    max-height: 68vh;
  }

  .modal-thumbnail-strip {
    display: flex;
    gap: 6px;
    margin-top: 7px;
    padding: 5px 2px 7px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
  }

  .demo-button {
    flex: 0 0 78px;
    min-height: 62px;
    scroll-snap-align: start;
  }

  .caption-container {
    padding-inline: 54px;
  }
}

@media (max-width: 380px) {
  .demo-button {
    flex-basis: 68px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mySlides.is-loading::before {
    animation: none;
  }
}
