/* Shared photo grids, upload flow, previews, captions, and lightbox. */
/* Event photo gallery */
.photo-group-heading {
  font-size: 1rem;
  color: var(--muted);
  margin: 1.25rem 0 0.5rem;
}

.photo-group-heading:first-of-type {
  margin-top: 0;
}

/* Shared photo grid. discussions.css and landing.css add scoped layout overrides later. */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

/* Responsive two-column grid for profile photos. */
.profile-photo-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
  margin-top: 0.75rem;
  max-width: 28rem;
}

.profile-photo-tile {
  display: block;
  border-radius: 0.3rem;
  overflow: hidden;
}

.profile-photo-tile img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.photo-caption-form {
  margin-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.photo-caption-form input[type="text"] {
  flex: 1;
  min-width: 8rem;
  margin: 0;
}

.photo-caption-form button {
  margin: 0;
}

/* Manage-page photo cards (feedback #117): each photo's controls (caption, Set as
   Cover Photo) sit in their own bordered card instead of flowing loose under the image
   in a dense grid, where it was hard to tell which button belonged to which photo. */
.manage-section .photo-item {
  padding: 0.6rem;
  border: 1px solid var(--divider);
  border-radius: 0.3rem;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.photo-cover-form button {
  margin: 0;
  width: 100%;
}

.photo-cover-form .photo-cover-active {
  background: color-mix(in srgb, var(--accent-dim) 20%, var(--panel));
}

/* Clickable dropzone with a client-side preview. */
.photo-dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  margin-top: 0.5rem;
  padding: 0.5rem 1rem;
  border: 2px dashed var(--seam);
  border-radius: 0.3rem;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.78rem;
}

.photo-dropzone p {
  margin: 0;
}

.photo-dropzone-icon {
  flex-shrink: 0;
  margin-right: 0.4rem;
}

@media (max-width: 640px) {
  .dropzone-drag-hint {
    display: none;
  }
}

.photo-dropzone:hover,
.photo-dropzone:focus-visible {
  border-color: var(--accent);
  color: var(--text);
}

.photo-dropzone.dragging {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.photo-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 0.6rem;
  margin-top: 0.75rem;
}

.photo-preview-item {
  position: relative;
  aspect-ratio: 1;
}

.photo-preview-item img,
.photo-preview-fallback {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0.2rem;
}

.photo-preview-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 0.7rem;
  text-align: center;
  word-break: break-word;
}

.photo-preview-remove {
  position: absolute;
  top: -0.4rem;
  right: -0.4rem;
  width: 1.5rem;
  height: 1.5rem;
  min-height: 1.5rem;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--error);
  color: #fff;
  font-size: 0.9rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.photo-preview-cover {
  position: absolute;
  bottom: -0.4rem;
  left: -0.4rem;
  width: 1.5rem;
  height: 1.5rem;
  min-height: 1.5rem;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: var(--accent);
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.photo-preview-item.is-cover {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 0.2rem;
}

.photo-cover-hint {
  margin-top: 0.4rem;
}

.photo-upload-warning {
  margin-top: 0.5rem;
}

.photo-upload-progress {
  margin-top: 0.5rem;
}

.photo-upload-progress-track {
  height: 0.5rem;
  border-radius: 0.15rem;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.photo-upload-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.2s ease;
}

.photo-upload-progress-bar.processing {
  animation: photo-upload-pulse 1.2s ease-in-out infinite;
}

@keyframes photo-upload-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* In-page photo viewer, replaces opening the raw image in a new tab */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 2rem;
}

.lightbox-overlay img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 0.2rem;
}

.lightbox-close {
  position: fixed;
  top: 1rem;
  right: 1rem;
  width: 2.5rem;
  height: 2.5rem;
  min-height: 2.5rem;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.lightbox-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 3rem;
  height: 3rem;
  min-height: 3rem;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.lightbox-prev {
  left: 1rem;
}

.lightbox-next {
  right: 1rem;
}

@media (max-width: 640px) {
  /* Keep the nav buttons from overlapping a full-width portrait photo on a phone. */
  .lightbox-nav {
    top: auto;
    bottom: 1rem;
    transform: none;
  }
}

/* Moved here from media-controls.css, which despite its name held no media rules -- these
   are the photo tiles in an upload/manage grid. discussions.css intentionally overrides
   .photo-item img sizing. */
.photo-item img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 0.3rem;
}

.photo-item-media {
  position: relative;
}

.photo-item-remove-form {
  margin: 0;
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
}

.photo-item-remove {
  width: 1.7rem;
  height: 1.7rem;
  min-height: 1.7rem;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 1.1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.photo-item-remove:hover,
.photo-item-remove:focus-visible {
  background: var(--error);
}

.photo-caption {
  margin: 0.4rem 0 0;
  color: var(--text);
  font-size: 0.9rem;
}

.photo-item details {
  margin-top: 0.5rem;
}

.photo-item summary {
  color: var(--accent);
  font-weight: 600;
}
