#yg-photo-gallery {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: none;
  margin: 0 0 24px;
  padding: 18px 20px 28px;
  box-sizing: border-box;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.72));
  border: 2px solid #ffe566;
  border-left: 0;
  border-right: 0;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

.yg-photo-gallery-title {
  margin: 0 0 8px;
  padding: 8px 12px;
  color: #ffe566;
  background: #111;
  font: 700 clamp(17px, 2.2vw, 26px) / 1.25 Georgia, "Times New Roman", serif;
  text-align: center;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.yg-photo-gallery-meta {
  margin: 0 0 18px;
  text-align: center;
  color: #ccc;
  font: 13px/1.4 system-ui, Helvetica, sans-serif;
}

.yg-photo-gallery-grid {
  display: block;
  column-count: 4;
  column-gap: 14px;
  overflow-anchor: none;
  min-height: 240px;
}

@media (max-width: 1200px) {
  .yg-photo-gallery-grid {
    column-count: 3;
  }
}

@media (max-width: 800px) {
  .yg-photo-gallery-grid {
    column-count: 2;
  }
}

@media (max-width: 480px) {
  .yg-photo-gallery-grid {
    column-count: 1;
  }
}

.yg-photo-gallery-grid > .yg-photo-card-wrap {
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
  display: inline-block;
  width: 100%;
  margin: 0 0 14px;
  vertical-align: top;
}

.yg-photo-sentinel {
  display: block;
  width: 100%;
  height: 1px;
  margin: 8px 0 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  pointer-events: none;
}

.yg-photo-card-wrap {
  position: relative;
  /* Do not use content-visibility:auto here — with loading=lazy it can
     leave first-viewport thumbs undownloaded until a scroll event. */
}

.yg-photo-card {
  position: relative;
  margin: 0;
  padding: 0;
  border: 0;
  width: 100%;
  background: #161616;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: auto;
  min-height: 120px;
  isolation: isolate;
}

.yg-photo-card.is-ready {
  min-height: 0;
}

.yg-photo-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(110deg, #1a1a1a 8%, #2c2c2c 18%, #1a1a1a 33%);
  background-size: 200% 100%;
  animation: yg-photo-shimmer 1.15s linear infinite;
  pointer-events: none;
}

.yg-photo-card.is-ready::before {
  opacity: 0;
  animation: none;
  transition: opacity 0.25s ease;
}

@keyframes yg-photo-shimmer {
  to {
    background-position-x: -200%;
  }
}

.yg-photo-card img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: auto;
  object-fit: contain;
  display: block;
  opacity: 0;
  transform: scale(1.03);
  transition: opacity 0.4s ease, transform 0.45s ease;
}

.yg-photo-card.is-ready img {
  opacity: 1;
  transform: none;
}

.yg-photo-card img.yg-is-gif {
  opacity: 1;
  transform: none !important;
}

.yg-photo-card-wrap:hover .yg-photo-card.is-ready img {
  transform: scale(1.045);
}

.yg-photo-card-wrap.yg-photo-gif:hover .yg-photo-card img {
  transform: none !important;
}

.yg-photo-card .yg-open-count {
  z-index: 5;
}

.yg-photo-del {
  display: none;
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 5;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: rgba(220, 20, 20, 0.92);
  color: #fff;
  font: bold 22px/1 system-ui, sans-serif;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  opacity: 0.9;
}

.yg-photo-del:hover {
  opacity: 1;
  transform: scale(1.08);
}

body.yg-gallery-owner .yg-photo-card-wrap:hover .yg-photo-del,
body.yg-gallery-owner .yg-photo-card-wrap:focus-within .yg-photo-del {
  display: block;
}

.yg-photo-cap {
  font-size: 13px;
  color: #ccc;
  padding: 6px 4px 0;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Shell gallery keeps a uniform grid (not homepage feed masonry) */
#yg-shell-gallery.yg-photo-gallery-grid,
.yg-shell-gallery.yg-photo-gallery-grid {
  display: grid;
  column-count: auto;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

#yg-shell-gallery .yg-photo-card,
.yg-shell-gallery .yg-photo-card {
  aspect-ratio: 1;
  min-height: 0;
}

#yg-shell-gallery .yg-photo-card img,
.yg-shell-gallery .yg-photo-card img {
  height: 100%;
  object-fit: cover;
}
