/* Photo galleries (views/photos.js) + Documents pocket (views/documents.js). */

/* --- photo grid: 3 square thumbs per row --- */
.ph-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  touch-action: pan-y; /* page keeps scrolling on touch; the long-press lift takes over */
}
.ph-tile {
  position: relative;
  aspect-ratio: 1;
  min-width: 44px; min-height: 44px;
  padding: 0;
  font: inherit; color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.ph-img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.ph-tile.ph-err::after {
  content: '⚠️';
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.ph-kind {
  position: absolute; left: 4px; bottom: 4px;
  padding: 2px 7px; border-radius: 999px;
  font-size: 11px; font-weight: 600; color: #fff;
  background: rgba(13, 22, 31, 0.62);
  pointer-events: none;
}

/* the '+ Add' tile is a <label> wrapping the hidden multi-file input */
.ph-add {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: var(--card);
  border-style: dashed;
}
.ph-add:active { transform: scale(0.98); }
.ph-add-icon { font-size: 26px; line-height: 1; color: var(--accent); }
.ph-add-text { font-size: 12px; font-weight: 600; color: var(--muted); }
.ph-add:has(.ph-file:disabled) { opacity: 0.7; } /* batch in flight */

/* visually-hidden file input (also used by the Documents '+ Upload' button) */
.ph-file {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  overflow: hidden;
  clip-path: inset(50%);
}

/* --- drag reorder --- */
.ph-tile.ph-lift {
  z-index: 5;
  transform: scale(1.06);
  box-shadow: 0 10px 28px rgba(13, 22, 31, 0.35);
  opacity: 0.95;
  transition: none;
}
.ph-grid.ph-dragging { touch-action: none; }
/* drop indicator: the lifted photo lands just before this tile */
.ph-tile.ph-drop { border-color: var(--accent); }
.ph-tile.ph-drop::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
  z-index: 2;
}

/* --- viewer sheet --- */
.ph-stage { display: flex; align-items: center; gap: 2px; }
.ph-full {
  flex: 1; min-width: 0;
  max-height: 60dvh; min-height: 160px;
  object-fit: contain;
  background: var(--bg);
  border-radius: 10px;
}
.ph-nav { flex-shrink: 0; }

/* --- documents --- */
.doc-icon { width: 34px; flex-shrink: 0; font-size: 24px; line-height: 1; text-align: center; }
