/* ── gallery.css ────────────────────────────────────────────────────────────
   Styles for the v11 gallery feature:
     ImageGallery      — carousel and grid inside ActivityDetail
     GalleryLightbox   — fullscreen image overlay (z-index 800)
     GalleryBrowseView — full-screen photo grid view mode

   Add to index.html AFTER mosaic.css:
   <link rel="stylesheet" href="_content/Playtypus.Core/css/gallery.css" />
───────────────────────────────────────────────────────────────────────────── */

/* ═══════════════════════════════════════════════════════════════════════════
   IMAGE GALLERY (inside ActivityDetail body)
═══════════════════════════════════════════════════════════════════════════ */

/* ── Shared ── */
.image-gallery {
  border-radius: var(--radius-md, 10px);
  overflow: hidden;
}

.image-gallery__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Tap-target button resets — must not look like a button */
.image-gallery__tap-target {
  display: block;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: zoom-in;
  width: 100%;
}

/* ── Single image ── */
.image-gallery--single .image-gallery__img {
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-md, 10px);
}

/* ── Carousel ── */
.image-gallery--carousel {
  display: flex;
  overflow-x: scroll;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.image-gallery--carousel::-webkit-scrollbar { display: none; }

.image-gallery__slide {
  scroll-snap-align: start;
  flex: 0 0 100%;
  position: relative;
}
.image-gallery__slide .image-gallery__img {
  aspect-ratio: 4 / 3;
}

/* Dot indicators (rendered below carousel by ImageGallery) */
.image-gallery__dots {
  display: flex;
  justify-content: center;
  gap: 5px;
  padding: 6px 0 2px;
}
.image-gallery__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-border, rgba(0,0,0,0.18));
  transition: background 0.2s;
}

/* ── Grid ── */
.image-gallery--grid {
  display: grid;
  grid-template-columns: repeat(var(--gallery-cols, 2), 1fr);
  gap: 3px;
}
.image-gallery__grid-item {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
}
.image-gallery__grid-item .image-gallery__img {
  transition: transform 0.2s ease;
}
.image-gallery__grid-item:active .image-gallery__img {
  transform: scale(0.97);
}
.image-gallery__grid-caption {
  position: absolute;
  bottom: 0; inset-inline: 0;
  padding: 20px 6px 6px;
  background: linear-gradient(transparent, rgba(0,0,0,0.55));
  color: #fff;
  font-size: 0.72rem;
  line-height: 1.3;
  pointer-events: none;
}

/* ── Caption bar (below single image or carousel slide) ── */
.image-gallery__caption-bar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 5px 2px 0;
}
.image-gallery__caption-text {
  font-size: 0.82rem;
  color: var(--color-text-secondary, #666);
  line-height: 1.4;
  flex: 1;
}
.image-gallery__credit {
  font-size: 0.72rem;
  color: var(--color-text-tertiary, #999);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Hero tap affordance */
.detail-panel__hero-tap {
  position: absolute;
  inset: 0;
  background: none;
  border: none;
  cursor: zoom-in;
  padding: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   GALLERY LIGHTBOX (fullscreen overlay)
═══════════════════════════════════════════════════════════════════════════ */

/* z-index audit (all existing values):
   detail panel: 200 | panic: 200 | tutorial: 300 | slideshow: 500
   Lightbox at 800 clears everything safely.                               */

.gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 800;
  display: flex;
  flex-direction: column;
  background: rgba(0,0,0,0.96);

  /* iOS Safari: prevent scroll bleed and dismiss-swipe conflicts */
  touch-action: pan-x;
  overscroll-behavior: contain;
  -webkit-tap-highlight-color: transparent;
}

/* Invisible full-bleed backdrop for tap-to-close */
.gallery-lightbox__backdrop {
  position: absolute;
  inset: 0;
  cursor: pointer;
}

/* ── Header ── */
.gallery-lightbox__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  position: relative;
  z-index: 1;
}
.gallery-lightbox__counter {
  color: rgba(255,255,255,0.7);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}
.gallery-lightbox__close {
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}
.gallery-lightbox__close:hover { background: rgba(255,255,255,0.22); }

/* ── Image area ── */
.gallery-lightbox__image-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.gallery-lightbox__image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  /* Native pinch-to-zoom — no JS needed */
  touch-action: pinch-zoom;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Navigation arrows (desktop only) ── */
.gallery-lightbox__arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.1);
  border: 1.5px solid rgba(255,255,255,0.15);
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: none;           /* hidden on mobile */
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  transition: background 0.15s;
}
.gallery-lightbox__arrow:hover  { background: rgba(255,255,255,0.22); }
.gallery-lightbox__arrow:disabled { opacity: 0.3; cursor: default; }
.gallery-lightbox__arrow--prev  { left: 12px; }
.gallery-lightbox__arrow--next  { right: 12px; }

@media (min-width: 640px) {
  .gallery-lightbox__arrow { display: flex; }
}

