/* photo-picker.css
   Shared photo picker surface moved from /public/css/photo_picker.css. */

/* ===== Masonry (grid layout) ===== */
.masonry {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  align-items: stretch;
  grid-auto-flow: row dense;
}

@media (max-width: 575.98px){
  .masonry {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}

.masonry-item {
  position: relative;
  background: var(--fx-surface);
  border-radius: .75rem;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
  transition: transform .08s ease-in-out, box-shadow .12s ease-in-out;
  padding-bottom: 100%;
}

.masonry-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(0,0,0,.10);
}

.masonry-item img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  z-index: 1;
}

.masonry-item::after{
  content:'';
  position:absolute;
  inset:0;
  border-radius:inherit;
  pointer-events:none;
  border:0 solid transparent;
  z-index:3;
  transition:border-color .15s ease, border-width .15s ease, border-style .15s ease;
}

.masonry-item.tile-on-current::after{
  border-width:3px;
  border-color:var(--bs-primary);
  border-style:solid;
}

.masonry-item.tile-on-other::after{
  border-width:3px;
  border-color:var(--line);
  border-style:solid;
}

/* Action overlays */
.photo-actions {
  position: absolute;
  inset: .5rem .5rem auto auto;
  display: flex;
  gap: .5rem;
  z-index: 5;
}

.photo-actions .btn {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  touch-action: manipulation;
}

.photo-zoom {
  position: absolute;
  right: .5rem;
  bottom: .5rem;
  z-index: 5;
}

.photo-zoom .btn {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  touch-action: manipulation;
}

/* "Main" badge */
.badge-main {
  position: absolute;
  left: .5rem;
  top: .5rem;
  z-index: 5;
}

/* ===== Gallery modal ===== */
.gallery-modal .modal-body {
  background: var(--fx-bg);
}

.gallery-modal .gallery-load-more {
  margin-bottom: 5.5rem;
}

@media (max-width: 575.98px) {
  .gallery-modal .gallery-load-more {
    margin-bottom: 6.25rem;
  }
}

.gallery-modal .nav-tabs .nav-link {
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--bs-secondary);
}

.gallery-modal .nav-tabs .nav-link.active {
  color: var(--bs-body-color);
  border-bottom-color: var(--bs-primary);
  background: transparent;
}

/* ===== Viewer ===== */
@media (max-width: 575.98px) {
  #photoViewer .modal-dialog { margin: 0; }
  #photoViewer .modal-content { border: 0; border-radius: 0; }
  #photoViewer .modal-dialog { width: 100vw; height: 100vh; }
  #photoViewer .modal-body { padding: 0; }
}

.zoom-stage {
  position: relative;
  width: 100%;
  height: 70vh;
  background: var(--bs-body-bg);
  overflow: hidden;
  touch-action: none;
}

@media (max-width: 575.98px) {
  .zoom-stage { height: calc(100vh - 112px); }
}

.zoom-img {
  will-change: transform;
  transform-origin: 0 0;
  user-select: none;
  -webkit-user-drag: none;
  max-width: none;
}

.floating-ui,
.zoom-controls,
.nav-arrows { z-index: 20; }

.floating-ui {
  position:absolute;
  right:1rem;
  bottom:1rem;
  display:flex;
  flex-direction:column;
  gap:.5rem;
}

.zoom-controls {
  position:absolute;
  left:1rem;
  bottom:1rem;
  display:flex;
  flex-direction:column;
  gap:.5rem;
}

.nav-arrows {
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 .5rem;
  pointer-events:none;
}

.nav-arrows .btn {
  pointer-events:auto;
  width:44px;
  height:44px;
  border-radius:50%;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  opacity:.9;
  box-shadow:0 4px 16px rgba(0,0,0,.25);
}

.status-badges {
  display:flex;
  align-items:center;
  gap:.5rem;
}

/* Gallery modal: select a spread instead of finishing immediately */
#gallery.gallery--select-mode {
  --photo-picker-select-offset: 8px;
}

#gallery.gallery--select-mode #btnFinish {
  display: none;
}

#gallery.gallery--select-mode #btnResetSelection,
#gallery.gallery--select-mode #btnFinishSelect {
  display: inline-flex;
}

#gallery.gallery--select-mode .masonry-item {
  position: relative;
}

#gallery.gallery--select-mode .photo-actions {
  position: absolute;
  left: var(--photo-picker-select-offset);
  right: auto;
  bottom: var(--photo-picker-select-offset);
  top: auto;
}

#gallery.gallery--select-mode .photo-zoom {
  position: absolute;
  right: var(--photo-picker-select-offset);
  bottom: var(--photo-picker-select-offset);
  top: auto;
}
