/* Instagram-style 3-column grid */
#photo-feed {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px; /* classic small gap */
  margin-top: 0;
}

.photo-item {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1; /* Ensures perfect squares */
  overflow: hidden;
  background-color: #fafafa;
}

.photo-item img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover; /* Fills the square without distorting */
  
  /* Image Protection */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
}

/* For mobile: prevent long-press to save, but still allow taps! */
@media screen and (hover: none) {
  .photo-item img {
    -webkit-touch-callout: none;
  }
  .photo-item {
    -webkit-user-select: none;
    -webkit-touch-callout: none;
  }
}

/* Custom Right-Click Notice */
#image_protection_notice {
  position: absolute;
  z-index: 999999;
  color: #000;
  padding: 8px 12px;
  width: 220px;
  font-size: 11px;
  font-family: Arial, Helvetica, sans-serif;
  margin: 0;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  pointer-events: none; /* Allows clicks to pass through after it appears */
}

/* --- Lightbox Modal Styles --- */
#photo-modal {
  display: none; /* Hidden by default */
  position: fixed;
  z-index: 99999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.85);
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

#photo-modal-content {
  position: relative;
  max-width: 90%;
  max-height: 90%;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
}

@media (min-width: 768px) {
  #photo-modal-content {
    flex-direction: row; /* Instagram-style side-by-side on desktop */
    max-width: 80%;
  }
}

#photo-modal-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  /* Protection */
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  user-select: none;
}

@media (min-width: 768px) {
  #photo-modal-img {
    height: 80vh;
    width: 80vh;
    max-width: 55vw;
    max-height: 55vw;
  }
}

#photo-modal-side {
  display: flex;
  flex-direction: column;
  min-width: 250px;
  max-width: 350px;
  background: #fff;
}

#photo-modal-header {
  display: flex;
  align-items: center;
  padding: 14px 16px;
}

.photo-modal-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  margin-right: 12px;
}

.photo-modal-author {
  font-weight: 600;
  font-size: 14px;
  color: #262626;
}

#photo-modal-divider {
  border: 0;
  height: 1px;
  background: #efefef;
  margin: 0;
}

#photo-modal-desc {
  padding: 16px;
  font-size: 14px;
  color: #262626;
  overflow-y: auto;
  flex-grow: 1;
}

#photo-modal-close {
  position: absolute;
  top: 15px;
  right: 25px;
  color: #fff;
  font-size: 35px;
  font-weight: bold;
  cursor: pointer;
  z-index: 100000;
}

/* Hide the dummy header we use to trigger the TOC layout */
#photo-feed-section h2 {
  display: none !important;
  margin: 0;
  padding: 0;
}

#photo-feed-section {
  margin-top: 0 !important;
  padding-top: 0 !important;
}

/* Responsive adjustment for mobile: maybe switch to 2 or 1 column if too small, but instagram keeps 3 usually. We'll keep 3. */
