/* ==========================================================================
   Avezz Media Hub — Galleries, Images & Lightbox (css/pages/media.css)
   1:1 Fidelity with UI/galleries.html & UI/images.html
   ========================================================================== */

:root {
  --stack-bg: #cdd3dc;
  --stack-border: rgba(15, 23, 42, 0.14);
  --stack-shadow: 0 -1px 4px rgba(15, 23, 42, 0.08);
  --stack-bright-step: 0.022;
  --gal-shadow-card: 0 14px 32px rgba(15, 23, 42, 0.14);
  --gal-shadow-bar: 0 12px 28px rgba(15, 23, 42, 0.14), 0 2px 6px rgba(15, 23, 42, 0.06);
}

[data-theme="dark"] {
  --stack-bg: #363840;
  --stack-border: rgba(255, 255, 255, 0.12);
  --stack-shadow: 0 -1px 5px rgba(0, 0, 0, 0.45);
  --stack-bright-step: -0.055;
  --gal-shadow-card: 0 18px 36px rgba(0, 0, 0, 0.5);
  --gal-shadow-bar: 0 14px 30px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.35);
}

.media-wrap {
  max-width: 1440px;
  margin: 0 auto;
  padding: 16px 16px 64px;
}

/* ==========================================================================
   1:1 GALLERIES GRID (UI/galleries.html)
   Quantity-Scaled Gray Stack Panels (1..10) + Enhanced Original Floating Bar
   ========================================================================== */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 44px 24px;
  padding-top: 10px;
}

.gallery-card {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding-top: var(--stack-h, 10px);
  padding-bottom: 18px;
}

.stack-anchor {
  position: relative;
  width: 100%;
}

.stack-layer {
  position: absolute;
  top: calc(-5px * var(--d));
  left: calc(6px * var(--d));
  right: calc(6px * var(--d));
  height: 290px;
  z-index: calc(20 - var(--d));
  border-radius: calc(30px - 1.2px * var(--d));
  background: var(--stack-bg);
  filter: brightness(calc(1 + (var(--d) - 1) * var(--stack-bright-step)));
  border: 1px solid var(--stack-border);
  box-shadow: var(--stack-shadow);
  pointer-events: none;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.gallery-card:hover .stack-layer {
  transform: translateY(calc(-1.5px * var(--d)));
}

.gallery-media {
  position: relative;
  z-index: 25;
  display: block;
  height: 340px;
  width: 100%;
  border-radius: 30px;
  overflow: hidden;
  background: #111827;
  box-shadow: var(--gal-shadow-card);
  text-decoration: none;
}

.gallery-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.gallery-card:hover .gallery-cover {
  transform: scale(1.04);
}

.gallery-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.84) 0%,
    rgba(0, 0, 0, 0.34) 44%,
    rgba(0, 0, 0, 0.08) 76%,
    rgba(0, 0, 0, 0.22) 100%
  );
  pointer-events: none;
}

.pic-count-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(15, 18, 24, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.24);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
  pointer-events: none;
}

.pic-count-badge .icon { width: 14px; height: 14px; }

.gallery-overlay {
  position: absolute;
  bottom: 54px;
  left: 0;
  right: 0;
  z-index: 4;
  padding: 0 22px;
}

.gallery-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.gallery-tag {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.28);
}

