﻿.pgallery {
  --gap: 0.75rem;
  --radius: 12px;

  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(1, minmax(0, 1fr));
}

@media (min-width: 640px) {
  .pgallery.pgallery--cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pgallery.pgallery--cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pgallery.pgallery--cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
  .pgallery.pgallery--cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pgallery.pgallery--cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pgallery.pgallery--cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.pgallery__item {
  margin: 0;
}

.pgallery__link {
  display: block;
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  outline: none;
}

.pgallery__img {
  display: block;
  width: 100%;
  height: auto;

  /* The key for "same size" in a grid */
  aspect-ratio: 4 / 3;
  object-fit: cover;

  /* Top-anchored cropping */
  object-position: center top;
}

.pgallery__caption {
  margin-top: 0.4rem;
  font-size: 0.95rem;
  line-height: 1.3;
}

@media (min-width: 900px) {
  .pgallery.pgallery--layout-hero {
    grid-template-rows: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }

  .pgallery.pgallery--layout-hero.pgallery--hero-split-2-3 {
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr);
  }

  .pgallery.pgallery--layout-hero.pgallery--hero-split-3-4 {
    grid-template-columns: minmax(0, 3fr) minmax(0, 0.5fr) minmax(0, 0.5fr);
  }

  .pgallery.pgallery--layout-hero .pgallery__item:first-child {
    grid-column: 1;
    grid-row: 1 / span 2;
    height: 100%;
  }

  .pgallery.pgallery--layout-hero .pgallery__item:first-child .pgallery__link {
    height: 100%;
  }

  .pgallery.pgallery--layout-hero .pgallery__item:first-child .pgallery__img {
    height: 100%;
    min-height: 100%;
  }

  .pgallery.pgallery--layout-hero.pgallery--count-3 .pgallery__item:nth-child(2) {
    grid-column: 2 / span 2;
    grid-row: 1;
  }

  .pgallery.pgallery--layout-hero.pgallery--count-3 .pgallery__item:nth-child(3) {
    grid-column: 2 / span 2;
    grid-row: 2;
  }

  .pgallery.pgallery--layout-hero.pgallery--count-4 .pgallery__item:nth-child(2) {
    grid-column: 2 / span 2;
    grid-row: 1;
  }

  .pgallery.pgallery--layout-hero.pgallery--count-4 .pgallery__item:nth-child(3) {
    grid-column: 2;
    grid-row: 2;
  }

  .pgallery.pgallery--layout-hero.pgallery--count-4 .pgallery__item:nth-child(4) {
    grid-column: 3;
    grid-row: 2;
  }

  .pgallery.pgallery--layout-hero.pgallery--count-5 .pgallery__item:nth-child(2) {
    grid-column: 2;
    grid-row: 1;
  }

  .pgallery.pgallery--layout-hero.pgallery--count-5 .pgallery__item:nth-child(3) {
    grid-column: 3;
    grid-row: 1;
  }

  .pgallery.pgallery--layout-hero.pgallery--count-5 .pgallery__item:nth-child(4) {
    grid-column: 2;
    grid-row: 2;
  }

  .pgallery.pgallery--layout-hero.pgallery--count-5 .pgallery__item:nth-child(5) {
    grid-column: 3;
    grid-row: 2;
  }
}

.pgallery-360 {
  --pgallery-360-aspect: 4 / 3;
  --pgallery-360-radius: 16px;
  --pgallery-360-control-bg: rgba(17, 17, 17, 0.72);
  --pgallery-360-control-color: #fff;

  position: relative;
  width: 100%;
}

.pgallery-360:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 4px;
}

.pgallery-360__stage {
  position: relative;
  aspect-ratio: var(--pgallery-360-aspect);
  border-radius: var(--pgallery-360-radius);
  overflow: hidden;
  background: #101214;
  user-select: none;
  touch-action: none;
  cursor: grab;
}

.pgallery-360.is-dragging .pgallery-360__stage {
  cursor: grabbing;
}

.pgallery-360__canvas,
.pgallery-360__fallback {
  display: block;
  width: 100%;
  height: 100%;
}

.pgallery-360__canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  image-rendering: auto;
}

.pgallery-360__fallback {
  position: absolute;
  inset: 0;
  object-fit: cover;
  opacity: 1;
  transition: opacity 180ms ease;
}

.pgallery-360.is-ready .pgallery-360__fallback {
  opacity: 0;
  pointer-events: none;
}

.pgallery-360__nav,
.pgallery-360__zoom,
.pgallery-360__fullscreen,
.pgallery-360__count {
  position: absolute;
  z-index: 2;
  background: var(--pgallery-360-control-bg);
  color: var(--pgallery-360-control-color);
  backdrop-filter: blur(8px);
}

.pgallery-360__nav,
.pgallery-360__zoom,
.pgallery-360__fullscreen {
  border: 0;
  cursor: pointer;
}

.pgallery-360__nav {
  top: 50%;
  width: 2.75rem;
  height: 2.75rem;
  margin-top: -1.375rem;
  border-radius: 999px;
  font-size: 1.75rem;
  line-height: 1;
}

.pgallery-360__nav--prev {
  left: 0.75rem;
}

.pgallery-360__nav--next {
  right: 0.75rem;
}

.pgallery-360__zoom {
  right: 0.75rem;
  bottom: 0.75rem;
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
}

.pgallery-360__fullscreen {
  right: 6.25rem;
  bottom: 0.75rem;
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
}

.pgallery-360__count {
  top: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  font-size: 0.85rem;
  line-height: 1;
}

.pgallery-360__nav:disabled {
  opacity: 0.45;
  cursor: default;
}

.pgallery-360__hint {
  position: absolute;
  left: 0.75rem;
  bottom: 0.75rem;
  z-index: 2;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.84);
  color: #111;
  font-size: 0.85rem;
  line-height: 1;
}

.pgallery-360__stage:fullscreen {
  aspect-ratio: auto;
  width: 100vw;
  height: 100vh;
  border-radius: 0;
}

@media (max-width: 640px) {
  .pgallery-360__nav {
    width: 2.4rem;
    height: 2.4rem;
    margin-top: -1.2rem;
  }

  .pgallery-360__hint {
    left: 0.65rem;
    bottom: auto;
    top: 0.65rem;
    font-size: 0.78rem;
  }

  .pgallery-360__fullscreen,
  .pgallery-360__zoom {
    bottom: 0.65rem;
    font-size: 0.8rem;
    padding: 0.45rem 0.7rem;
  }

  .pgallery-360__fullscreen {
    right: 0.65rem;
    bottom: 3.25rem;
  }

  .pgallery-360__zoom {
    right: 0.65rem;
  }
}
