/* 
========================================
Gallery Page Styles - Gunawangsa Merr
========================================
*/

/* Gallery Tabs */
.gallery-tabs {
  display: flex;
  justify-content: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.gallery-tab {
  background-color: rgba(6, 16, 31, 0.85);
  color: var(--white-dim);
  padding: 0.75rem 1.5rem;
  margin: 0.25rem;
  border-radius: 30px;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
  border: 1px solid var(--black-lightest);
}

.gallery-tab.active, .gallery-tab:hover {
  background-color: var(--gold);
  color: var(--black);
}

/* Gallery Grid */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}
/* Gallery header (aligned with News header style: short lines + gap) */
.gallery-header { text-align:center; margin:2rem 0 4rem; position:relative; }
.gallery-header { font-size:2.5rem; font-weight:700; color:var(--gold); margin:0 1rem; display:inline-block; --header-line-gap:14px; }
/* New short lines anchored to the text with spacing */
.gallery-header::before,
.gallery-header::after { content:''; position:absolute; top:50%; height:1px; background-color:#9a7e53; opacity:1; width:200px; transform:translateY(-50%) scaleX(1); }
.gallery-header::before { right:calc(100% + var(--header-line-gap)); }
.gallery-header::after { left:calc(100% + var(--header-line-gap)); }

@media (max-width: 576px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
  }
}

/* Gallery Card */
.gallery-card {
  background-color: rgba(6, 16, 31, 0.85);
  border: 1px solid var(--black-lightest);
  border-radius: 8px;
  overflow: hidden;
  transition: var(--transition);
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
}

.gallery-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--gold-shadow);
  border-color: var(--gold-dark);
}

/* Gallery Card Image */
.gallery-img-container {
  position: relative;
  padding-top: 56.25%; /* 16:9 Aspect Ratio to match YouTube */
  overflow: hidden;
  background-color: var(--black-lightest);
}

.gallery-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: var(--transition);
  filter: brightness(0.9) contrast(1.1); /* Restore filter for consistent look */
}

.gallery-card:hover .gallery-img {
  transform: scale(1.05);
  filter: brightness(1) contrast(1.05); /* Brighter on hover */
}

/* Gallery Card Video */
.gallery-video-container {
  position: relative;
  padding-top: 56.25%; /* 16:9 Aspect Ratio */
  overflow: hidden;
  background-color: var(--black-lightest);
}



.gallery-video,
.gallery-video-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain; /* Changed to contain */
  background: #000;
  filter: brightness(0.9) contrast(1.1); /* Restore filter for consistent look */
  max-width: 100%;
  margin: 0 auto;
}

.gallery-video-container:hover .gallery-video {
  filter: brightness(1) contrast(1.05); /* Brighter on hover */
}

/* Gallery Content */
.gallery-content {
  padding: 1.25rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.gallery-title {
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-size: 1.25rem;
  color: var(--gold);
}

/* Error State */
.gallery-error {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--black-light);
  color: var(--gold-dark);
  padding: 1rem;
  text-align: center;
}

/* Lightbox Modal */
.gallery-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.lightbox-content {
  position: relative;
  max-width: 90%;
  max-height: 90%;
}

.lightbox-img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  box-shadow: var(--box-shadow);
}

.lightbox-video {
  max-width: 100%;
  max-height: 80vh;
}

.lightbox-close {
  position: absolute;
  top: -40px;
  right: 0;
  color: var(--white);
  background: transparent;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  transition: var(--transition);
}

.lightbox-close:hover {
  color: var(--gold);
}

.lightbox-caption {
  color: var(--white);
  text-align: center;
  margin-top: 1rem;
  padding: 0.5rem;
  
}

/* Lightbox navigation placed inside content so we tighten horizontal gap */
/* Lightbox nav: place arrows just OUTSIDE media so they don't cover content */
.lightbox-content { position: relative; }
.lightbox-nav {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 0; /* collapse height so it doesn't overlay below */
  pointer-events: none; /* only buttons clickable */
  z-index: 2001;
}

.lightbox-prev,
.lightbox-next {
  position: absolute;
  top: 0; /* relative to 50% center line of nav */
  transform: translateY(-50%);
  background-color: rgba(0, 0, 0, 0.55);
  color: var(--white);
  border: 1px solid rgba(255,255,255,0.18);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  pointer-events: auto;
  backdrop-filter: blur(4px);
}

/* Offset outside content bounds */
.lightbox-prev { left: -62px; }
.lightbox-next { right: -62px; }

.lightbox-prev:hover,
.lightbox-next:hover {
  background-color: var(--gold);
  color: var(--black);
  border-color: var(--gold);
}

