/* ============================================================
   centroid-lightbox.css
   Centroid Gallery + Lightbox styles
   Usage: <link rel="stylesheet" href="/css/centroid-lightbox.css">
   ============================================================ */

/* --- Gallery wrapper (contains optional title) --- */
.centroid-gallery {
  box-sizing: border-box;
  min-width: 0 !important;
  width: 100%;
  max-width: 100%;
}

.centroid-lightbox-wrapper {
  box-sizing: border-box;
  min-width: 0;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}

/* Gallery-wide title (<h2> above the grid) */
.centroid-gallery-title {
  display: block;
  text-align: center;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 26px;
  font-weight: bold;
  color: #333;
  margin: 18px 0 12px;
  line-height: 1.3;
}

/* --- Thumbnail grid (internal) --- */
.cl-gallery {
  display: grid !important;
  box-sizing: border-box;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  grid-template-columns: repeat(var(--centroid-gallery-columns, 3), minmax(0, 1fr)) !important;
  gap: 8px;
  padding: 10px 0;
}

@media (max-width: 600px) {
  .cl-gallery {
    grid-template-columns: 1fr !important;
  }
}

/* Each gallery figure/card */
.centroid-gallery-item {
  display: flex !important;
  flex-direction: column;
  min-width: 0 !important;
  max-width: 100% !important;
  margin: 0 !important;
  min-height: 0 !important;
  max-height: unset !important;       /* uniform baseline for all cards */
  background: #d8d8d8;               /* visible placeholder before image loads */
}

/* Ensure figcaption + thumbnail fill figure space without collapsing */
.centroid-gallery-item > .centroid-gallery-link,
.centroid-gallery-item .centroid-gallery-seemore {
  flex-shrink: 0 !important;
  width: 95% !important;
  padding: 4px !important;
  margin: 2px auto;
}

.centroid-gallery-item > .centroid-gallery-link {
  width: 100% !important;
  padding: 6px !important;
  margin: 0;
}

/* Image link anchor — stretch to fill container width */
.centroid-gallery-link {
  display: block !important;
  box-sizing: border-box;
  text-decoration: none;
  width: 100% !important;
}

/* Images that are direct children of .centroid-gallery-link (default case) */
.centroid-gallery-link > img {
  box-sizing: border-box;
  width: 100% !important;
  margin: 0 auto;
  height: auto !important;            /* natural aspect ratio, not forced 320px */
  object-fit: cover;     /* full image visible, no cropping */
  border: 2px solid #ccc !important;
  border-radius: 6px !important;
  display: block !important;
  cursor: zoom-in !important;
}

/* Images nested inside a wrapper div (e.g. .vcp-img-wrap from external pages) */
.centroid-gallery-link > div img,
.centroid-gallery-link > div > div img {
  max-width: 100% !important;
  width: 100% !important;
  height: auto !important;            /* natural aspect ratio */
  object-fit: contain !important;
  display: block !important;
  cursor: zoom-in !important;
}

/* Wrapper divs inside the link — stretch to fill container */
.centroid-gallery-link > div {
  width: 100% !important;
  height: auto !important;
  display: flex !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* Fallback: any img nested anywhere inside .centroid-gallery-link */
.centroid-gallery-link div img {
  max-width: 100% !important;
  width: 100% !important;
  height: auto !important;
  display: block !important;
}

/* Caption / figcaption area below thumbnail — anchored to top */

/* Title inside caption */
.centroid-gallery-title-text {
  padding: 8px 8px 4px;
  display: block !important;
  font-weight: bold !important;
  margin-bottom: 2px !important;
  color: #333 !important;
}

.centroid-gallery-separator {
  width: 95%;
  margin: 4px auto !important;
  border: 0;
  border-top: 1px solid #ccc !important;
}

/* Caption text span */
.centroid-gallery-caption-text {
  padding: 4px 8px 8px;
  display: block !important;
  color: #555 !important;
}

/* "See More" link beneath thumbnail — always below figure content */
.centroid-gallery-seemore {
  display: block !important;
  width: 100% !important;
  text-align: center !important;
  padding: 6px 0 !important;
  font-family: Arial, Helvetica, sans-serif !important;
  font-size: 13px !important;
  color: #4facfe !important;
  font-weight: bold !important;
  text-decoration: none !important;
}

.centroid-gallery-seemore:hover {
  color: #6bc4ff !important;
}

.centroid-lightbox-wrapper .cl-gallery .centroid-gallery-link img {
  box-sizing: border-box;
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 4 / 3;
  min-height: 0 !important;
  max-height: 300px !important;
  object-fit: cover !important;
}

/* Hidden until decoded — placeholder background on <figure> shows instead */
.centroid-gallery-link img[data-src] {
  visibility: hidden;
}

.centroid-gallery-link img:hover {
  border-color: #555;
}

/* --- Caption / figcaption area below thumbnail --- */
.centroid-gallery-caption {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  /*padding: 6px 10px 8px;*/
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  color: #3a3a3a;
  background: linear-gradient(to bottom, transparent, rgba(255,255,255,0.35));
  border-radius: 0 0 6px 6px;
  height: stretch;
  max-height:800px;
  width: stretch;
}

/* Per-image title (shown above caption text) */
.centroid-gallery-title-text {
  display: block;
  font-weight: bold;
  font-size: 13px;
  color: #222;
}

/* Caption text (shown after optional title, separated by em-dash) */
.centroid-gallery-caption-text {
  display: block;
  font-size: 12.5px;
  color: #444;
}

/* --- "See More" link (only visible when extraLink is set) --- */
.centroid-gallery-seemore {
  display: block;
  text-align: center;
  padding: 6px 8px;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 12px;
  font-weight: bold;
  color: #0066cc;
  text-decoration: none;
  background: rgba(0, 102, 204, 0.04);
  border-top: 1px solid rgba(0, 102, 204, 0.15);
  transition: background 0.15s ease, color 0.15s ease;
}

.centroid-gallery-seemore:hover {
  background: rgba(0, 102, 204, 0.12);
  color: #003d80;
}

/* --- Lightbox overlay --- */
.centroid-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}

