.polaroid-grid .polaroid[data-cat-gallery-item] {
  cursor: zoom-in;
  outline: none;
}

.polaroid-grid .polaroid[data-cat-gallery-item]:focus-visible {
  box-shadow: 0 0 0 4px #fff, 0 0 0 7px var(--ink, #17131d), var(--shadow);
}

.cat-gallery-open {
  overflow: hidden;
}

.cat-lightbox[hidden] {
  display: none;
}

.cat-lightbox {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background: rgba(18, 14, 24, .82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: cat-gallery-in .22s ease-out both;
}

.cat-lightbox__dialog {
  position: relative;
  display: grid;
  grid-template-columns: 52px minmax(0, 760px) 52px;
  align-items: center;
  gap: clamp(8px, 2vw, 20px);
  width: min(100%, 920px);
  max-height: 100%;
}

.cat-lightbox__stage {
  position: relative;
  min-width: 0;
  padding: clamp(12px, 2vw, 18px) clamp(12px, 2vw, 18px) clamp(16px, 2.4vw, 24px);
  overflow: hidden;
  border: 2px solid #17131d;
  background: #fff;
  box-shadow: 9px 9px 0 #17131d;
  transform: rotate(-.35deg);
}

.cat-lightbox__stage::before {
  position: absolute;
  z-index: 2;
  top: -1px;
  left: 50%;
  width: 86px;
  height: 23px;
  border: 1px solid #17131d;
  background: repeating-conic-gradient(#17131d 0 25%, #fff 0 50%) 50% / 18px 18px;
  content: "";
  transform: translateX(-50%) rotate(-2deg);
}

.cat-lightbox__photo-button {
  position: relative;
  display: grid;
  width: 100%;
  min-height: 260px;
  max-height: min(70vh, 720px);
  padding: 0;
  place-items: center;
  overflow: hidden;
  touch-action: pan-y;
  border: 1.5px solid #17131d;
  border-radius: 0;
  background: linear-gradient(145deg, #ffd8ee, #eee3ff);
  color: #17131d;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.cat-lightbox__photo-button:focus-visible,
.cat-lightbox__control:focus-visible,
.cat-lightbox__close:focus-visible {
  outline: 3px solid #dfff33;
  outline-offset: 3px;
}

.cat-lightbox__image {
  display: block;
  width: 100%;
  height: min(66vh, 680px);
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(5px 7px 0 rgba(23, 19, 29, .16));
  transform: translate3d(var(--cat-drag-x, 0), 0, 0) rotate(var(--cat-drag-angle, 0deg));
  transition: transform .24s ease, opacity .18s ease;
  will-change: transform;
}

.cat-lightbox__stage.is-dragging .cat-lightbox__image {
  transition: none;
}

.cat-lightbox__stage.is-changing .cat-lightbox__image {
  opacity: 0;
  transform: translate3d(var(--cat-exit-x, 0), 0, 0) rotate(var(--cat-exit-angle, 0deg));
}

.cat-lightbox__caption {
  margin: 17px 4px 0;
  color: #17131d;
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: clamp(12px, 1.6vw, 15px);
  line-height: 1.45;
  text-align: center;
}

.cat-lightbox__counter {
  display: block;
  margin-top: 5px;
  color: #756d79;
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.cat-lightbox__speech {
  position: absolute;
  z-index: 3;
  right: clamp(12px, 4vw, 34px);
  bottom: clamp(12px, 4vw, 30px);
  max-width: min(76%, 330px);
  margin: 0;
  padding: 11px 14px;
  border: 2px solid #17131d;
  border-radius: 16px 16px 3px 16px;
  background: #dfff33;
  box-shadow: 4px 4px 0 #17131d;
  font-weight: 800;
  line-height: 1.3;
  transform-origin: right bottom;
  animation: cat-speech-in .18s cubic-bezier(.2, .8, .2, 1.25) both;
  pointer-events: none;
}

.cat-lightbox__control,
.cat-lightbox__close {
  display: grid;
  width: 48px;
  height: 48px;
  padding: 0;
  place-items: center;
  border: 2px solid #17131d;
  border-radius: 50%;
  background: #fff;
  box-shadow: 3px 3px 0 #17131d;
  color: #17131d;
  font: 900 23px/1 system-ui, sans-serif;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}

.cat-lightbox__control:hover,
.cat-lightbox__close:hover {
  background: #dfff33;
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 #17131d;
}

.cat-lightbox__close {
  position: absolute;
  z-index: 4;
  top: -12px;
  right: -12px;
  width: 46px;
  height: 46px;
  font-size: 25px;
}

.cat-lightbox__hint {
  position: absolute;
  top: calc(100% + 13px);
  left: 50%;
  margin: 0;
  color: rgba(255, 255, 255, .84);
  font: 11px/1.4 "DM Mono", ui-monospace, monospace;
  text-align: center;
  white-space: nowrap;
  transform: translateX(-50%);
}

@keyframes cat-gallery-in {
  from { opacity: 0; }
}

@keyframes cat-speech-in {
  from { opacity: 0; transform: scale(.7) rotate(3deg); }
}

@media (max-width: 620px) {
  .cat-lightbox {
    padding: max(12px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  }

  .cat-lightbox__dialog {
    grid-template-columns: 1fr;
    width: min(94vw, 520px);
  }

  .cat-lightbox__stage {
    grid-column: 1;
    grid-row: 1;
    padding: 12px 12px 16px;
    box-shadow: 6px 6px 0 #17131d;
  }

  .cat-lightbox__photo-button {
    min-height: 250px;
  }

  .cat-lightbox__image {
    height: min(67vh, 590px);
  }

  .cat-lightbox__control {
    position: absolute;
    z-index: 4;
    top: 50%;
    width: 48px;
    height: 48px;
    transform: translateY(-50%);
  }

  .cat-lightbox__control:hover {
    transform: translate(1px, calc(-50% + 1px));
  }

  .cat-lightbox__control--prev { left: 5px; }
  .cat-lightbox__control--next { right: 5px; }
  .cat-lightbox__close { top: -5px; right: -5px; }
  .cat-lightbox__hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .cat-lightbox,
  .cat-lightbox__speech {
    animation: none;
  }

  .cat-lightbox__image,
  .cat-lightbox__control,
  .cat-lightbox__close {
    transition: none;
  }
}

.reduce-motion .cat-lightbox,
.reduce-motion .cat-lightbox__speech {
  animation: none;
}

.reduce-motion .cat-lightbox__image,
.reduce-motion .cat-lightbox__control,
.reduce-motion .cat-lightbox__close {
  transition: none;
}
