/* ModalSelect - Reusable grid selection modal styles */

.modal-select-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  overflow: hidden;
  /* It clips, and its search row and breadcrumbs run to its edges: it
     reaches out a step at the top and the sides so their focus rings are
     not cut off. Not at the bottom, where the modal's buttons follow and
     a step further would be a scrollbar. Where the content sits has not
     moved. */
  margin: calc(-1 * var(--space-1)) calc(-1 * var(--space-1)) 0;
  padding: var(--space-1) var(--space-1) 0;
}

.modal-select-header {
  flex-shrink: 0;
}

/* Base grid: a .tile-grid (common/style.css) that extends .scroll-region. */
.modal-select-grid {
  grid-auto-rows: min-content;
  align-content: start;
}

/* Base item tile */
.modal-select-item {
  aspect-ratio: 1;
  background: var(--color-background);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  overflow: hidden;
  transition:
    border-color 0.15s ease,
    transform 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.25s ease-out;
}

/* Hover (border accent + lift) comes from the shared, hover-device-gated tile
   rule in style.css (gated so iOS's sticky :hover doesn't flash it on touch). */

.modal-select-item.selected {
  border-color: var(--color-accent);
  border-width: 3px;
}

/* Loading spinner in tiles */
.modal-select-item .loading-spinner {
  width: 48px;
  height: 48px;
}

/* Load More tile */
.modal-select-load-more {
  background: var(--color-surface);
  border-style: dashed;
  color: var(--color-text);
  font-size: var(--font-size-lg);
}

:where(html[data-pointer='mouse']) .modal-select-load-more:hover {
  color: var(--color-accent);
}

/* Message states */
.modal-select-message {
  text-align: center;
  padding: var(--space-4);
  grid-column: 1 / -1;
}

.modal-select-message.error {
  color: var(--color-error);
}

/* Default error state for loadImage */
.modal-select-error {
  color: var(--color-text-dark);
  font-size: var(--font-size-lg);
}
