/* The studio gallery (templates/public/includes/gallery_window.html and
 * gallery_open.html), on the homepage's studio cards and the contacts page.
 *
 * The opener covers a card's photo, its label in a corner. The window: nearly
 * the whole screen, dark, each photo whole in the middle; js/public/gallery.js
 * adds the arrows, keys and counter, js/public/dialogs.js opens it. It opens
 * only on new pages, so, like the class window, it keeps its own ::backdrop
 * (CONVENTIONS.md 6.14).
 */

.ui-gallery__open {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  width: 100%;
  margin: 0;
  padding: var(--ui-space-3);
  border: 0;
  background: transparent;
  color: var(--ui-color-on-band);
  cursor: pointer;
}

.ui-gallery__open:focus-visible {
  outline: 2px solid var(--ui-color-focus);
  outline-offset: -4px;
}

.ui-gallery__chip {
  display: inline-flex;
  align-items: center;
  gap: var(--ui-space-2);
  padding: var(--ui-space-2) var(--ui-space-3);
  border-radius: var(--ui-radius-pill);
  background: var(--ui-color-band);
  color: var(--ui-color-on-band);
  font-size: var(--ui-text-sm);
  font-weight: var(--ui-weight-semibold);
}

.ui-gallery__chip-icon,
.ui-gallery__icon {
  display: block;
  flex: none;
}

/* The gallery window: nearly the whole screen, dark, the photo whole in the
   middle. A column only when open - a display rule on a closed dialog would
   show it. */
.ui-gallery {
  width: min(75rem, calc(100% - 2 * var(--ui-space-3)));
  max-width: none;
  height: calc(100vh - 2 * var(--ui-space-5));
  max-height: none;
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: var(--ui-radius-lg);
  background: var(--ui-color-band);
  color: var(--ui-color-on-band);
  box-shadow: var(--ui-shadow-raised);
  overflow: hidden;
}

.ui-gallery[open] {
  display: flex;
  flex-direction: column;
}

.ui-gallery::backdrop {
  background: var(--ui-color-scrim);
}

.ui-gallery:focus-visible {
  outline: none;
}

.ui-gallery__head {
  display: flex;
  flex: none;
  align-items: center;
  gap: var(--ui-space-3);
  padding: var(--ui-space-3) var(--ui-space-3) var(--ui-space-3) var(--ui-space-5);
}

.ui-gallery__title {
  flex: 1 1 auto;
  margin: 0;
  color: var(--ui-color-on-band);
}

.ui-gallery__count {
  margin: 0;
  color: var(--ui-color-on-band-soft);
  font-size: var(--ui-text-sm);
  font-variant-numeric: tabular-nums;
}

.ui-gallery__close-form {
  margin: 0;
}

.ui-gallery__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  margin: 0;
  padding: 0;
  border: 1px solid var(--ui-color-on-band-line);
  border-radius: var(--ui-radius-pill);
  background: var(--ui-color-band);
  color: var(--ui-color-on-band);
  cursor: pointer;
}

.ui-gallery__button:focus-visible {
  outline: 2px solid var(--ui-color-focus-on-band);
  outline-offset: 2px;
}

.ui-gallery__button:disabled {
  opacity: 0.4;
  cursor: default;
}

.ui-gallery__stage {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
}

.ui-gallery__track {
  display: flex;
  height: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.ui-gallery__track:focus-visible {
  outline: 2px solid var(--ui-color-focus-on-band);
  outline-offset: -2px;
}

.ui-gallery__slide {
  display: flex;
  flex: 0 0 100%;
  align-items: center;
  justify-content: center;
  min-width: 0;
  margin: 0;
  padding: 0 var(--ui-space-3) var(--ui-space-3);
  scroll-snap-align: center;
  scroll-snap-stop: always;
}

.ui-gallery__photo {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 100%;
  margin: 0;
  object-fit: contain;
  border-radius: var(--ui-radius-sm);
}

.ui-gallery__step {
  position: absolute;
  top: 50%;
  z-index: 1;
  transform: translateY(-50%);
}

.ui-gallery__step--prev {
  left: var(--ui-space-3);
}

.ui-gallery__step--next {
  right: var(--ui-space-3);
}
