/*
 * Photo / video galleries: 4 per row, shared by the profile edit form and the
 * public View Profile page.
 *
 * Why this file exists: both pages render their tiles into ONE wrapper
 * (#image-grid / #video-grid) that sits inside a grid container, so the
 * container's 4 columns only ever had a single cell. The grid has to be the
 * wrapper itself. Load this AFTER the vendor stylesheets (edit.css and
 * profileview.css), which is why the selectors are id + class.
 *
 * Columns: 4 (>=768px), 3 (576-767px), 2 (<=575px), 1 (<=340px).
 */

#image-grid.media-grid,
#video-grid.media-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  width: 100%;
  min-width: 0;
  overflow: visible;          /* edit.css made #video-grid a scrolling flex row */
  padding: 0;
}

#image-grid.media-grid > *,
#video-grid.media-grid > * {
  min-width: 0;
  margin: 0;
  flex: none;
}

/* The wrapper spans every column of whatever grid it sits in. */
.client-card > .media-grid {
  grid-column: 1 / -1;
}
.client-card:has(> .media-grid) {
  display: block;             /* the old 4-col grid only held this one wrapper */
  margin: 0;
  padding: 0;
}

/* Edit form: the old 5-column upload grids only ever held the wrapper too. */
.image_upload,
.video_upload {
  display: block;
}

/* ---- tiles -------------------------------------------------------------- */

.media-grid .main-content {
  margin: 0;
  padding: 0;
}
.media-grid .main-content .inner {
  overflow: hidden;
}

/* Image tile (view profile and edit form) */
.media-grid img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 10px;
}

/* Video preview tile (overrides the old fixed 150px height) */
.media-grid video,
.client-card .main-content .media-grid video {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 10px;
  background: #000;
}

/* Edit form tiles: the delete "X" overlays the tile's top-right corner. */
.media-grid .input-img {
  position: relative;
  width: 100%;
  height: auto;
  border-radius: 10px;
}
.media-grid .input-img img,
.media-grid .input-img video {
  width: 100%;
  height: auto;
}

/* Single "add" tile at the end of each gallery. */
.media-grid .media-add {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  border: 3px dashed #679222;
  border-radius: 10px;
  background: rgb(103 146 34 / 20%);
  overflow: hidden;
}
#video-grid.media-grid .media-add {
  aspect-ratio: 4 / 3;
}
.media-grid .media-add .btn_upload {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  padding: 0;
  background: transparent;
}
.media-grid .media-add .btn_upload input {
  width: 100%;
  height: 100%;
  left: 0;
  top: 0;
}
.media-grid .media-add .btn_upload span {
  text-align: center;
  padding: 0 8px;
}

/* ---- responsive --------------------------------------------------------- */

@media (max-width: 767px) {
  #image-grid.media-grid,
  #video-grid.media-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
  }
}
@media (max-width: 575px) {
  #image-grid.media-grid,
  #video-grid.media-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
}
@media (max-width: 340px) {
  #image-grid.media-grid,
  #video-grid.media-grid {
    grid-template-columns: 1fr;
  }
}
