/* Additions for the cached, paginated gallery. Loaded after styles.css. */

.photo-tile {
  /* Masonry column item: keep each photo's natural portrait/landscape shape. */
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
  content-visibility: auto;
}

.photo-tile img {
  width: 100%;
  height: auto;
  display: block;
  background: rgba(255, 255, 255, 0.04);
}

.grid-sentinel {
  height: 1px;
}

.grid-status {
  padding: 1rem 1.5rem 3rem;
  text-align: center;
}

.sync-notice {
  margin: 0 1.5rem 1rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: rgba(255, 196, 0, 0.12);
  border: 1px solid rgba(255, 196, 0, 0.35);
  font-size: 0.9rem;
}

.download-dialog {
  max-width: 32rem;
  padding: 1.5rem;
  border: none;
  border-radius: 12px;
}

.download-parts {
  display: grid;
  gap: 0.5rem;
  margin: 1rem 0;
}

.download-part {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0.85rem;
  border-radius: 8px;
  border: 1px solid rgba(128, 128, 128, 0.35);
}

.sync-cell {
  white-space: nowrap;
  font-size: 0.85rem;
}

.icon-button.danger {
  color: #fff;
  background: rgba(179, 38, 30, 0.9);
}

.icon-button.danger:hover {
  background: #8b241a;
}

/* ---------------------------------------------------------------------------
   Tile overlay actions + multi-select action bar
   --------------------------------------------------------------------------- */

.tile-overlay {
  position: absolute;
  right: 0.5rem;
  z-index: 2;
  display: flex;
  gap: 0.35rem;
}

.tile-overlay-top {
  top: 0.5rem;
}

.tile-overlay-bottom {
  bottom: 0.5rem;
}

.tile-overlay:empty {
  display: none;
}

.tile-overlay .favorite-button,
.tile-overlay .tile-download,
.tile-overlay .tile-select {
  position: static;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.35rem;
  height: 2.35rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 0.35rem 0.9rem rgba(20, 20, 20, 0.2);
  cursor: pointer;
  transition: transform 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}

.tile-overlay .tile-select svg,
.tile-overlay .tile-download svg {
  width: 1.15rem;
  height: 1.15rem;
}

.tile-overlay .tile-select.active {
  color: #fff;
  background: var(--accent);
}

.tile-overlay .favorite-button.active,
.tile-overlay .favorite-button.active:hover {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 0.35rem 0.9rem rgba(20, 20, 20, 0.2);
}

/* Desktop: the tile shows only its number until the pointer is over it. */
@media (hover: hover) and (pointer: fine) {
  .tile-overlay {
    opacity: 0;
    transition: opacity 0.18s ease, transform 0.18s ease;
  }

  .tile-overlay-top {
    transform: translateY(-0.25rem);
  }

  .tile-overlay-bottom {
    transform: translateY(0.25rem);
  }

  .photo-tile:hover .tile-overlay,
  .photo-tile:focus-within .tile-overlay,
  .photo-tile.selected .tile-overlay {
    opacity: 1;
    transform: none;
  }
}

/* Touch: keep the buttons on screen, translucent and sized down for small tiles. */
@media (hover: none) {
  .tile-overlay .favorite-button,
  .tile-overlay .tile-download,
  .tile-overlay .tile-select {
    width: 1.95rem;
    height: 1.95rem;
    background: rgba(255, 255, 255, 0.62);
  }

  .tile-overlay .favorite-button {
    font-size: 0.9rem;
  }

  .tile-overlay .tile-select svg,
  .tile-overlay .tile-download svg {
    width: 0.98rem;
    height: 0.98rem;
  }

  .tile-overlay .favorite-button.active,
  .tile-overlay .tile-select.active {
    background: var(--accent);
  }
}

.photo-tile.selected {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

.photo-tile.selected img {
  opacity: 0.86;
}

.photo-tile.is-hidden-from-guests img {
  opacity: 0.5;
  filter: grayscale(0.4);
}

.photo-tile.is-hidden-from-guests::after {
  content: "Hidden";
  position: absolute;
  left: 0.6rem;
  bottom: 0.6rem;
  padding: 0.22rem 0.45rem;
  border-radius: 4px;
  color: #fff;
  background: rgba(0, 0, 0, 0.62);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.photo-tile.is-cover {
  box-shadow: 0 0 0 3px var(--sage);
}

.selection-bar {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.55rem;
  border-radius: 999px;
  color: #fff;
  background: rgba(22, 22, 21, 0.94);
  box-shadow: 0 1rem 2.4rem rgba(0, 0, 0, 0.35);
  transform: translateX(-50%);
}

.selection-bar.hidden {
  display: none;
}

.selection-count {
  padding: 0 0.35rem 0 0.6rem;
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
}

.selection-divider {
  width: 1px;
  height: 1.4rem;
  margin: 0 0.15rem;
  background: rgba(255, 255, 255, 0.22);
}

.selection-action,
.selection-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.3rem;
  height: 2.3rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  color: inherit;
  background: transparent;
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease;
}

.selection-action svg,
.selection-clear svg {
  width: 1.15rem;
  height: 1.15rem;
}

.selection-action:hover,
.selection-clear:hover {
  background: rgba(255, 255, 255, 0.16);
}

.selection-action.active {
  color: var(--sage);
}

.selection-action.danger:hover {
  color: #fff;
  background: rgba(179, 38, 30, 0.92);
}

.selection-action.hidden {
  display: none;
}

/* Lightbox footer actions mirror the round icon buttons used on the tiles. */
.dialog-actions {
  gap: 0.5rem;
}

.dialog-actions > button,
.dialog-actions > .download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.6rem;
  height: 2.6rem;
  min-height: 2.6rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease;
}

.dialog-actions svg {
  width: 1.2rem;
  height: 1.2rem;
}

.dialog-actions > button:hover,
.dialog-actions > .download-button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.32);
}

#lightboxFavorite,
#lightboxRemove {
  background: rgba(255, 255, 255, 0.16);
}

#lightboxFavorite.active,
#lightboxFavorite.active:hover {
  color: #fff;
  background: var(--accent);
}

/* styles.css paints #lightboxFavorite:hover red; touch devices keep :hover stuck
   after a tap, which left an un-favorited photo looking favorited. */
#lightboxFavorite:hover {
  background: rgba(255, 255, 255, 0.32);
}

#lightboxHide.active {
  color: var(--sage);
}

#lightboxRemove:hover {
  background: rgba(179, 38, 30, 0.92);
}

/* Responsive columns + toolbar for tablets and phones. */
@media (max-width: 760px) {
  .gallery-grid {
    padding: 0.5rem;
  }

  .hero {
    min-height: 68vh;
  }

  .hero img {
    height: 100%;
    min-height: 68vh;
    object-fit: contain;
  }

  .toolbar {
    position: static;
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
  }

  .actions {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .hero-overlay {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .role-badge {
    align-self: flex-start;
    max-width: 100%;
    flex-shrink: 0;
  }
}

@media (max-width: 430px) {
  .tile-overlay .favorite-button,
  .tile-overlay .tile-download,
  .tile-overlay .tile-select {
    width: 1.75rem;
    height: 1.75rem;
  }

  .tile-overlay .tile-select svg,
  .tile-overlay .tile-download svg {
    width: 0.9rem;
    height: 0.9rem;
  }

  .selection-bar {
    left: 0.6rem;
    right: 0.6rem;
    bottom: 0.85rem;
    justify-content: space-between;
    transform: none;
  }

  .dialog-actions > button,
  .dialog-actions > .download-button {
    width: 2.3rem;
    height: 2.3rem;
    min-height: 2.3rem;
  }
}

