/* Portfolio thumbnail hover effect - matches ccac.gov */
.ccac-portfolio-gallery {
  display: grid;
  grid-template-columns: repeat(4, 180px);
  gap: 1rem;
  grid-auto-rows: minmax(100px, auto);
  margin: 2rem 0;
}

.ccac-portfolio-gallery .field__item > a.glightbox {
  border: solid 3px var(--white, #fff);
  background: #000;
  height: 100%;
  width: 100%;
  display: flex;
  align-items: center;
  transition: all 0.2s ease-in-out;
  position: relative;
  box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.4);
}

.ccac-portfolio-gallery .field__item > a.glightbox img {
  max-width: 100%;
  height: auto;
  aspect-ratio: 200 / 259;
}

@media screen and (max-width: 49.99em) and (min-width: 37.5em) {
  .ccac-portfolio-gallery {
    grid-template-columns: repeat(3, 190px);
  }
}

@media screen and (max-width: 37.49em) {
  .ccac-portfolio-gallery {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
  }
}

.ccac-portfolio-gallery a.glightbox {
  position: relative;
  display: flex;
  transition: 0.2s ease-in-out;
}

.ccac-portfolio-gallery a.glightbox::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5) url('/themes/custom/gallatin2/img/search.svg') no-repeat center center;
  background-size: 20%;
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
  z-index: 1;
}

.ccac-portfolio-gallery a.glightbox:hover::before,
.ccac-portfolio-gallery a.glightbox:focus::before {
  opacity: 1;
}

/* Match Colorbox styling from ccac.gov */
.glightbox-clean .gslide-description {
  background: rgba(0, 0, 0, 0.7) !important;
  position: absolute !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  padding: 10px 15px !important;
}

.glightbox-clean .gdesc-inner {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
}

.glightbox-clean .gslide-title {
  color: #fff !important;
  font-size: 14px !important;
  font-weight: normal !important;
  margin: 0 !important;
  flex: 1 !important;
}

/* Counter display "X of Y" - matches cboxCurrent from Colorbox */
.glightbox-clean .gslide-counter {
  color: #fff !important;
  font-size: 14px !important;
  white-space: nowrap !important;
  margin-left: 15px !important;
}

/* Navigation arrows - always visible including mobile */
.glightbox-clean .gnext,
.glightbox-clean .gprev {
  display: flex !important;
  opacity: 1 !important;
  visibility: visible !important;
  width: 44px !important;
  height: 44px !important;
}

/* Mobile: position buttons at top left, aligned with close button */
@media (max-width: 768px) {
  .glightbox-clean .gnext,
  .glightbox-clean .gprev {
    position: fixed !important;
    top: 15px !important;
    bottom: auto !important;
    transform: none !important;
    z-index: 9999 !important;
  }

  .glightbox-clean .gprev {
    left: 15px !important;
  }

  .glightbox-clean .gnext {
    left: 65px !important;
    right: auto !important;
  }
}

/* Desktop: dark semi-transparent buttons with white arrows */
@media (min-width: 768px) {
  .glightbox-clean .gnext,
  .glightbox-clean .gprev {
    background-color: rgba(0, 0, 0, 0.5) !important;
    border-radius: 4px !important;
  }

  .glightbox-clean .gnext svg,
  .glightbox-clean .gprev svg {
    fill: #fff !important;
  }

  .glightbox-clean .gnext svg path,
  .glightbox-clean .gprev svg path {
    fill: #fff !important;
  }

  .glightbox-clean .gnext:hover,
  .glightbox-clean .gprev:hover {
    background-color: rgba(0, 0, 0, 0.7) !important;
  }
}

/* Close button styling */
.glightbox-clean .gclose {
  background-color: rgba(0, 0, 0, 0.3) !important;
  border-radius: 4px !important;
}

.glightbox-clean .gclose:hover {
  background-color: rgba(0, 0, 0, 0.5) !important;
}

/* Image container */
.glightbox-clean .gslide-inner-content {
  position: relative !important;
}

