/* Gallery Container */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  grid-gap: 30px;
  margin: 2rem 0;
}

/* Gallery Item */
.gallery-item {
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  background-color: #fff;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  height: fit-content; /* Adjust to content height */
}

.gallery-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

/* Commentary Section */
.meme-commentary {
  padding: 15px;
  font-size: 1.1rem;
  background-color: #f8f8f8;
  border-bottom: 1px solid #eee;
  font-weight: 500;
  color: #333;
  line-height: 1.4;
}

/* Image Styling */
.gallery-link {
  display: block;
  line-height: 0;
}

.gallery-item img {
  width: 100%;
  height: auto;
  display: block;
}

/* Video Styling */
.video-container {
  position: relative;
  width: 100%;
  /* Remove fixed aspect ratio */
  padding-top: 0;
  height: auto;
  overflow: hidden;
  line-height: 0;
}

.gallery-video {
  width: 100%;
  height: auto;
  display: block;
  background-color: #000;
  /* Not absolute positioning anymore */
  position: relative;
}

/* Caption Section */
.gallery-item figcaption {
  padding: 15px;
  background-color: #fff;
  border-top: 1px solid #eee;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.meme-tags-container {
  display: flex;
  justify-content: space-between; /* This pushes date to far right */
  align-items: center;
  width: 100%; /* Ensure full width */
}

.meme-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.meme-date {
  font-size: 0.8rem; /* Similar size to tags */
  color: #777;
  margin-left: auto; /* Ensures it stays at the far right */
  white-space: nowrap;
}

.meme-tag {
  font-size: 0.8rem; /* Match date size */
  padding: 3px 8px;
  background-color: #f0f0f0;
  border-radius: 12px;
  color: #555;
}

.meme-tag:hover {
  background-color: #e22d30;
  color: white;
}

/* Responsive Adjustments */
@media (max-width: 767px) {
  .gallery {
    grid-template-columns: 1fr;
  }
  
  .meme-commentary {
    font-size: 1rem;
  }
}

@media (min-width: 768px) and (max-width: 1199px) {
  .gallery {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  }
}

@media (min-width: 1600px) {
  .gallery {
    grid-template-columns: repeat(auto-fill, minmax(500px, 1fr));
  }
}

/* Sticky controls */
.meme-controls {
  position: sticky;
  top: 20px;
  z-index: 100;
  background-color: #fff;
  padding: 15px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Search container */
.meme-search-container {
  display: flex;
  max-width: 400px;
}

.meme-search-container input {
  flex: 1;
  padding: 8px 15px;
  border: 1px solid #ddd;
  border-radius: 4px 0 0 4px;
  font-size: 0.9rem;
}

.meme-search-container button {
  padding: 8px 15px;
  background-color: #e22d30;
  color: white;
  border: none;
  border-radius: 0 4px 4px 0;
  cursor: pointer;
  font-size: 0.9rem;
}
.meme-search-container button:hover {
  background-color: #c01f22;
}

/* Make tags clickable */
.meme-tag {
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}

.meme-tag:hover {
  background-color: #e22d30;
  color: white;
}

/* Filter indicator */
.active-filter {
  display: none;
  align-items: center;
  padding: 10px 15px;
  background-color: #f8f8f8;
  border-radius: 8px;
  border-left: 4px solid #e22d30;
}

.active-filter.visible {
  display: flex;
}

.filter-label {
  font-weight: bold;
  margin-right: 10px;
}

.filter-value {
  background-color: #e22d30;
  color: white;
  padding: 3px 10px;
  border-radius: 15px;
  margin-right: 10px;
}

.clear-filter {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: #555;
  font-weight: bold;
}

.clear-filter:hover {
  color: #e22d30;
}

.no-results {
  padding: 15px;
  background-color: #f8f8f8;
  border-radius: 8px;
  text-align: center;
  margin: 20px 0;
}

.no-results a {
  color: #e22d30;
  text-decoration: none;
  font-weight: bold;
}

/* Meme actions (permalink and share) */
.meme-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
  gap: 12px;
}

.content .meme-permalink {
font-weight: normal;
color: #777;
}

.meme-permalink, 
.meme-share {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  border-radius: 4px;
  color: #777;
  transition: color 0.2s, background-color 0.2s;
  background: none;
  border: none;
  cursor: pointer;
}

.meme-permalink:hover, 
.meme-share:hover {
  color: #e22d30;
  background-color: #f5f5f5;
}

/* Share modal */
.share-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.share-modal.visible {
  display: flex;
}

.share-modal-content {
  background-color: white;
  padding: 20px;
  border-radius: 8px;
  max-width: 500px;
  width: 100%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.share-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.share-modal-title {
  font-size: 1.2rem;
  font-weight: bold;
  margin: 0;
}

.share-modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.5rem;
  color: #777;
}

.share-modal-close:hover {
  color: #e22d30;
}

.share-modal-body {
  margin-bottom: 15px;
}

.share-url-container {
  display: flex;
  margin-bottom: 15px;
}

.share-url-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px 0 0 4px;
  font-size: 0.9rem;
}

.share-url-copy {
  padding: 8px 12px;
  background-color: #e22d30;
  color: white;
  border: none;
  border-radius: 0 4px 4px 0;
  cursor: pointer;
  font-size: 0.9rem;
}

.share-url-copy:hover {
  background-color: #c01f22;
}

.share-options {
  display: flex;
  gap: 10px;
}

.share-option {
  background-color: #f5f5f5;
  border: none;
  padding: 8px 15px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.share-option:hover {
  background-color: #e9e9e9;
}

.share-facebook {
  color: #4267B2;
}

.share-linkedin {
  color: #0077B5;
}

/* When a permalink is used, highlight the meme */
:target {
  animation: highlight 2s ease-out;
}

@keyframes highlight {
  0% { 
    outline: none;
    box-shadow: 0 0 0 0px rgba(226, 45, 48, 0); 
  }
  20% { 
    outline: none;
    box-shadow: 0 0 0 8px rgba(226, 45, 48, 0.4); 
  }
  100% { 
    outline: none;
    box-shadow: 0 0 0 0px rgba(226, 45, 48, 0); 
  }
}