.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

.photo-grid__item {
  display: block;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--card-bg);
}

.photo-grid__item img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
}

.photo-grid__item-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.photo-grid__item-actions {
  display: flex;
  gap: 0.35rem;
  justify-content: center;
}

.photo-grid__item-actions button {
  font-size: 0.85rem;
  color: var(--primary);
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  padding: 0.15rem 0.6rem;
}

.photo-grid__item-actions button:hover {
  border-color: var(--primary);
}

.photo-grid__item-wrapper[draggable="true"] {
  cursor: grab;
}

/* A card someone else uploaded is still draggable (see denyDrag in
   drag_reorder_controller.js) so there's a moment to explain why it
   won't move, but the cursor hints at that boundary up front instead
   of just looking like an ordinary, movable card. */
.photo-grid__item-wrapper[draggable="true"][data-owned="false"] {
  cursor: not-allowed;
}

.photo-grid__item-frame {
  position: relative;
}

/* See drag_reorder_controller.js's denyDrag/showOwnershipNotice —
   appears over a card someone tried to drag without owning it, and
   fades back out on its own a few seconds later. */
.photo-grid__ownership-notice {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: #ffffff;
  background: rgba(15, 23, 42, 0.85);
  border-radius: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.photo-grid__ownership-notice--visible {
  opacity: 1;
}

/* Drag feedback (see drag_reorder_controller.js's dragEnter/dragLeave) —
   applied to whatever card a drag is currently hovering over, own photo
   or not, since any card is a valid drop target regardless of who it
   belongs to. Dropping here inserts the dragged photo into the gap
   right before this one (PhotosController#move_to). */
.photo-grid__item.drag-over {
  outline: 3px dashed var(--primary);
  outline-offset: 2px;
}

/* Exists purely to be submitted by drag_reorder_controller.js —
   never shown or clicked directly. */
.photo-grid__move-to-form {
  display: none;
}

.photo-detail__nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.photo-detail__image {
  max-width: 100%;
  flex: 1 1 auto;
  min-width: 0;
  /* A square bounding box (height always equal to whatever width this
     row ends up giving it) so a tall portrait doesn't tower over a wide
     landscape — object-fit: contain then letterboxes the actual photo
     inside that box rather than cropping it (see :large's own
     resize_to_limit, which already avoids cropping server-side; this is
     the same idea for display). */
  aspect-ratio: 1 / 1;
  object-fit: contain;
  background: var(--card-bg);
  border-radius: 16px;
  border: 1px solid var(--border);
}

.photo-detail__position {
  text-align: center;
  font-weight: 700;
  color: var(--muted);
  margin: 0 0 0.5rem;
}

.photo-detail__nav-arrow {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--muted);
  font-size: 1.25rem;
  line-height: 1;
  text-decoration: none;
}

.photo-detail__nav-arrow:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.tag-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.5rem 0;
}

.tag-badge {
  display: inline-flex;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--secondary);
  color: var(--secondary-text);
  font-size: 0.8rem;
  font-weight: 600;
}

.tag-badge--special {
  background: var(--primary);
  color: #ffffff;
}
