/* Photo viewer and mobile galleries. Load after the page's photo styles. */
img[data-photo-viewer-open] {
  cursor: zoom-in;
}

img[data-photo-viewer-open]:focus-visible {
  outline: 3px solid var(--yellow, #f3ca00);
  outline-offset: -4px;
}

.photo-carousel-controls {
  display: none;
}

.photo-carousel-controls[hidden],
.photo-viewer [hidden] {
  display: none !important;
}

.photo-viewer-is-open {
  overflow: hidden;
}

dialog.photo-viewer {
  position: fixed;
  inset: 0;
  box-sizing: border-box;
  width: 100%;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  color: #fff;
  background: #11130f;
  border: 0;
}

dialog.photo-viewer[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.photo-viewer::backdrop {
  background: rgba(0, 0, 0, .94);
}

.photo-viewer__topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: max(16px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) 14px max(24px, env(safe-area-inset-left));
}

.photo-viewer__title {
  margin: 0;
  color: #d2d4c9;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.5px;
}

.photo-viewer button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 48px;
  min-height: 48px;
  padding: 8px 14px;
  color: #fff;
  background: #22251e;
  border: 1px solid #51564a;
  border-radius: 3px;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.photo-viewer button:hover {
  color: #f3ca00;
  border-color: #f3ca00;
}

.photo-viewer button:focus-visible,
.photo-carousel-controls__button:focus-visible {
  outline: 3px solid #f3ca00;
  outline-offset: 3px;
}

.photo-viewer button:disabled,
.photo-carousel-controls__button:disabled {
  opacity: .3;
  cursor: default;
}

.photo-viewer__close {
  gap: 14px;
  font-size: 13px !important;
  font-weight: 700 !important;
}

.photo-viewer__close span:last-child {
  font-size: 27px;
  line-height: 1;
}

.photo-viewer__stage {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 52px;
  gap: clamp(12px, 2vw, 28px);
  align-items: center;
  min-width: 0;
  min-height: 0;
  padding: 0 max(24px, env(safe-area-inset-right)) 0 max(24px, env(safe-area-inset-left));
}

.photo-viewer__arrow {
  grid-row: 1;
  font-size: 26px !important;
}

.photo-viewer__arrow--previous {
  grid-column: 1;
}

.photo-viewer__arrow--next {
  grid-column: 3;
}

.photo-viewer__viewport {
  grid-column: 2;
  grid-row: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  touch-action: pan-y pinch-zoom;
}

.photo-viewer .photo-viewer__frame {
  position: relative;
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
  overflow: hidden;
  isolation: isolate;
  background: #11130f;
}

.photo-viewer .photo-viewer__frame::after {
  content: none !important;
}

.photo-viewer .photo-viewer__image-layer {
  position: relative !important;
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  aspect-ratio: auto !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  background: transparent !important;
}

.photo-viewer .photo-viewer__image-layer > img[data-photo-viewer-source] {
  position: static !important;
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  max-width: none !important;
  max-height: none !important;
  aspect-ratio: auto !important;
  margin: 0 !important;
  object-fit: contain !important;
  object-position: center !important;
  transform: none !important;
  filter: none !important;
  cursor: default;
}

.photo-viewer__footer {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 20px;
  padding: 18px max(24px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
}

.photo-viewer__caption {
  max-width: 800px;
  margin: 0;
  color: #e3e5dc;
  font-size: 14px;
  line-height: 1.5;
}

.photo-viewer__count {
  flex: 0 0 auto;
  margin: 0;
  color: #f3ca00;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

@media (max-width: 760px) {
  .service-profile__gallery.photo-carousel,
  .service-treatment-card__media--pair.photo-carousel {
    position: relative;
    display: flex !important;
    flex-direction: row;
    align-items: flex-start;
    gap: 12px !important;
    width: 100%;
    max-width: 100%;
    height: var(--photo-carousel-height, auto);
    min-width: 0;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .photo-carousel::-webkit-scrollbar {
    display: none;
  }

  .photo-carousel > .photo-carousel__slide {
    flex: 0 0 100%;
    box-sizing: border-box;
    width: 100%;
    height: auto !important;
    min-width: 0;
    max-width: none;
    margin: 0;
    scroll-snap-align: start;
    scroll-snap-stop: always;
  }

  .photo-carousel img[data-photo-viewer-open] {
    display: block;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    aspect-ratio: auto !important;
    object-fit: contain !important;
    object-position: center !important;
    transform: none !important;
  }

  .photo-carousel img[data-photo-viewer-pending] {
    background: #22251e;
  }

  .photo-carousel-controls {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr) 46px;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin: 12px 0 0;
    color: var(--white, #fff);
  }

  .service-profile > .photo-carousel-controls {
    margin-top: -28px;
  }

  .photo-carousel-controls__button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    min-width: 46px;
    height: 44px;
    padding: 0;
    color: var(--white, #fff);
    background: #22251e;
    border: 1px solid #51564a;
    border-radius: 3px;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
  }

  .photo-carousel-controls__count {
    text-align: center;
    color: var(--yellow, #f3ca00);
    font-size: 13px;
    font-weight: 800;
  }

  .photo-carousel-controls__hint {
    grid-column: 1 / -1;
    margin: 0 0 6px;
    color: var(--muted, #bcc0b3);
    font-size: 11px;
    line-height: 1.5;
    text-align: center;
  }

  .photo-viewer__topbar {
    gap: 10px;
    padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 12px max(12px, env(safe-area-inset-left));
  }

  .photo-viewer__title {
    font-size: 9px;
    letter-spacing: .9px;
  }

  .photo-viewer__stage {
    position: relative;
    display: block;
    padding: 0 max(10px, env(safe-area-inset-right)) 58px max(10px, env(safe-area-inset-left));
  }

  .photo-viewer__arrow {
    position: absolute;
    bottom: 0;
    z-index: 2;
    min-width: 48px;
    min-height: 44px;
  }

  .photo-viewer__arrow--previous {
    left: calc(50% - 60px);
  }

  .photo-viewer__arrow--next {
    right: calc(50% - 60px);
  }

  .photo-viewer__footer {
    align-items: flex-start;
    gap: 12px;
    padding: 14px max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  }

  .photo-viewer__caption {
    font-size: 12px;
  }

  .photo-viewer__count {
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .photo-carousel {
    scroll-behavior: auto !important;
  }
}
