/* ==========================================================================
   Gallery page styles - Devatha Industries
   ========================================================================== */

/* ---------- Tabs (Photos / Videos) ---------- */
.gallery_tabs {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 35px;
}

.gallery_tabs button {
  border: 1px solid #031652;
  background-color: transparent;
  color: #031652;
  font-weight: 600;
  padding: 10px 32px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.gallery_tabs button:hover {
  background-color: #1d2943;
  border-color: #1d2943;
  color: #ffffff;
}

.gallery_tabs button.active {
  background-color: #031652;
  color: #ffffff;
}

.gallery_panel[hidden] {
  display: none;
}

/* ---------- Responsive image / video grid ---------- */
.gallery_grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
}

.gallery_item {
  position: relative;
  /* Column flex so that tiles in a row can match heights: the thumbnail
     absorbs any slack left by shorter captions instead of leaving a
     white gap under the tile. */
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 0;
  border: 1px solid #e4e4e4;
  border-radius: 6px;
  overflow: hidden;
  background-color: #f4f4f4;
  cursor: pointer;
  transition: box-shadow 0.25s ease, transform 0.25s ease;
}

.gallery_item:hover,
.gallery_item:focus {
  box-shadow: 0 6px 18px rgba(3, 22, 82, 0.28);
  transform: translateY(-3px);
  outline: none;
}

.gallery_item:focus-visible {
  outline: 3px solid #fc0909;
  outline-offset: 2px;
}

/* Uniform tiles regardless of the source image aspect ratio.
   padding-top sets the base ratio; flex-grow lets it take up any extra
   row height, and the object-fit image simply fills whatever it gets. */
.gallery_item .thumb_box {
  position: relative;
  width: 100%;
  padding-top: 75%; /* 4:3 */
  flex: 1 0 auto;
}

.gallery_item .thumb_box img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Reels / Shorts are vertical, so video tiles use a 9:16 frame */
.video_grid {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.video_grid .gallery_item .thumb_box {
  padding-top: 177.78%; /* 9:16 */
  background-color: #131313;
}

/* Fallback tile used when a video has no poster image */
.poster_fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 20px;
  text-align: center;
  background: linear-gradient(150deg, #031652 0%, #1d2943 60%, #0b1f6b 100%);
  color: #ffffff;
}

.poster_fallback .fa {
  font-size: 46px;
  opacity: 0.92;
}

.poster_fallback span {
  font-size: 13px;
  line-height: 1.4;
  opacity: 0.85;
}

/* Small source badge in the corner of every video tile */
.source_badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background-color: rgba(0, 0, 0, 0.62);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  pointer-events: none;
}

.source_badge.is_youtube {
  background-color: rgba(255, 0, 0, 0.88);
}

.source_badge.is_instagram {
  background: linear-gradient(45deg, #f09433, #dc2743, #bc1888);
}

.source_badge.is_facebook {
  background-color: rgba(24, 119, 242, 0.92);
}

.gallery_item .item_caption {
  padding: 10px 12px;
  font-size: 14px;
  color: #031652;
  background-color: #ffffff;
  text-align: center;
}

/* Play badge on video thumbnails */
.play_badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 68px;
  height: 48px;
  border-radius: 12px;
  background-color: rgba(252, 9, 9, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
  pointer-events: none;
}

.play_badge::before {
  content: "";
  border-style: solid;
  border-width: 11px 0 11px 18px;
  border-color: transparent transparent transparent #ffffff;
}

.gallery_item:hover .play_badge {
  background-color: #fc0909;
}

/* ---------- Empty state (used until video links are supplied) ---------- */
.gallery_empty {
  text-align: center;
  padding: 40px 20px;
  color: #5c5c5c;
  border: 1px dashed #c9c9c9;
  border-radius: 6px;
}

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background-color: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 15px;
}

.lightbox[hidden] {
  display: none;
}

.lightbox_stage {
  position: relative;
  width: 100%;
  max-width: 1000px;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.lightbox_stage img {
  max-width: 100%;
  max-height: 78vh;
  object-fit: contain;
  border-radius: 4px;
}

/* 16:9 wrapper for standard landscape video */
.lightbox_video {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  max-height: 78vh;
}

/* Vertical wrapper for Reels / Shorts */
.lightbox_video.is_portrait {
  padding-top: 0;
  height: 80vh;
  width: auto;
  aspect-ratio: 9 / 16;
  max-width: 100%;
}

/* Instagram's embed adds its own header/footer chrome, so it needs a
   slightly wider, taller frame than a bare 9:16 player. */
.lightbox_video.is_instagram {
  padding-top: 0;
  aspect-ratio: auto;
  height: 84vh;
  width: 100%;
  max-width: 400px;
}

/* Placeholder text behind the iframe while the embed loads */
.lightbox_loading {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  text-align: center;
  color: #b9b9b9;
  font-size: 14px;
}

.lightbox_video iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 4px;
  background-color: #000000;
}

/* "Open on YouTube / Instagram / Facebook" fallback link */
.lightbox_source {
  display: inline-block;
  margin-top: 12px;
  color: #ffffff;
  font-size: 14px;
  text-decoration: underline;
  opacity: 0.85;
}

.lightbox_source:hover,
.lightbox_source:focus {
  color: #ffffff;
  opacity: 1;
}

.lightbox_caption {
  color: #ffffff;
  font-size: 15px;
  margin-top: 14px;
  text-align: center;
}

.lightbox_btn {
  position: absolute;
  background-color: rgba(3, 22, 82, 0.75);
  color: #ffffff;
  border: 0;
  border-radius: 50%;
  width: 46px;
  height: 46px;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
}

.lightbox_btn:hover,
.lightbox_btn:focus {
  background-color: #fc0909;
  outline: none;
}

.lightbox_close {
  top: 15px;
  right: 15px;
  position: fixed;
}

.lightbox_prev {
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  position: fixed;
}

.lightbox_next {
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  position: fixed;
}

/* ---------- Responsive tweaks ---------- */
@media (max-width: 768px) {
  .gallery_grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
  }

  .gallery_tabs button {
    padding: 8px 22px;
    font-size: 14px;
  }

  .lightbox {
    padding: 60px 10px;
  }

  .lightbox_btn {
    width: 40px;
    height: 40px;
    font-size: 22px;
  }
}

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

@media (max-width: 480px) {
  .gallery_grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .video_grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .gallery_item .item_caption {
    font-size: 12px;
    padding: 7px 8px;
  }

  .lightbox_video.is_portrait,
  .lightbox_video.is_instagram {
    height: 74vh;
  }
}