/* Ensure description is over image */
.glightbox-clean .gslide-media {
  position: relative !important;
}

.glightbox-clean .goverlay {
  background: rgba(0, 0, 0, 0.85) !important;
}

/* Colorbox leaves the page scrollbar in place while the lightbox is open. */
html:has(body.glightbox-open) {
  overflow: visible !important;
}

body.glightbox-open {
  overflow: visible !important;
  margin-right: 0 !important;
  padding-right: 0 !important;
}

/* Desktop Colorbox parity: Drupal keeps the dialog at the image's 880px
   content width, with the caption overlaid across the lower edge. GLightbox
   otherwise shrinks the image and leaves a taller caption below it. */
@media (min-width: 768px) {
  body.glightbox-mobile #glightbox-body,
  body.glightbox-mobile #glightbox-body .gcontainer {
    height: 100vh !important;
  }

  .glightbox-clean .ginner-container {
    width: min(880px, calc(100vw - 30px), calc((100vh - 40px) * 0.7725)) !important;
    max-width: min(calc(100vw - 30px), calc((100vh - 40px) * 0.7725)) !important;
    height: min(1176px, calc(100vh - 16px)) !important;
    max-height: calc(100vh - 16px) !important;
    display: block !important;
    position: relative !important;
    left: 0 !important;
    background: #000 !important;
  }

  .glightbox-clean .gslide-inner-content {
    width: 100% !important;
    height: 100% !important;
  }

  .glightbox-clean .gslide-media {
    width: 100% !important;
    max-width: 100% !important;
    height: calc(100% - 38px) !important;
    max-height: calc(100% - 38px) !important;
    display: block !important;
  }

  .glightbox-clean .gslider {
    overflow: visible !important;
  }

  .glightbox-clean .gslide-image img {
    width: 100% !important;
    height: auto !important;
    max-width: 100% !important;
    max-height: none !important;
    margin: 0 !important;
  }

  .glightbox-clean .gslide-description {
    width: 100% !important;
    max-width: 100% !important;
    top: calc(100% - 38px) !important;
    bottom: auto !important;
    height: auto !important;
    min-height: 72px !important;
    max-height: none !important;
    box-sizing: border-box !important;
    overflow: visible !important;
    padding: 0 140px 0 15px !important;
  }

  .glightbox-clean .gdesc-inner {
    display: block !important;
    padding: 0 !important;
    height: 100% !important;
  }

  .glightbox-clean .gslide-title {
    display: block !important;
    width: 100% !important;
    max-width: none !important;
    font-size: 16px !important;
    line-height: 24px !important;
    padding: 0 !important;
  }

  .glightbox-clean .gslide-counter {
    position: absolute !important;
    top: 2px !important;
    right: 80px !important;
    margin: 0 !important;
    padding: 0 0 0 15px !important;
    line-height: 24px !important;
    font-size: 16px !important;
  }

  .glightbox-clean .gclose {
    width: 25px !important;
    height: 25px !important;
    top: calc((100vh - min(1176px, calc(100vh - 16px))) / 2 - 10px) !important;
    right: calc((100vw - min(880px, calc(100vw - 30px), calc((100vh - 40px) * 0.7725))) / 2 - 17px) !important;
  }

  .glightbox-clean .gprev,
  .glightbox-clean .gnext {
    position: absolute !important;
    top: auto !important;
    width: 21px !important;
    height: 15px !important;
    bottom: calc((100vh - min(1176px, calc(100vh - 16px))) / 2 + 12px) !important;
    transform: none !important;
    padding: 0 !important;
    background: transparent !important;
    border-radius: 0 !important;
  }

  .glightbox-clean .gprev {
    right: calc((100vw - min(880px, calc(100vw - 30px), calc((100vh - 40px) * 0.7725))) / 2 + 38px) !important;
    left: auto !important;
  }

  .glightbox-clean .gnext {
    left: auto !important;
    right: calc((100vw - min(880px, calc(100vw - 30px), calc((100vh - 40px) * 0.7725))) / 2 + 8px) !important;
  }
}

