/* WordPress-style caption and gallery styling */

/* Caption container */
.wp-caption {
  margin-bottom: 1.5em;
  max-width: 100%;
  background: #f9f9f9;
  border: 1px solid #f0f0f0;
  padding: 5px;
  text-align: center;
  box-sizing: border-box;
}

/* Caption text */
.wp-caption-text {
  margin: 0.8em 0;
  font-size: 0.9em;
  font-style: italic;
  color: #666;
}

/* Caption alignment */
.alignnone {
  margin: 1.5em 0;
}

.aligncenter {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.alignleft {
  float: left;
  margin-right: 1.5em;
  margin-bottom: 1em;
}

.alignright {
  float: right;
  margin-left: 1.5em;
  margin-bottom: 1em;
}

/* WordPress gallery */
.gallery {
  display: grid;
  grid-gap: 15px;
  margin: 1.5em auto;
  padding: 15px;
  background: #f9f9f9;
  border: 1px solid #f0f0f0;
  width: 100%;
  max-width: 800px;
  box-sizing: border-box;
}

/* Set default column count */
.gallery {
  grid-template-columns: repeat(3, 1fr);
}

/* Specific column counts */
.gallery-columns-1 {
  grid-template-columns: 1fr;
}

.gallery-columns-2 {
  grid-template-columns: repeat(2, 1fr);
}

.gallery-columns-3 {
  grid-template-columns: repeat(3, 1fr);
}

.gallery .wp-caption {
  width: 100% !important; /* Override inline styles */
  margin: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border: 1px solid #ddd;
  padding: 8px;
  box-sizing: border-box;
}

@media (max-width: 768px) {
  .gallery-columns-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .gallery-columns-2,
  .gallery-columns-3 {
    grid-template-columns: 1fr;
  }
}

.gallery .wp-caption img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
  object-fit: contain;
  flex: 1;
  border: none;
}

.gallery .wp-caption-text {
  font-size: 0.8em;
  padding: 5px;
  margin: 0;
  color: #666;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Image links */
.image-link {
  display: inline-block;
  transition: opacity 0.3s ease;
}

.image-link:hover {
  opacity: 0.9;
}

/* Clear floats after captions */
.clearfix::after {
  content: "";
  clear: both;
  display: table;
}