/* ── Caption ── */
.gallery-lightbox__caption {
  padding: 12px 20px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(0,0,0,0.65));
  position: relative;
  z-index: 1;
}
.gallery-lightbox__caption-text {
  margin: 0;
  color: rgba(255,255,255,0.9);
  font-size: 0.88rem;
  line-height: 1.45;
}
.gallery-lightbox__credit {
  margin: 3px 0 0;
  color: rgba(255,255,255,0.5);
  font-size: 0.75rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   GALLERY BROWSE VIEW (full view-mode replacing the activity grid)
═══════════════════════════════════════════════════════════════════════════ */

.gallery-browse {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2px;
  background: var(--color-border, rgba(0,0,0,0.08));
}

.gallery-browse__item {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  cursor: pointer;
  background: var(--color-surface-raised, #f0f0f2);
  -webkit-tap-highlight-color: transparent;
}

.gallery-browse__item:focus-visible {
  outline: 3px solid var(--color-accent, #3b82f6);
  outline-offset: -3px;
  z-index: 1;
}

/* Active state: slight scale, no jitter */
.gallery-browse__item:active {
  transform: scale(0.97);
  transition: transform 0.1s ease;
}

/* Done: subtle overlay without killing the image */
.gallery-browse__item--done::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.25);
  pointer-events: none;
}

/* Locked: greyscale + reduced opacity */
.gallery-browse__item--locked {
  cursor: default;
}
.gallery-browse__item--locked .gallery-browse__image,
.gallery-browse__item--locked .gallery-browse__placeholder {
  filter: grayscale(80%);
  opacity: 0.5;
}

/* ── Photo ── */
.gallery-browse__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s ease;
}
.gallery-browse__item:active .gallery-browse__image {
  transform: scale(1.03);
}

/* ── Emoji placeholder (no photo) ── */
.gallery-browse__placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--category-color, var(--color-surface-raised, #e8eaf0));
}
.gallery-browse__emoji {
  font-size: 2.8rem;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.12));
}

/* ── Status badges ── */
.gallery-browse__done-badge,
.gallery-browse__lock-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 3px 5px;
  border-radius: 4px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.gallery-browse__done-badge {
  background: rgba(34,197,94,0.85);
  color: #fff;
}
.gallery-browse__lock-badge {
  background: rgba(0,0,0,0.5);
  color: #fff;
}

/* ── Title overlay ── */
.gallery-browse__overlay {
  position: absolute;
  bottom: 0; inset-inline: 0;
  background: linear-gradient(transparent 0%, rgba(0,0,0,0.58) 100%);
  padding: 28px 7px 7px;
  pointer-events: none;
}
.gallery-browse__title {
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

/* ── Desktop: 3-column grid ── */
@media (min-width: 600px) {
  .gallery-browse {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (min-width: 900px) {
  .gallery-browse {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   LOGBOOK PHOTO UPLOADER (LogbookPhotoUploader.razor)
═══════════════════════════════════════════════════════════════════════════ */

.photo-uploader { display: flex; flex-direction: column; gap: 8px; }

.photo-uploader__grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.photo-uploader__thumb {
  position: relative;
  width: 90px; height: 90px;
  border-radius: var(--radius-md, 10px);
  overflow: hidden;
  flex-shrink: 0;
}

.photo-uploader__thumb--single { width: 120px; height: 120px; }

.photo-uploader__img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
}

.photo-uploader__delete {
  position: absolute; top: 4px; right: 4px;
  background: rgba(0,0,0,0.55);
  border: none; color: #fff;
  font-size: 0.7rem; width: 22px; height: 22px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; line-height: 1;
  transition: background 0.15s;
}
.photo-uploader__delete:hover { background: rgba(200,0,0,0.7); }

.photo-uploader__add {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  width: 90px; height: 90px;
  border: 2px dashed var(--color-border, rgba(0,0,0,0.18));
  border-radius: var(--radius-md, 10px);
  background: var(--color-surface-raised, #f5f5f7);
  cursor: pointer;
  color: var(--color-text-secondary, #666);
  transition: border-color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.photo-uploader__add:hover:not(:disabled) {
  border-color: var(--color-accent, #3b82f6);
  background: rgba(59,130,246,0.06);
}
.photo-uploader__add:disabled { opacity: 0.5; cursor: default; }
.photo-uploader__add--single { width: 120px; height: 120px; font-size: 1.2rem; }

.photo-uploader__add-icon { display: flex; align-items: center; justify-content: center; }
.photo-uploader__add-label {
  font-size: 0.7rem; font-weight: 600;
  text-align: center; line-height: 1.2;
}
.photo-uploader__spinner {
  font-size: 1.2rem;
  animation: pt-spin 1s linear infinite;
}
@keyframes pt-spin { to { transform: rotate(360deg); } }
.photo-uploader__error {
  font-size: 0.8rem;
  color: var(--color-error, #dc2626);
  margin: 0;
}
