/* Gallery styles — design-system friendly variables */
:root {
  --g-background: #fff;
  --g-primary: var(--primay-color, #6c070f);
  --g-text: #111;
  --g-muted: #666;
  --g-radius: var(--radius, 8px);
  --g-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  /* Smoother shadow */
  --g-gap: 1.5rem;
}

.page {
  background: var(--g-background)
}

.gallery-section {
  padding: 3rem 0;
  /* More breathing room */
}

/* Header Styling - Enforce block layout */
.gallery-header {
  margin-bottom: 2.5rem;
  text-align: center;
  min-height: 130px;
}

.gallery-header--back {
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  min-height: 140px;
  padding-bottom: 0.5rem;
}

.gallery-header h1 {
  display: block !important;
  margin: 0 0 0.5rem 0;
  font-size: 2.5rem;
  /* Slightly larger for centered title */
  font-weight: 700;
  color: var(--g-text);
  line-height: 1.2;
}

.gallery-title {
  margin: 0;
}

.gallery-title.is-loading {
  color: var(--g-muted);
  font-weight: 600;
  letter-spacing: 0.2px;
}

.gallery-header .lead {
  display: block !important;
  color: var(--g-muted);
  margin: 0 auto;
  /* Center the block */
  font-size: 1.1rem;
  max-width: 800px;
  text-align: center;
}

.gallery-header--back .lead {
  margin: 0;
  max-width: 900px;
}

.gallery-back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  line-height: 1;
}

.gallery-controls {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 2rem;
  min-height: 40px;
}

/* Grid System - Mobile First */
.gallery-grid {
  display: grid;
  grid-template-columns: 1fr;
  /* Default 1 column */
  gap: var(--g-gap);
  width: 100%;
}

.gallery-grid .spinner {
  width: 100%;
  padding: 2rem 0;
  text-align: center;
  color: var(--g-muted);
  font-weight: 600;
  letter-spacing: 0.2px;
}

/* Responsive columns */
@media(min-width: 576px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 576px) {
  .gallery-header--back {
    align-items: center;
    text-align: center;
    min-height: 150px;
  }

  .gallery-header--back .lead {
    margin: 0 auto;
  }

  /* Force stack and center for main header on mobile */
  .gallery-header h1,
  .gallery-header .lead {
    display: block !important;
    width: 100%;
    text-align: center;
    margin-left: auto;
    margin-right: auto;
  }
}

@media(min-width: 992px) {
  .gallery-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media(min-width: 1200px) {
  .gallery-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Specific overrides for Images view to have more columns */
.gallery-grid.view-images {
  grid-template-columns: 1fr;
  /* 1 col on mobile for albums */
}

@media(min-width: 768px) {
  .gallery-grid.view-images {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media(min-width: 1024px) {
  .gallery-grid.view-images {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media(min-width: 1400px) {
  .gallery-grid.view-images {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* Card Styles */
.gallery-card,
.photo-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--g-radius);
  box-shadow: var(--g-shadow);
  background: #f0f0f0;
  aspect-ratio: 4/3;
  /* Slightly taller than 3/2 */
  transition: transform .3s cubic-bezier(0.165, 0.84, 0.44, 1), box-shadow .3s ease;
  display: block;
  text-decoration: none;
  color: inherit;
  width: 100%;
}


.gallery-card:hover,
.photo-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
}

.gallery-img-wrapper,
.photo-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.gallery-card img,
.photo-card img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: transform .5s ease;
}

@media(hover:hover) {

  .gallery-card:hover img,
  .photo-card:hover img {
    transform: scale(1.08);
  }
}

/* Gradient Overlay - Bottom to Top with Primary Color */
.gallery-info,
.photo-wrapper .overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 1.5rem 1rem 1rem;
  /* Top padding to allow gradient fade */
  /* Gradient using --g-primary (assuming it's defined like #6c070f) */
  /* We need hex to rgba conversion or hardcoded if var() doesn't support alpha easily without CSS color-mix */
  /* Assuming --g-primary is #6c070f. rgba(108, 7, 15, ...) */
  background: linear-gradient(to top, rgba(108, 7, 15, 0.9) 0%, rgba(108, 7, 15, 0.7) 60%, rgba(108, 7, 15, 0) 100%);
  color: #fff;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.gallery-info h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.3;
  color: #fff;
  /* Explicit white */
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.gallery-info p {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  color: #fff;
  /* Explicit white */
  opacity: 0.95;
  /* Increased opacity for better visibility */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.category-badge {
  position: absolute;
  top: 15px;
  right: 15px;
  background: var(--g-primary);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
  z-index: 20;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.gallery-info .meta {
  display: flex;
  gap: 12px;
  font-size: 0.8rem;
  margin-top: 6px;
  color: #fff;
  /* Explicit white */
  opacity: 0.8;
}

.gallery-count {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  backdrop-filter: blur(4px);
  z-index: 20;
}

/* Photo specific overlay (simple zoom icon) */
.photo-wrapper .overlay {
  background: rgba(0, 0, 0, 0.3);
  /* Base dim */
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .3s ease;
  height: 100%;
}

/* Always show zoom icon on mobile/touch devices */
@media (max-width: 768px) {
  .photo-wrapper .overlay {
    opacity: 1;
    background: rgba(0, 0, 0, 0.15);
  }
}

.photo-card:hover .overlay {
  opacity: 1;
}

.photo-wrapper .overlay i {
  font-size: 2rem;
  color: white;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

/* Pagination */
.pagination {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  margin-top: 1.5rem
}

.pagination button {
  padding: .45rem .85rem;
  border-radius: 6px;
  border: 1px solid #e6e6e6;
  background: #fff;
  cursor: pointer;
  color: var(--g-text);
  transition: all .2s;
  text-decoration: none;
}

.pagination button:hover:not([disabled]) {
  background: #f8f9fa;
  border-color: #ccc
}

.pagination button[aria-disabled="true"] {
  opacity: .5;
  cursor: not-allowed
}

.pagination .page-num[aria-current="true"] {
  background: var(--g-primary);
  color: #fff;
  border-color: var(--g-primary)
}

/* View Header */
.gallery-view-header {
  display: flex;
  gap: 1rem
}

#backToCatBtn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(2px)
}

.modal.open {
  display: flex
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85)
}

.modal-content {
  position: relative;
  z-index: 2;
  max-width: 95%;
  width: 1100px;
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center
}

.modal-body {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-height: 90vh
}

.modal-body img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5)
}

.modal-caption {
  color: #fff;
  text-align: center;
  margin-top: 1rem;
  width: 100%
}

.modal-caption h2 {
  font-size: 1.1rem;
  margin: 0 0 0.25rem
}

.modal-counter {
  font-size: 0.85rem;
  opacity: 0.8
}

.modal-close,
.modal-prev,
.modal-next {
  background: transparent;
  border: 0;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  padding: 10px;
  transition: opacity .2s;
  display: flex;
  align-items: center;
  justify-content: center
}

.modal-close:hover,
.modal-prev:hover,
.modal-next:hover {
  opacity: 0.7
}

.modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 10;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.5rem
}

/* Small view adjustments */
@media(max-width:639px) {
  .gallery-item {
    aspect-ratio: 3/2.2
  }

  .modal-content {
    width: 100%;
    gap: 0
  }

  .modal-prev,
  .modal-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.4);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.5rem
  }

  .modal-prev {
    left: 10px
  }

  .modal-next {
    right: 10px
  }
}