/*
 * Photos on the web: the firearm page's Photos panel, a wish list entry's photo, and the web
 * photo search. Tokens come from styles.css; nothing here restyles what it already covers.
 * views/photos.ts links this file itself the first time one of its panels renders.
 */

/* A control that stays in the tree but out of sight (the file and camera inputs). */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.photo-pick {
  position: relative;
  display: inline-flex;
}

/* ---------- the firearm page's Photos panel ---------- */

.photo-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.photo-row {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.photo-row.primary {
  border-color: var(--brass);
  box-shadow: 0 0 0 1px var(--brass-dim);
}

.photo-row .plate {
  border-bottom: 1px solid var(--border);
}

.photo-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px 12px;
}

.photo-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.photo-size {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.photo-caption {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.photo-actions button.ghost {
  padding: 5px 9px;
  font-size: 12px;
}

.photo-status {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
}

.photo-status:empty {
  display: none;
}

/* ---------- a wish list entry's photo ---------- */

.photo-hero {
  max-width: 560px;
  margin-bottom: 12px;
}

/* ---------- the web photo search ---------- */

.photo-query {
  display: flex;
  gap: 10px;
  align-items: stretch;
  margin-bottom: 10px;
}

.photo-query input {
  flex: 1;
  min-width: 0;
}

.photo-query button.primary {
  width: auto;
  flex: 0 0 auto;
}

.photo-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.photo-results:empty {
  display: none;
}

.photo-results .empty {
  grid-column: 1 / -1;
}

.photo-result {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 0 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.photo-result:hover:not(:disabled) {
  border-color: var(--brass);
}

.photo-result:disabled {
  opacity: 0.5;
  cursor: default;
}

.photo-result.busy {
  opacity: 1;
  border-color: var(--brass);
}

.photo-result .thumb {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--surface-2);
}

.photo-result .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-result .thumb .placeholder {
  color: var(--muted);
  font-family: var(--display);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.photo-result .cap {
  padding: 0 8px;
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-result.busy .cap {
  color: var(--brass);
}
