/* Lookbook grid: vertical page scroll. Do not lock html overflow (unlike gallery-harden.css). */

html:has(body.lookbook:not(.lookbook-open)),
body.lookbook:not(.lookbook-open) {
  height: auto;
  overflow-x: hidden;
  overflow-y: auto;
}

body.lookbook {
  margin: 0;
}

body.lookbook:not(.lookbook-open) .page {
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
}

/* Keep Format header in document flow on the grid. panorama/theme.js
   later marks .theme_header as absolute (gallery overlay); that must not
   collapse the masonry page. */
body.lookbook:not(.lookbook-open) .theme_header {
  position: relative !important;
}

body.lookbook-open,
html:has(body.lookbook-open) {
  overflow: hidden !important;
  height: 100%;
}

#lookbook-overlay[hidden] {
  display: none !important;
}

#lookbook-overlay {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 10000;
  overflow-x: auto;
  overflow-y: hidden;
  height: 100%;
  height: 100dvh;
  background: #f6f1f1;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

#lookbook-overlay::-webkit-scrollbar {
  display: none;
}

#lookbook-overlay #content {
  opacity: 1 !important;
  visibility: visible !important;
  height: 100%;
  max-width: none;
  margin-top: 0 !important;
  top: 0 !important;
  min-height: 0 !important;
  position: relative;
}

#lookbook-overlay .gallery_content,
#lookbook-overlay .assets,
#lookbook-overlay #assets,
#lookbook-overlay #assets_wrap {
  display: inline-block;
  width: auto;
  max-width: none;
  vertical-align: top;
  overflow: visible;
  height: 100%;
  font-size: 0;
  white-space: nowrap;
}

#lookbook-overlay .asset {
  display: inline-block;
  height: 100%;
  position: relative;
  white-space: normal;
  vertical-align: top;
  visibility: visible !important;
}

#lookbook-overlay .asset.loading {
  background: none !important;
}

#lookbook-overlay .asset .wrap {
  height: 100%;
  display: inline-block;
  max-height: 100%;
  width: auto;
}

#lookbook-overlay .asset.image .img {
  height: 100%;
  width: auto;
  text-align: center;
  min-width: 0;
}

#lookbook-overlay .asset img {
  width: auto !important;
  max-width: none !important;
  display: inline-block;
  vertical-align: middle;
  height: 100% !important;
  max-height: 100% !important;
}

/* Mobile overlay: keep each photo inside the viewport; strip scrolls inside overlay. */
@media only screen and (max-width: 767px),
  only screen and (max-width: 850px) and (orientation: landscape) {
  #lookbook-overlay {
    width: 100%;
    max-width: 100vw;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }

  #lookbook-overlay .asset {
    max-width: 100vw;
  }

  #lookbook-overlay .asset .wrap,
  #lookbook-overlay .asset.image .img {
    max-width: 100vw;
  }

  #lookbook-overlay .asset img {
    width: auto !important;
    height: auto !important;
    max-width: 100vw !important;
    max-height: 100% !important;
    object-fit: contain;
  }
}

#lookbook-overlay .gallery_content {
  position: relative;
  height: 100%;
}

/* Side gutters so any photo (including first/last) can sit on the overlay
   midline. Not .asset — they are not gallery frames and are not clickable. */
#lookbook-overlay .lookbook-spacer-start,
#lookbook-overlay .lookbook-spacer-end {
  display: inline-block;
  height: 1px;
  max-height: 1px;
  overflow: hidden;
  vertical-align: top;
  pointer-events: none;
  font-size: 0;
  line-height: 0;
  background: none;
  border: 0;
  margin: 0;
  padding: 0;
  box-sizing: content-box;
}
