
/* ============================
   Gallery Grid & Cards
   ============================ */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
}

.gallery-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  background: var(--c-surface);
  height: 100%;
}

.gallery-card:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1;
}

.gallery-card.selected {
  border-color: var(--c-primary);
  background: var(--c-surface-active);
}

.gallery-card img.preview {
  width: auto;
  max-width: 100%;
  object-fit: contain;
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  box-shadow: var(--shadow-sm);
}

.gallery-card .card-title {
  font-size: 0.85rem;
  text-align: center;
  color: var(--c-text-primary);
  word-break: break-word;
  line-height: 1.2;
  margin-top: auto; /* Push to bottom if flex column */
}

/* ============================
   Gallery Modal
   ============================ */
.gallery-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.gallery-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.gallery-modal-content {
  position: relative;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  width: 90%;
  max-width: 900px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  z-index: 1001;
  overflow: hidden;
}

.gallery-modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: transparent;
  border: none;
  color: var(--c-text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  z-index: 10;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-modal-close:hover {
  color: var(--c-text-primary);
  background: rgba(255,255,255,0.1);
  border-radius: 50%;
}

.gallery-modal-body {
  display: flex;
  flex-direction: row;
  padding: 2rem;
  gap: 2rem;
  overflow-y: auto;
  height: 100%;
}

.gallery-modal-image-container {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0,0,0,0.2);
  border-radius: var(--radius-sm);
  padding: 1rem;
  min-height: 300px;
}

.gallery-modal-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: var(--shadow-md);
}

.gallery-modal-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.gallery-modal-title {
  font-size: 1.75rem;
  margin: 0;
  line-height: 1.2;
}

.gallery-modal-description {
  color: var(--c-text-secondary);
  line-height: 1.6;
  font-size: 1rem;
}

.gallery-modal-author {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  color: var(--c-text-secondary);
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--c-border);
}

.gallery-modal-author a {
  color: var(--c-primary);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.gallery-modal-actions {
  margin-top: auto;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  padding-top: 1.5rem;
}

@media (max-width: 768px) {
  .gallery-modal-body {
    flex-direction: column;
    padding: 1rem;
    gap: 1rem;
  }
  .gallery-modal-image-container {
    min-height: 200px;
    max-height: 40vh;
  }
  .gallery-modal-title {
    font-size: 1.4rem;
  }
}
