/* LiteCMS v2.63: consistent 16:9 project stage + live glass caption.
   Scoped to standalone project pages. Loaded after the v2.62 stylesheet. */

/* No layout jump when switching between images, comparisons and YouTube. */
.screen-gallery-project .screen-gallery-hero,
.screen-gallery-project .screen-gallery-hero:has(.media-stage-item .media-frame-video) {
  box-sizing: border-box !important;
  width: 100% !important;
  max-width: none !important;
  height: auto !important;
  min-height: 0 !important;
  padding: 0 0 clamp(140px, 15vw, 174px) !important;
  overflow: hidden !important;
  background: linear-gradient(180deg, #212a32 0%, #303a43 45%, #818c90 76%, var(--v255-page, #f6f6f3) 100%) !important;
}

/* The media stage uses intrinsic 16:9 geometry, never viewport-height.
   Keep position:relative so the hero height includes the gallery frame. */
.screen-gallery-project .screen-gallery-visual {
  position: relative !important;
  top: auto !important;
  bottom: auto !important;
  left: auto !important;
  right: auto !important;
  width: min(100%, 980px) !important;
  max-width: 980px !important;
  aspect-ratio: 16 / 9 !important;
  height: auto !important;
  margin: 0 auto !important;
  padding: 0 !important;
  transform: translate3d(0, var(--v256-scroll-shift, 0px), 0) !important;
  overflow: visible !important;
  isolation: isolate;
}
.screen-gallery-project .focused-project-gallery,
.screen-gallery-project .project-media-gallery,
.screen-gallery-project .media-stage,
.screen-gallery-project .media-stage-item,
.screen-gallery-project .media-frame,
.screen-gallery-project .media-frame.media-frame-compare,
.screen-gallery-project .media-frame-compare .media-compare-visual {
  box-sizing: border-box !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: none !important;
  aspect-ratio: auto !important;
  margin: 0 !important;
}
.screen-gallery-project .focused-project-gallery,
.screen-gallery-project .project-media-gallery,
.screen-gallery-project .media-stage,
.screen-gallery-project .media-stage-item { overflow: hidden !important; }
.screen-gallery-project .media-frame,
.screen-gallery-project .media-frame.media-frame-compare { overflow: hidden !important; }

/* Fit all gallery types to the same rectangular canvas. Never deform images. */
.screen-gallery-project .media-frame-image img,
.screen-gallery-project .media-frame-compare .media-compare-visual > img,
.screen-gallery-project .media-frame-compare .media-compare-visual > img.media-compare-before-image,
.screen-gallery-project .media-frame-compare .media-compare-visual > img.media-compare-after-image {
  display: block !important;
  position: absolute;
  width: 100% !important;
  height: 100% !important;
  inset: 0;
  object-fit: cover !important;
  object-position: center center !important;
  transform: none !important;
}
.screen-gallery-project .media-frame-image { position: relative !important; }
.screen-gallery-project .media-frame-video iframe,
.screen-gallery-project .media-frame-html iframe,
.screen-gallery-project .media-frame.media-frame-video > iframe {
  box-sizing: border-box !important;
  display: block !important;
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  aspect-ratio: 16 / 9 !important;
  margin: 0 !important;
  border: 0 !important;
}
.screen-gallery-project .media-frame-video,
.screen-gallery-project .media-frame-html { position: relative !important; }

/* The comparison uses the exact same crop on both images, so the slider
   preserves alignment while moving the original clipping divider. */
.screen-gallery-project .media-frame-compare .media-compare-visual { position: relative !important; overflow: hidden !important; }

/* Preserve the bottom fade into the light content section, independent of
   which slide type is active. The title itself stays below the gallery. */
.screen-gallery-project .screen-gallery-fade,
.screen-gallery-project .screen-gallery-hero:has(.media-stage-item .media-frame-video) .screen-gallery-fade {
  height: clamp(210px, 23vw, 290px) !important;
  z-index: 2 !important;
}
.screen-gallery-project .screen-gallery-identity {
  bottom: 34px !important;
  z-index: 4 !important;
}

/* Per-slide title and description, partially overlapping the lower-right
   of the image, with a little space beyond the image edge when available. */
.screen-gallery-project .screen-gallery-glass {
  box-sizing: border-box !important;
  position: absolute !important;
  z-index: 12 !important;
  right: clamp(12px, 2.4vw, 28px) !important;
  bottom: -30px !important;
  width: min(390px, calc(100% - 40px)) !important;
  max-height: min(175px, 42vw) !important;
  overflow: auto !important;
  margin: 0 !important;
  padding: 19px 22px 20px 24px !important;
  background: rgba(249, 250, 249, .82) !important;
  border: 1px solid rgba(255,255,255,.65) !important;
  border-left: 4px solid #29343c !important;
  border-radius: 2px !important;
  box-shadow: 0 14px 42px rgba(13,24,30,.14) !important;
  color: #273238 !important;
  -webkit-backdrop-filter: blur(16px) saturate(1.05);
  backdrop-filter: blur(16px) saturate(1.05);
  pointer-events: auto;
}
.screen-gallery-project .screen-gallery-glass[hidden] { display: none !important; }
.screen-gallery-project .screen-gallery-glass strong {
  display: block !important;
  color: #263239 !important;
  font-size: 17px !important;
  font-weight: 720 !important;
  line-height: 1.3 !important;
  margin: 0 0 5px !important;
}
.screen-gallery-project .screen-gallery-glass p {
  color: #3c464d !important;
  font-size: 14px !important;
  line-height: 1.48 !important;
  margin: 0 !important;
}
/* With a caption present, keep thumbnail navigation on the unobscured left. */
.screen-gallery-project .screen-gallery-visual:has(> .screen-gallery-glass:not([hidden])) .media-thumbs {
  width: min(48%, 420px) !important;
  max-width: min(48%, 420px) !important;
}
/* Descriptions no longer take up a detached column below the gallery. */
.screen-gallery-project .screen-gallery-meta { grid-template-columns: 1fr !important; }
.screen-gallery-project .screen-gallery-facts { max-width: 760px !important; }

@media (max-width: 760px) {
  .screen-gallery-project .screen-gallery-hero,
  .screen-gallery-project .screen-gallery-hero:has(.media-stage-item .media-frame-video) {
    /* Reserve the actual mobile toolbar height above the 16:9 canvas.
       Otherwise two rows of navigation cover nearly half of the image. */
    padding-top: 105px !important;
    padding-bottom: 170px !important;
  }
  body.portfolio-universal-project .screen-gallery-hero .media-compare-label {
    /* Gallery now begins below the navigation, so flags return to the top. */
    top: 12px !important;
  }
  .screen-gallery-project .screen-gallery-visual { width: 100% !important; max-width: none !important; }
  .screen-gallery-project .screen-gallery-identity { bottom: 27px !important; }
  .screen-gallery-project .screen-gallery-glass {
    right: 12px !important;
    bottom: -32px !important;
    width: min(320px, 83%) !important;
    max-height: 135px !important;
    padding: 11px 13px 12px 15px !important;
  }
  .screen-gallery-project .screen-gallery-glass strong { font-size: 14px !important; }
  .screen-gallery-project .screen-gallery-glass p { font-size: 12px !important; line-height: 1.4 !important; }
  .screen-gallery-project .media-arrow { top: 48% !important; }
  /* Original gallery controls stay usable beside the caption. */
  .screen-gallery-project .screen-gallery-visual:has(> .screen-gallery-glass:not([hidden])) .media-thumbs {
    width: 43% !important;
    max-width: 43% !important;
  }
}
@media (prefers-reduced-motion: reduce) {
  .screen-gallery-project .screen-gallery-visual {
    transform: none !important;
  }
}
