/**
 * @file
 * Gallery grid + lightbox for .node-view .gallery
 */

.node-view .gallery > .field-content {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.node-view .gallery > .field-content > div {
  margin: 0;
  min-width: 0;
}

.node-view .gallery > .field-content > div > div {
  margin: 0;
  height: 100%;
}

.node-view .gallery a {
  display: block;
  cursor: pointer;
  overflow: hidden;
  border-radius: 7px;
  border: 1px dashed #eee;
  background: #f0f0f0;
  line-height: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.node-view .gallery a:hover,
.node-view .gallery a:focus-visible {
  opacity: 0.92;
  outline: 2px solid #18181b;
  outline-offset: 2px;
}

.node-view .gallery img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 0;
  border: 0;
}

@media screen and (min-width: 601px) {
  .node-view .gallery > .field-content {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media screen and (min-width: 1001px) {
  .node-view .gallery > .field-content {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ---- Lightbox ---- */

.cpg-lightbox {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(9, 9, 11, 0.92);
  color: #fafafa;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.cpg-lightbox.is-open {
  opacity: 1;
  visibility: visible;
}

.cpg-lightbox__dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: min(100%, 1100px);
  max-height: 100%;
  outline: none;
}

.cpg-lightbox__figure {
  margin: 0;
  max-width: 100%;
  max-height: calc(100vh - 5.5rem);
  display: flex;
  align-items: center;
  justify-content: center;
}

.cpg-lightbox__img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 5.5rem);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
  user-select: none;
  -webkit-user-drag: none;
}

.cpg-lightbox__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  margin-top: 0.85rem;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.cpg-lightbox__counter {
  flex: 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: #ffffff;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.65);
}

.cpg-lightbox__btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.28);
  color: #ffffff;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}

.cpg-lightbox__btn:hover,
.cpg-lightbox__btn:focus-visible {
  background: rgba(255, 255, 255, 0.45);
  border-color: #ffffff;
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

.cpg-lightbox__btn:active {
  transform: scale(0.96);
}

.cpg-lightbox__btn svg {
  width: 1.35rem;
  height: 1.35rem;
  fill: none;
  stroke: #ffffff;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cpg-lightbox__close {
  position: absolute;
  top: 0.75rem;
  inset-inline-end: 0.75rem;
  z-index: 2;
  background: rgba(255, 255, 255, 0.35);
}

body.cpg-lightbox-open {
  overflow: hidden;
}

@media screen and (max-width: 600px) {
  .cpg-lightbox {
    padding: 0.5rem;
  }

  .cpg-lightbox__toolbar .cpg-lightbox__btn {
    width: 2.5rem;
    height: 2.5rem;
  }

  .cpg-lightbox__figure,
  .cpg-lightbox__img {
    max-height: calc(100vh - 6.5rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .node-view .gallery a,
  .cpg-lightbox,
  .cpg-lightbox__btn {
    transition: none;
  }
}
