/* --- GRID Instagram --- */
.insta-grid {
  display: grid;
  grid-template-columns: repeat(4,1fr);
  gap: 8px;
  max-width: 1200px;
  margin: 1em auto;
  padding: 0 1em;
}
@media (max-width: 768px) {
  .insta-grid {
    grid-template-columns: repeat(2,1fr);
  }
}

/* --- ITEM --- */
.insta-item {
  position: relative;
  width: 100%;
  padding-bottom: 125%;      /* ratio 4:5 */
  overflow: hidden;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: #e0e0e0;
  cursor: pointer;
}

/* --- Placeholder Skeleton --- */
.insta-item.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    rgba(224,224,224,1) 0%,
    rgba(200,200,200,1) 50%,
    rgba(224,224,224,1) 100%
  );
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* --- IMG & VIDEO --- */
.insta-item img,
.insta-item video {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity .3s ease, transform .3s ease;
}
.insta-item.loaded img,
.insta-item.loaded video {
  opacity: 1;
}
.insta-item:hover img,
.insta-item:hover video {
  transform: scale(1.05);
}

/* --- OVERLAY --- */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: .5em;
  opacity: 0;
  transition: opacity .2s ease;
}
.insta-item.loaded:hover .overlay {
  opacity: 1;
}
.overlay span {
  color: #fff;
  text-align: center;
  font-size: .9em;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Modal overlay */
.insta-modal {
  display: none;
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.8);
  align-items: center;
  justify-content: center;
  z-index: 10000;
}
.insta-modal.open {
  display: flex;
}

/* Modal box */
.insta-modal-content {
  position: relative;
  max-width: 90%;
  max-height: 90%;
}

/* Imagen o video */
.insta-modal-content img,
.insta-modal-content video {
  width: 100%;
  height: auto;
  border-radius: 6px;
  background: #000;
}

/* Botón cerrar */
.insta-modal-close {
  position: absolute;
  top: -10px; right: -10px;
  font-size: 2rem;
  color: #fff;
  cursor: pointer;
}