/* Project gallery modal mobile polish */
.modal[style*="display: block"] {
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: radial-gradient(circle at 50% 24%, rgba(20, 20, 20, 0.5), rgba(0, 0, 0, 0.94));
  backdrop-filter: blur(4px);
}

.modal[style*="display: block"] .modal-content {
  width: auto;
  max-width: min(96vw, 1080px);
  max-height: calc(100svh - 2.5rem);
  object-fit: contain;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-drag: none;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65);
}

.modal[style*="display: block"] .modal-image-animated {
  animation: modal-image-reveal 360ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes modal-image-reveal {
  from {
    opacity: 0;
    transform: scale(0.985);
    filter: saturate(0.92);
  }

  to {
    opacity: 1;
    transform: scale(1);
    filter: saturate(1);
  }
}

.modal[style*="display: block"] .close {
  display: grid;
  place-items: center;
  top: max(0.8rem, env(safe-area-inset-top));
  right: max(0.8rem, env(safe-area-inset-right));
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(0, 0, 0, 0.55);
  color: #ffffff;
  font-size: 32px;
  line-height: 1;
  z-index: 1010;
}

.modal[style*="display: block"] .modal-prev,
.modal[style*="display: block"] .modal-next {
  top: 50%;
  margin-top: 0;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.52);
  color: #40e0d0;
  font-size: 28px;
  transition: transform 180ms ease, background-color 180ms ease, color 180ms ease;
}

.modal[style*="display: block"] .modal-prev:active,
.modal[style*="display: block"] .modal-next:active {
  transform: translateY(-50%) scale(0.95);
}

.modal[style*="display: block"] .modal-prev {
  left: clamp(0.5rem, 2vw, 1.2rem);
}

.modal[style*="display: block"] .modal-next {
  right: clamp(0.5rem, 2vw, 1.2rem);
}

@media (width <= 768px) {
  .modal[style*="display: block"] {
    padding: 0.5rem;
  }

  .modal[style*="display: block"] .modal-content {
    width: 100%;
    max-width: 100%;
    max-height: calc(100svh - 1rem);
    border-radius: 12px;
  }

  .modal[style*="display: block"] .modal-prev,
  .modal[style*="display: block"] .modal-next {
    width: 44px;
    height: 44px;
    top: auto;
    bottom: calc(0.75rem + env(safe-area-inset-bottom));
    transform: none;
    font-size: 24px;
  }

  .modal[style*="display: block"] .modal-prev:active,
  .modal[style*="display: block"] .modal-next:active {
    transform: scale(0.94);
  }

  .modal[style*="display: block"] .modal-prev {
    left: calc(50% - 54px);
  }

  .modal[style*="display: block"] .modal-next {
    right: calc(50% - 54px);
  }

  body:has(.modal[style*="display: block"]) {
    overflow: hidden;
    touch-action: none;
  }

  body:has(.modal[style*="display: block"]) .social-bubbles {
    opacity: 0;
    pointer-events: none;
  }
}