@media (max-width: 480px) {
  .glightbox-clean .ginner-container {
    margin-left: 4px !important;
    margin-right: 0 !important;
  }
}

/* Readability exception for the portfolio lightbox caption. The public
   Colorbox clips long descriptions at some viewport heights; keep the Hugo
   caption complete and readable while preserving the image and controls. */
@media (min-width: 768px) {
  .glightbox-clean .ginner-container {
    height: auto !important;
    max-height: calc(100vh - 24px) !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .glightbox-clean .gslide-media {
    flex: 0 1 auto !important;
    height: auto !important;
    max-height: calc(100vh - 190px) !important;
    overflow: hidden !important;
  }

  .glightbox-clean .gslide-image img {
    width: auto !important;
    max-width: 100% !important;
    max-height: calc(100vh - 190px) !important;
    object-fit: contain !important;
  }

  .glightbox-clean .gslide-description {
    position: relative !important;
    top: auto !important;
    bottom: auto !important;
    flex: 0 0 auto !important;
    min-height: 0 !important;
    max-height: 150px !important;
    overflow-y: auto !important;
    padding: 12px 140px 12px 15px !important;
  }

  .glightbox-clean .gslide-title {
    max-height: none !important;
    overflow: visible !important;
  }
}

@media (max-width: 767px) {
  .glightbox-clean .gslide-description {
    max-height: 240px !important;
    overflow-y: auto !important;
    padding-bottom: 12px !important;
  }

  .glightbox-clean .gslide-title {
    max-height: none !important;
    overflow: visible !important;
  }
}

@media (max-width: 767px) and (max-height: 600px) {
  .glightbox-clean .ginner-container {
    top: 8px !important;
  }
}

/* Below the Colorbox desktop breakpoint, keep the image and caption in the
   compact flow used by the public site's narrow lightbox. */
@media (max-width: 767px) {
  .glightbox-clean .ginner-container {
    width: 98% !important;
    max-width: none !important;
    height: auto !important;
    max-height: none !important;
    display: block !important;
    position: relative !important;
    left: auto !important;
    padding-bottom: 38px !important;
    box-sizing: content-box !important;
  }

  .glightbox-clean .gslide-inner-content {
    width: 100% !important;
    height: auto !important;
  }

  .glightbox-clean .gslide-media {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: calc(100vh - 52px) !important;
    display: block !important;
    padding-bottom: 7px !important;
    box-sizing: content-box !important;
    overflow: hidden !important;
  }

  .glightbox-clean .gslide-image img {
    width: 100% !important;
    height: auto !important;
    max-width: 100% !important;
    max-height: none !important;
    margin: 0 !important;
  }

  .glightbox-clean .gslider {
    overflow: visible !important;
  }

  .glightbox-clean .gslide-description {
    width: 100% !important;
    max-width: none !important;
    top: calc(100% - 38px) !important;
    bottom: auto !important;
    height: auto !important;
    min-height: 72px !important;
    max-height: none !important;
    box-sizing: border-box !important;
    overflow: visible !important;
    padding: 0 140px 0 15px !important;
  }

  .glightbox-clean .gdesc-inner {
    display: block !important;
    padding: 0 !important;
    height: 100% !important;
  }

  .glightbox-clean .gslide-title {
    display: block !important;
    width: 100% !important;
    max-width: none !important;
    font-size: 16px !important;
    line-height: 24px !important;
    padding: 0 !important;
  }

  .glightbox-clean .gslide-counter {
    position: absolute !important;
    top: 2px !important;
    right: 80px !important;
    margin: 0 !important;
    padding: 0 0 0 15px !important;
    line-height: 24px !important;
    font-size: 16px !important;
  }
}

@media (max-width: 480px) {
  .glightbox-clean .ginner-container {
    margin-left: 4px !important;
    margin-right: 0 !important;
  }
}