.gallery-title {
  color: #ffffff;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.32;
  width: 94%;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Floating Action Bar (1:1 UI/galleries.html) */
.gallery-floating-bar {
  position: absolute;
  bottom: -22px;
  left: 12px;
  right: 12px;
  z-index: 30;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--gal-shadow-bar);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.gallery-floating-bar .action-group {
  gap: 9px;
}

.gal-author {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.gal-author:hover { color: var(--accent); text-decoration: none; }

.gal-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.gal-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.actions {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.act-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 6px;
  border-radius: 8px;
  color: var(--text-muted);
  background: none;
  border: 0;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s ease, background 0.15s ease, transform 0.12s ease;
}

.act-btn:hover { background: var(--surface-alt); color: var(--text); text-decoration: none; }
.act-btn:active { transform: scale(0.94); }
.act-btn.like.active { color: var(--accent); }
.act-btn.deslike.active { color: var(--negative); }
.act-btn.share.active { color: var(--star); }
.act-count { font-size: 12px; font-weight: 600; color: var(--text); }

/* ==========================================================================
   1:1 IMAGES BROWSER (UI/images.html)
   Pinterest Masonry & Smart 2D Auto-Span Grid (No Cropping + Overlay Socials)
   ========================================================================== */
.images-stage {
  position: relative;
  width: 100%;
  min-height: 260px;
}

.images-stage:not(.is-masonry-ready) {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.images-stage.is-masonry-ready > .tile {
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform, width;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), width 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.tile {
  display: flex;
  flex-direction: column;
  position: relative;
}

.tile-media {
  position: relative;
  width: 100%;
  border-radius: 12px;
  overflow: visible;
  background: var(--surface-alt);
  cursor: pointer;
  box-shadow: var(--shadow);
}

.tile-img-clip {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.tile-img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  transition: transform 0.25s ease;
}

.tile-img:not([width]) { aspect-ratio: 4 / 3; }

.images-stage.is-smart2d .tile-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.tile-media:hover .tile-img { transform: scale(1.02); }

.tile-overlay {
  position: absolute;
  inset: 0;
  padding: 8px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.42), transparent 36%, transparent 62%, rgba(0, 0, 0, 0.56));
  opacity: 0;
  transition: opacity 0.16s ease;
  pointer-events: none;
}

.tile:hover .tile-overlay,
.tile:focus-within .tile-overlay,
.tile.has-open-menu .tile-overlay,
.tile.is-center-focus .tile-overlay {
  opacity: 1;
}

.tile-top-bar,
.tile-bottom-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.tile-overlay a,
.tile-overlay button,
.tile-overlay form,
.tile-overlay .card-menu-anchor {
  pointer-events: auto;
}

.tile-pill {
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(18, 18, 20, 0.72);
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
  backdrop-filter: blur(6px);
  text-decoration: none;
}

.tile-pill:hover { background: rgba(18, 18, 20, 0.92); text-decoration: none; }

.tile-title {
  position: relative;
  z-index: 4;
  height: 28px;
  line-height: 28px;
  padding: 0 3px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
  user-select: text;
  -webkit-user-select: text;
  pointer-events: auto;
  transition: color 0.15s ease;
}
.tile-title:hover,
.tile:hover .tile-title { color: var(--accent); text-decoration: underline; }

/* ==========================================================================
   GALLERY DETAIL & IMAGE DETAIL PAGES
   ========================================================================== */
.detail-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 16px 56px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.detail-hero-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.detail-stage-img {
  width: 100%;
  max-height: 76vh;
  object-fit: contain;
  border-radius: var(--radius);
  background: var(--surface-muted);
  cursor: zoom-in;
}

.gallery-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.gallery-detail-item {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface-alt);
  aspect-ratio: 4 / 3;
  cursor: zoom-in;
  box-shadow: var(--shadow);
}

.gallery-detail-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.25s ease;
}

.gallery-detail-item:hover img { transform: scale(1.04); }

/* ==========================================================================
   FULL-SCREEN LIGHTBOX
   ========================================================================== */
.avezz-lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(10, 10, 14, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 56px 56px;
}

.avezz-lightbox.open { display: flex; }

.lb-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #f3f4f6;
}

.lb-counter { font-size: 13px; font-weight: 700; color: rgba(255, 255, 255, 0.8); }
.lb-top-actions { display: flex; align-items: center; gap: 8px; }

.lb-btn {
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-size: 12.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.18);
  cursor: pointer;
}
.lb-btn:hover { background: rgba(255, 255, 255, 0.24); text-decoration: none; }
.lb-btn-icon { width: 34px; padding: 0; font-size: 20px; }

.lb-stage {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.lb-img {
  max-width: 100%;
  max-height: calc(100dvh - 130px);
  border-radius: 10px;
  object-fit: contain;
  box-shadow: 0 20px 56px rgba(0, 0, 0, 0.6);
}

.lb-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-size: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
}
.lb-nav:hover { background: rgba(255, 255, 255, 0.28); }
.lb-prev { left: 14px; }
.lb-next { right: 14px; }

.lb-caption {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(90vw, 720px);
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(15, 18, 24, 0.72);
  color: #f3f4f6;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 640px) {
  .avezz-lightbox { padding: 58px 12px 52px; }
  .lb-nav { width: 36px; height: 36px; font-size: 22px; }
}
