/* Instagram-style Gallery grid */
.gallery-main {
  max-width: 930px;
  margin: 0 auto;
  padding: 2rem 1rem;
}
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
}
.gallery-item {
  position: relative;
  overflow: hidden;
  border-radius: 0;
  background: #111;
  aspect-ratio: 1;
  cursor: pointer;
}
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: filter 0.2s ease;
}
.gallery-caption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.8);
  color: #fff;
  font-size: 0.9rem;
  padding: 0.5em 0.75em;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.gallery-item:hover .gallery-caption,
.gallery-item:focus-within .gallery-caption {
  opacity: 1;
  pointer-events: auto;
}

.post-link {
  display: inline-block;
  color: #ff0000;
  text-decoration: none;
  font-size: 0.85em;
  margin-top: 0.25em;
  font-weight: 500;
  transition: color 0.2s ease;
  pointer-events: auto;
}

.post-link:hover {
  color: #ff0000;
  text-decoration: underline;
}

.gallery-item:hover img {
  filter: brightness(0.85);
}

.gallery-fallback {
  grid-column: 1/-1;
  text-align: center;
  color: #888;
  font-size: 1.1em;
  padding: 2em 0;
}

/* Instagram-style responsive behavior */
@media (max-width: 768px) {
  .gallery-main {
    padding: 1rem 0.5rem;
  }
  
  .gallery-grid {
    gap: 2px;
  }
  
  .gallery-caption {
    font-size: 0.8rem;
    padding: 0.4em 0.6em;
  }
}

@media (max-width: 480px) {
  .gallery-main {
    padding: 1rem 0.25rem;
  }
  
  .gallery-grid {
    gap: 1px;
  }
}

/* Image Modal - Post-like card design */
.image-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 2rem;
  box-sizing: border-box;
}

.modal-content {
  position: relative;
  max-width: 800px;
  max-height: 80vh;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 1.5rem;
  cursor: default;
  overflow: hidden;
}

.modal-content img {
  width: 100%;
  max-height: 60vh;
  object-fit: contain;
  display: block;
  margin: 0 auto 1rem auto;
}

.modal-caption {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: bold;
  color: var(--fg);
  text-align: center;
  padding: 0.5rem 0;
  border-top: 1px solid var(--border);
}

.modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg);
  font-size: 1.5rem;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.modal-close:hover {
  border-color: var(--fg);
}

/* Mobile modal adjustments */
@media (max-width: 768px) {
  .image-modal {
    padding: 1rem;
  }
  
  .modal-content {
    max-width: 100%;
    max-height: 85vh;
    padding: 1rem;
  }
  
  .modal-content img {
    max-height: 60vh;
    margin-bottom: 0.75rem;
  }
  
  .modal-caption {
    font-size: 1rem;
    padding: 0.4rem 0;
  }
  
  .modal-close {
    width: 28px;
    height: 28px;
    font-size: 1.2rem;
  }
}