@media (max-width: 767.98px) {
  .lightbox-prev, .lightbox-next { width:42px; height:42px; }
  .lightbox-prev { left: -50px; }
  .lightbox-next { right: -50px; }
  /* When screen very narrow, bring them inside slightly */
  @media (max-width: 420px) {
    .lightbox-prev { left: -40px; }
    .lightbox-next { right: -40px; }
  }
}
/* Extra small width: pull arrows fully inside and shrink */
@media (max-width: 380px) {
  .lightbox-prev, .lightbox-next { left: 8px; right: 8px; width:38px; height:38px; background-color: rgba(0,0,0,0.65); }
  .lightbox-prev { left: 6px; }
  .lightbox-next { right: 6px; }
  .lightbox-img, .lightbox-video { max-height: 55vh; }
  .lightbox-caption { font-size: .8rem; padding: .4rem .6rem; }
}

/* Low height screens (landscape phones / small viewports) */
@media (max-height: 560px) {
  .lightbox-img, .lightbox-video { max-height: 60vh; }
  .lightbox-close { top: -32px; font-size: 1.6rem; }
  .lightbox-prev, .lightbox-next { width:42px; height:42px; }
  .lightbox-caption { max-height: 20vh; overflow:auto; font-size: .8rem; }
}
@media (max-height: 480px) {
  /* Switch arrows inside content area to avoid overflow */
  .lightbox-prev { left: 8px; }
  .lightbox-next { right: 8px; }
  .lightbox-prev, .lightbox-next { width:38px; height:38px; }
  .lightbox-img, .lightbox-video { max-height: 52vh; }
  .lightbox-caption { margin-top: .6rem; }
}
@media (max-height: 420px) {
  .lightbox-img, .lightbox-video { max-height: 48vh; }
  .lightbox-caption { font-size: .7rem; }
}

/* Dynamic compact mode (added by JS when both width & height are tight) */
.gallery-lightbox.lightbox-compact .lightbox-img,
.gallery-lightbox.lightbox-compact .lightbox-video { max-height: 50vh; }
.gallery-lightbox.lightbox-compact .lightbox-prev { left: 10px; }
.gallery-lightbox.lightbox-compact .lightbox-next { right: 10px; }
.gallery-lightbox.lightbox-compact .lightbox-prev,
.gallery-lightbox.lightbox-compact .lightbox-next { width:38px; height:38px; }
.gallery-lightbox.lightbox-compact .lightbox-caption { font-size: .75rem; padding:.45rem .6rem; }

/* Ensure caption does not overflow outside viewport */
.lightbox-caption { max-width: 100%; word-wrap: break-word; overflow-wrap: anywhere; }

/* Gallery Tab Panes */
.gallery-tab-pane {
  display: none;
}

.gallery-tab-pane.active {
  display: block;
  animation: fadeIn 0.4s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Gallery Item Type Classes */
.gallery-image-item, .gallery-video-item {
  transition: all 0.3s ease;
}

/* Mobile Optimizations */
@media (max-width: 767px) {
  .gallery-tabs {
    flex-wrap: wrap;
  }
  
  .gallery-tab {
    margin: 0.25rem;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }
  
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(100%, 1fr));
  }
}

/* ===================== Responsive Gallery Enhancements ===================== */
/* XL ≥1200px */
@media (min-width: 1200px) {
  .gallery-header { font-size: 3rem; letter-spacing: 5px; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
}
/* LG 992–1199 */
@media (min-width: 992px) and (max-width: 1199.98px) {
  .gallery-header { font-size: 2.7rem; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
}
/* MD 768–991 */
@media (min-width: 768px) and (max-width: 991.98px) {
  .gallery-header { font-size: 2.3rem; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
}
/* SM 576–767 */
@media (min-width: 576px) and (max-width: 767.98px) {
  .gallery-header { font-size: 2rem; letter-spacing: 3.5px; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1.25rem; }
  .gallery-card { border-radius: 10px; }
}
/* XS <576 */
@media (max-width: 575.98px) {
  .gallery-header { font-size: 1.65rem; letter-spacing: 3px; }
  .gallery-header::before,
  .gallery-header::after { width:50px; }
  .gallery-grid { grid-template-columns: 1fr; gap: 1rem; }
  .gallery-content { padding: 1rem 0.9rem 1.1rem; }
}
/* General tablet & down adjustments */
@media (max-width: 991.98px) {
  .gallery-header { margin: 1.8rem 0 3rem; }
}
/* Orientation tweaks */
@media (orientation: portrait) and (max-width: 767.98px) {
  .gallery-header { margin: 1.6rem 0 2.4rem; }
  .gallery-card .gallery-img { filter: brightness(0.95); }
}
@media (orientation: landscape) and (max-width: 991.98px) {
  .gallery-header { margin: 1.2rem 0 2.2rem; }
  .gallery-grid { gap: 1rem; }
}

