/* Gallery masonry + lightbox — header/filters keep original Tabo styles */

.tg-gallery {
  --tg-gold: hsl(35, 55%, 58%);
  --tg-cream: hsl(35, 30%, 92%);
  --tg-font-body: 'BananaGrotesk', 'Outfit', sans-serif;

  width: 100%;
  float: none;
  clear: both;
}

.tg-gallery * {
  box-sizing: border-box;
}

/* Keep original site container width for the new grid */
.gallery_container_images.tg-gallery-grid-section {
  width: 1170px;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding: 20px 15px 0;
  float: none;
}

.tg-gallery-grid {
  column-count: 1;
  column-gap: 0.75rem;
}

@media (min-width: 640px) {
  .tg-gallery-grid {
    column-count: 2;
  }
}

@media (min-width: 1024px) {
  .tg-gallery-grid {
    column-count: 3;
  }
}

/* Match Lovable: 4 columns on wide screens */
@media (min-width: 1280px) {
  .tg-gallery-grid {
    column-count: 4;
  }
}

.tg-gallery-item {
  break-inside: avoid;
  margin-bottom: 0.75rem;
  opacity: 0;
  transform: translateY(24px) scale(0.98);
  animation: tg-fade-up 0.35s ease forwards;
}

@keyframes tg-fade-up {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.tg-gallery-card {
  position: relative;
  cursor: pointer;
  overflow: hidden;
  border-radius: 0.5rem;
}

.tg-gallery-media {
  position: relative;
  overflow: hidden;
  width: 100%;
}

.tg-aspect-wide {
  aspect-ratio: 16 / 10;
}

.tg-aspect-standard {
  aspect-ratio: 5 / 4;
}

.tg-aspect-tall {
  aspect-ratio: 4 / 5;
}

.tg-aspect-video {
  aspect-ratio: 16 / 9;
}

.tg-aspect-video-std {
  aspect-ratio: 4 / 3;
}

.tg-gallery-media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.7s ease;
  display: block;
}

.tg-gallery-card:hover .tg-gallery-media img {
  transform: scale(1.1);
}

.tg-gallery-media .tg-gallery-video-thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  pointer-events: none;
  transition: transform 0.7s ease;
  display: block;
  background: #1a1a1a;
}

.tg-gallery-card:hover .tg-gallery-media .tg-gallery-video-thumb {
  transform: scale(1.1);
}

.tg-gallery-overlay {
  position: absolute;
  inset: 0;
  background: transparent;
  transition: background 0.5s ease;
  pointer-events: none;
}

.tg-gallery-card:hover .tg-gallery-overlay {
  background: rgba(20, 12, 8, 0.4);
}

.tg-gallery-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.tg-gallery-play-btn {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background: hsla(35, 55%, 58%, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  transition: transform 0.3s ease;
}

.tg-gallery-play-btn svg {
  width: 22px;
  height: 22px;
  color: hsl(25, 50%, 12%);
  margin-left: 2px;
  fill: currentColor;
}

.tg-gallery-card:hover .tg-gallery-play-btn {
  transform: scale(1.1);
}

.tg-gallery-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.75rem;
  transform: translateY(100%);
  transition: transform 0.5s ease;
  pointer-events: none;
}

.tg-gallery-card:hover .tg-gallery-caption {
  transform: translateY(0);
}