.centroid-lightbox.active {
  display: flex;
}

/* Full-res image — kept in compositor with visibility:hidden so
   Chromium doesn't destroy its GPU layer between navigations */
.centroid-lightbox__img {
  width: 95vw;
  height: 95vh;
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
  border-radius: 4px;
  cursor: default;
  position: absolute;
  visibility: hidden;
  opacity: 0;
  will-change: opacity;
  transition: opacity 0.4s ease;
}

.centroid-lightbox__img.lb-visible {
  visibility: visible;
  opacity: 1;
}

/* Thumbnail preview — <img> element shares Chrome's decoded-image cache
   with the gallery thumbnail so it renders without a re-decode flash */
.centroid-lightbox__preview {
  position: absolute;
  width: 95vw;
  height: 95vh;
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
  border-radius: 4px;
  visibility: hidden;
  opacity: 0;
  will-change: opacity;
  transition: opacity 0.4s ease;
}

.centroid-lightbox__preview.lb-visible {
  visibility: visible;
  opacity: 1;
}

/* --- Title displayed in lightbox above the image --- */
.centroid-lightbox__title {
  position: absolute;
  top: 30px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 70vw;
  color: #ffffff;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 18px;
  font-weight: bold;
  line-height: 1.45;
  text-align: center;
  background: rgba(0, 0, 0, 0.9);
  padding: 8px 22px;
  border-radius: 6px;
  pointer-events: none;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s ease;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.centroid-lightbox.active .centroid-lightbox__title {
  opacity: 1;
}

/* --- Caption displayed in lightbox below the image --- */
.centroid-lightbox__caption {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 80vw;
  display: none;
  align-items: center;
  gap: 14px;
  color: #f0f0f0;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
  background: rgba(0, 0, 0, 0.9);
  padding: 8px 20px;
  border-radius: 8px;
  pointer-events: none;
  z-index: 10001;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.centroid-lightbox.active .centroid-lightbox__caption {
  opacity: 1;
}

.lb-caption-text {
  flex: 1 1 auto;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* --- "See More" CTA button --- */
.lb-seemore-cta {
  flex-shrink: 0;
  display: inline-block;
  color: #ffffff !important;
  font-size: 13px;
  font-weight: bold;
  font-family: Arial, Helvetica, sans-serif;
  text-decoration: none !important;
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  padding: 6px 18px;
  border-radius: 24px;
  white-space: nowrap;
  pointer-events: auto;
  cursor: pointer;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  box-shadow: 0 2px 8px rgba(79, 172, 254, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
}

.lb-seemore-cta:hover {
  background: linear-gradient(135deg, #6bc4ff 0%, #33f5ff 100%) !important;
  box-shadow: 0 4px 14px rgba(79, 172, 254, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transform: translateY(-1px) scale(1.04);
}

.lb-seemore-cta:active {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 1px 4px rgba(79, 172, 254, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.lb-seemore-cta:visited {
  color: #ffffff !important;
}

/* Close button */
.centroid-lightbox__close {
  position: absolute;
  top: 14px;
  right: 22px;
  color: #fff;
  font-size: 38px;
  font-family: Arial, sans-serif;
  cursor: pointer;
  line-height: 1;
  user-select: none;
  z-index: 10001;
}

/* Open-in-new-tab button */
.centroid-lightbox__open {
  position: absolute;
  top: 14px;
  right: 70px;
  color: #fff !important;
  font-size: 14px;
  font-family: Arial, sans-serif;
  cursor: pointer;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.15);
  padding: 5px 10px;
  border-radius: 4px;
  line-height: 1.6;
  user-select: none;
  z-index: 10001;
}

.centroid-lightbox__open:hover {
  background: rgba(255, 255, 255, 0.28) !important;
  color: #fff !important;
}

.centroid-lightbox__open:visited {
  color: #ddd !important;
}

/* Prev / Next arrows */
.centroid-lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: #fff;
  font-size: 48px;
  font-family: Arial, sans-serif;
  cursor: pointer;
  user-select: none;
  padding: 0 18px;
  line-height: 1;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  z-index: 10001;
  transition: background 0.15s;
}

.centroid-lightbox__nav:hover {
  background: rgba(0, 0, 0, 0.6);
}

.centroid-lightbox__prev {
  left: 12px;
}

.centroid-lightbox__next {
  right: 12px;
}

/* Squircle loading spinner */
.centroid-lightbox__spinner {
  display: none;
  position: absolute;
  z-index: 10000;
  width: 52px;
  height: 52px;
  border: 5px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
  animation: centroid-squircle-spin 0.9s linear infinite;
}

@keyframes centroid-squircle-spin {
  to { transform: rotate(360deg); }
}

@media screen {
  .centroid-lightbox {
    box-sizing: border-box;
    inset: auto;
    top: var(--centroid-lightbox-top, 0px);
    left: var(--centroid-lightbox-left, 0px);
    width: var(--centroid-lightbox-width, 100vw);
    max-width: var(--centroid-lightbox-width, 100vw);
    height: 100%;
    height: var(--centroid-lightbox-height, 100dvh);
    max-height: var(--centroid-lightbox-height, 100dvh);
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    grid-template-rows: 44px auto minmax(0, 1fr) auto 44px;
    gap: 8px;
    overflow: hidden;
  }

  .centroid-lightbox.active {
    display: grid;
  }

  .centroid-lightbox .centroid-lightbox__img,
  .centroid-lightbox .centroid-lightbox__preview {
    position: static;
    grid-column: 1 / -1;
    grid-row: 3;
    width: 100% !important;
    height: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: 100% !important;
    max-height: 100% !important;
    margin: 0;
    object-fit: contain !important;
  }

  .centroid-lightbox__open {
    position: static;
    grid-column: 1 / 3;
    grid-row: 1;
    justify-self: start;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    min-height: 44px;
    max-width: 100%;
    font-size: 13px;
    line-height: 1.3;
    overflow-wrap: anywhere;
  }

  .centroid-lightbox__close,
  .centroid-lightbox__nav {
    position: static;
    transform: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 44px;
    height: 44px;
    padding: 0;
  }

  .centroid-lightbox__close {
    grid-column: 3;
    grid-row: 1;
  }

  .centroid-lightbox__prev {
    grid-column: 1;
    grid-row: 5;
  }

  .centroid-lightbox__next {
    grid-column: 3;
    grid-row: 5;
  }

  .centroid-lightbox__title,
  .centroid-lightbox__caption {
    box-sizing: border-box;
    position: static;
    transform: none;
    grid-column: 1 / -1;
    min-width: 0;
    max-width: 100%;
    width: auto;
    margin: auto;
    overflow: auto;
    overflow-wrap: anywhere;
    pointer-events: auto;
  }

  .centroid-lightbox__title {
    grid-row: 2;
    max-height: calc(var(--centroid-lightbox-height, 100dvh) * 0.15);
    padding: 4px 8px;
    font-size: 14px;
  }

  .centroid-lightbox__caption {
    grid-row: 4;
    max-height: calc(var(--centroid-lightbox-height, 100dvh) * 0.2);
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    padding: 8px;
    font-size: 13px;
  }

  .centroid-lightbox .lb-caption-text {
    flex: 1 1 160px;
    min-width: 0;
  }

  .centroid-lightbox .lb-seemore-cta {
    box-sizing: border-box;
    min-height: 44px;
    padding: 12px 18px;
  }

  .centroid-lightbox__spinner {
    position: static;
    grid-column: 1 / -1;
    grid-row: 3;
    place-self: center;
  }
}
