.gallery-trigger {
  cursor: zoom-in;
}

.gallery-trigger:focus-visible {
  outline: 3px solid #a877ff;
  outline-offset: 4px;
}

.activity-card {
  position: relative;
}

.gallery-modal[hidden] {
  display: none;
}

body.gallery-open {
  overflow: hidden;
}

.gallery-modal {
  position: fixed;
  z-index: 2000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: clamp(14px, 2.5vw, 38px);
  opacity: 0;
  transition: opacity .22s ease;
}

.gallery-modal.open {
  opacity: 1;
}

.gallery-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: rgba(4, 2, 10, .94);
  backdrop-filter: blur(16px);
  cursor: zoom-out;
}

.gallery-dialog {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(1380px, 100%);
  height: min(900px, calc(100vh - clamp(28px, 5vw, 76px)));
  min-height: 0;
  padding: clamp(18px, 2vw, 30px);
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 24px;
  color: #fff;
  background: #0a0714;
  box-shadow: 0 30px 100px rgba(0, 0, 0, .6);
  overflow: hidden;
}

.gallery-header {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 30px;
  padding-bottom: 18px;
}

.gallery-header p {
  margin: 0 0 4px;
  color: #a877ff;
  font: 700 9px/1 "Space Mono", monospace;
  letter-spacing: .15em;
}

.gallery-header h2 {
  margin: 0;
  font-family: "Archivo Black", sans-serif;
  font-size: clamp(22px, 2.2vw, 38px);
  letter-spacing: -.045em;
  text-transform: uppercase;
}

.gallery-count {
  color: rgba(255, 255, 255, .45);
  font: 700 11px/1 "Space Mono", monospace;
  letter-spacing: .1em;
}

.gallery-count span {
  color: #fff;
  font-size: 17px;
}

.gallery-close {
  position: relative;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .19);
  border-radius: 50%;
  color: #fff;
  background: transparent;
  cursor: pointer;
  transition: background .2s ease, transform .2s ease;
}

.gallery-close:hover {
  background: #8b4fff;
  transform: rotate(5deg);
}

.gallery-close span {
  position: absolute;
  top: 22px;
  left: 13px;
  width: 19px;
  height: 1px;
  background: currentColor;
  transform: rotate(45deg);
}

.gallery-close span:last-child {
  transform: rotate(-45deg);
}

.gallery-stage {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(10px, 2vw, 28px);
  min-height: 0;
  padding: 10px 0 18px;
}

.gallery-main-image {
  display: block;
  justify-self: center;
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
  border-radius: 15px;
  object-fit: contain;
  opacity: 0;
  transition: opacity .2s ease;
}

.gallery-main-image.loaded {
  opacity: 1;
}

.gallery-arrow {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 50%;
  color: #fff;
  background: rgba(255, 255, 255, .06);
  font-size: 22px;
  cursor: pointer;
  transition: color .2s ease, background .2s ease, transform .2s ease;
}

.gallery-arrow:hover {
  color: #0a0714;
  background: #fff;
  transform: scale(1.06);
}

.gallery-modal.single .gallery-arrow {
  visibility: hidden;
}

.gallery-thumbs {
  display: flex;
  gap: 9px;
  padding-top: 15px;
  border-top: 1px solid rgba(255, 255, 255, .1);
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: #8b4fff transparent;
}

.gallery-thumb {
  flex: 0 0 100px;
  width: 100px;
  height: 67px;
  padding: 3px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  opacity: .46;
  transition: opacity .2s ease, border-color .2s ease;
}

.gallery-thumb:hover,
.gallery-thumb.active {
  border-color: #9c68ff;
  opacity: 1;
}

.gallery-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 6px;
  object-fit: cover;
}

@media (max-width: 720px) {
  .gallery-modal {
    padding: 0;
  }

  .gallery-dialog {
    width: 100%;
    height: 100dvh;
    padding: 16px;
    border: 0;
    border-radius: 0;
  }

  .gallery-header {
    grid-template-columns: 1fr auto auto;
    gap: 14px;
    padding-bottom: 10px;
  }

  .gallery-header h2 {
    font-size: 20px;
  }

  .gallery-header p {
    display: none;
  }

  .gallery-close {
    width: 40px;
    height: 40px;
  }

  .gallery-close span {
    top: 19px;
    left: 11px;
    width: 18px;
  }

  .gallery-stage {
    display: block;
    padding: 8px 0 12px;
  }

  .gallery-main-image {
    width: 100%;
    height: 100%;
  }

  .gallery-arrow {
    position: absolute;
    z-index: 1;
    top: 50%;
    width: 42px;
    height: 42px;
    background: rgba(7, 4, 15, .72);
    transform: translateY(-50%);
  }

  .gallery-arrow:hover {
    transform: translateY(-50%);
  }

  .gallery-prev { left: 9px; }
  .gallery-next { right: 9px; }

  .gallery-thumb {
    flex-basis: 78px;
    width: 78px;
    height: 54px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-modal,
  .gallery-main-image,
  .gallery-close,
  .gallery-arrow,
  .gallery-thumb {
    transition: none;
  }
}