.tg-gallery-caption p {
  margin: 0;
  font-family: var(--tg-font-body);
  font-size: 0.75rem;
  color: var(--tg-cream);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.tg-gallery-type-icon {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  color: var(--tg-gold);
}

html[lang="ar"] .tg-gallery-type-icon {
  right: auto;
  left: 0.5rem;
}

.tg-gallery-card:hover .tg-gallery-type-icon {
  opacity: 1;
}

.tg-gallery-type-icon svg {
  width: 14px;
  height: 14px;
  display: block;
}

.tg-gallery-empty {
  text-align: center;
  padding: 3rem 1rem;
  font-family: var(--tg-font-body);
  color: #6b6b6b;
  font-size: 1rem;
}

/* Match original responsive container widths */
@media (max-width: 1199px) {
  .gallery_container_images.tg-gallery-grid-section {
    width: 100%;
    padding-left: 20px;
    padding-right: 20px;
  }
}

/* Lightbox */
.tg-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(20, 12, 8, 0.95);
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.tg-lightbox.is-open {
  display: flex;
  opacity: 1;
}

.tg-lightbox-close,
.tg-lightbox-prev,
.tg-lightbox-next {
  position: absolute;
  background: transparent;
  border: 0;
  color: rgba(245, 237, 224, 0.5);
  cursor: pointer;
  padding: 0.5rem;
  z-index: 10;
  transition: color 0.2s ease;
  line-height: 0;
}

.tg-lightbox-close:hover,
.tg-lightbox-prev:hover,
.tg-lightbox-next:hover {
  color: var(--tg-cream);
}

.tg-lightbox-close {
  top: 1.5rem;
  right: 1.5rem;
  color: rgba(245, 237, 224, 0.7);
}

html[lang="ar"] .tg-lightbox-close {
  right: auto;
  left: 1.5rem;
}

.tg-lightbox-prev {
  left: 1rem;
}

.tg-lightbox-next {
  right: 1rem;
}

/* Arabic: swap arrow sides + flip chevron direction */
html[lang="ar"] .tg-lightbox-prev {
  left: auto;
  right: 1rem;
}

html[lang="ar"] .tg-lightbox-next {
  right: auto;
  left: 1rem;
}

html[lang="ar"] .tg-lightbox-prev svg,
html[lang="ar"] .tg-lightbox-next svg {
  transform: scaleX(-1);
}

@media (min-width: 768px) {
  .tg-lightbox-prev {
    left: 2rem;
  }
  .tg-lightbox-next {
    right: 2rem;
  }
  html[lang="ar"] .tg-lightbox-prev {
    left: auto;
    right: 2rem;
  }
  html[lang="ar"] .tg-lightbox-next {
    right: auto;
    left: 2rem;
  }
}

.tg-lightbox-close svg,
.tg-lightbox-prev svg,
.tg-lightbox-next svg {
  display: block;
}

.tg-lightbox-body {
  max-width: 95vw;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tg-lightbox-body img {
  width: auto;
  height: auto;
  max-height: 90vh;
  max-width: 95vw;
  border-radius: 0.25rem;
  display: block;
}

.tg-lightbox-video {
  border-radius: 0.25rem;
  overflow: hidden;
  background: #000;
}

/* YouTube embed: same viewport limits as uploaded file videos */
.tg-lightbox-video.tg-lightbox-video-embed {
  width: min(95vw, calc(92vh * 16 / 9));
  height: min(92vh, calc(95vw * 9 / 16));
  max-width: 95vw;
  max-height: 92vh;
  aspect-ratio: auto;
}

.tg-lightbox-video iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.tg-lightbox-video video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
  object-fit: contain;
}

/* Uploaded video files: natural ratio, no black letterbox wrapper */
.tg-lightbox-video.tg-lightbox-video-file {
  width: auto;
  max-width: 95vw;
  aspect-ratio: auto;
  background: transparent;
  overflow: visible;
}

.tg-lightbox-video.tg-lightbox-video-file video {
  width: auto;
  height: auto;
  max-width: 95vw;
  max-height: 92vh;
  background: transparent;
  object-fit: contain;
  border-radius: 0.25rem;
}

/* Portrait uploaded videos: fill height, no black bars behind the video */
.tg-lightbox-video.tg-lightbox-video-file.tg-lightbox-video-portrait video {
  max-height: 92vh;
  max-width: min(95vw, calc(92vh * 9 / 16));
  width: auto;
  height: auto;
  background: transparent;
}

.tg-lightbox.tg-lightbox-has-portrait-video .tg-lightbox-body {
  max-height: 90vh;
}

.tg-lightbox-counter {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--tg-font-body);
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  color: rgba(245, 237, 224, 0.4);
}

body.tg-lightbox-active {
  overflow: hidden;
}

/* Neutralize Bootstrap row float interference inside redesign */
.tg-gallery.row {
  margin-left: 0;
  margin-right: 0;
}

.tg-gallery::before,
.tg-gallery::after {
  display: none !important;
  content: none !important;
}
