/* Holy Puzzle: My puzzles (templates/holypuzzle/my-puzzle.html); the picker itself is in picker.css */

.picker-preview {
  border-radius: var(--bs-border-radius-lg);
  overflow: hidden;
}
#previewImg { max-height: 50vh; }
@media (max-width: 575.98px) {
  #previewImg { max-height: 40vh; }
}

#saveProgress { height: 6px; }

/* ---------- Saved puzzles: masonry gallery ---------- */
.masonry {
  column-count: 2;
  column-gap: .75rem;
}
@media (min-width: 768px)  { .masonry { column-count: 3; column-gap: 1rem; } }
@media (min-width: 1200px) { .masonry { column-count: 4; } }

.masonry-item {
  display: block;
  width: 100%;
  margin-bottom: .75rem;
  break-inside: avoid;
  border-radius: var(--bs-border-radius-lg);
  overflow: hidden;
  position: relative;
  background: var(--bs-secondary-bg);
  transition: opacity .25s ease, transform .25s ease;
}
@media (min-width: 768px) { .masonry-item { margin-bottom: 1rem; } }
.masonry-item.removing { opacity: 0; transform: scale(.96); }

.masonry-item img {
  display: block;
  width: 100%;
  height: auto;
  transition: transform .3s ease, opacity .3s ease;
  opacity: 0;
}
.masonry-item img.loaded { opacity: 1; }
.masonry-item:hover img,
.masonry-item:focus-within img { transform: scale(1.04); }

/* a just-saved photo glows briefly */
.masonry-item.just-saved { animation: savedGlow 2.4s ease; }
@keyframes savedGlow {
  0%, 40% { box-shadow: 0 0 0 4px var(--bs-success); }
  100%    { box-shadow: 0 0 0 0 transparent; }
}

/* title + date, top-left; remove button top-right */
.masonry-item .caption {
  position: absolute;
  top: .5rem;
  left: .5rem;
  right: .5rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .25rem;
  pointer-events: none;
}
.masonry-item .caption .name {
  padding: .1rem .5rem;
  border-radius: 999px;
  color: #fff;
  font-size: .75rem;
  background: rgba(0, 0, 0, .5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.masonry-item .caption .name small { opacity: .75; }
.masonry-item .btn-remove {
  pointer-events: auto;
  flex: 0 0 auto;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(0, 0, 0, .5);
  border: 1px solid rgba(255, 255, 255, .35);
  opacity: .8;
}
.masonry-item .btn-remove:hover,
.masonry-item .btn-remove:focus-visible {
  opacity: 1;
  color: #fff;
  background: var(--bs-danger);
}

/* Jigsaw / Tile buttons, along the bottom (semi-transparent) */
.masonry-item .play-bar {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  gap: .375rem;
  padding: 1.75rem .5rem .5rem;
  background: linear-gradient(transparent, rgba(0, 0, 0, .6));
}
.masonry-item .play-bar .btn {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  padding: .375rem .25rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .2);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.masonry-item .play-bar .btn-primary {
  --bs-btn-bg: rgba(var(--bs-primary-rgb), .5);
  --bs-btn-border-color: rgba(255, 255, 255, .35);
  --bs-btn-hover-bg: rgba(var(--bs-primary-rgb), .8);
  --bs-btn-hover-border-color: rgba(255, 255, 255, .5);
  --bs-btn-active-bg: rgba(var(--bs-primary-rgb), .9);
}
.masonry-item .play-bar .btn-light {
  --bs-btn-bg: rgba(255, 255, 255, .22);
  --bs-btn-border-color: rgba(255, 255, 255, .45);
  --bs-btn-hover-bg: rgba(255, 255, 255, .8);
  --bs-btn-hover-border-color: rgba(255, 255, 255, .8);
  --bs-btn-active-bg: rgba(255, 255, 255, .9);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .4);
}
.masonry-item .play-bar .btn-light:hover,
.masonry-item .play-bar .btn-light:active {
  color: #212529;
  text-shadow: none;
}
